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

[MGTL] Add (back) MeshSearchLength to config.

Now at the top level of the project's config.
parent 0ef62398
No related branches found
No related tags found
No related merge requests found
Showing with 32 additions and 20 deletions
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "MathLib/Curve/CreatePiecewiseLinearCurve.h" #include "MathLib/Curve/CreatePiecewiseLinearCurve.h"
#include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h" #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
#include "MeshGeoToolsLib/ConstructMeshesFromGeometries.h" #include "MeshGeoToolsLib/ConstructMeshesFromGeometries.h"
#include "MeshGeoToolsLib/CreateSearchLength.h"
#include "MeshGeoToolsLib/SearchLength.h"
#include "MeshLib/Mesh.h" #include "MeshLib/Mesh.h"
#include "NumLib/ODESolver/ConvergenceCriterion.h" #include "NumLib/ODESolver/ConvergenceCriterion.h"
...@@ -134,9 +136,13 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, ...@@ -134,9 +136,13 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config,
_mesh_vec.push_back(mesh); _mesh_vec.push_back(mesh);
} }
std::unique_ptr<MeshGeoToolsLib::SearchLength> search_length_algorithm =
MeshGeoToolsLib::createSearchLengthAlgorithm(project_config,
*_mesh_vec[0]);
auto additional_meshes = auto additional_meshes =
MeshGeoToolsLib::constructAdditionalMeshesFromGeoObjects(*_geoObjects, MeshGeoToolsLib::constructAdditionalMeshesFromGeoObjects(
*_mesh_vec[0]); *_geoObjects, *_mesh_vec[0], std::move(search_length_algorithm));
// release the unique_ptr's while copying to the raw pointers storage. // release the unique_ptr's while copying to the raw pointers storage.
// TODO (naumov) Store unique_ptr's in _mesh_vec. // TODO (naumov) Store unique_ptr's in _mesh_vec.
std::transform(begin(additional_meshes), end(additional_meshes), std::transform(begin(additional_meshes), end(additional_meshes),
......
...@@ -65,14 +65,12 @@ constructAdditionalMeshesFromGeometries( ...@@ -65,14 +65,12 @@ constructAdditionalMeshesFromGeometries(
std::vector<std::unique_ptr<MeshLib::Mesh>> std::vector<std::unique_ptr<MeshLib::Mesh>>
constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const& geo_objects, constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const& geo_objects,
MeshLib::Mesh const& mesh) MeshLib::Mesh const& mesh,
std::unique_ptr<SearchLength>
search_length_algorithm)
{ {
std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes; std::vector<std::unique_ptr<MeshLib::Mesh>> additional_meshes;
// TODO (naumov) add config for search length algorithms.
auto search_length_algorithm =
std::make_unique<MeshGeoToolsLib::SearchLength>();
auto const& mesh_node_searcher = auto const& mesh_node_searcher =
MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher( MeshGeoToolsLib::MeshNodeSearcher::getMeshNodeSearcher(
mesh, std::move(search_length_algorithm)); mesh, std::move(search_length_algorithm));
......
...@@ -17,6 +17,10 @@ namespace GeoLib ...@@ -17,6 +17,10 @@ namespace GeoLib
class GEOObjects; class GEOObjects;
} }
namespace MeshGeoToolsLib
{
class SearchLength;
}
namespace MeshGeoToolsLib namespace MeshGeoToolsLib
{ {
/// For each named geometry in the give geo_objects (defined on the given \c /// For each named geometry in the give geo_objects (defined on the given \c
...@@ -24,6 +28,7 @@ namespace MeshGeoToolsLib ...@@ -24,6 +28,7 @@ namespace MeshGeoToolsLib
/// bulk mesh elements and nodes. /// bulk mesh elements and nodes.
std::vector<std::unique_ptr<MeshLib::Mesh>> std::vector<std::unique_ptr<MeshLib::Mesh>>
constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const& geo_objects, constructAdditionalMeshesFromGeoObjects(GeoLib::GEOObjects const& geo_objects,
MeshLib::Mesh const& mesh); MeshLib::Mesh const& mesh,
std::unique_ptr<SearchLength>
search_length_algorithm);
} // namespace MeshGeoToolsLib } // namespace MeshGeoToolsLib
...@@ -21,29 +21,28 @@ std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm( ...@@ -21,29 +21,28 @@ std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm(
BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh) BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh)
{ {
boost::optional<BaseLib::ConfigTree> config = boost::optional<BaseLib::ConfigTree> config =
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__search_length_algorithm} //! \ogs_file_param{prj__search_length_algorithm}
external_config.getConfigSubtreeOptional("search_length_algorithm"); external_config.getConfigSubtreeOptional("search_length_algorithm");
if (!config) if (!config)
return std::unique_ptr<MeshGeoToolsLib::SearchLength>{ {
new MeshGeoToolsLib::SearchLength()}; return std::make_unique<MeshGeoToolsLib::SearchLength>();
}
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__search_length_algorithm__type} //! \ogs_file_param{prj__search_length_algorithm__type}
std::string const type = config->getConfigParameter<std::string>("type"); std::string const type = config->getConfigParameter<std::string>("type");
//! \ogs_file_param_special{prj__process_variables__process_variable__boundary_conditions__boundary_condition__search_length_algorithm__fixed} //! \ogs_file_param_special{prj__search_length_algorithm__fixed}
if (type == "fixed") if (type == "fixed")
{ {
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__search_length_algorithm__fixed__value} //! \ogs_file_param{prj__search_length_algorithm__fixed__value}
double const length = config->getConfigParameter<double>("value"); double const length = config->getConfigParameter<double>("value");
return std::unique_ptr<MeshGeoToolsLib::SearchLength>{ return std::make_unique<MeshGeoToolsLib::SearchLength>(length);
new MeshGeoToolsLib::SearchLength(length)};
} }
if (type == "heuristic") if (type == "heuristic")
{ {
//! \ogs_file_param_special{prj__process_variables__process_variable__boundary_conditions__boundary_condition__search_length_algorithm__heuristic} //! \ogs_file_param_special{prj__search_length_algorithm__heuristic}
return std::unique_ptr<MeshGeoToolsLib::HeuristicSearchLength>{ return std::make_unique<HeuristicSearchLength>(mesh);
new MeshGeoToolsLib::HeuristicSearchLength(mesh)};
} }
OGS_FATAL("Unknown search length algorithm type '%s'.", type.c_str()); OGS_FATAL("Unknown search length algorithm type '%s'.", type.c_str());
} }
......
...@@ -27,6 +27,10 @@ namespace MeshGeoToolsLib ...@@ -27,6 +27,10 @@ namespace MeshGeoToolsLib
{ {
class SearchLength; class SearchLength;
/// Creates a search length algorithm from the given config.
///
/// In case, that there is no tag for the search length algorithm found in the
/// config, the default SearchLength algorithm is returned.
std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm( std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm(
BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh); BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh);
} // end namespace MeshGeoToolsLib } // end namespace MeshGeoToolsLib
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