OGS
MeshElementParameter.cpp
Go to the documentation of this file.
1 
11 #include "MeshElementParameter.h"
12 
13 #include "BaseLib/ConfigTree.h"
14 #include "MeshLib/Mesh.h"
15 
16 namespace ParameterLib
17 {
18 std::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(char const *fmt, Args const &... args)
Definition: Logging.h:27
Definition of the Mesh class.
void checkConfigParameter(std::string const &param, T const &value) const
T getConfigParameter(std::string const &param) const
Properties & getProperties()
Definition: Mesh.h:123
PropertyVector< T > const * getPropertyVector(std::string const &name) const
std::unique_ptr< ParameterBase > createMeshElementParameter(std::string const &name, BaseLib::ConfigTree const &config, MeshLib::Mesh const &mesh)