OGS
CreateSearchLength.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
7#include "BaseLib/Error.h"
10
11namespace MeshGeoToolsLib
12{
13std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm(
14 BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh)
15{
16 std::optional<BaseLib::ConfigTree> config =
18 external_config.getConfigSubtreeOptional("search_length_algorithm");
19
20 if (!config)
21 {
22 return std::make_unique<MeshGeoToolsLib::SearchLength>();
23 }
24
26 std::string const type = config->getConfigParameter<std::string>("type");
27
29 if (type == "fixed")
30 {
32 auto const length = config->getConfigParameter<double>("value");
33 return std::make_unique<MeshGeoToolsLib::SearchLength>(length);
34 }
35 if (type == "heuristic")
36 {
38 return std::make_unique<HeuristicSearchLength>(mesh);
39 }
40 OGS_FATAL("Unknown search length algorithm type '{:s}'.", type);
41}
42
43} // end namespace MeshGeoToolsLib
#define OGS_FATAL(...)
Definition Error.h:19
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
std::unique_ptr< MeshGeoToolsLib::SearchLength > createSearchLengthAlgorithm(BaseLib::ConfigTree const &external_config, MeshLib::Mesh const &mesh)