OGS
CreateSearchLength.cpp
Go to the documentation of this file.
1
10#include "CreateSearchLength.h"
11
12#include "BaseLib/ConfigTree.h"
13#include "BaseLib/Error.h"
16
17namespace MeshGeoToolsLib
18{
19std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm(
20 BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh)
21{
22 std::optional<BaseLib::ConfigTree> config =
24 external_config.getConfigSubtreeOptional("search_length_algorithm");
25
26 if (!config)
27 {
28 return std::make_unique<MeshGeoToolsLib::SearchLength>();
29 }
30
32 std::string const type = config->getConfigParameter<std::string>("type");
33
35 if (type == "fixed")
36 {
38 auto const length = config->getConfigParameter<double>("value");
39 return std::make_unique<MeshGeoToolsLib::SearchLength>(length);
40 }
41 if (type == "heuristic")
42 {
44 return std::make_unique<HeuristicSearchLength>(mesh);
45 }
46 OGS_FATAL("Unknown search length algorithm type '{:s}'.", type);
47}
48
49} // end namespace MeshGeoToolsLib
Functionality to build different search length algorithm objects from given config.
#define OGS_FATAL(...)
Definition Error.h:26
Interface for heuristic search length strategy.
Base class for different search length strategies.
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
std::unique_ptr< MeshGeoToolsLib::SearchLength > createSearchLengthAlgorithm(BaseLib::ConfigTree const &external_config, MeshLib::Mesh const &mesh)