12#include <spdlog/fmt/ranges.h>
14#include <nlohmann/json.hpp>
15#include <range/v3/algorithm/find.hpp>
16#include <range/v3/iterator/operations.hpp>
17#include <range/v3/range/conversion.hpp>
18#include <range/v3/view/filter.hpp>
19#include <range/v3/view/transform.hpp>
20#include <unordered_set>
30 std::string_view
const json_string)
32 json
const meta_data = json::parse(json_string);
34 fields_ = meta_data[
"integration_point_arrays"] |
35 ranges::views::transform(
39 md[
"name"], md[
"number_of_components"],
40 md[
"integration_order"]};
42 ranges::to<std::vector>;
48 std::string
const& field_name)
const
50 auto it = ranges::find(
55 OGS_FATAL(
"No integration point meta data with name '{:s}' found.",
64 json_meta_data[
"integration_point_arrays"] = json::array();
66 for (
auto const& field :
fields_)
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}});
74 return json_meta_data.dump();
79 std::unordered_set<std::string> seen;
81 auto const duplicates =
83 ranges::views::transform(
85 ranges::views::filter([&seen](std::string
const& name)
86 {
return !seen.insert(name).second; }) |
87 ranges::to<std::vector>;
89 if (!duplicates.empty())
91 OGS_FATAL(
"Duplicate integration point meta data names found: {:s}.",
92 fmt::join(duplicates,
", "));
97 std::optional<IntegrationPointMetaData>
const& ip_meta_data,
98 std::string
const& field_name)
103 "The required 'IntegrationPointMetaData' array is not available in "
104 "the vtk field data but is needed to evaluate the integration "
105 "point property '{:s}'.",
108 return (*ip_meta_data)[field_name];
IntegrationPointMetaDataSingleField getIntegrationPointMetaDataSingleField(std::optional< IntegrationPointMetaData > const &ip_meta_data, std::string const &field_name)