13#include <nlohmann/json.hpp>
26 auto const& ip_values = writer.
values();
36 for (
const auto& element_ip_values : ip_values)
38 std::copy(element_ip_values.begin(), element_ip_values.end(),
39 std::back_inserter(field_data));
50 std::vector<MeshLib::IntegrationPointMetaData>
const& meta_data)
53 json_meta_data[
"integration_point_arrays"] = json::array();
55 for (
auto const& md : meta_data)
57 json_meta_data[
"integration_point_arrays"].push_back(
59 {
"number_of_components", md.n_components},
60 {
"integration_order", md.integration_order}});
64 std::string
const json_string = json_meta_data.dump();
66 mesh,
"IntegrationPointMetaData",
69 std::copy(json_string.begin(), json_string.end(),
70 std::back_inserter(dictionary));
76 json
const& meta_data, std::string
const& name)
78 auto const& ip_meta_data = meta_data[
"integration_point_arrays"];
80 find_if(cbegin(ip_meta_data), cend(ip_meta_data),
81 [&name](
auto const& md) {
return md[
"name"] == name; });
82 it != cend(ip_meta_data))
84 return {name, (*it)[
"number_of_components"],
85 (*it)[
"integration_order"]};
87 OGS_FATAL(
"No integration point meta data with name '{:s}' found.", name);
94 std::vector<std::unique_ptr<IntegrationPointWriter>>
const&
95 integration_point_writer)
97 std::vector<IntegrationPointMetaData> meta_data;
98 meta_data.reserve(size(integration_point_writer));
99 transform(cbegin(integration_point_writer), cend(integration_point_writer),
100 back_inserter(meta_data),
101 [&](
auto const& ip_writer)
103 if (!meta_data.empty())
115 "Integration point data '{:s}' is present in the vtk field data "
116 "but the required 'IntegrationPointMetaData' array is not "
120 auto const& mesh_property_ip_meta_data =
121 *properties.template getPropertyVector<char>(
122 "IntegrationPointMetaData");
124 if (mesh_property_ip_meta_data.getMeshItemType() !=
127 OGS_FATAL(
"IntegrationPointMetaData array must be field data.");
133 json::parse(mesh_property_ip_meta_data.begin(),
134 mesh_property_ip_meta_data.end()),
static MeshLib::IntegrationPointMetaData addIntegrationPointData(MeshLib::Mesh &mesh, MeshLib::IntegrationPointWriter const &writer)
static MeshLib::IntegrationPointMetaData extractIntegrationPointMetaData(json const &meta_data, std::string const &name)
static void addIntegrationPointMetaData(MeshLib::Mesh &mesh, std::vector< MeshLib::IntegrationPointMetaData > const &meta_data)
Definition of the Mesh class.
std::size_t getNumberOfElements() const
Get the number of elements.
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
bool existsPropertyVector(std::string_view name) const
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
IntegrationPointMetaData getIntegrationPointMetaData(MeshLib::Properties const &properties, std::string const &name)
void addIntegrationPointDataToMesh(MeshLib::Mesh &mesh, std::vector< std::unique_ptr< IntegrationPointWriter > > const &integration_point_writer)
std::vector< std::vector< double > > values() const
int integrationOrder() const
int numberOfComponents() const