Skip to content
Snippets Groups Projects
Commit fe177380 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Pass domain mesh and meshes to PV construction.

parent 7ff18efb
No related branches found
No related tags found
No related merge requests found
...@@ -112,6 +112,7 @@ std::unique_ptr<MeshLib::Mesh> readSingleMesh( ...@@ -112,6 +112,7 @@ std::unique_ptr<MeshLib::Mesh> readSingleMesh(
{ {
std::string const mesh_file = BaseLib::copyPathToFileName( std::string const mesh_file = BaseLib::copyPathToFileName(
mesh_config_parameter.getValue<std::string>(), project_directory); mesh_config_parameter.getValue<std::string>(), project_directory);
DBUG("Reading mesh file \'%s\'.", mesh_file.c_str());
auto mesh = std::unique_ptr<MeshLib::Mesh>( auto mesh = std::unique_ptr<MeshLib::Mesh>(
MeshLib::IO::readMeshFromFile(mesh_file)); MeshLib::IO::readMeshFromFile(mesh_file));
...@@ -137,26 +138,45 @@ std::vector<std::unique_ptr<MeshLib::Mesh>> readMeshes( ...@@ -137,26 +138,45 @@ std::vector<std::unique_ptr<MeshLib::Mesh>> readMeshes(
{ {
std::vector<std::unique_ptr<MeshLib::Mesh>> meshes; std::vector<std::unique_ptr<MeshLib::Mesh>> meshes;
meshes.push_back( //! \ogs_file_param{prj__meshes}
auto optional_meshes = config.getConfigSubtreeOptional("meshes");
if (optional_meshes)
{
DBUG("Reading multiple meshes.");
for (auto mesh_config :
//! \ogs_file_param{prj__meshes__mesh}
optional_meshes->getConfigParameterList("mesh"))
{
meshes.push_back(readSingleMesh(mesh_config, project_directory));
}
}
else
{ // Read single mesh with geometry.
WARN(
"Consider switching from mesh and geometry input to multiple "
"meshes input. See "
"https://www.opengeosys.org/docs/tools/model-preparation/"
"constructmeshesfromgeometry/ tool for conversion.");
//! \ogs_file_param{prj__mesh} //! \ogs_file_param{prj__mesh}
readSingleMesh(config.getConfigParameter("mesh"), project_directory)); meshes.push_back(readSingleMesh(config.getConfigParameter("mesh"),
project_directory));
std::string const geometry_file = BaseLib::copyPathToFileName(
//! \ogs_file_param{prj__geometry} std::string const geometry_file = BaseLib::copyPathToFileName(
config.getConfigParameter<std::string>("geometry"), //! \ogs_file_param{prj__geometry}
project_directory); config.getConfigParameter<std::string>("geometry"),
GeoLib::GEOObjects geoObjects; project_directory);
readGeometry(geometry_file, geoObjects); GeoLib::GEOObjects geoObjects;
readGeometry(geometry_file, geoObjects);
std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
MeshGeoToolsLib::createSearchLengthAlgorithm(config, *meshes[0]); std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
auto additional_meshes = MeshGeoToolsLib::createSearchLengthAlgorithm(config, *meshes[0]);
MeshGeoToolsLib::constructAdditionalMeshesFromGeoObjects( auto additional_meshes =
geoObjects, *meshes[0], std::move(search_length_algorithm)); MeshGeoToolsLib::constructAdditionalMeshesFromGeoObjects(
geoObjects, *meshes[0], std::move(search_length_algorithm));
std::move(begin(additional_meshes), end(additional_meshes),
std::back_inserter(meshes)); std::move(begin(additional_meshes), end(additional_meshes),
std::back_inserter(meshes));
}
return meshes; return meshes;
} }
} // namespace } // namespace
...@@ -215,20 +235,26 @@ void ProjectData::parseProcessVariables( ...@@ -215,20 +235,26 @@ void ProjectData::parseProcessVariables(
{ {
DBUG("Parse process variables:"); DBUG("Parse process variables:");
if (_mesh_vec.empty() || _mesh_vec[0] == nullptr)
{
ERR("A mesh is required to define process variables.");
return;
}
std::set<std::string> names; std::set<std::string> names;
for (auto var_config for (auto var_config
//! \ogs_file_param{prj__process_variables__process_variable} //! \ogs_file_param{prj__process_variables__process_variable}
: process_variables_config.getConfigSubtreeList("process_variable")) : process_variables_config.getConfigSubtreeList("process_variable"))
{ {
auto pv = // Either the mesh name is given, or the first mesh's name will be
ProcessLib::ProcessVariable{var_config, _mesh_vec, _parameters}; // taken. Taking the first mesh's value is deprecated.
auto const mesh_name =
//! \ogs_file_param{prj__process_variables__process_variable__mesh}
var_config.getConfigParameter<std::string>("mesh",
_mesh_vec[0]->getName());
auto& mesh = *BaseLib::findElementOrError(
begin(_mesh_vec), end(_mesh_vec),
[&mesh_name](auto const& m) { return m->getName() == mesh_name; },
"Expected to find a mesh named " + mesh_name + ".");
auto pv = ProcessLib::ProcessVariable{var_config, mesh, _mesh_vec,
_parameters};
if (!names.insert(pv.getName()).second) if (!names.insert(pv.getName()).second)
OGS_FATAL("A process variable with name `%s' already exists.", OGS_FATAL("A process variable with name `%s' already exists.",
pv.getName().c_str()); pv.getName().c_str());
......
...@@ -23,12 +23,12 @@ namespace ProcessLib ...@@ -23,12 +23,12 @@ namespace ProcessLib
{ {
ProcessVariable::ProcessVariable( ProcessVariable::ProcessVariable(
BaseLib::ConfigTree const& config, BaseLib::ConfigTree const& config,
MeshLib::Mesh& mesh,
std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
std::vector<std::unique_ptr<ParameterBase>> const& parameters) std::vector<std::unique_ptr<ParameterBase>> const& parameters)
: //! \ogs_file_param{prj__process_variables__process_variable__name} : //! \ogs_file_param{prj__process_variables__process_variable__name}
_name(config.getConfigParameter<std::string>("name")), _name(config.getConfigParameter<std::string>("name")),
_mesh(*meshes[0]), // Using the first mesh as the main mesh. _mesh(mesh),
// TODO (naumov) potentially extend to named meshes.
//! \ogs_file_param{prj__process_variables__process_variable__components} //! \ogs_file_param{prj__process_variables__process_variable__components}
_n_components(config.getConfigParameter<int>("components")), _n_components(config.getConfigParameter<int>("components")),
//! \ogs_file_param{prj__process_variables__process_variable__order} //! \ogs_file_param{prj__process_variables__process_variable__order}
......
...@@ -39,6 +39,7 @@ class ProcessVariable ...@@ -39,6 +39,7 @@ class ProcessVariable
public: public:
ProcessVariable( ProcessVariable(
BaseLib::ConfigTree const& config, BaseLib::ConfigTree const& config,
MeshLib::Mesh& mesh,
std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
std::vector<std::unique_ptr<ParameterBase>> const& parameters); std::vector<std::unique_ptr<ParameterBase>> const& parameters);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment