OGS
CreateSaturationWeightedThermalConductivity.cpp
Go to the documentation of this file.
1
13
14#include <boost/mp11.hpp>
15#include <string>
16
17#include "BaseLib/Algorithm.h"
18#include "BaseLib/ConfigTree.h"
21#include "ParameterLib/Utils.h"
23
24namespace
25{
26template <MaterialPropertyLib::MeanType MeanType, int Dim>
27std::unique_ptr<MaterialPropertyLib::Property>
29 std::string name,
30 ParameterLib::Parameter<double> const& dry_thermal_conductivity,
31 ParameterLib::Parameter<double> const& wet_thermal_conductivity)
32{
33 return std::make_unique<
35 Dim>>(
36 std::move(name), dry_thermal_conductivity, wet_thermal_conductivity);
37}
38} // namespace
39
40namespace MaterialPropertyLib
41{
43 int const geometry_dimension,
44 BaseLib::ConfigTree const& config,
45 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
46{
48 config.checkConfigParameter("type",
49 "SaturationWeightedThermalConductivity");
50
52 auto property_name = config.peekConfigParameter<std::string>("name");
53
54 DBUG("Create SaturationWeightedThermalConductivity medium property");
55
56 std::string const& dry_thermal_conductivity_parameter_name =
58 config.getConfigParameter<std::string>("dry_thermal_conductivity");
59 auto const& dry_thermal_conductivity = ParameterLib::findParameter<double>(
60 dry_thermal_conductivity_parameter_name, parameters, 0, nullptr);
61
62 std::string const& wet_thermal_conductivity_parameter_name =
64 config.getConfigParameter<std::string>("wet_thermal_conductivity");
65 auto const& wet_thermal_conductivity = ParameterLib::findParameter<double>(
66 wet_thermal_conductivity_parameter_name, parameters, 0, nullptr);
67
68 std::string const& mean_type_str =
70 config.getConfigParameter<std::string>("mean_type");
71
72 const std::map<std::string, MeanType> mean_type_map{
73 {"arithmetic_linear", MeanType::ARITHMETIC_LINEAR},
74 {"arithmetic_squareroot", MeanType::ARITHMETIC_SQUAREROOT},
75 {"geometric", MeanType::GEOMETRIC}};
76 MeanType const& mean_type = BaseLib::getOrError(
77 mean_type_map, mean_type_str,
78 "Specified mean type for the thermal conductivity could not be found.");
79
80 std::map<
81 std::pair<MeanType, int>,
82 std::unique_ptr<Property> (*)(
83 std::string /*name*/,
84 ParameterLib::Parameter<double> const& /*dry_thermal_conductivity*/,
86 double> const& /*wet_thermal_conductivity*/)>
87 map_dim_and_mean_to_creator;
88
89 // initialize the map
90 {
91 using namespace boost::mp11;
92 using Dims = mp_list<mp_int<1>, mp_int<2>, mp_int<3>>;
93 using Means = mp_list<
94 std::integral_constant<MeanType, MeanType::ARITHMETIC_LINEAR>,
95 std::integral_constant<MeanType, MeanType::ARITHMETIC_SQUAREROOT>,
96 std::integral_constant<MeanType, MeanType::GEOMETRIC>>;
97 using DimsAndMeanTypes =
98 mp_product<mp_list, Dims,
99 Means>; // Cartesian product of Dims and Means.
100
101 mp_for_each<DimsAndMeanTypes>(
102 [&map_dim_and_mean_to_creator]<typename Dim, typename Mean>(
103 mp_list<Dim, Mean>)
104 {
105 map_dim_and_mean_to_creator.emplace(
106 std::pair{Mean::value, Dim::value},
108 Dim::value>);
109 });
110 }
111
112 auto const it = map_dim_and_mean_to_creator.find(
113 std::pair{mean_type, geometry_dimension});
114
115 if (it == map_dim_and_mean_to_creator.end())
116 {
117 OGS_FATAL(
118 "Cannot create a SaturationWeightedThermalConductivity model for "
119 "dimension {} and mean type {}",
120 geometry_dimension, mean_type_str);
121 }
122
123 auto* creator = it->second;
124 return creator(std::move(property_name),
125 dry_thermal_conductivity,
126 wet_thermal_conductivity);
127}
128} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
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:114
std::unique_ptr< Property > createSaturationWeightedThermalConductivity(int const geometry_dimension, BaseLib::ConfigTree const &config, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
std::unique_ptr< MaterialPropertyLib::Property > createSaturationWeightedThermalConductivity(std::string name, ParameterLib::Parameter< double > const &dry_thermal_conductivity, ParameterLib::Parameter< double > const &wet_thermal_conductivity)