6#include <spdlog/fmt/ranges.h>
8#include <nlohmann/json.hpp>
9#include <range/v3/algorithm/find.hpp>
10#include <range/v3/iterator/operations.hpp>
11#include <range/v3/range/conversion.hpp>
12#include <range/v3/view/filter.hpp>
13#include <range/v3/view/transform.hpp>
14#include <unordered_set>
24 std::string_view
const json_string)
26 json
const meta_data = json::parse(json_string);
28 fields_ = meta_data[
"integration_point_arrays"] |
29 ranges::views::transform(
33 md[
"name"], md[
"number_of_components"],
34 md[
"integration_order"]};
36 ranges::to<std::vector>;
42 std::string
const& field_name)
const
44 auto it = ranges::find(
49 OGS_FATAL(
"No integration point meta data with name '{:s}' found.",
58 json_meta_data[
"integration_point_arrays"] = json::array();
60 for (
auto const& field :
fields_)
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}});
68 return json_meta_data.dump();
73 std::unordered_set<std::string> seen;
75 auto const duplicates =
77 ranges::views::transform(
79 ranges::views::filter([&seen](std::string
const& name)
80 {
return !seen.insert(name).second; }) |
81 ranges::to<std::vector>;
83 if (!duplicates.empty())
85 OGS_FATAL(
"Duplicate integration point meta data names found: {:s}.",
86 fmt::join(duplicates,
", "));
91 std::optional<IntegrationPointMetaData>
const& ip_meta_data,
92 std::string
const& field_name)
97 "The required 'IntegrationPointMetaData' array is not available in "
98 "the vtk field data but is needed to evaluate the integration "
99 "point property '{:s}'.",
102 return (*ip_meta_data)[field_name];
IntegrationPointMetaDataSingleField getIntegrationPointMetaDataSingleField(std::optional< IntegrationPointMetaData > const &ip_meta_data, std::string const &field_name)