World Builder  1.1.0-pre
A geodynamic initial conditions generator
uniform.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2018-2024 by the authors of the World Builder code.
3 
4  This file is part of the World Builder.
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19 
21 
22 
23 #include "world_builder/nan.h"
27 
28 
29 namespace WorldBuilder
30 {
31 
32  using namespace Utilities;
33 
34  namespace Features
35  {
36  namespace SubductingPlateModels
37  {
38  namespace Temperature
39  {
40  Uniform::Uniform(WorldBuilder::World *world_)
41  :
42  min_depth(NaN::DSNAN),
43  max_depth(NaN::DSNAN),
44  temperature(NaN::DSNAN),
45  operation(Operations::REPLACE)
46  {
47  this->world = world_;
48  this->name = "uniform";
49  }
50 
52  = default;
53 
54  void
55  Uniform::declare_entries(Parameters &prm, const std::string & /*unused*/)
56  {
57  // Document plugin and require entries if needed.
58  // Add `temperature` and to the required parameters.
59  prm.declare_entry("", Types::Object({"temperature"}),
60  "Uniform temperature model. Set the temperature to a constant value.");
61 
62  // Declare entries of this plugin
63  prm.declare_entry("min distance slab top", Types::Double(0),
64  "todo The depth in meters from which the composition of this feature is present.");
65 
66  prm.declare_entry("max distance slab top", Types::Double(std::numeric_limits<double>::max()),
67  "todo The depth in meters to which the composition of this feature is present.");
68 
69  prm.declare_entry("temperature", Types::Double(293.15),
70  "The temperature in degree Kelvin which this feature should have");
71 
72  }
73 
74  void
76  {
77 
78  min_depth = prm.get<double>("min distance slab top");
79  max_depth = prm.get<double>("max distance slab top");
80  operation = string_operations_to_enum(prm.get<std::string>("operation"));
81  temperature = prm.get<double>("temperature");
82  }
83 
84 
85  double
86  Uniform::get_temperature(const Point<3> & /*position_in_cartesian_coordinates*/,
87  const double /*depth*/,
88  const double /*gravity*/,
89  double temperature_,
90  const double /*feature_min_depth*/,
91  const double /*feature_max_depth*/,
93  const AdditionalParameters & /*additional_parameters*/) const
94  {
95 
96  if (distance_from_plane.distance_from_plane <= max_depth && distance_from_plane.distance_from_plane >= min_depth)
97  {
98  return apply_operation(operation,temperature_,temperature);
99  }
100 
101  return temperature_;
102  }
103 
105  } // namespace Temperature
106  } // namespace SubductingPlateModels
107  } // namespace Features
108 } // namespace WorldBuilder
109 
const double DSNAN
Definition: nan.h:41
Operations string_operations_to_enum(const std::string &operation)
static void declare_entries(Parameters &prm, const std::string &parent_name="")
Definition: uniform.cc:55
#define WB_REGISTER_FEATURE_SUBDUCTING_PLATE_TEMPERATURE_MODEL(classname, name)
Definition: interface.h:156
double apply_operation(const Operations operation, const double old_value, const double new_value)
void declare_entry(const std::string &name, const Types::Interface &type, const std::string &documentation)
Definition: parameters.cc:197
double get_temperature(const Point< 3 > &position, const double depth, const double gravity, double temperature, const double feature_min_depth, const double feature_max_depth, const WorldBuilder::Utilities::PointDistanceFromCurvedPlanes &distance_from_planes, const AdditionalParameters &additional_parameters) const override final
Definition: uniform.cc:86
T get(const std::string &name)