World Builder  1.1.0-pre
A geodynamic initial conditions generator
wrapper_cpp.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 #include "world_builder/world.h"
23 
24 using namespace WorldBuilder;
25 namespace wrapper_cpp
26 {
27  WorldBuilderWrapper::WorldBuilderWrapper(std::string filename, bool has_output_dir, const std::string &output_dir, const unsigned long random_number_seed)
28  : ptr_ptr_world(nullptr)
29  {
30  WorldBuilder::World *a = new WorldBuilder::World(std::move(filename), has_output_dir, output_dir, random_number_seed);
31  ptr_ptr_world = reinterpret_cast<void *>(a);
32  }
33 
34 
36  {
37  WorldBuilder::World *a = reinterpret_cast<WorldBuilder::World *>(ptr_ptr_world);
38  delete a;
39  }
40 
41 
42  double
43  WorldBuilderWrapper::temperature_2d(double x, double z, double depth)
44  {
45  const std::array<double,2> position = {{x,z}};
46  return reinterpret_cast<WorldBuilder::World *>(ptr_ptr_world)->temperature(position,depth);
47  }
48 
49  double
50  WorldBuilderWrapper::temperature_2d(double x, double z, double depth, double /*gravity*/)
51  {
52  return temperature_2d(x,z,depth);
53  }
54 
55  double WorldBuilderWrapper::temperature_3d(double x, double y, double z, double depth)
56  {
57  const std::array<double,3> position = {{x,y,z}};
58  return reinterpret_cast<WorldBuilder::World *>(ptr_ptr_world)->temperature(position,depth);
59  }
60 
61  double WorldBuilderWrapper::temperature_3d(double x, double y, double z, double depth, double /*gravity*/)
62  {
63  return temperature_3d(x,y,z,depth);
64  }
65 
66  double WorldBuilderWrapper::composition_2d(double x, double z, double depth, unsigned int composition_number)
67  {
68  const std::array<double,2> position = {{x,z}};
69  return reinterpret_cast<WorldBuilder::World *>(ptr_ptr_world)->composition(position,depth,composition_number);
70  }
71 
72  double WorldBuilderWrapper::composition_3d(double x, double y, double z, double depth, unsigned int composition_number)
73  {
74  const std::array<double,3> position = {{x,y,z}};
75  return reinterpret_cast<WorldBuilder::World *>(ptr_ptr_world)->composition(position,depth,composition_number);
76  }
77 } // namespace wrapper_cpp
double temperature_2d(double x, double z, double depth)
Definition: wrapper_cpp.cc:43
double composition_2d(double x, double z, double depth, unsigned int composition_number)
Definition: wrapper_cpp.cc:66
double composition_3d(double x, double y, double z, double depth, unsigned int composition_number)
Definition: wrapper_cpp.cc:72
double temperature_3d(double x, double y, double z, double depth)
Definition: wrapper_cpp.cc:55