World Builder  1.1.0-pre
A geodynamic initial conditions generator
uniform_raw.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"
28 
29 
30 namespace WorldBuilder
31 {
32 
33  using namespace Utilities;
34 
35  namespace Features
36  {
37  namespace SubductingPlateModels
38  {
39  namespace Velocity
40  {
41  UniformRaw::UniformRaw(WorldBuilder::World *world_)
42  :
43  min_depth(NaN::DSNAN),
44  max_depth(NaN::DSNAN),
45  velocity({{NaN::DSNAN,NaN::DSNAN,NaN::DSNAN}}),
46  operation(Operations::REPLACE)
47  {
48  this->world = world_;
49  this->name = "uniform raw";
50  }
51 
53  = default;
54 
55  void
56  UniformRaw::declare_entries(Parameters &prm, const std::string & /*unused*/)
57  {
58  // Document plugin and require entries if needed.
59  // Add `velocity` and to the required parameters.
60  prm.declare_entry("", Types::Object({"velocity"}),
61  "Uniform velocity model. Set the velocity to a constant value.");
62 
63  // Declare entries of this plugin
64  prm.declare_entry("min distance slab top", Types::Double(0),
65  "todo The depth in meters from which the composition of this feature is present.");
66 
67  prm.declare_entry("max distance slab top", Types::Double(std::numeric_limits<double>::max()),
68  "todo The depth in meters to which the composition of this feature is present.");
69 
70  prm.declare_entry("velocity", Types::Array(Types::Double(0.0),3,3),
71  "The velocity in meter per year");
72 
73  }
74 
75  void
77  {
78 
79  min_depth = prm.get<double>("min distance slab top");
80  max_depth = prm.get<double>("max distance slab top");
81  operation = string_operations_to_enum(prm.get<std::string>("operation"));
82  std::vector<double> velocity_vec = prm.get_vector<double>("velocity");
83  velocity[0] = velocity_vec[0];
84  velocity[1] = velocity_vec[1];
85  velocity[2] = velocity_vec[2];
86  }
87 
88 
89  std::array<double,3>
90  UniformRaw::get_velocity(const Point<3> & /*position_in_cartesian_coordinates*/,
91  const double /*depth*/,
92  const double /*gravity*/,
93  std::array<double,3> velocity_,
94  const double /*feature_min_depth*/,
95  const double /*feature_max_depth*/,
97  const AdditionalParameters & /*additional_parameters*/) const
98  {
99 
100  if (distance_from_plane.distance_from_plane <= max_depth && distance_from_plane.distance_from_plane >= min_depth)
101  {
102  return {{
103  apply_operation(operation,velocity_[0],velocity[0]),
104  apply_operation(operation,velocity_[1],velocity[1]),
105  apply_operation(operation,velocity_[2],velocity[2])
106  }
107  };
108  }
109 
110  return velocity_;
111  }
112 
114  } // namespace Velocity
115  } // namespace SubductingPlateModels
116  } // namespace Features
117 } // namespace WorldBuilder
118 
const double DSNAN
Definition: nan.h:41
#define WB_REGISTER_FEATURE_SUBDUCTING_PLATE_VELOCITY_MODEL(classname, name)
Definition: interface.h:156
std::array< double, 3 > get_velocity(const Point< 3 > &position, const double depth, const double gravity, std::array< double, 3 > velocity, 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_raw.cc:90
Operations string_operations_to_enum(const std::string &operation)
double apply_operation(const Operations operation, const double old_value, const double new_value)
static void declare_entries(Parameters &prm, const std::string &parent_name="")
Definition: uniform_raw.cc:56
void declare_entry(const std::string &name, const Types::Interface &type, const std::string &documentation)
Definition: parameters.cc:197
std::vector< T > get_vector(const std::string &name)
T get(const std::string &name)