Loading [MathJax]/extensions/tex2jax.js
OGS
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
IntegrationPointWriter.cpp
Go to the documentation of this file.
1
12
13#include <range/v3/view/join.hpp>
14
15#include "MeshLib/Mesh.h"
17
23{
24 auto const& ip_values = writer.values(/*t, x, dof_table*/);
25 assert(ip_values.size() == mesh.getNumberOfElements());
26
27 // create field data and fill it with nodal values, and an offsets cell
28 // array indicating where the cell's integration point data starts.
31 writer.numberOfComponents());
32 field_data.clear();
33
34 ranges::copy(ip_values | ranges::views::join,
35 std::back_inserter(field_data));
36
37 return {writer.name(), writer.numberOfComponents(),
38 writer.integrationOrder()};
39}
40
44 MeshLib::Mesh& mesh, MeshLib::IntegrationPointMetaData const& ip_meta_data)
45{
46 // Store the field data.
47 std::string const json_string = ip_meta_data.toJsonString();
49 mesh, "IntegrationPointMetaData",
51 dictionary.clear();
52 std::copy(json_string.begin(), json_string.end(),
53 std::back_inserter(dictionary));
54}
55
56namespace MeshLib
57{
59 MeshLib::Mesh& mesh,
60 std::vector<std::unique_ptr<IntegrationPointWriter>> const&
61 integration_point_writer)
62{
63 auto meta_data = IntegrationPointMetaData{
64 integration_point_writer |
65 ranges::views::transform(
66 [&](auto const& ip_writer)
67 { return addIntegrationPointData(mesh, *ip_writer); })};
68
69 if (!meta_data.empty())
70 {
72 }
73}
74
75std::optional<IntegrationPointMetaData> getIntegrationPointMetaData(
76 MeshLib::Properties const& properties)
77{
78 if (!properties.existsPropertyVector<char>("IntegrationPointMetaData"))
79 {
80 return std::nullopt;
81 }
82 auto const& mesh_property_ip_meta_data =
83 *properties.template getPropertyVector<char>(
84 "IntegrationPointMetaData");
85
86 if (mesh_property_ip_meta_data.getMeshItemType() !=
88 {
89 OGS_FATAL("IntegrationPointMetaData array must be field data.");
90 }
91
92 // Find the current integration point data entry and extract the
93 // meta data.
94 return IntegrationPointMetaData{std::string_view{
95 mesh_property_ip_meta_data.data(), mesh_property_ip_meta_data.size()}};
96}
97} // namespace MeshLib
#define OGS_FATAL(...)
Definition Error.h:26
static MeshLib::IntegrationPointMetaDataSingleField addIntegrationPointData(MeshLib::Mesh &mesh, MeshLib::IntegrationPointWriter const &writer)
static void addIntegrationPointMetaDataSingleField(MeshLib::Mesh &mesh, MeshLib::IntegrationPointMetaData const &ip_meta_data)
Definition of the Mesh class.
Description of the stored integration point meta data for all fields.
std::string toJsonString() const
Converts integration point meta data to a JSON string.
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:99
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
Definition Properties.h:33
bool existsPropertyVector(std::string_view name) const
Definition Properties.h:74
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
std::optional< IntegrationPointMetaData > getIntegrationPointMetaData(MeshLib::Properties const &properties)
void addIntegrationPointDataToMesh(MeshLib::Mesh &mesh, std::vector< std::unique_ptr< IntegrationPointWriter > > const &integration_point_writer)
std::vector< std::vector< double > > values() const