OGS
IntegrationPointWriter.cpp File Reference

Detailed Description

Definition in file IntegrationPointWriter.cpp.

#include "IntegrationPointWriter.h"
#include <nlohmann/json.hpp>
#include "MeshLib/Mesh.h"
Include dependency graph for IntegrationPointWriter.cpp:

Go to the source code of this file.

Namespaces

 ProcessLib
 

Functions

static ProcessLib::IntegrationPointMetaData addIntegrationPointData (MeshLib::Mesh &mesh, ProcessLib::IntegrationPointWriter const &writer)
 
static void addIntegrationPointMetaData (MeshLib::Mesh &mesh, std::vector< ProcessLib::IntegrationPointMetaData > const &meta_data)
 
static ProcessLib::IntegrationPointMetaData extractIntegrationPointMetaData (json const &meta_data, std::string const &name)
 
void ProcessLib::addIntegrationPointDataToMesh (MeshLib::Mesh &mesh, std::vector< std::unique_ptr< IntegrationPointWriter >> const &integration_point_writer)
 
IntegrationPointMetaData ProcessLib::getIntegrationPointMetaData (MeshLib::Properties const &properties, std::string const &name)
 

Function Documentation

◆ addIntegrationPointData()

static ProcessLib::IntegrationPointMetaData addIntegrationPointData ( MeshLib::Mesh mesh,
ProcessLib::IntegrationPointWriter const &  writer 
)
static

Adds the integration point data and creates meta data for it.

Returns meta data for the written integration point data.

Definition at line 22 of file IntegrationPointWriter.cpp.

24 {
25  auto const& ip_values = writer.values(/*t, x, dof_table*/);
26  assert(ip_values.size() == mesh.getNumberOfElements());
27 
28  // create field data and fill it with nodal values, and an offsets cell
29  // array indicating where the cell's integration point data starts.
30  auto& field_data = *MeshLib::getOrCreateMeshProperty<double>(
31  mesh, writer.name(), MeshLib::MeshItemType::IntegrationPoint,
32  writer.numberOfComponents());
33  field_data.clear();
34 
35  for (const auto& element_ip_values : ip_values)
36  {
37  std::copy(element_ip_values.begin(), element_ip_values.end(),
38  std::back_inserter(field_data));
39  }
40 
41  return {writer.name(), writer.numberOfComponents(),
42  writer.integrationOrder()};
43 }
std::size_t getNumberOfElements() const
Get the number of elements.
Definition: Mesh.h:91
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37

References MathLib::LinAlg::copy(), MeshLib::Mesh::getNumberOfElements(), ProcessLib::IntegrationPointWriter::integrationOrder(), MeshLib::IntegrationPoint, ProcessLib::IntegrationPointWriter::name(), ProcessLib::IntegrationPointWriter::numberOfComponents(), and ProcessLib::IntegrationPointWriter::values().

Referenced by ProcessLib::addIntegrationPointDataToMesh().

◆ addIntegrationPointMetaData()

static void addIntegrationPointMetaData ( MeshLib::Mesh mesh,
std::vector< ProcessLib::IntegrationPointMetaData > const &  meta_data 
)
static

Adds integration point meta data as char mesh property encoded in JSON format, which is then stored as VTK's field data.

Definition at line 47 of file IntegrationPointWriter.cpp.

50 {
51  json json_meta_data;
52  json_meta_data["integration_point_arrays"] = json::array();
53 
54  for (auto const& md : meta_data)
55  {
56  json_meta_data["integration_point_arrays"].push_back(
57  {{"name", md.name},
58  {"number_of_components", md.n_components},
59  {"integration_order", md.integration_order}});
60  }
61 
62  // Store the field data.
63  std::string const json_string = json_meta_data.dump();
64  auto& dictionary = *MeshLib::getOrCreateMeshProperty<char>(
65  mesh, "IntegrationPointMetaData",
67  dictionary.clear();
68  std::copy(json_string.begin(), json_string.end(),
69  std::back_inserter(dictionary));
70 }

References MathLib::LinAlg::copy(), and MeshLib::IntegrationPoint.

Referenced by ProcessLib::addIntegrationPointDataToMesh().

◆ extractIntegrationPointMetaData()

static ProcessLib::IntegrationPointMetaData extractIntegrationPointMetaData ( json const &  meta_data,
std::string const &  name 
)
static

For the given json object and the name extract integration point meta data, or fail if no meta data was found for the given name.

Definition at line 74 of file IntegrationPointWriter.cpp.

76 {
77  auto const& ip_meta_data = meta_data["integration_point_arrays"];
78  if (auto const it =
79  find_if(cbegin(ip_meta_data), cend(ip_meta_data),
80  [&name](auto const& md) { return md["name"] == name; });
81  it != cend(ip_meta_data))
82  {
83  return {name, (*it)["number_of_components"],
84  (*it)["integration_order"]};
85  }
86  OGS_FATAL("No integration point meta data with name '{:s}' found.", name);
87 }
#define OGS_FATAL(...)
Definition: Error.h:26

References MaterialPropertyLib::name, and OGS_FATAL.

Referenced by ProcessLib::getIntegrationPointMetaData().