OGS
MeshLib::IntegrationPointMetaData Class Reference

Detailed Description

Description of the stored integration point meta data for all fields.

Definition at line 35 of file IntegrationPointMetaData.h.

#include <IntegrationPointMetaData.h>

Public Member Functions

 IntegrationPointMetaData (std::string_view const json_string)
 Constructs integration point meta data from a JSON encoded string.
 IntegrationPointMetaData (ranges::input_range auto &&range)
std::string toJsonString () const
 Converts integration point meta data to a JSON string.
constexpr bool empty () const
IntegrationPointMetaDataSingleField const & operator[] (std::string const &field_name) const
auto operator<=> (IntegrationPointMetaData const &) const =default

Private Member Functions

void checkFieldNamesAreUnique () const

Private Attributes

std::vector< IntegrationPointMetaDataSingleFieldfields_

Constructor & Destructor Documentation

◆ IntegrationPointMetaData() [1/2]

MeshLib::IntegrationPointMetaData::IntegrationPointMetaData ( std::string_view const json_string)
explicit

Constructs integration point meta data from a JSON encoded string.

Definition at line 23 of file IntegrationPointMetaData.cpp.

25{
26 json const meta_data = json::parse(json_string);
27
28 fields_ = meta_data["integration_point_arrays"] |
29 ranges::views::transform(
30 [](auto const& md)
31 {
32 return IntegrationPointMetaDataSingleField{
33 md["name"], md["number_of_components"],
34 md["integration_order"]};
35 }) |
36 ranges::to<std::vector>;
37
39}
std::vector< IntegrationPointMetaDataSingleField > fields_

References checkFieldNamesAreUnique(), and fields_.

Referenced by operator<=>().

◆ IntegrationPointMetaData() [2/2]

MeshLib::IntegrationPointMetaData::IntegrationPointMetaData ( ranges::input_range auto && range)
inlineexplicit

Definition at line 41 of file IntegrationPointMetaData.h.

44 :
45#if defined(__cpp_lib_containers_ranges) && \
46 __cpp_lib_containers_ranges >= 202202L
47 fields_(std::from_range, std::forward<decltype(range)>(range))
48#else
49 fields_(ranges::to<std::vector<IntegrationPointMetaDataSingleField>>(
50 std::forward<decltype(range)>(range)))
51#endif
52 {
54 }

References checkFieldNamesAreUnique(), and fields_.

Member Function Documentation

◆ checkFieldNamesAreUnique()

void MeshLib::IntegrationPointMetaData::checkFieldNamesAreUnique ( ) const
private

Definition at line 71 of file IntegrationPointMetaData.cpp.

72{
73 std::unordered_set<std::string> seen;
74
75 auto const duplicates =
76 fields_ |
77 ranges::views::transform(
79 ranges::views::filter([&seen](std::string const& name)
80 { return !seen.insert(name).second; }) |
81 ranges::to<std::vector>;
82
83 if (!duplicates.empty())
84 {
85 OGS_FATAL("Duplicate integration point meta data names found: {:s}.",
86 fmt::join(duplicates, ", "));
87 }
88}
#define OGS_FATAL(...)
Definition Error.h:19

References MeshLib::IntegrationPointMetaDataSingleField::field_name, fields_, and OGS_FATAL.

Referenced by IntegrationPointMetaData(), and IntegrationPointMetaData().

◆ empty()

bool MeshLib::IntegrationPointMetaData::empty ( ) const
inlineconstexpr

Definition at line 58 of file IntegrationPointMetaData.h.

58{ return fields_.empty(); }

References fields_.

◆ operator<=>()

auto MeshLib::IntegrationPointMetaData::operator<=> ( IntegrationPointMetaData const & ) const
default

◆ operator[]()

IntegrationPointMetaDataSingleField const & MeshLib::IntegrationPointMetaData::operator[] ( std::string const & field_name) const

Definition at line 41 of file IntegrationPointMetaData.cpp.

43{
44 auto it = ranges::find(
46
47 if (it == fields_.end())
48 {
49 OGS_FATAL("No integration point meta data with name '{:s}' found.",
50 field_name);
51 }
52 return *it;
53}

References MeshLib::IntegrationPointMetaDataSingleField::field_name, fields_, and OGS_FATAL.

◆ toJsonString()

std::string MeshLib::IntegrationPointMetaData::toJsonString ( ) const

Converts integration point meta data to a JSON string.

Definition at line 55 of file IntegrationPointMetaData.cpp.

56{
57 json json_meta_data;
58 json_meta_data["integration_point_arrays"] = json::array();
59
60 for (auto const& field : fields_)
61 {
62 json_meta_data["integration_point_arrays"].push_back(
63 {{"name", field.field_name},
64 {"number_of_components", field.n_components},
65 {"integration_order", field.integration_order}});
66 }
67
68 return json_meta_data.dump();
69}

References fields_.

Referenced by addIntegrationPointMetaDataSingleField().

Member Data Documentation

◆ fields_

std::vector<IntegrationPointMetaDataSingleField> MeshLib::IntegrationPointMetaData::fields_
private

The documentation for this class was generated from the following files: