OGS
CreateOutputConfig.cpp File Reference

Detailed Description

Definition in file CreateOutputConfig.cpp.

Include dependency graph for CreateOutputConfig.cpp:

Go to the source code of this file.

Namespaces

namespace  ProcessLib
 

Functions

std::string createMeshOutputName (std::vector< int > const &material_ids, std::string const &mesh_name)
 
std::string parseOutputMeshConfig (BaseLib::ConfigTree const &output_mesh_config, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes)
 
OutputConfig ProcessLib::createOutputConfig (const BaseLib::ConfigTree &config, std::vector< std::unique_ptr< MeshLib::Mesh > > &meshes)
 

Function Documentation

◆ createMeshOutputName()

std::string createMeshOutputName ( std::vector< int > const &  material_ids,
std::string const &  mesh_name 
)

Definition at line 25 of file CreateOutputConfig.cpp.

27{
28 if (material_ids.empty())
29 {
30 return mesh_name;
31 }
32 return mesh_name + "_" + fmt::format("{}", fmt::join(material_ids, "_"));
33}

Referenced by parseOutputMeshConfig().

◆ parseOutputMeshConfig()

std::string parseOutputMeshConfig ( BaseLib::ConfigTree const &  output_mesh_config,
std::vector< std::unique_ptr< MeshLib::Mesh > > &  meshes 
)
Input File Parameter:
prj__time_loop__output__meshes__mesh__material_ids

Definition at line 35 of file CreateOutputConfig.cpp.

38{
39 auto const mesh_name = output_mesh_config.getValue<std::string>();
40 auto const& mesh = *BaseLib::findElementOrError(
41 begin(meshes), end(meshes),
42 [&mesh_name](auto const& mesh)
43 {
44 assert(mesh != nullptr);
45 return mesh->getName() == mesh_name;
46 },
47 "Required mesh with name '" + mesh_name + "' not found.");
48
49 auto material_id_string =
51 output_mesh_config.getConfigAttributeOptional<std::string>(
52 "material_ids");
53
54 if (!material_id_string)
55 {
56 return mesh_name;
57 }
58
59 auto const material_ids_for_output =
60 BaseLib::splitMaterialIdString(*material_id_string);
61#ifdef USE_PETSC
62 // this mesh isn't yet a NodePartitionedMesh
63 auto subdomain_mesh = MeshLib::createMaterialIDsBasedSubMesh(
64 mesh, material_ids_for_output,
65 createMeshOutputName(material_ids_for_output, mesh_name));
66 auto const* bulk_mesh =
67 dynamic_cast<MeshLib::NodePartitionedMesh const*>(&mesh);
69 bulk_mesh, subdomain_mesh.get()));
70#else
72 mesh, material_ids_for_output,
73 createMeshOutputName(material_ids_for_output, mesh_name)));
74#endif
75
76 return meshes.back()->getName();
77}
std::string createMeshOutputName(std::vector< int > const &material_ids, std::string const &mesh_name)
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:98
std::iterator_traits< InputIt >::reference findElementOrError(InputIt begin, InputIt end, Predicate predicate, std::string const &error="")
Definition: Algorithm.h:69
std::vector< int > splitMaterialIdString(std::string const &material_id_string)
std::unique_ptr< MeshLib::Mesh > createMaterialIDsBasedSubMesh(MeshLib::Mesh const &mesh, std::vector< int > const &material_ids, std::string const &name_for_created_mesh)
std::unique_ptr< NodePartitionedMesh > transformMeshToNodePartitionedMesh(NodePartitionedMesh const *const bulk_mesh, Mesh const *const subdomain_mesh)

References MeshLib::createMaterialIDsBasedSubMesh(), createMeshOutputName(), BaseLib::findElementOrError(), BaseLib::ConfigTree::getConfigAttributeOptional(), MeshLib::Mesh::getName(), BaseLib::ConfigTree::getValue(), BaseLib::splitMaterialIdString(), and MeshLib::transformMeshToNodePartitionedMesh().

Referenced by ProcessLib::createOutputConfig().