OGS
MeshElementParameter.cpp
Go to the documentation of this file.
1
12
13#include "BaseLib/ConfigTree.h"
14#include "MeshLib/Mesh.h"
15
16namespace ParameterLib
17{
18std::unique_ptr<ParameterBase> createMeshElementParameter(
19 std::string const& name, BaseLib::ConfigTree const& config,
20 MeshLib::Mesh const& mesh)
21{
23 config.checkConfigParameter("type", "MeshElement");
24 auto const field_name =
26 config.getConfigParameter<std::string>("field_name");
27 DBUG("Using field_name {:s}", field_name);
28
29 // TODO other data types than only double
30 auto const& property =
31 mesh.getProperties().getPropertyVector<double>(field_name);
32
33 if (property->getMeshItemType() != MeshLib::MeshItemType::Cell)
34 {
35 OGS_FATAL("The mesh property `{:s}' is not an element property.",
36 field_name);
37 }
38
39 return std::make_unique<MeshElementParameter<double>>(name, mesh,
40 *property);
41}
42
43} // namespace ParameterLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Definition of the Mesh class.
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
Properties & getProperties()
Definition Mesh.h:134
PropertyVector< T > const * getPropertyVector(std::string_view name) const
std::unique_ptr< ParameterBase > createMeshElementParameter(std::string const &name, BaseLib::ConfigTree const &config, MeshLib::Mesh const &mesh)