OGS 6.1.0-1721-g6382411ad
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"
14 
17 
18 namespace MeshGeoToolsLib
19 {
20 std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm(
21  BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh)
22 {
23  boost::optional<BaseLib::ConfigTree> config =
25  external_config.getConfigSubtreeOptional("search_length_algorithm");
26 
27  if (!config)
28  {
29  return std::make_unique<MeshGeoToolsLib::SearchLength>();
30  }
31 
33  std::string const type = config->getConfigParameter<std::string>("type");
34 
36  if (type == "fixed")
37  {
39  double const length = config->getConfigParameter<double>("value");
40  return std::make_unique<MeshGeoToolsLib::SearchLength>(length);
41  }
42  if (type == "heuristic")
43  {
45  return std::make_unique<HeuristicSearchLength>(mesh);
46  }
47  OGS_FATAL("Unknown search length algorithm type '%s'.", type.c_str());
48 }
49 
50 } // end namespace MeshGeoToolsLib
Implementation of heuristic search length strategy.
std::unique_ptr< MeshGeoToolsLib::SearchLength > createSearchLengthAlgorithm(BaseLib::ConfigTree const &external_config, MeshLib::Mesh const &mesh)
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
boost::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
Definition: ConfigTree.cpp:156