OGS
CreateSigmoid.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
4#include "CreateSigmoid.h"
5
7#include "BaseLib/Error.h"
10
11namespace MaterialPropertyLib
12{
13std::unique_ptr<Sigmoid> createSigmoid(BaseLib::ConfigTree const& config)
14{
16 config.checkConfigParameter("type", "Sigmoid");
17
19 auto const name = config.peekConfigParameter<std::string>("name");
20 DBUG("Create sigmoid property '{:s}'.", name);
21
22 auto const steepness =
24 config.getConfigParameter<double>("steepness");
25
26 auto const midpoint =
28 config.getConfigParameter<double>("midpoint");
29
30 auto const lower_bound =
32 config.getConfigParameter<double>("lower_bound");
33
34 auto const upper_bound =
36 config.getConfigParameter<double>("upper_bound");
37
38 // Parse independent variable
39 auto const independent_variable_str =
41 config.getConfigParameter<std::string>("independent_variable");
42
43 // Spatial/temporal coordinates not yet supported; would need to
44 // reintroduce a SpatialTemporalVariable and dispatch in value().
45 if (std::ranges::any_of(std::array{"t", "x", "y", "z"},
46 [&](const char* v)
47 { return independent_variable_str == v; }))
48
49 {
51 "In the sigmoid property '{:s}', the spatial/temporal independent "
52 "variable '{:s}' is not supported yet. Use a material variable "
53 "instead. See CreateSigmoid.cpp for how to re-enable "
54 "spatial/temporal independent variables.",
55 name, independent_variable_str);
56 }
57
58 auto const independent_variable =
59 convertStringToVariable(independent_variable_str);
60
61 return std::make_unique<Sigmoid>(name, steepness, midpoint, lower_bound,
62 upper_bound, independent_variable);
63}
64
65} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:10
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
T peekConfigParameter(std::string const &param) const
T getConfigParameter(std::string const &param) const
void checkConfigParameter(std::string const &param, std::string_view const value) const
std::unique_ptr< Sigmoid > createSigmoid(BaseLib::ConfigTree const &config)
Create a Sigmoid property from XML configuration.
Variable convertStringToVariable(std::string const &string)