OGS
MeshLib::IntegrationPointMetaData Class Reference

Detailed Description

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

Definition at line 41 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 29 of file IntegrationPointMetaData.cpp.

31{
32 json const meta_data = json::parse(json_string);
33
34 fields_ = meta_data["integration_point_arrays"] |
35 ranges::views::transform(
36 [](auto const& md)
37 {
38 return IntegrationPointMetaDataSingleField{
39 md["name"], md["number_of_components"],
40 md["integration_order"]};
41 }) |
42 ranges::to<std::vector>;
43
45}
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 47 of file IntegrationPointMetaData.h.

50 :
51#if defined(__cpp_lib_containers_ranges) && \
52 __cpp_lib_containers_ranges >= 202202L
53 fields_(std::from_range, std::forward<decltype(range)>(range))
54#else
55 fields_(ranges::to<std::vector<IntegrationPointMetaDataSingleField>>(
56 std::forward<decltype(range)>(range)))
57#endif
58 {
60 }

References checkFieldNamesAreUnique(), and fields_.

Member Function Documentation

◆ checkFieldNamesAreUnique()

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

Definition at line 77 of file IntegrationPointMetaData.cpp.

78{
79 std::unordered_set<std::string> seen;
80
81 auto const duplicates =
82 fields_ |
83 ranges::views::transform(
85 ranges::views::filter([&seen](std::string const& name)
86 { return !seen.insert(name).second; }) |
87 ranges::to<std::vector>;
88
89 if (!duplicates.empty())
90 {
91 OGS_FATAL("Duplicate integration point meta data names found: {:s}.",
92 fmt::join(duplicates, ", "));
93 }
94}
#define OGS_FATAL(...)
Definition Error.h:26

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

Referenced by IntegrationPointMetaData(), and IntegrationPointMetaData().

◆ empty()

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

Definition at line 64 of file IntegrationPointMetaData.h.

64{ 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 47 of file IntegrationPointMetaData.cpp.

49{
50 auto it = ranges::find(
52
53 if (it == fields_.end())
54 {
55 OGS_FATAL("No integration point meta data with name '{:s}' found.",
56 field_name);
57 }
58 return *it;
59}

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 61 of file IntegrationPointMetaData.cpp.

62{
63 json json_meta_data;
64 json_meta_data["integration_point_arrays"] = json::array();
65
66 for (auto const& field : fields_)
67 {
68 json_meta_data["integration_point_arrays"].push_back(
69 {{"name", field.field_name},
70 {"number_of_components", field.n_components},
71 {"integration_order", field.integration_order}});
72 }
73
74 return json_meta_data.dump();
75}

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: