OGS 6.2.1-97-g73d1aeda3
MeshNodeParameter.cpp
Go to the documentation of this file.
1 
10 #include "MeshNodeParameter.h"
11 #include "BaseLib/ConfigTree.h"
12 #include "MeshLib/Mesh.h"
13 
14 namespace ParameterLib
15 {
16 std::unique_ptr<ParameterBase> createMeshNodeParameter(
17  std::string const& name, BaseLib::ConfigTree const& config,
18  MeshLib::Mesh const& mesh)
19 {
21  config.checkConfigParameter("type", "MeshNode");
22  auto const field_name =
24  config.getConfigParameter<std::string>("field_name");
25  DBUG("Using field_name %s", field_name.c_str());
26 
27  // TODO other data types than only double
28  auto const& property =
29  mesh.getProperties().getPropertyVector<double>(field_name);
30 
31  if (property->getMeshItemType() != MeshLib::MeshItemType::Node)
32  {
33  OGS_FATAL("The mesh property `%s' is not a nodal property.",
34  field_name.c_str());
35  }
36 
37  return std::make_unique<MeshNodeParameter<double>>(name, mesh, *property);
38 }
39 
40 } // namespace ParameterLib
MeshLib::Properties & getProperties()
Definition: Mesh.h:134
Definition of the Mesh class.
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, T const &value) const
PropertyVector< T > const * getPropertyVector(std::string const &name) const
Definition: Properties.h:119
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
std::unique_ptr< ParameterBase > createMeshNodeParameter(std::string const &name, BaseLib::ConfigTree const &config, MeshLib::Mesh const &mesh)