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 34 of file ProcessVariable.cpp.

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