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

24{
25 json const meta_data = json::parse(json_string);
26
27 fields_ = meta_data["integration_point_arrays"] |
28 ranges::views::transform(
29 [](auto const& md)
30 {
31 return IntegrationPointMetaDataSingleField{
32 md["name"], md["number_of_components"],
33 md["integration_order"]};
34 }) |
35 ranges::to<std::vector>;
36
38}
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 70 of file IntegrationPointMetaData.cpp.

71{
72 auto const duplicates = BaseLib::getDuplicates(
73 fields_ | ranges::views::transform(
75
76 if (!duplicates.empty())
77 {
78 OGS_FATAL("Duplicate integration point meta data names found: {:s}.",
79 fmt::join(duplicates, ", "));
80 }
81}
#define OGS_FATAL(...)
Definition Error.h:10
std::vector< ranges::range_value_t< Range > > getDuplicates(Range &&range)
Definition Algorithm.h:178

References MeshLib::IntegrationPointMetaDataSingleField::field_name, fields_, BaseLib::getDuplicates(), 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 40 of file IntegrationPointMetaData.cpp.

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

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

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

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: