swh:1:snp:f521c49ab17ef7db6ec70b2430e1ed203f50383f
Raw File
Tip revision: 5d096d82789f29991ab661240be799f5463aa322 authored by Lars Bilke on 29 June 2021, 13:18:14 UTC
Merge branch 'fix-cmake-3.16' into 'master'
Tip revision: 5d096d8
CreateSearchLength.cpp
/**
 * \file
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 */

#include "CreateSearchLength.h"

#include "BaseLib/ConfigTree.h"
#include "BaseLib/Error.h"
#include "MeshGeoToolsLib/HeuristicSearchLength.h"
#include "MeshGeoToolsLib/SearchLength.h"

namespace MeshGeoToolsLib
{
std::unique_ptr<MeshGeoToolsLib::SearchLength> createSearchLengthAlgorithm(
    BaseLib::ConfigTree const& external_config, MeshLib::Mesh const& mesh)
{
    std::optional<BaseLib::ConfigTree> config =
        //! \ogs_file_param{prj__search_length_algorithm}
        external_config.getConfigSubtreeOptional("search_length_algorithm");

    if (!config)
    {
        return std::make_unique<MeshGeoToolsLib::SearchLength>();
    }

    //! \ogs_file_param{prj__search_length_algorithm__type}
    std::string const type = config->getConfigParameter<std::string>("type");

    //! \ogs_file_param_special{prj__search_length_algorithm__fixed}
    if (type == "fixed")
    {
        //! \ogs_file_param{prj__search_length_algorithm__fixed__value}
        auto const length = config->getConfigParameter<double>("value");
        return std::make_unique<MeshGeoToolsLib::SearchLength>(length);
    }
    if (type == "heuristic")
    {
        //! \ogs_file_param_special{prj__search_length_algorithm__heuristic}
        return std::make_unique<HeuristicSearchLength>(mesh);
    }
    OGS_FATAL("Unknown search length algorithm type '{:s}'.", type);
}

}  // end namespace MeshGeoToolsLib
back to top