OGS
CellAverageData.cpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2
// SPDX-License-Identifier: BSD-3-Clause
3
4
#include "
CellAverageData.h
"
5
6
#include "
MeshLib/Utils/getOrCreateMeshProperty.h
"
7
8
namespace
ProcessLib
9
{
10
MeshLib::PropertyVector<double>
&
CellAverageData::getOrCreatePropertyVector
(
11
std::string
const
& name,
unsigned
const
num_comp)
12
{
13
if
(
auto
const
it =
cell_averages_
.find(name); it !=
cell_averages_
.end())
14
{
15
auto
& prop_vec = *it->second;
16
auto
const
num_comp_mesh = prop_vec.getNumberOfGlobalComponents();
17
if
(num_comp_mesh ==
static_cast<
int
>
(num_comp))
18
{
19
return
prop_vec;
20
}
21
22
OGS_FATAL
(
23
"The requested property '{}' has {} components, but the one "
24
"present in the mesh has {} components."
,
25
name, num_comp, num_comp_mesh);
26
}
27
28
auto
const
name_in_mesh = name +
"_avg"
;
29
auto
[it, emplaced] =
cell_averages_
.emplace(
30
name,
MeshLib::getOrCreateMeshProperty<double>
(
31
const_cast<
MeshLib::Mesh
&
>
(
mesh_
), name_in_mesh,
32
MeshLib::MeshItemType::Cell
, num_comp));
33
34
if
(!it->second)
35
{
36
OGS_FATAL
(
"The cell property '{}' could not be added to the mesh."
,
37
name_in_mesh);
38
}
39
40
if
(!emplaced)
41
{
42
OGS_FATAL
(
43
"Internal logic error. Something very bad happened. The cell "
44
"property '{}' was not added to the list of cell averages to "
45
"compute. There is some very strange inconsistency in the "
46
"code. Trouble ahead!"
,
47
name_in_mesh);
48
}
49
50
return
*it->second;
51
}
52
}
// namespace ProcessLib
CellAverageData.h
OGS_FATAL
#define OGS_FATAL(...)
Definition
Error.h:19
MeshLib::Mesh
Definition
Mesh.h:34
MeshLib::PropertyVector
Definition
PropertyVector.h:52
getOrCreateMeshProperty.h
MeshLib::getOrCreateMeshProperty
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
Definition
getOrCreateMeshProperty.h:17
MeshLib::MeshItemType::Cell
@ Cell
Definition
MeshEnums.h:16
ProcessLib
Definition
ProjectData.h:40
ProcessLib::CellAverageData::mesh_
MeshLib::Mesh const & mesh_
Definition
CellAverageData.h:19
ProcessLib::CellAverageData::getOrCreatePropertyVector
MeshLib::PropertyVector< double > & getOrCreatePropertyVector(std::string const &name, unsigned const num_comp)
Definition
CellAverageData.cpp:10
ProcessLib::CellAverageData::cell_averages_
std::map< std::string, MeshLib::PropertyVector< double > * > cell_averages_
Definition
CellAverageData.h:20
ProcessLib
Output
CellAverageData.cpp
Generated by
1.14.0