OGS
anonymous_namespace{ProcessVariable.cpp} Namespace Reference

Functions

MeshLib::Mesh const & findMeshInConfig (BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< MeshLib::Mesh >> const &meshes)
 

Function Documentation

◆ findMeshInConfig()

MeshLib::Mesh const& anonymous_namespace{ProcessVariable.cpp}::findMeshInConfig ( BaseLib::ConfigTree const &  config,
std::vector< std::unique_ptr< MeshLib::Mesh >> const &  meshes 
)
Input File Parameter:
prj__process_variables__process_variable__source_terms__source_term__mesh
Input File Parameter:
prj__process_variables__process_variable__boundary_conditions__boundary_condition__mesh
Input File Parameter:
prj__process_variables__process_variable__source_terms__source_term__geometrical_set
Input File Parameter:
prj__process_variables__process_variable__source_terms__source_term__geometry
Input File Parameter:
prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometrical_set
Input File Parameter:
prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometry

Definition at line 31 of file ProcessVariable.cpp.

34 {
35  //
36  // Get the mesh name from the config.
37  //
38  std::string mesh_name; // Either given directly in <mesh> or constructed
39  // from <geometrical_set>_<geometry>.
40 
41 #ifdef DOXYGEN_DOCU_ONLY
43  config.getConfigParameterOptional<std::string>("mesh");
44 #endif // DOXYGEN_DOCU_ONLY
45 
46  auto optional_mesh_name =
48  config.getConfigParameterOptional<std::string>("mesh");
49  if (optional_mesh_name)
50  {
51  mesh_name = *optional_mesh_name;
52  }
53  else
54  {
55 #ifdef DOXYGEN_DOCU_ONLY
57  config.getConfigParameterOptional<std::string>("geometrical_set");
59  config.getConfigParameter<std::string>("geometry");
60 #endif // DOXYGEN_DOCU_ONLY
61 
62  // Looking for the mesh created before for the given geometry.
63  auto const geometrical_set_name =
65  config.getConfigParameter<std::string>("geometrical_set");
66  auto const geometry_name =
68  config.getConfigParameter<std::string>("geometry");
69 
70  mesh_name = MeshGeoToolsLib::meshNameFromGeometry(geometrical_set_name,
71  geometry_name);
72  }
73 
74  //
75  // Find and extract mesh from the list of meshes.
76  //
77  auto const& mesh = *BaseLib::findElementOrError(
78  begin(meshes), end(meshes),
79  [&mesh_name](auto const& mesh)
80  {
81  assert(mesh != nullptr);
82  return mesh->getName() == mesh_name;
83  },
84  "Required mesh with name '" + mesh_name + "' not found.");
85  DBUG("Found mesh '{:s}' with id {:d}.", mesh.getName(), mesh.getID());
86 
87  return mesh;
88 }
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
std::iterator_traits< InputIt >::reference findElementOrError(InputIt begin, InputIt end, Predicate predicate, std::string const &error="")
Definition: Algorithm.h:69
std::string meshNameFromGeometry(std::string const &geometrical_set_name, std::string const &geometry_name)

References DBUG(), BaseLib::findElementOrError(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigParameterOptional(), and MeshGeoToolsLib::meshNameFromGeometry().

Referenced by ProcessLib::ProcessVariable::ProcessVariable().