OGS
ProcessLib::CellAverageData Struct Reference

Detailed Description

Definition at line 18 of file CellAverageData.h.

#include <CellAverageData.h>

Collaboration diagram for ProcessLib::CellAverageData:
[legend]

Public Member Functions

 CellAverageData (MeshLib::Mesh &mesh)
 
MeshLib::PropertyVector< double > & getOrCreatePropertyVector (std::string const &name, unsigned const num_comp)
 

Private Attributes

MeshLib::Mesh const & mesh_
 
std::map< std::string, MeshLib::PropertyVector< double > * > cell_averages_
 

Constructor & Destructor Documentation

◆ CellAverageData()

ProcessLib::CellAverageData::CellAverageData ( MeshLib::Mesh & mesh)
inlineexplicit

Definition at line 20 of file CellAverageData.h.

20: mesh_{mesh} {}
MeshLib::Mesh const & mesh_

Member Function Documentation

◆ getOrCreatePropertyVector()

MeshLib::PropertyVector< double > & ProcessLib::CellAverageData::getOrCreatePropertyVector ( std::string const & name,
unsigned const num_comp )

Definition at line 17 of file CellAverageData.cpp.

19{
20 if (auto const it = cell_averages_.find(name); it != cell_averages_.end())
21 {
22 auto& prop_vec = *it->second;
23 auto const num_comp_mesh = prop_vec.getNumberOfGlobalComponents();
24 if (num_comp_mesh == static_cast<int>(num_comp))
25 {
26 return prop_vec;
27 }
28
30 "The requested property '{}' has {} components, but the one "
31 "present in the mesh has {} components.",
32 name, num_comp, num_comp_mesh);
33 }
34
35 auto const name_in_mesh = name + "_avg";
36 auto [it, emplaced] = cell_averages_.emplace(
38 const_cast<MeshLib::Mesh&>(mesh_), name_in_mesh,
40
41 if (!it->second)
42 {
43 OGS_FATAL("The cell property '{}' could not be added to the mesh.",
44 name_in_mesh);
45 }
46
47 if (!emplaced)
48 {
50 "Internal logic error. Something very bad happened. The cell "
51 "property '{}' was not added to the list of cell averages to "
52 "compute. There is some very strange inconsistency in the "
53 "code. Trouble ahead!",
54 name_in_mesh);
55 }
56
57 return *it->second;
58}
#define OGS_FATAL(...)
Definition Error.h:26
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
std::map< std::string, MeshLib::PropertyVector< double > * > cell_averages_

References MeshLib::Cell, cell_averages_, MeshLib::PropertyVectorBase::getNumberOfGlobalComponents(), MeshLib::getOrCreateMeshProperty(), mesh_, and OGS_FATAL.

Referenced by ProcessLib::detail::computeCellAverages().

Member Data Documentation

◆ cell_averages_

std::map<std::string, MeshLib::PropertyVector<double>*> ProcessLib::CellAverageData::cell_averages_
private

Definition at line 27 of file CellAverageData.h.

Referenced by getOrCreatePropertyVector().

◆ mesh_

MeshLib::Mesh const& ProcessLib::CellAverageData::mesh_
private

Definition at line 26 of file CellAverageData.h.

Referenced by getOrCreatePropertyVector().


The documentation for this struct was generated from the following files: