OGS
CreateSaturationWeightedThermalConductivity.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
6#include <boost/mp11.hpp>
7#include <string>
8
9#include "BaseLib/Algorithm.h"
10#include "BaseLib/ConfigTree.h"
13#include "ParameterLib/Utils.h"
15
16namespace
17{
18template <MaterialPropertyLib::MeanType MeanType, int Dim>
19std::unique_ptr<MaterialPropertyLib::Property>
21 std::string name,
22 ParameterLib::Parameter<double> const& dry_thermal_conductivity,
23 ParameterLib::Parameter<double> const& wet_thermal_conductivity)
24{
25 return std::make_unique<
27 Dim>>(
28 std::move(name), dry_thermal_conductivity, wet_thermal_conductivity);
29}
30} // namespace
31
32namespace MaterialPropertyLib
33{
35 int const geometry_dimension,
36 BaseLib::ConfigTree const& config,
37 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>& parameters)
38{
40 config.checkConfigParameter("type",
41 "SaturationWeightedThermalConductivity");
42
44 auto property_name = config.peekConfigParameter<std::string>("name");
45
46 DBUG("Create SaturationWeightedThermalConductivity medium property");
47
48 auto& dry_thermal_conductivity =
51 config, parameters, property_name, "dry_thermal_conductivity",
52 "dry_inline");
53
54 auto& wet_thermal_conductivity =
57 config, parameters, property_name, "wet_thermal_conductivity",
58 "wet_inline");
59
60 std::string const& mean_type_str =
62 config.getConfigParameter<std::string>("mean_type");
63
64 const std::map<std::string, MeanType> mean_type_map{
65 {"arithmetic_linear", MeanType::ARITHMETIC_LINEAR},
66 {"arithmetic_squareroot", MeanType::ARITHMETIC_SQUAREROOT},
67 {"geometric", MeanType::GEOMETRIC}};
68 MeanType const& mean_type = BaseLib::getOrError(
69 mean_type_map, mean_type_str,
70 "Specified mean type for the thermal conductivity could not be found.");
71
72 std::map<
73 std::pair<MeanType, int>,
74 std::unique_ptr<Property> (*)(
75 std::string /*name*/,
76 ParameterLib::Parameter<double> const& /*dry_thermal_conductivity*/,
78 double> const& /*wet_thermal_conductivity*/)>
79 map_dim_and_mean_to_creator;
80
81 // initialize the map
82 {
83 using namespace boost::mp11;
84 using Dims = mp_list<mp_int<1>, mp_int<2>, mp_int<3>>;
85 using Means = mp_list<
86 std::integral_constant<MeanType, MeanType::ARITHMETIC_LINEAR>,
87 std::integral_constant<MeanType, MeanType::ARITHMETIC_SQUAREROOT>,
88 std::integral_constant<MeanType, MeanType::GEOMETRIC>>;
89 using DimsAndMeanTypes =
90 mp_product<mp_list, Dims,
91 Means>; // Cartesian product of Dims and Means.
92
93 mp_for_each<DimsAndMeanTypes>(
94 [&map_dim_and_mean_to_creator]<typename Dim, typename Mean>(
95 mp_list<Dim, Mean>)
96 {
97 map_dim_and_mean_to_creator.emplace(
98 std::pair{Mean::value, Dim::value},
100 Dim::value>);
101 });
102 }
103
104 auto const it = map_dim_and_mean_to_creator.find(
105 std::pair{mean_type, geometry_dimension});
106
107 if (it == map_dim_and_mean_to_creator.end())
108 {
109 OGS_FATAL(
110 "Cannot create a SaturationWeightedThermalConductivity model for "
111 "dimension {} and mean type {}",
112 geometry_dimension, mean_type_str);
113 }
114
115 auto* creator = it->second;
116 return creator(std::move(property_name),
117 dry_thermal_conductivity,
118 wet_thermal_conductivity);
119}
120} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
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
Saturation dependent thermal conductivity model for soil.
OGS_NO_DANGLING Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
Definition Algorithm.h:111
std::unique_ptr< Property > createSaturationWeightedThermalConductivity(int const geometry_dimension, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > &parameters)
Parameter< double > & getNamedOrCreateInlineParameter(BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterBase > > &parameters, std::string const &property_name, std::string const &tag_name, std::string const &inline_suffix)
std::unique_ptr< MaterialPropertyLib::Property > createSaturationWeightedThermalConductivity(std::string name, ParameterLib::Parameter< double > const &dry_thermal_conductivity, ParameterLib::Parameter< double > const &wet_thermal_conductivity)