diff --git a/_2github_2workspace_2include_2utilities_2mdarray_2mdarray_8hpp-example.html b/_2github_2workspace_2include_2utilities_2mdarray_2mdarray_8hpp-example.html index 1d723d11d6..da02f7aba1 100644 --- a/_2github_2workspace_2include_2utilities_2mdarray_2mdarray_8hpp-example.html +++ b/_2github_2workspace_2include_2utilities_2mdarray_2mdarray_8hpp-example.html @@ -290,7 +290,7 @@ diff --git a/_abstract_c_lib_bmi_adapter_8hpp_source.html b/_abstract_c_lib_bmi_adapter_8hpp_source.html index bb0a470267..3fd52d3208 100644 --- a/_abstract_c_lib_bmi_adapter_8hpp_source.html +++ b/_abstract_c_lib_bmi_adapter_8hpp_source.html @@ -184,7 +184,7 @@ diff --git a/_aorc_forcing_8hpp_source.html b/_aorc_forcing_8hpp_source.html index 2a2d2f3c0b..b214f1bc02 100644 --- a/_aorc_forcing_8hpp_source.html +++ b/_aorc_forcing_8hpp_source.html @@ -228,7 +228,7 @@ diff --git a/_bmi___adapter_8hpp_source.html b/_bmi___adapter_8hpp_source.html index 9f981a299e..39693dd1bf 100644 --- a/_bmi___adapter_8hpp_source.html +++ b/_bmi___adapter_8hpp_source.html @@ -200,7 +200,7 @@ diff --git a/_bmi___c___adapter_8hpp_source.html b/_bmi___c___adapter_8hpp_source.html index 776284a1ec..107da3f77b 100644 --- a/_bmi___c___adapter_8hpp_source.html +++ b/_bmi___c___adapter_8hpp_source.html @@ -532,7 +532,7 @@ diff --git a/_bmi___c___formulation_8hpp_source.html b/_bmi___c___formulation_8hpp_source.html index 489e34c96f..4cc0f96cf5 100644 --- a/_bmi___c___formulation_8hpp_source.html +++ b/_bmi___c___formulation_8hpp_source.html @@ -184,7 +184,7 @@ diff --git a/_bmi___cpp___adapter_8hpp_source.html b/_bmi___cpp___adapter_8hpp_source.html index 69e7f559b2..6f1d210242 100644 --- a/_bmi___cpp___adapter_8hpp_source.html +++ b/_bmi___cpp___adapter_8hpp_source.html @@ -492,7 +492,7 @@ diff --git a/_bmi___cpp___formulation_8hpp_source.html b/_bmi___cpp___formulation_8hpp_source.html index 667a30fd58..5961a178ef 100644 --- a/_bmi___cpp___formulation_8hpp_source.html +++ b/_bmi___cpp___formulation_8hpp_source.html @@ -179,7 +179,7 @@ diff --git a/_bmi___formulation_8hpp_source.html b/_bmi___formulation_8hpp_source.html index a00195ef0b..8d3220e7ed 100644 --- a/_bmi___formulation_8hpp_source.html +++ b/_bmi___formulation_8hpp_source.html @@ -358,7 +358,7 @@ diff --git a/_bmi___fortran___adapter_8hpp_source.html b/_bmi___fortran___adapter_8hpp_source.html index bc6dfd97d1..4ea48dc52f 100644 --- a/_bmi___fortran___adapter_8hpp_source.html +++ b/_bmi___fortran___adapter_8hpp_source.html @@ -100,448 +100,450 @@
1#ifndef NGEN_BMI_FORTRAN_ADAPTER_HPP
2#define NGEN_BMI_FORTRAN_ADAPTER_HPP
3
-
4#ifdef NGEN_BMI_FORTRAN_ACTIVE
+
4#include <NGenConfig.h>
5
-
6#include "AbstractCLibBmiAdapter.hpp"
-
7#include "Bmi_Fortran_Common.h"
-
8#include "bmi.h"
-
9#include "State_Exception.hpp"
-
10#include "utilities/ExternalIntegrationException.hpp"
-
11
-
12// Forward declaration to provide access to protected items in testing
-
13class Bmi_Fortran_Adapter_Test;
-
14
-
15namespace models {
-
16 namespace bmi {
-
17
-
18 typedef struct Bmi_Fortran_Handle_Wrapper {
-
19 void ** handle;
-
20 } Bmi_Fortran_Handle_Wrapper;
-
21
-
26 class Bmi_Fortran_Adapter final : public AbstractCLibBmiAdapter {
-
27
-
28 public:
+
6#if NGEN_WITH_BMI_FORTRAN
+
7
+
8#include "AbstractCLibBmiAdapter.hpp"
+
9#include "Bmi_Fortran_Common.h"
+
10#include "bmi.h"
+
11#include "State_Exception.hpp"
+
12#include "utilities/ExternalIntegrationException.hpp"
+
13
+
14// Forward declaration to provide access to protected items in testing
+
15class Bmi_Fortran_Adapter_Test;
+
16
+
17namespace models {
+
18 namespace bmi {
+
19
+
20 typedef struct Bmi_Fortran_Handle_Wrapper {
+
21 void ** handle;
+
22 } Bmi_Fortran_Handle_Wrapper;
+
23
+
28 class Bmi_Fortran_Adapter final : public AbstractCLibBmiAdapter {
29
-
30 explicit Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path,
-
31 std::string forcing_file_path,
-
32 bool allow_exceed_end, bool has_fixed_time_step,
-
33 const std::string &registration_func, utils::StreamHandler output)
-
34 : Bmi_Fortran_Adapter(type_name, library_file_path, "", forcing_file_path, allow_exceed_end,
-
35 has_fixed_time_step,
-
36 registration_func, output) {}
-
37
-
38 Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
-
39 std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
-
40 std::string registration_func,
-
41 utils::StreamHandler output) : AbstractCLibBmiAdapter(type_name,
-
42 library_file_path,
-
43 bmi_init_config,
-
44 forcing_file_path,
-
45 allow_exceed_end,
-
46 has_fixed_time_step,
-
47 registration_func,
-
48 output) {
-
49 try {
-
50 construct_and_init_backing_model_for_fortran();
-
51 // Make sure this is set to 'true' after this function call finishes
-
52 model_initialized = true;
-
53 bmi_model_time_convert_factor = get_time_convert_factor();
-
54 }
-
55 // Record the exception message before re-throwing to handle subsequent function calls properly
-
56 catch( models::external::State_Exception& e)
-
57 {
-
58 model_initialized = true;
-
59 throw e;
-
60 }
-
61 catch( ::external::ExternalIntegrationException& e)
-
62 {
-
63 model_initialized = true;
-
64 throw e;
-
65 }
-
66 catch (std::runtime_error &e) {
-
67 //Catch `runtime_error`s that may possible be thrown from acquire_time_conversion_factor
-
68 // Make sure this is set to 'true' after this function call finishes
-
69 model_initialized = true;
-
70 throw e;
-
71 }
-
72 catch (std::exception &e) {
-
73 //This will catch any other exception, but the it will be cast to this base type.
-
74 //This means it looses it any specific type/message information. So if construct_and_init_backing_model_for_fortran
-
75 //throws an exception besides runtime_error, catch that type explicitly.
-
76 model_initialized = true;
-
77 throw e;
-
78 }
-
79 }
-
80
-
81 Bmi_Fortran_Adapter(Bmi_Fortran_Adapter const&) = delete;
-
82 Bmi_Fortran_Adapter(Bmi_Fortran_Adapter&&) = delete;
-
83
-
84 std::string GetComponentName() override;
+
30 public:
+
31
+
32 explicit Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path,
+
33 std::string forcing_file_path,
+
34 bool allow_exceed_end, bool has_fixed_time_step,
+
35 const std::string &registration_func, utils::StreamHandler output)
+
36 : Bmi_Fortran_Adapter(type_name, library_file_path, "", forcing_file_path, allow_exceed_end,
+
37 has_fixed_time_step,
+
38 registration_func, output) {}
+
39
+
40 Bmi_Fortran_Adapter(const std::string &type_name, std::string library_file_path, std::string bmi_init_config,
+
41 std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
+
42 std::string registration_func,
+
43 utils::StreamHandler output) : AbstractCLibBmiAdapter(type_name,
+
44 library_file_path,
+
45 bmi_init_config,
+
46 forcing_file_path,
+
47 allow_exceed_end,
+
48 has_fixed_time_step,
+
49 registration_func,
+
50 output) {
+
51 try {
+
52 construct_and_init_backing_model_for_fortran();
+
53 // Make sure this is set to 'true' after this function call finishes
+
54 model_initialized = true;
+
55 bmi_model_time_convert_factor = get_time_convert_factor();
+
56 }
+
57 // Record the exception message before re-throwing to handle subsequent function calls properly
+
58 catch( models::external::State_Exception& e)
+
59 {
+
60 model_initialized = true;
+
61 throw e;
+
62 }
+
63 catch( ::external::ExternalIntegrationException& e)
+
64 {
+
65 model_initialized = true;
+
66 throw e;
+
67 }
+
68 catch (std::runtime_error &e) {
+
69 //Catch `runtime_error`s that may possible be thrown from acquire_time_conversion_factor
+
70 // Make sure this is set to 'true' after this function call finishes
+
71 model_initialized = true;
+
72 throw e;
+
73 }
+
74 catch (std::exception &e) {
+
75 //This will catch any other exception, but the it will be cast to this base type.
+
76 //This means it looses it any specific type/message information. So if construct_and_init_backing_model_for_fortran
+
77 //throws an exception besides runtime_error, catch that type explicitly.
+
78 model_initialized = true;
+
79 throw e;
+
80 }
+
81 }
+
82
+
83 Bmi_Fortran_Adapter(Bmi_Fortran_Adapter const&) = delete;
+
84 Bmi_Fortran_Adapter(Bmi_Fortran_Adapter&&) = delete;
85
-
94 double GetCurrentTime() override;
-
95
-
96 double GetEndTime() override;
+
86 std::string GetComponentName() override;
+
87
+
96 double GetCurrentTime() override;
97
-
104 int GetInputItemCount() override {
-
105 return inner_get_input_item_count();
-
106 }
-
107
-
113 std::vector<std::string> GetInputVarNames() override;
-
114
-
121 int GetOutputItemCount() override {
-
122 return inner_get_output_item_count();
-
123 }
-
124
-
125 std::vector<std::string> GetOutputVarNames() override;
+
98 double GetEndTime() override;
+
99
+
106 int GetInputItemCount() override {
+
107 return inner_get_input_item_count();
+
108 }
+
109
+
115 std::vector<std::string> GetInputVarNames() override;
+
116
+
123 int GetOutputItemCount() override {
+
124 return inner_get_output_item_count();
+
125 }
126
-
136 double GetStartTime() override;
-
137
-
148 double GetTimeStep() override;
-
149
-
158 std::string GetTimeUnits() override;
-
159
-
169 void GetValue(std::string name, void *dest) override {
-
170 inner_get_value(name, dest);
-
171 }
-
172
-
173 void GetValueAtIndices(std::string name, void *dest, int *inds, int count) override;
+
127 std::vector<std::string> GetOutputVarNames() override;
+
128
+
138 double GetStartTime() override;
+
139
+
150 double GetTimeStep() override;
+
151
+
160 std::string GetTimeUnits() override;
+
161
+
171 void GetValue(std::string name, void *dest) override {
+
172 inner_get_value(name, dest);
+
173 }
174
-
175 void GetGridShape(const int grid, int *shape) override;
+
175 void GetValueAtIndices(std::string name, void *dest, int *inds, int count) override;
176
-
177 void GetGridSpacing(const int grid, double *spacing) override;
+
177 void GetGridShape(const int grid, int *shape) override;
178
-
179 void GetGridOrigin(const int grid, double *origin) override;
+
179 void GetGridSpacing(const int grid, double *spacing) override;
180
-
181 void GetGridX(const int grid, double *x) override;
+
181 void GetGridOrigin(const int grid, double *origin) override;
182
-
183 void GetGridY(const int grid, double *y) override;
+
183 void GetGridX(const int grid, double *x) override;
184
-
185 void GetGridZ(const int grid, double *z) override;
+
185 void GetGridY(const int grid, double *y) override;
186
-
187 int GetGridNodeCount(const int grid) override;
+
187 void GetGridZ(const int grid, double *z) override;
188
-
189 int GetGridEdgeCount(const int grid) override;
+
189 int GetGridNodeCount(const int grid) override;
190
-
191 int GetGridFaceCount(const int grid) override;
+
191 int GetGridEdgeCount(const int grid) override;
192
-
193 void GetGridEdgeNodes(const int grid, int *edge_nodes) override;
+
193 int GetGridFaceCount(const int grid) override;
194
-
195 void GetGridFaceEdges(const int grid, int *face_edges) override;
+
195 void GetGridEdgeNodes(const int grid, int *edge_nodes) override;
196
-
197 void GetGridFaceNodes(const int grid, int *face_nodes) override;
+
197 void GetGridFaceEdges(const int grid, int *face_edges) override;
198
-
199 void GetGridNodesPerFace(const int grid, int *nodes_per_face) override;
+
199 void GetGridFaceNodes(const int grid, int *face_nodes) override;
200
-
201 void *GetValuePtr(std::string name) override {
-
202 throw std::runtime_error(model_name + " cannot currently get pointers for Fortran-based BMI modules.");
-
203 }
-
204
-
220 template<class T>
-
221 T *GetValuePtr(const std::string &name) {
-
222 int nbytes;
-
223 if (get_var_nbytes(&bmi_model->handle, name.c_str(), &nbytes) != BMI_SUCCESS)
-
224 throw std::runtime_error(model_name + " failed to get pointer for BMI variable " + name + ".");
-
225 void *dest = GetValuePtr(name);
-
226 T *ptr = (T *) dest;
-
227 return ptr;
-
228 }
-
229
-
236 int GetVarItemsize(std::string name) override;
-
237
-
247 int GetVarNbytes(std::string name) override;
-
248
-
255 int GetVarGrid(std::string name) override;
-
256
-
263 std::string GetVarType(std::string name) override;
-
264
-
271 std::string GetVarUnits(std::string name) override;
-
272
-
279 std::string GetVarLocation(std::string name) override;
-
280
-
287 std::string GetGridType(int grid_id) override;
-
288
-
295 int GetGridRank(int grid_id) override;
-
296
-
303 int GetGridSize(int grid_id) override;
-
304
-
320 const std::string
-
321 get_analogous_cxx_type(const std::string &external_type_name, const size_t item_size) override {
-
322 if (external_type_name == "int" || external_type_name == "integer") {
-
323 return "int";
-
324 }
-
325 else if (external_type_name == "float" || external_type_name == "real") {
-
326 return "float";
-
327 }
-
328 else if (external_type_name == "double" || external_type_name == "double precision") {
-
329 return "double";
-
330 }
-
331 else {
-
332 throw std::runtime_error(
-
333 "Bmi_Fortran_Adapter received unrecognized Fortran type name '" + external_type_name +
-
334 "' for which the analogous C++ type could not be determined");
-
335 }
-
336 }
-
337
-
343 bool is_model_initialized() override;
-
344
-
345 void SetValue(std::string name, void *src) override;
+
201 void GetGridNodesPerFace(const int grid, int *nodes_per_face) override;
+
202
+
203 void *GetValuePtr(std::string name) override {
+
204 throw std::runtime_error(model_name + " cannot currently get pointers for Fortran-based BMI modules.");
+
205 }
+
206
+
222 template<class T>
+
223 T *GetValuePtr(const std::string &name) {
+
224 int nbytes;
+
225 if (get_var_nbytes(&bmi_model->handle, name.c_str(), &nbytes) != BMI_SUCCESS)
+
226 throw std::runtime_error(model_name + " failed to get pointer for BMI variable " + name + ".");
+
227 void *dest = GetValuePtr(name);
+
228 T *ptr = (T *) dest;
+
229 return ptr;
+
230 }
+
231
+
238 int GetVarItemsize(std::string name) override;
+
239
+
249 int GetVarNbytes(std::string name) override;
+
250
+
257 int GetVarGrid(std::string name) override;
+
258
+
265 std::string GetVarType(std::string name) override;
+
266
+
273 std::string GetVarUnits(std::string name) override;
+
274
+
281 std::string GetVarLocation(std::string name) override;
+
282
+
289 std::string GetGridType(int grid_id) override;
+
290
+
297 int GetGridRank(int grid_id) override;
+
298
+
305 int GetGridSize(int grid_id) override;
+
306
+
322 const std::string
+
323 get_analogous_cxx_type(const std::string &external_type_name, const size_t item_size) override {
+
324 if (external_type_name == "int" || external_type_name == "integer") {
+
325 return "int";
+
326 }
+
327 else if (external_type_name == "float" || external_type_name == "real") {
+
328 return "float";
+
329 }
+
330 else if (external_type_name == "double" || external_type_name == "double precision") {
+
331 return "double";
+
332 }
+
333 else {
+
334 throw std::runtime_error(
+
335 "Bmi_Fortran_Adapter received unrecognized Fortran type name '" + external_type_name +
+
336 "' for which the analogous C++ type could not be determined");
+
337 }
+
338 }
+
339
+
345 bool is_model_initialized() override;
346
-
357 template<class T>
-
358 void SetValue(std::string name, std::vector<T> src) {
-
359 int item_size, total_bytes;
-
360 try {
-
361 item_size = GetVarItemsize(name);
-
362 total_bytes = GetVarNbytes(name);
-
363 }
-
364 catch (std::runtime_error &e) {
-
365 throw std::runtime_error("Cannot set " + name + " variable of " + model_name +
-
366 "; unable to test item and array sizes are equal (does variable " + name +
-
367 " exist for model " + model_name + "?)");
-
368 }
-
369 if (item_size != sizeof(src[0])) {
-
370 throw std::runtime_error("Cannot set " + name + " variable of " + model_name +
-
371 " with values of different item size");
-
372 }
-
373 if (src.size() != total_bytes / item_size) {
-
374 throw std::runtime_error(
-
375 "Cannot set " + name + " variable of " + model_name + " from vector of size " +
-
376 std::to_string(src.size()) + " (expected size " + std::to_string(total_bytes / item_size) +
-
377 ")");
-
378 }
-
379 SetValue(std::move(name), static_cast<void *>(src.data()));
-
380 }
-
381
-
382 void SetValueAtIndices(std::string name, int *inds, int count, void *src) override;
+
347 void SetValue(std::string name, void *src) override;
+
348
+
359 template<class T>
+
360 void SetValue(std::string name, std::vector<T> src) {
+
361 int item_size, total_bytes;
+
362 try {
+
363 item_size = GetVarItemsize(name);
+
364 total_bytes = GetVarNbytes(name);
+
365 }
+
366 catch (std::runtime_error &e) {
+
367 throw std::runtime_error("Cannot set " + name + " variable of " + model_name +
+
368 "; unable to test item and array sizes are equal (does variable " + name +
+
369 " exist for model " + model_name + "?)");
+
370 }
+
371 if (item_size != sizeof(src[0])) {
+
372 throw std::runtime_error("Cannot set " + name + " variable of " + model_name +
+
373 " with values of different item size");
+
374 }
+
375 if (src.size() != total_bytes / item_size) {
+
376 throw std::runtime_error(
+
377 "Cannot set " + name + " variable of " + model_name + " from vector of size " +
+
378 std::to_string(src.size()) + " (expected size " + std::to_string(total_bytes / item_size) +
+
379 ")");
+
380 }
+
381 SetValue(std::move(name), static_cast<void *>(src.data()));
+
382 }
383
-
392 template<class T>
-
393 void SetValueAtIndices(const std::string &name, std::vector<int> inds, std::vector<T> src) {
-
394 if (inds.size() != src.size()) {
-
395 throw std::runtime_error("Cannot set specified indexes for " + name + " variable of " + model_name +
-
396 " when index collection is different size than collection of values.");
-
397 }
-
398 if (inds.empty()) {
-
399 return;
-
400 }
-
401 size_t item_size;
-
402 try {
-
403 item_size = (size_t) GetVarItemsize(name);
-
404 }
-
405 catch (std::runtime_error &e) {
-
406 throw std::runtime_error("Cannot set specified indexes for " + name + " variable of " + model_name +
-
407 "; unable to test item sizes are equal (does variable exist for model?)");
-
408 }
-
409 if (item_size != sizeof(src[0])) {
-
410 throw std::runtime_error("Cannot set specified indexes for " + name + " variable of " + model_name +
-
411 " with values of different item size");
-
412 }
-
413 SetValueAtIndices(name, inds.data(), inds.size(), static_cast<void *>(src.data()));
-
414 }
-
415
-
422 void Update() override;
-
423
-
436 void UpdateUntil(double time) override;
-
437
-
438 protected:
+
384 void SetValueAtIndices(std::string name, int *inds, int count, void *src) override;
+
385
+
394 template<class T>
+
395 void SetValueAtIndices(const std::string &name, std::vector<int> inds, std::vector<T> src) {
+
396 if (inds.size() != src.size()) {
+
397 throw std::runtime_error("Cannot set specified indexes for " + name + " variable of " + model_name +
+
398 " when index collection is different size than collection of values.");
+
399 }
+
400 if (inds.empty()) {
+
401 return;
+
402 }
+
403 size_t item_size;
+
404 try {
+
405 item_size = (size_t) GetVarItemsize(name);
+
406 }
+
407 catch (std::runtime_error &e) {
+
408 throw std::runtime_error("Cannot set specified indexes for " + name + " variable of " + model_name +
+
409 "; unable to test item sizes are equal (does variable exist for model?)");
+
410 }
+
411 if (item_size != sizeof(src[0])) {
+
412 throw std::runtime_error("Cannot set specified indexes for " + name + " variable of " + model_name +
+
413 " with values of different item size");
+
414 }
+
415 SetValueAtIndices(name, inds.data(), inds.size(), static_cast<void *>(src.data()));
+
416 }
+
417
+
424 void Update() override;
+
425
+
438 void UpdateUntil(double time) override;
439
-
449 void construct_and_init_backing_model() override {
-
450 construct_and_init_backing_model_for_fortran();
-
451 }
-
452
-
461 inline void execModuleRegistration() {
-
462 if (get_dyn_lib_handle() == nullptr) {
-
463 dynamic_library_load();
-
464 }
-
465 void *symbol;
-
466 // TODO: verify this doesn't need to just return void, rather than void*
-
467 void *(*dynamic_register_bmi)(void *model);
-
468
-
469 try {
-
470 // Acquire the BMI struct func pointer registration function
-
471 symbol = dynamic_load_symbol(get_bmi_registration_function());
-
472 // TODO: as with the TODO above, verify this doesn't need to just return void, rather than void*
-
473 dynamic_register_bmi = (void *(*)(void *)) symbol;
-
474 // Call registration function, which for Fortran sets up the Fortran BMI object and sets the passed
-
475 // opaque handle param to point to the Fortran BMI object.
-
476 dynamic_register_bmi(&bmi_model->handle);
-
477 }
-
478 catch (const ::external::ExternalIntegrationException &e) {
-
479 // "Override" the default message in this case
-
480 this->init_exception_msg =
-
481 "Cannot init " + this->model_name + " without valid library registration function: " +
-
482 this->init_exception_msg;
-
483 throw ::external::ExternalIntegrationException(this->init_exception_msg);
-
484 }
-
485 }
-
486
-
487 private:
+
440 protected:
+
441
+
451 void construct_and_init_backing_model() override {
+
452 construct_and_init_backing_model_for_fortran();
+
453 }
+
454
+
463 inline void execModuleRegistration() {
+
464 if (get_dyn_lib_handle() == nullptr) {
+
465 dynamic_library_load();
+
466 }
+
467 void *symbol;
+
468 // TODO: verify this doesn't need to just return void, rather than void*
+
469 void *(*dynamic_register_bmi)(void *model);
+
470
+
471 try {
+
472 // Acquire the BMI struct func pointer registration function
+
473 symbol = dynamic_load_symbol(get_bmi_registration_function());
+
474 // TODO: as with the TODO above, verify this doesn't need to just return void, rather than void*
+
475 dynamic_register_bmi = (void *(*)(void *)) symbol;
+
476 // Call registration function, which for Fortran sets up the Fortran BMI object and sets the passed
+
477 // opaque handle param to point to the Fortran BMI object.
+
478 dynamic_register_bmi(&bmi_model->handle);
+
479 }
+
480 catch (const ::external::ExternalIntegrationException &e) {
+
481 // "Override" the default message in this case
+
482 this->init_exception_msg =
+
483 "Cannot init " + this->model_name + " without valid library registration function: " +
+
484 this->init_exception_msg;
+
485 throw ::external::ExternalIntegrationException(this->init_exception_msg);
+
486 }
+
487 }
488
-
500 inline void construct_and_init_backing_model_for_fortran() {
-
501 if (model_initialized)
-
502 return;
-
503 bmi_model = std::make_unique<Bmi_Fortran_Handle_Wrapper>(Bmi_Fortran_Handle_Wrapper());
-
504 dynamic_library_load();
-
505 execModuleRegistration();
-
506 int init_result = initialize(&bmi_model->handle, bmi_init_config.c_str());
-
507 if (init_result != BMI_SUCCESS) {
-
508 init_exception_msg = "Failure when attempting to initialize " + model_name;
-
509 throw models::external::State_Exception(init_exception_msg);
-
510 }
-
511 }
-
512
-
522 inline int inner_get_input_item_count() {
-
523 int item_count;
-
524 if (get_input_item_count(&bmi_model->handle, &item_count) != BMI_SUCCESS) {
-
525 throw std::runtime_error(model_name + " failed to get model input item count.");
-
526 }
-
527 return item_count;
-
528 }
-
529
-
539 inline int inner_get_output_item_count() {
-
540 int item_count;
-
541 if (get_output_item_count(&bmi_model->handle, &item_count) != BMI_SUCCESS) {
-
542 throw std::runtime_error(model_name + " failed to get model output item count.");
-
543 }
-
544 return item_count;
-
545 }
-
546
-
547 inline std::string inner_get_var_type(const std::string &name) {
-
548 char type_c_str[BMI_MAX_TYPE_NAME];
-
549 if (get_var_type(&bmi_model->handle, name.c_str(), type_c_str) != BMI_SUCCESS) {
-
550 throw std::runtime_error(model_name + " failed to get variable type for " + name + ".");
-
551 }
-
552 return {type_c_str};
-
553 }
-
554
-
570 inline void inner_get_value(const std::string& name, void *dest) {
-
571 std::string varType = inner_get_var_type(name);
-
572 //Can use the C type or the fortran type, e.g. int or integer
-
573 if (varType == "int" || varType == "integer") {
-
574 inner_get_value_int(name, (int *)dest);
-
575 }
-
576 else if (varType == "float" || varType == "real") {
-
577 inner_get_value_float(name, (float *)dest);
-
578 }
-
579 else if (varType == "double" || varType == "double precision") {
-
580 inner_get_value_double(name, (double *)dest);
-
581 }
-
582 else {
-
583 throw ::external::ExternalIntegrationException(
-
584 "Can't get model " + model_name + " variable " + name + " of type '" + varType + ".");
-
585 }
-
586 }
-
587
-
603 inline void inner_get_value_int(const std::string& name, int *dest) {
-
604 if (get_value_int(&bmi_model->handle, name.c_str(), dest) != BMI_SUCCESS) {
-
605 throw std::runtime_error(model_name + " failed to get values for variable " + name + ".");
-
606 }
-
607 }
-
608
-
624 inline void inner_get_value_float(const std::string& name, float *dest) {
-
625 if (get_value_float(&bmi_model->handle, name.c_str(), dest) != BMI_SUCCESS) {
-
626 throw std::runtime_error(model_name + " failed to get values for variable " + name + ".");
-
627 }
-
628 }
-
629
-
645 inline void inner_get_value_double(const std::string& name, double *dest) {
-
646 if (get_value_double(&bmi_model->handle, name.c_str(), dest) != BMI_SUCCESS) {
-
647 throw std::runtime_error(model_name + " failed to get values for variable " + name + ".");
-
648 }
-
649 }
-
650
-
664 std::shared_ptr<std::vector<std::string>> inner_get_variable_names(bool is_input_variables) {
-
665 // Writing this def once here at beginning: fewer lines, but this may or may not be used.
-
666 std::string varType = (is_input_variables) ? "input" : "output";
-
667
-
668 // Obtain this via inner functions, which should use the model directly and not other member functions
-
669 int variableCount;
-
670 try {
-
671 variableCount = (is_input_variables) ? inner_get_input_item_count() : inner_get_output_item_count();
-
672 }
-
673 catch (const std::exception &e) {
-
674 throw std::runtime_error(model_name + " failed to count of " + varType + " variable names array.");
-
675 }
-
676
-
677 // With variable count now obtained, create the vector
-
678 std::shared_ptr<std::vector<std::string>> var_names = std::make_shared<std::vector<std::string>>(
-
679 std::vector<std::string>(variableCount));
-
680
-
681 // Must get the names from the model as an array of C strings
-
682 // The array can be on the stack ...
-
683 std::vector<char*> names_array(variableCount);
-
684 // ... but allocate the space for the individual C strings (i.e., the char * elements)
-
685 for (int i = 0; i < variableCount; i++) {
-
686 names_array[i] = static_cast<char *>(malloc(sizeof(char) * BMI_MAX_VAR_NAME));
-
687 }
-
688
-
689 // With the necessary char** in hand, get the names from the model
-
690 int names_result;
-
691 if (is_input_variables) {
-
692 names_result = get_input_var_names(bmi_model.get(), names_array.data());
-
693 }
-
694 else {
-
695 names_result = get_output_var_names(bmi_model.get(), names_array.data());
-
696 }
-
697 if (names_result != BMI_SUCCESS) {
-
698 throw std::runtime_error(model_name + " failed to get array of " + varType + " variables names.");
-
699 }
-
700
-
701 // Then convert from array of C strings to vector of strings, freeing the allocated space as we go
-
702 for (int i = 0; i < variableCount; ++i) {
-
703 (*var_names)[i] = std::string(names_array[i]);
-
704 free(names_array[i]);
-
705 }
-
706
-
707 return var_names;
-
708 }
-
709
-
725 inline void inner_set_value(const std::string& name, void *src) {
-
726 std::string varType = inner_get_var_type(name);
-
727 //Can use the C type or the fortran type, e.g. int or integer
-
728 if (varType == "int" || varType == "integer") {
-
729 inner_set_value_int(name, (int *)src);
-
730 }
-
731 else if (varType == "float" || varType == "real") {
-
732 inner_set_value_float(name, (float *)src);
-
733 }
-
734 else if (varType == "double" || varType == "double precision") {
-
735 inner_set_value_double(name, (double *)src);
-
736 }
-
737 else {
-
738 throw ::external::ExternalIntegrationException(
-
739 "Can't get model " + model_name + " variable " + name + " of type '" + varType + ".");
-
740 }
-
741 }
-
742
-
758 inline void inner_set_value_int(const std::string& name, int *src) {
-
759 if (set_value_int(&bmi_model->handle, name.c_str(), src) != BMI_SUCCESS) {
-
760 throw models::external::State_Exception("Failed to set values of " + name + " int variable for " + model_name);
-
761 }
-
762 }
-
763
-
779 inline void inner_set_value_float(const std::string& name, float *src) {
-
780 if (set_value_float(&bmi_model->handle, name.c_str(), src) != BMI_SUCCESS) {
-
781 throw models::external::State_Exception("Failed to set values of " + name + " float variable for " + model_name);
-
782 }
-
783 }
-
784
-
800 inline void inner_set_value_double(const std::string& name, double *src) {
-
801 if (set_value_double(&bmi_model->handle, name.c_str(), src) != BMI_SUCCESS) {
-
802 throw models::external::State_Exception("Failed to set values of " + name + " double variable for " + model_name);
-
803 }
-
804 }
-
805
-
806 friend class ::Bmi_Fortran_Adapter_Test;
+
489 private:
+
490
+
502 inline void construct_and_init_backing_model_for_fortran() {
+
503 if (model_initialized)
+
504 return;
+
505 bmi_model = std::make_unique<Bmi_Fortran_Handle_Wrapper>(Bmi_Fortran_Handle_Wrapper());
+
506 dynamic_library_load();
+
507 execModuleRegistration();
+
508 int init_result = initialize(&bmi_model->handle, bmi_init_config.c_str());
+
509 if (init_result != BMI_SUCCESS) {
+
510 init_exception_msg = "Failure when attempting to initialize " + model_name;
+
511 throw models::external::State_Exception(init_exception_msg);
+
512 }
+
513 }
+
514
+
524 inline int inner_get_input_item_count() {
+
525 int item_count;
+
526 if (get_input_item_count(&bmi_model->handle, &item_count) != BMI_SUCCESS) {
+
527 throw std::runtime_error(model_name + " failed to get model input item count.");
+
528 }
+
529 return item_count;
+
530 }
+
531
+
541 inline int inner_get_output_item_count() {
+
542 int item_count;
+
543 if (get_output_item_count(&bmi_model->handle, &item_count) != BMI_SUCCESS) {
+
544 throw std::runtime_error(model_name + " failed to get model output item count.");
+
545 }
+
546 return item_count;
+
547 }
+
548
+
549 inline std::string inner_get_var_type(const std::string &name) {
+
550 char type_c_str[BMI_MAX_TYPE_NAME];
+
551 if (get_var_type(&bmi_model->handle, name.c_str(), type_c_str) != BMI_SUCCESS) {
+
552 throw std::runtime_error(model_name + " failed to get variable type for " + name + ".");
+
553 }
+
554 return {type_c_str};
+
555 }
+
556
+
572 inline void inner_get_value(const std::string& name, void *dest) {
+
573 std::string varType = inner_get_var_type(name);
+
574 //Can use the C type or the fortran type, e.g. int or integer
+
575 if (varType == "int" || varType == "integer") {
+
576 inner_get_value_int(name, (int *)dest);
+
577 }
+
578 else if (varType == "float" || varType == "real") {
+
579 inner_get_value_float(name, (float *)dest);
+
580 }
+
581 else if (varType == "double" || varType == "double precision") {
+
582 inner_get_value_double(name, (double *)dest);
+
583 }
+
584 else {
+
585 throw ::external::ExternalIntegrationException(
+
586 "Can't get model " + model_name + " variable " + name + " of type '" + varType + ".");
+
587 }
+
588 }
+
589
+
605 inline void inner_get_value_int(const std::string& name, int *dest) {
+
606 if (get_value_int(&bmi_model->handle, name.c_str(), dest) != BMI_SUCCESS) {
+
607 throw std::runtime_error(model_name + " failed to get values for variable " + name + ".");
+
608 }
+
609 }
+
610
+
626 inline void inner_get_value_float(const std::string& name, float *dest) {
+
627 if (get_value_float(&bmi_model->handle, name.c_str(), dest) != BMI_SUCCESS) {
+
628 throw std::runtime_error(model_name + " failed to get values for variable " + name + ".");
+
629 }
+
630 }
+
631
+
647 inline void inner_get_value_double(const std::string& name, double *dest) {
+
648 if (get_value_double(&bmi_model->handle, name.c_str(), dest) != BMI_SUCCESS) {
+
649 throw std::runtime_error(model_name + " failed to get values for variable " + name + ".");
+
650 }
+
651 }
+
652
+
666 std::shared_ptr<std::vector<std::string>> inner_get_variable_names(bool is_input_variables) {
+
667 // Writing this def once here at beginning: fewer lines, but this may or may not be used.
+
668 std::string varType = (is_input_variables) ? "input" : "output";
+
669
+
670 // Obtain this via inner functions, which should use the model directly and not other member functions
+
671 int variableCount;
+
672 try {
+
673 variableCount = (is_input_variables) ? inner_get_input_item_count() : inner_get_output_item_count();
+
674 }
+
675 catch (const std::exception &e) {
+
676 throw std::runtime_error(model_name + " failed to count of " + varType + " variable names array.");
+
677 }
+
678
+
679 // With variable count now obtained, create the vector
+
680 std::shared_ptr<std::vector<std::string>> var_names = std::make_shared<std::vector<std::string>>(
+
681 std::vector<std::string>(variableCount));
+
682
+
683 // Must get the names from the model as an array of C strings
+
684 // The array can be on the stack ...
+
685 std::vector<char*> names_array(variableCount);
+
686 // ... but allocate the space for the individual C strings (i.e., the char * elements)
+
687 for (int i = 0; i < variableCount; i++) {
+
688 names_array[i] = static_cast<char *>(malloc(sizeof(char) * BMI_MAX_VAR_NAME));
+
689 }
+
690
+
691 // With the necessary char** in hand, get the names from the model
+
692 int names_result;
+
693 if (is_input_variables) {
+
694 names_result = get_input_var_names(bmi_model.get(), names_array.data());
+
695 }
+
696 else {
+
697 names_result = get_output_var_names(bmi_model.get(), names_array.data());
+
698 }
+
699 if (names_result != BMI_SUCCESS) {
+
700 throw std::runtime_error(model_name + " failed to get array of " + varType + " variables names.");
+
701 }
+
702
+
703 // Then convert from array of C strings to vector of strings, freeing the allocated space as we go
+
704 for (int i = 0; i < variableCount; ++i) {
+
705 (*var_names)[i] = std::string(names_array[i]);
+
706 free(names_array[i]);
+
707 }
+
708
+
709 return var_names;
+
710 }
+
711
+
727 inline void inner_set_value(const std::string& name, void *src) {
+
728 std::string varType = inner_get_var_type(name);
+
729 //Can use the C type or the fortran type, e.g. int or integer
+
730 if (varType == "int" || varType == "integer") {
+
731 inner_set_value_int(name, (int *)src);
+
732 }
+
733 else if (varType == "float" || varType == "real") {
+
734 inner_set_value_float(name, (float *)src);
+
735 }
+
736 else if (varType == "double" || varType == "double precision") {
+
737 inner_set_value_double(name, (double *)src);
+
738 }
+
739 else {
+
740 throw ::external::ExternalIntegrationException(
+
741 "Can't get model " + model_name + " variable " + name + " of type '" + varType + ".");
+
742 }
+
743 }
+
744
+
760 inline void inner_set_value_int(const std::string& name, int *src) {
+
761 if (set_value_int(&bmi_model->handle, name.c_str(), src) != BMI_SUCCESS) {
+
762 throw models::external::State_Exception("Failed to set values of " + name + " int variable for " + model_name);
+
763 }
+
764 }
+
765
+
781 inline void inner_set_value_float(const std::string& name, float *src) {
+
782 if (set_value_float(&bmi_model->handle, name.c_str(), src) != BMI_SUCCESS) {
+
783 throw models::external::State_Exception("Failed to set values of " + name + " float variable for " + model_name);
+
784 }
+
785 }
+
786
+
802 inline void inner_set_value_double(const std::string& name, double *src) {
+
803 if (set_value_double(&bmi_model->handle, name.c_str(), src) != BMI_SUCCESS) {
+
804 throw models::external::State_Exception("Failed to set values of " + name + " double variable for " + model_name);
+
805 }
+
806 }
807
-
808 private:
-
810 std::unique_ptr<Bmi_Fortran_Handle_Wrapper> bmi_model = nullptr;
-
811
-
812 };
-
813 }
-
814}
-
815
-
816#endif // NGEN_BMI_FORTRAN_ACTIVE
+
808 friend class ::Bmi_Fortran_Adapter_Test;
+
809
+
810 private:
+
812 std::unique_ptr<Bmi_Fortran_Handle_Wrapper> bmi_model = nullptr;
+
813
+
814 };
+
815 }
+
816}
817
-
818#endif //NGEN_BMI_FORTRAN_ADAPTER_HPP
+
818#endif // NGEN_WITH_BMI_FORTRAN
+
819
+
820#endif //NGEN_BMI_FORTRAN_ADAPTER_HPP
Custom exception indicating a problem when integrating with some external component.
Definition ExternalIntegrationException.hpp:14
Custom exception indicating bad external model state.
Definition State_Exception.hpp:18
This class provides a copyable interface to a std::ostream or std::ostream like object that may not s...
Definition StreamHandler.hpp:14
@@ -554,7 +556,7 @@ diff --git a/_bmi___fortran___common_8h_source.html b/_bmi___fortran___common_8h_source.html index 92e4809ce3..a728292cde 100644 --- a/_bmi___fortran___common_8h_source.html +++ b/_bmi___fortran___common_8h_source.html @@ -100,131 +100,133 @@
1#ifndef NGEN_BMI_FORTRAN_COMMON_H
2#define NGEN_BMI_FORTRAN_COMMON_H
3
-
4#ifdef NGEN_BMI_FORTRAN_ACTIVE
+
4#include <NGenConfig.h>
5
-
18extern "C" {
-
19
-
21 extern int initialize(void *fortran_bmi_handle, const char *config_file);
-
22
-
23 extern int update(void *fortran_bmi_handle);
+
6#if NGEN_WITH_BMI_FORTRAN
+
7
+
20extern "C" {
+
21
+
23 extern int initialize(void *fortran_bmi_handle, const char *config_file);
24
-
25 extern int update_until(void *fortran_bmi_handle, double *then);
+
25 extern int update(void *fortran_bmi_handle);
26
-
27 extern int finalize(void *fortran_bmi_handle);
+
27 extern int update_until(void *fortran_bmi_handle, double *then);
28
-
29 /* Exchange items */
-
30 extern int get_component_name(void *fortran_bmi_handle, char *name);
-
31
-
32 extern int get_input_item_count(void *fortran_bmi_handle, int *count);
+
29 extern int finalize(void *fortran_bmi_handle);
+
30
+
31 /* Exchange items */
+
32 extern int get_component_name(void *fortran_bmi_handle, char *name);
33
-
34 extern int get_output_item_count(void *fortran_bmi_handle, int *count);
+
34 extern int get_input_item_count(void *fortran_bmi_handle, int *count);
35
-
36 extern int get_input_var_names(void *fortran_bmi_handle, char **names);
+
36 extern int get_output_item_count(void *fortran_bmi_handle, int *count);
37
-
38 extern int get_output_var_names(void *fortran_bmi_handle, char **names);
+
38 extern int get_input_var_names(void *fortran_bmi_handle, char **names);
39
-
40 /* Variable information */
-
41 extern int get_var_grid(void *fortran_bmi_handle, const char *name, int *grid);
-
42
-
43 extern int get_var_type(void *fortran_bmi_handle, const char *name, char *type);
+
40 extern int get_output_var_names(void *fortran_bmi_handle, char **names);
+
41
+
42 /* Variable information */
+
43 extern int get_var_grid(void *fortran_bmi_handle, const char *name, int *grid);
44
-
45 extern int get_var_units(void *fortran_bmi_handle, const char *name, char *units);
+
45 extern int get_var_type(void *fortran_bmi_handle, const char *name, char *type);
46
-
47 extern int get_var_itemsize(void *fortran_bmi_handle, const char *name, int *size);
+
47 extern int get_var_units(void *fortran_bmi_handle, const char *name, char *units);
48
-
49 extern int get_var_nbytes(void *fortran_bmi_handle, const char *name, int *nbytes);
+
49 extern int get_var_itemsize(void *fortran_bmi_handle, const char *name, int *size);
50
-
51 extern int get_var_location(void *fortran_bmi_handle, const char *name, char *location);
+
51 extern int get_var_nbytes(void *fortran_bmi_handle, const char *name, int *nbytes);
52
-
53 /* Time information */
-
54 extern int get_current_time(void *fortran_bmi_handle, double *time);
-
55
-
56 extern int get_start_time(void *fortran_bmi_handle, double *time);
+
53 extern int get_var_location(void *fortran_bmi_handle, const char *name, char *location);
+
54
+
55 /* Time information */
+
56 extern int get_current_time(void *fortran_bmi_handle, double *time);
57
-
58 extern int get_end_time(void *fortran_bmi_handle, double *time);
+
58 extern int get_start_time(void *fortran_bmi_handle, double *time);
59
-
60 extern int get_time_units(void *fortran_bmi_handle, char *units);
+
60 extern int get_end_time(void *fortran_bmi_handle, double *time);
61
-
62 extern int get_time_step(void *fortran_bmi_handle, double *time_step);
+
62 extern int get_time_units(void *fortran_bmi_handle, char *units);
63
-
64 /* Getters */
-
65 extern int get_value_int(void *fortran_bmi_handle, const char *name, int *dest);
-
66
-
67 extern int get_value_float(void *fortran_bmi_handle, const char *name, float *dest);
+
64 extern int get_time_step(void *fortran_bmi_handle, double *time_step);
+
65
+
66 /* Getters */
+
67 extern int get_value_int(void *fortran_bmi_handle, const char *name, int *dest);
68
-
69 extern int get_value_double(void *fortran_bmi_handle, const char *name, double *dest);
+
69 extern int get_value_float(void *fortran_bmi_handle, const char *name, float *dest);
70
-
71 /* The following functions are not currently implemented in the Fortran iso_c_binding middleware, and as such
-
72 * not declared here. This is not a problem, since it is fairly easy to work around their absence using the primary
-
73 * getter and setter functions.
-
74 *
-
75 * They can be added if needed/possible in the future, but implementations must be added to the middleware before
-
76 * these declarations will be valid.
-
77 */
-
78 extern int get_value_ptr_int(void *fortran_bmi_handle, const char *name, int *dest);
-
79 extern int get_value_ptr_float(void *fortran_bmi_handle, const char *name, float *dest);
-
80 extern int get_value_ptr_double(void *fortran_bmi_handle, const char *name, double *dest);
-
81 extern int get_value_at_indices_int(void *fortran_bmi_handle, const char *name, int *dest, int indices);
-
82 extern int get_value_at_indices_float(void *fortran_bmi_handle, const char *name, float *dest, int indices);
-
83 extern int get_value_at_indices_double(void *fortran_bmi_handle, const char *name, double *dest, int indices);
-
84 extern int set_value_at_indices_int(void *fortran_bmi_handle, const char *name, int indices, int *src);
-
85 extern int set_value_at_indices_float(void *fortran_bmi_handle, const char *name, int indices, float *src);
-
86 extern int set_value_at_indices_double(void *fortran_bmi_handle, const char *name, int indices, double *src);
-
87
-
88 /* Setters */
-
89 extern int set_value_int(void *fortran_bmi_handle, const char *name, int *src);
-
90
-
91 extern int set_value_float(void *fortran_bmi_handle, const char *name, float *src);
+
71 extern int get_value_double(void *fortran_bmi_handle, const char *name, double *dest);
+
72
+
73 /* The following functions are not currently implemented in the Fortran iso_c_binding middleware, and as such
+
74 * not declared here. This is not a problem, since it is fairly easy to work around their absence using the primary
+
75 * getter and setter functions.
+
76 *
+
77 * They can be added if needed/possible in the future, but implementations must be added to the middleware before
+
78 * these declarations will be valid.
+
79 */
+
80 extern int get_value_ptr_int(void *fortran_bmi_handle, const char *name, int *dest);
+
81 extern int get_value_ptr_float(void *fortran_bmi_handle, const char *name, float *dest);
+
82 extern int get_value_ptr_double(void *fortran_bmi_handle, const char *name, double *dest);
+
83 extern int get_value_at_indices_int(void *fortran_bmi_handle, const char *name, int *dest, int indices);
+
84 extern int get_value_at_indices_float(void *fortran_bmi_handle, const char *name, float *dest, int indices);
+
85 extern int get_value_at_indices_double(void *fortran_bmi_handle, const char *name, double *dest, int indices);
+
86 extern int set_value_at_indices_int(void *fortran_bmi_handle, const char *name, int indices, int *src);
+
87 extern int set_value_at_indices_float(void *fortran_bmi_handle, const char *name, int indices, float *src);
+
88 extern int set_value_at_indices_double(void *fortran_bmi_handle, const char *name, int indices, double *src);
+
89
+
90 /* Setters */
+
91 extern int set_value_int(void *fortran_bmi_handle, const char *name, int *src);
92
-
93 extern int set_value_double(void *fortran_bmi_handle, const char *name, double *src);
+
93 extern int set_value_float(void *fortran_bmi_handle, const char *name, float *src);
94
-
95 /* Grid information */
-
96 extern int get_grid_rank(void *fortran_bmi_handle, int *grid, int *rank);
-
97
-
98 extern int get_grid_size(void *fortran_bmi_handle, int *grid, int *size);
+
95 extern int set_value_double(void *fortran_bmi_handle, const char *name, double *src);
+
96
+
97 /* Grid information */
+
98 extern int get_grid_rank(void *fortran_bmi_handle, int *grid, int *rank);
99
-
100 extern int get_grid_type(void *fortran_bmi_handle, int *grid, char *type);
+
100 extern int get_grid_size(void *fortran_bmi_handle, int *grid, int *size);
101
-
102 /* Uniform rectilinear */
-
103 extern int get_grid_shape(void *fortran_bmi_handle, int *grid, int *shape);
-
104
-
105 extern int get_grid_spacing(void *fortran_bmi_handle, int *grid, double *spacing);
+
102 extern int get_grid_type(void *fortran_bmi_handle, int *grid, char *type);
+
103
+
104 /* Uniform rectilinear */
+
105 extern int get_grid_shape(void *fortran_bmi_handle, int *grid, int *shape);
106
-
107 extern int get_grid_origin(void *fortran_bmi_handle, int *grid, double *origin);
+
107 extern int get_grid_spacing(void *fortran_bmi_handle, int *grid, double *spacing);
108
-
109 /* Non-uniform rectilinear, curvilinear */
-
110 extern int get_grid_x(void *fortran_bmi_handle, int *grid, double *x);
-
111
-
112 extern int get_grid_y(void *fortran_bmi_handle, int *grid, double *y);
+
109 extern int get_grid_origin(void *fortran_bmi_handle, int *grid, double *origin);
+
110
+
111 /* Non-uniform rectilinear, curvilinear */
+
112 extern int get_grid_x(void *fortran_bmi_handle, int *grid, double *x);
113
-
114 extern int get_grid_z(void *fortran_bmi_handle, int *grid, double *z);
+
114 extern int get_grid_y(void *fortran_bmi_handle, int *grid, double *y);
115
-
116 /* Unstructured */
-
117 extern int get_grid_node_count(void *fortran_bmi_handle, int *grid, int *count);
-
118
-
119 extern int get_grid_edge_count(void *fortran_bmi_handle, int *grid, int *count);
+
116 extern int get_grid_z(void *fortran_bmi_handle, int *grid, double *z);
+
117
+
118 /* Unstructured */
+
119 extern int get_grid_node_count(void *fortran_bmi_handle, int *grid, int *count);
120
-
121 extern int get_grid_face_count(void *fortran_bmi_handle, int *grid, int *count);
+
121 extern int get_grid_edge_count(void *fortran_bmi_handle, int *grid, int *count);
122
-
123 extern int get_grid_edge_nodes(void *fortran_bmi_handle, int *grid, int *edge_nodes);
+
123 extern int get_grid_face_count(void *fortran_bmi_handle, int *grid, int *count);
124
-
125 extern int get_grid_face_edges(void *fortran_bmi_handle, int *grid, int *face_edges);
+
125 extern int get_grid_edge_nodes(void *fortran_bmi_handle, int *grid, int *edge_nodes);
126
-
127 extern int get_grid_face_nodes(void *fortran_bmi_handle, int *grid, int *face_nodes);
+
127 extern int get_grid_face_edges(void *fortran_bmi_handle, int *grid, int *face_edges);
128
-
129 extern int get_grid_nodes_per_face(void *fortran_bmi_handle, int *grid, int *nodes_per_face);
-
130}
-
131
-
132#endif // NGEN_BMI_FORTRAN_ACTIVE
+
129 extern int get_grid_face_nodes(void *fortran_bmi_handle, int *grid, int *face_nodes);
+
130
+
131 extern int get_grid_nodes_per_face(void *fortran_bmi_handle, int *grid, int *nodes_per_face);
+
132}
133
-
134#endif //NGEN_BMI_FORTRAN_COMMON_H
+
134#endif // NGEN_WITH_BMI_FORTRAN
+
135
+
136#endif //NGEN_BMI_FORTRAN_COMMON_H
diff --git a/_bmi___fortran___formulation_8hpp_source.html b/_bmi___fortran___formulation_8hpp_source.html index 1c7bec9231..1acf3f5a83 100644 --- a/_bmi___fortran___formulation_8hpp_source.html +++ b/_bmi___fortran___formulation_8hpp_source.html @@ -100,56 +100,58 @@
1#ifndef NGEN_BMI_FORTRAN_FORMULATION_HPP
2#define NGEN_BMI_FORTRAN_FORMULATION_HPP
3
-
4#ifdef NGEN_BMI_FORTRAN_ACTIVE
+
4#include <NGenConfig.h>
5
-
6#include "Bmi_Module_Formulation.hpp"
-
7#include "Bmi_Fortran_Adapter.hpp"
-
8#include <GenericDataProvider.hpp>
-
9
-
10// TODO: consider merging this somewhere with the C value in that formulation header
-
11#define BMI_FORTRAN_DEFAULT_REGISTRATION_FUNC "register_bmi"
-
12
-
13class Bmi_Fortran_Formulation_Test;
+
6#if NGEN_WITH_BMI_FORTRAN
+
7
+
8#include "Bmi_Module_Formulation.hpp"
+
9#include "Bmi_Fortran_Adapter.hpp"
+
10#include <GenericDataProvider.hpp>
+
11
+
12// TODO: consider merging this somewhere with the C value in that formulation header
+
13#define BMI_FORTRAN_DEFAULT_REGISTRATION_FUNC "register_bmi"
14
-
15using namespace models::bmi;
+
15class Bmi_Fortran_Formulation_Test;
16
-
17namespace realization {
+
17using namespace models::bmi;
18
-
19 class Bmi_Fortran_Formulation : public Bmi_Module_Formulation {
+
19namespace realization {
20
-
21 public:
+
21 class Bmi_Fortran_Formulation : public Bmi_Module_Formulation {
22
-
23 Bmi_Fortran_Formulation(std::string id, std::shared_ptr<data_access::GenericDataProvider> forcing, utils::StreamHandler output_stream);
+
23 public:
24
-
25 std::string get_formulation_type() override;
+
25 Bmi_Fortran_Formulation(std::string id, std::shared_ptr<data_access::GenericDataProvider> forcing, utils::StreamHandler output_stream);
26
-
59 double get_response(::time_step_t index, ::time_step_t t_delta) override;
-
60
-
61 protected:
+
27 std::string get_formulation_type() override;
+
28
+
61 double get_response(::time_step_t index, ::time_step_t t_delta) override;
62
-
75 std::shared_ptr<Bmi_Adapter> construct_model(const geojson::PropertyMap& properties) override;
-
76
-
77 time_t convert_model_time(const double &model_time) override {
-
78 return (time_t) (get_bmi_model()->convert_model_time_to_seconds(model_time));
-
79 }
-
80
-
81 double get_var_value_as_double(const std::string &var_name) override;
+
63 protected:
+
64
+
77 std::shared_ptr<Bmi_Adapter> construct_model(const geojson::PropertyMap& properties) override;
+
78
+
79 time_t convert_model_time(const double &model_time) override {
+
80 return (time_t) (get_bmi_model()->convert_model_time_to_seconds(model_time));
+
81 }
82
-
83 double get_var_value_as_double(const int &index, const std::string &var_name) override;
+
83 double get_var_value_as_double(const std::string &var_name) override;
84
-
85 friend class Bmi_Multi_Formulation;
+
85 double get_var_value_as_double(const int &index, const std::string &var_name) override;
86
-
87 // Unit test access
-
88 friend class ::Bmi_Multi_Formulation_Test;
-
89 friend class ::Bmi_Formulation_Test;
-
90 friend class ::Bmi_Fortran_Formulation_Test;
-
91 };
-
92
-
93}
+
87 friend class Bmi_Multi_Formulation;
+
88
+
89 // Unit test access
+
90 friend class ::Bmi_Multi_Formulation_Test;
+
91 friend class ::Bmi_Formulation_Test;
+
92 friend class ::Bmi_Fortran_Formulation_Test;
+
93 };
94
-
95#endif // NGEN_BMI_FORTRAN_ACTIVE
+
95}
96
-
97#endif //NGEN_BMI_FORTRAN_FORMULATION_HPP
+
97#endif // NGEN_WITH_BMI_FORTRAN
+
98
+
99#endif //NGEN_BMI_FORTRAN_FORMULATION_HPP
This class provides a copyable interface to a std::ostream or std::ostream like object that may not s...
Definition StreamHandler.hpp:14
std::map< std::string, JSONProperty > PropertyMap
Shorthand for a mapping between strings and properties.
Definition JSONProperty.hpp:21
Definition AbstractCLibBmiAdapter.hpp:7
@@ -160,7 +162,7 @@ diff --git a/_bmi___module___formulation_8hpp_source.html b/_bmi___module___formulation_8hpp_source.html index 3af3940b6f..7da2c68ab8 100644 --- a/_bmi___module___formulation_8hpp_source.html +++ b/_bmi___module___formulation_8hpp_source.html @@ -412,7 +412,7 @@ diff --git a/_bmi___multi___formulation_8hpp_source.html b/_bmi___multi___formulation_8hpp_source.html index ca52bfaa61..a13a06a941 100644 --- a/_bmi___multi___formulation_8hpp_source.html +++ b/_bmi___multi___formulation_8hpp_source.html @@ -575,44 +575,44 @@
Abstraction of formulation with backing model object(s) that implements the BMI.
Definition Bmi_Formulation.hpp:49
const std::vector< std::string > & get_output_variable_names() const
Get the names of variables in formulation output.
Definition Bmi_Formulation.hpp:173
Abstraction of a formulation with multiple backing model object that implements the BMI.
Definition Bmi_Multi_Formulation.hpp:25
-
bool is_time_step_beyond_end_time(time_step_t t_index)
Get whether this time step goes beyond this formulations (i.e., any of it's modules') end time.
Definition Bmi_Multi_Formulation.cpp:424
-
bool is_bmi_input_variable(const std::string &var_name) override
Definition Bmi_Multi_Formulation.cpp:395
+
bool is_time_step_beyond_end_time(time_step_t t_index)
Get whether this time step goes beyond this formulations (i.e., any of it's modules') end time.
Definition Bmi_Multi_Formulation.cpp:426
+
bool is_bmi_input_variable(const std::string &var_name) override
Definition Bmi_Multi_Formulation.cpp:397
std::shared_ptr< T > init_nested_module(int mod_index, std::string identifier, geojson::PropertyMap properties)
Initialize a nested formulation from the given properties and update multi formulation metadata.
Definition Bmi_Multi_Formulation.hpp:654
-
double get_response(time_step_t t_index, time_step_t t_delta) override
Execute the backing model formulation for the given time step, where it is of the specified size,...
Definition Bmi_Multi_Formulation.cpp:328
+
double get_response(time_step_t t_index, time_step_t t_delta) override
Execute the backing model formulation for the given time step, where it is of the specified size,...
Definition Bmi_Multi_Formulation.cpp:330
double get_var_value_as_double(const std::string &var_name) override
Get value for some BMI model variable.
Definition Bmi_Multi_Formulation.hpp:544
std::vector< nested_module_ptr > modules
The nested BMI modules composing this multi-module formulation, in their order of execution.
Definition Bmi_Multi_Formulation.hpp:783
-
std::string get_output_line_for_timestep(int timestep, std::string delimiter) override
Get a formatted line of output values for the given time step as a delimited string.
Definition Bmi_Multi_Formulation.cpp:292
+
std::string get_output_line_for_timestep(int timestep, std::string delimiter) override
Get a formatted line of output values for the given time step as a delimited string.
Definition Bmi_Multi_Formulation.cpp:294
int next_time_step_index
Index value (0-based) of the time step that will be processed by the next update of the model.
Definition Bmi_Multi_Formulation.hpp:791
-
const std::string & get_config_mapped_variable_name(const std::string &model_var_name) override
When possible, translate a variable name for a BMI model to an internally recognized name.
Definition Bmi_Multi_Formulation.cpp:220
+
const std::string & get_config_mapped_variable_name(const std::string &model_var_name) override
When possible, translate a variable name for a BMI model to an internally recognized name.
Definition Bmi_Multi_Formulation.cpp:222
Bmi_Formulation nested_module_type
Definition Bmi_Multi_Formulation.hpp:29
-
const time_t & get_bmi_model_start_time_forcing_offset_s() override
Definition Bmi_Multi_Formulation.cpp:198
+
const time_t & get_bmi_model_start_time_forcing_offset_s() override
Definition Bmi_Multi_Formulation.cpp:200
bool is_out_vars_from_last_mod
Whether the Bmi_Formulation::output_variable_names value is just the analogous value from this instan...
Definition Bmi_Multi_Formulation.hpp:781
std::vector< double > get_values(const CatchmentAggrDataSelector &selector, data_access::ReSampleMethod m) override
Get the values of a forcing property for an arbitrary time period, converting units if needed.
Definition Bmi_Multi_Formulation.hpp:404
void set_index_for_primary_module(int index)
Set the index of the primary module.
Definition Bmi_Multi_Formulation.hpp:488
time_t get_variable_time_end(const std::string &variable_name)
Get the exclusive ending of the period of time over which this instance can provide data for this for...
Definition Bmi_Multi_Formulation.hpp:278
long get_data_stop_time() override
Get the exclusive ending of the period of time over which this instance can provide data for this for...
Definition Bmi_Multi_Formulation.hpp:263
-
bool is_bmi_using_forcing_file() const override
Whether the backing model uses/reads the forcing file directly for getting input data.
Definition Bmi_Multi_Formulation.cpp:408
+
bool is_bmi_using_forcing_file() const override
Whether the backing model uses/reads the forcing file directly for getting input data.
Definition Bmi_Multi_Formulation.cpp:410
const std::vector< std::string > get_bmi_output_variables() override
Get the output variables of the last nested BMI model.
Definition Bmi_Multi_Formulation.hpp:139
void check_output_var_names()
Check that the output variable names in the global bmi_multi are valid names.
Definition Bmi_Multi_Formulation.hpp:497
time_t convert_model_time(const double &model_time) override
Convert a time value from the model to an epoch time in seconds.
Definition Bmi_Multi_Formulation.hpp:59
void init_deferred_associations()
Initialize the deferred associations with the providers in deferredProviders.
Definition Bmi_Multi_Formulation.hpp:603
-
bool is_bmi_output_variable(const std::string &var_name) override
Definition Bmi_Multi_Formulation.cpp:404
+
bool is_bmi_output_variable(const std::string &var_name) override
Definition Bmi_Multi_Formulation.cpp:406
virtual ~Bmi_Multi_Formulation()
Definition Bmi_Multi_Formulation.hpp:43
std::vector< std::string > module_types
Definition Bmi_Multi_Formulation.hpp:784
-
const std::string & get_forcing_file_path() const override
Definition Bmi_Multi_Formulation.cpp:288
+
const std::string & get_forcing_file_path() const override
Definition Bmi_Multi_Formulation.cpp:290
std::vector< std::shared_ptr< data_access::OptionalWrappedDataProvider > > deferredProviders
A collection of wrappers to nested formulations providing some output to an earlier nested formulatio...
Definition Bmi_Multi_Formulation.hpp:768
long record_duration() override
Return the stride in the time dimension.
Definition Bmi_Multi_Formulation.hpp:292
double get_var_value_as_double(const int &index, const std::string &var_name) override
Get value for some BMI model variable at a specific index.
Definition Bmi_Multi_Formulation.hpp:572
-
void create_multi_formulation(geojson::PropertyMap properties, bool needs_param_validation)
Creating a multi-BMI-module formulation from NGen config.
Definition Bmi_Multi_Formulation.cpp:15
+
void create_multi_formulation(geojson::PropertyMap properties, bool needs_param_validation)
Creating a multi-BMI-module formulation from NGen config.
Definition Bmi_Multi_Formulation.cpp:17
void create_formulation(geojson::PropertyMap properties) override
Definition Bmi_Multi_Formulation.hpp:85
bool is_property_sum_over_time_step(const std::string &name) override
Get whether a property's per-time-step values are each an aggregate sum over the entire time step.
Definition Bmi_Multi_Formulation.hpp:455
-
bool is_bmi_model_time_step_fixed() override
Test whether all backing models have fixed time step size.
Definition Bmi_Multi_Formulation.cpp:399
+
bool is_bmi_model_time_step_fixed() override
Test whether all backing models have fixed time step size.
Definition Bmi_Multi_Formulation.cpp:401
void setup_nested_deferred_provider(const std::string &bmi_input_var_name, const std::string &framework_output_name, std::shared_ptr< T > mod, int mod_index)
Setup a deferred provider for a nested module, tracking the class as needed.
Definition Bmi_Multi_Formulation.hpp:726
const std::vector< std::string > get_bmi_input_variables() override
Get the input variables of the first nested BMI model.
Definition Bmi_Multi_Formulation.hpp:128
friend Bmi_Multi_Formulation_Test
Definition Bmi_Multi_Formulation.hpp:795
std::vector< std::shared_ptr< std::map< std::string, std::string > > > module_variable_maps
Per-module maps (ordered as in modules) of configuration-mapped names to BMI variable names.
Definition Bmi_Multi_Formulation.hpp:789
std::vector< std::string > available_forcings
The set of available "forcings" (output variables, plus their mapped aliases) this instance can provi...
Definition Bmi_Multi_Formulation.hpp:755
-
bool is_model_initialized() override
Test whether all backing models have been initialize using the BMI standard Initialize function.
Definition Bmi_Multi_Formulation.cpp:413
+
bool is_model_initialized() override
Test whether all backing models have been initialize using the BMI standard Initialize function.
Definition Bmi_Multi_Formulation.cpp:415
std::map< std::string, std::shared_ptr< data_access::GenericDataProvider > > availableData
A mapping of data properties to their providers.
Definition Bmi_Multi_Formulation.hpp:706
std::vector< int > deferredProviderModuleIndices
The module indices for the modules associated with each item in deferredProviders.
Definition Bmi_Multi_Formulation.hpp:776
const double get_model_start_time()
Get the end time for the primary nested BMI model in its native format and units.
Definition Bmi_Multi_Formulation.hpp:343
@@ -622,11 +622,11 @@
time_t convert_model_time(const double &model_time, int module_index)
Convert a time value from the model to an epoch time in seconds.
Definition Bmi_Multi_Formulation.hpp:76
const double get_model_current_time() override
Get the current time for the primary nested BMI model in its native format and units.
Definition Bmi_Multi_Formulation.hpp:325
Bmi_Multi_Formulation(std::string id, std::shared_ptr< data_access::GenericDataProvider > forcing_provider, utils::StreamHandler output_stream)
Minimal constructor for objects initialize using the Formulation_Manager and subsequent calls to crea...
Definition Bmi_Multi_Formulation.hpp:40
-
const bool & get_allow_model_exceed_end_time() const override
Get whether a model may perform updates beyond its end_time.
Definition Bmi_Multi_Formulation.cpp:165
+
const bool & get_allow_model_exceed_end_time() const override
Get whether a model may perform updates beyond its end_time.
Definition Bmi_Multi_Formulation.cpp:167
void create_formulation(boost::property_tree::ptree &config, geojson::PropertyMap *global=nullptr) override
Definition Bmi_Multi_Formulation.hpp:80
size_t get_ts_index_for_time(const time_t &epoch_time) override
Get the index of the forcing time step that contains the given point in time.
Definition Bmi_Multi_Formulation.hpp:364
long get_data_start_time() override
Get the inclusive beginning of the period of time over which this instance can provide data for this ...
Definition Bmi_Multi_Formulation.hpp:224
-
boost::span< const std::string > get_available_variable_names() override
Get the collection of forcing output property names this instance can provide.
Definition Bmi_Multi_Formulation.cpp:187
+
boost::span< const std::string > get_available_variable_names() override
Get the collection of forcing output property names this instance can provide.
Definition Bmi_Multi_Formulation.cpp:189
std::string get_formulation_type() override
Definition Bmi_Multi_Formulation.hpp:316
time_t get_variable_time_begin(const std::string &variable_name)
Get the inclusive beginning of the period of time over which this instance can provide data for this ...
Definition Bmi_Multi_Formulation.hpp:239
std::shared_ptr< nested_module_type > nested_module_ptr
Definition Bmi_Multi_Formulation.hpp:30
@@ -647,7 +647,7 @@ diff --git a/_bmi___py___adapter_8hpp_source.html b/_bmi___py___adapter_8hpp_source.html index 4bb9179024..30b7dfc6db 100644 --- a/_bmi___py___adapter_8hpp_source.html +++ b/_bmi___py___adapter_8hpp_source.html @@ -100,567 +100,569 @@
1#ifndef NGEN_BMI_PY_ADAPTER_H
2#define NGEN_BMI_PY_ADAPTER_H
3
-
4#ifdef ACTIVATE_PYTHON
+
4#include <NGenConfig.h>
5
-
6#include <cstring>
-
7#include <exception>
-
8#include <memory>
-
9#include <string>
-
10
-
11#include "pybind11/pybind11.h"
-
12#include "pybind11/pytypes.h"
-
13#include "pybind11/numpy.h"
-
14
-
15#include "boost/algorithm/string/join.hpp"
+
6#if NGEN_WITH_PYTHON
+
7
+
8#include <cstring>
+
9#include <exception>
+
10#include <memory>
+
11#include <string>
+
12
+
13#include "pybind11/pybind11.h"
+
14#include "pybind11/pytypes.h"
+
15#include "pybind11/numpy.h"
16
-
17#include "Bmi_Adapter.hpp"
+
17#include "boost/algorithm/string/join.hpp"
18
-
19#include "utilities/StreamHandler.hpp"
-
20#include "utilities/python/InterpreterUtil.hpp"
-
21
-
22// Forward declaration to provide access to protected items in testing
-
23class Bmi_Py_Adapter_Test;
-
24
-
25namespace py = pybind11;
+
19#include "Bmi_Adapter.hpp"
+
20
+
21#include "utilities/StreamHandler.hpp"
+
22#include "utilities/python/InterpreterUtil.hpp"
+
23
+
24// Forward declaration to provide access to protected items in testing
+
25class Bmi_Py_Adapter_Test;
26
-
27using namespace pybind11::literals; // to bring in the `_a` literal for pybind11 keyword args functionality
+
27namespace py = pybind11;
28
-
29namespace models {
-
30 namespace bmi {
-
31
-
36 class Bmi_Py_Adapter final : public Bmi_Adapter {
-
37
-
38 public:
+
29using namespace pybind11::literals; // to bring in the `_a` literal for pybind11 keyword args functionality
+
30
+
31namespace models {
+
32 namespace bmi {
+
33
+
38 class Bmi_Py_Adapter final : public Bmi_Adapter {
39
-
40 Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
-
41 bool allow_exceed_end, bool has_fixed_time_step, utils::StreamHandler output);
-
42
-
43 Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
-
44 std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
- -
46
-
47 Bmi_Py_Adapter(Bmi_Py_Adapter const&) = delete;
-
48 Bmi_Py_Adapter(Bmi_Py_Adapter&&) = delete;
-
49
-
50 ~Bmi_Py_Adapter() override {
-
51 Finalize();
-
52 }
-
53
-
62 template <typename T>
-
63 void copy_to_array(const std::string& name, T *dest)
-
64 {
-
65 py::array_t<T> backing_array = bmi_model->attr("get_value_ptr")(name);
-
66 auto uncheck_proxy = backing_array.template unchecked<1>();
-
67 for (ssize_t i = 0; i < backing_array.size(); ++i) {
-
68 dest[i] = uncheck_proxy(i);
-
69 }
-
70 }
-
71
-
79 template <typename T>
-
80 std::vector<T> copy_to_vector(const std::string& name)
-
81 {
-
82 py::array_t<T> backing_array = bmi_model->attr("get_value_ptr")(name);
-
83 std::vector<T> dest(backing_array.size());
-
84 auto uncheck_proxy = backing_array.template unchecked<1>();
-
85 for (ssize_t i = 0; i < backing_array.size(); ++i) {
-
86 dest[i] = uncheck_proxy(i);
-
87 }
-
88 return dest;
-
89 }
-
90
-
91 void Finalize() override {
-
92 bmi_model->attr("finalize")();
-
93 }
-
94
-
95 std::string GetComponentName() override;
+
40 public:
+
41
+
42 Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
+
43 bool allow_exceed_end, bool has_fixed_time_step, utils::StreamHandler output);
+
44
+
45 Bmi_Py_Adapter(const std::string &type_name, std::string bmi_init_config, const std::string &bmi_python_type,
+
46 std::string forcing_file_path, bool allow_exceed_end, bool has_fixed_time_step,
+ +
48
+
49 Bmi_Py_Adapter(Bmi_Py_Adapter const&) = delete;
+
50 Bmi_Py_Adapter(Bmi_Py_Adapter&&) = delete;
+
51
+
52 ~Bmi_Py_Adapter() override {
+
53 Finalize();
+
54 }
+
55
+
64 template <typename T>
+
65 void copy_to_array(const std::string& name, T *dest)
+
66 {
+
67 py::array_t<T> backing_array = bmi_model->attr("get_value_ptr")(name);
+
68 auto uncheck_proxy = backing_array.template unchecked<1>();
+
69 for (ssize_t i = 0; i < backing_array.size(); ++i) {
+
70 dest[i] = uncheck_proxy(i);
+
71 }
+
72 }
+
73
+
81 template <typename T>
+
82 std::vector<T> copy_to_vector(const std::string& name)
+
83 {
+
84 py::array_t<T> backing_array = bmi_model->attr("get_value_ptr")(name);
+
85 std::vector<T> dest(backing_array.size());
+
86 auto uncheck_proxy = backing_array.template unchecked<1>();
+
87 for (ssize_t i = 0; i < backing_array.size(); ++i) {
+
88 dest[i] = uncheck_proxy(i);
+
89 }
+
90 return dest;
+
91 }
+
92
+
93 void Finalize() override {
+
94 bmi_model->attr("finalize")();
+
95 }
96
-
97 double GetCurrentTime() override;
+
97 std::string GetComponentName() override;
98
-
99 double GetEndTime() override;
+
99 double GetCurrentTime() override;
100
-
101 int GetInputItemCount() override;
+
101 double GetEndTime() override;
102
-
103 std::vector<std::string> GetInputVarNames() override;
+
103 int GetInputItemCount() override;
104
-
105 int GetOutputItemCount() override;
+
105 std::vector<std::string> GetInputVarNames() override;
106
-
107 std::vector<std::string> GetOutputVarNames() override;
+
107 int GetOutputItemCount() override;
108
-
109 int GetGridEdgeCount(const int grid) override {
-
110 return py::int_(bmi_model->attr("get_grid_edge_count")(grid));
-
111 }
-
112
-
113 void GetGridEdgeNodes(const int grid, int *edge_nodes) override {
-
114 // As per BMI docs:
-
115 // "For each edge, connectivity is given as node at edge tail, followed by node at edge head."
-
116 // "The total length of the array is 2 * get_grid_edge_count."
-
117 get_and_copy_grid_array<int>("get_grid_edge_nodes", grid, edge_nodes, 2*GetGridEdgeCount(grid), "int");
-
118 }
-
119
-
120 int GetGridFaceCount(const int grid) override {
-
121 return py::int_(bmi_model->attr("get_grid_face_count")(grid));
-
122 }
-
123
-
124 void GetGridFaceEdges(const int grid, int *face_edges) override {
-
125 // As per BMI docs:
-
126 // "The length of the array returned is the sum of the values of get_grid_nodes_per_face."
-
127 int nodes_per_face_sum = get_sum_of_grid_nodes_per_face(grid);
-
128 get_and_copy_grid_array<int>("get_grid_face_edges", grid, face_edges, nodes_per_face_sum, "int");
-
129 }
-
130
-
131 void GetGridFaceNodes(const int grid, int *face_nodes) override {
-
132 int nodes_per_face_sum = get_sum_of_grid_nodes_per_face(grid);
-
133 get_and_copy_grid_array<int>("get_grid_face_nodes", grid, face_nodes, nodes_per_face_sum, "int");
-
134 }
-
135
-
136 int GetGridNodeCount(const int grid) override {
-
137 return py::int_(bmi_model->attr("get_grid_node_count")(grid));
-
138 }
-
139
-
140 void GetGridNodesPerFace(const int grid, int *nodes_per_face) override {
-
141 get_and_copy_grid_array<int>(
-
142 "get_grid_nodes_per_face", grid, nodes_per_face, GetGridFaceCount(grid), "int");
-
143 }
-
144
-
145 void GetGridOrigin(const int grid, double *origin) override {
-
146 get_and_copy_grid_array<double>("get_grid_origin", grid, origin, GetGridRank(grid), "double");
-
147 }
-
148
-
149 int GetGridRank(const int grid) override {
-
150 return py::int_(bmi_model->attr("get_grid_rank")(grid));
-
151 }
-
152
-
153 void GetGridShape(const int grid, int *shape) override {
-
154 get_and_copy_grid_array<int>("get_grid_shape", grid, shape, GetGridRank(grid), "int");
-
155 }
-
156
-
157 int GetGridSize(const int grid) override {
-
158 return py::int_(bmi_model->attr("get_grid_size")(grid));
-
159 }
-
160
-
161 void GetGridSpacing(const int grid, double *spacing) override {
-
162 get_and_copy_grid_array<double>("get_grid_spacing", grid, spacing, GetGridRank(grid), "float");
-
163 }
-
164
-
165 std::string GetGridType(const int grid) override {
-
166 return py::str(bmi_model->attr("get_grid_type")(grid));
-
167 }
-
168
-
169 void GetGridX(const int grid, double *x) override {
-
170 // From the BMI docs:
-
171 // "The length of the resulting one-dimensional array depends on the grid type. (It will have either
-
172 // get_grid_rank or get_grid_size elements.) See Model grids for more information."
-
173 // Leaving this not implemented for now, since it is probably not yet needed, to make sure a proper
-
174 // solution to determining the array length is used.
-
175 // FIXME adjust comment
-
176 get_grid_coordinates("get_grid_x", grid, 0, x);
-
177 }
-
178
-
179 void GetGridY(const int grid, double *y) override {
-
180 // From the BMI docs:
-
181 // "The length of the resulting one-dimensional array depends on the grid type. (It will have either
-
182 // get_grid_rank or get_grid_size elements.) See Model grids for more information."
-
183 // Leaving this not implemented for now, since it is probably not yet needed, to make sure a proper
-
184 // solution to determining the array length is used.
-
185 // FIXME adjust comment
-
186 get_grid_coordinates("get_grid_y", grid, 1, y);
-
187 }
-
188
-
189 void GetGridZ(const int grid, double *z) override {
-
190 // From the BMI docs:
-
191 // "The length of the resulting one-dimensional array depends on the grid type. (It will have either
-
192 // get_grid_rank or get_grid_size elements.) See Model grids for more information."
-
193 // Leaving this not implemented for now, since it is probably not yet needed, to make sure a proper
-
194 // solution to determining the array length is used.
-
195 // FIXME adjust comment
-
196 get_grid_coordinates("get_grid_z", grid, 2, z);
-
197 }
-
198
-
199 double GetStartTime() override;
+
109 std::vector<std::string> GetOutputVarNames() override;
+
110
+
111 int GetGridEdgeCount(const int grid) override {
+
112 return py::int_(bmi_model->attr("get_grid_edge_count")(grid));
+
113 }
+
114
+
115 void GetGridEdgeNodes(const int grid, int *edge_nodes) override {
+
116 // As per BMI docs:
+
117 // "For each edge, connectivity is given as node at edge tail, followed by node at edge head."
+
118 // "The total length of the array is 2 * get_grid_edge_count."
+
119 get_and_copy_grid_array<int>("get_grid_edge_nodes", grid, edge_nodes, 2*GetGridEdgeCount(grid), "int");
+
120 }
+
121
+
122 int GetGridFaceCount(const int grid) override {
+
123 return py::int_(bmi_model->attr("get_grid_face_count")(grid));
+
124 }
+
125
+
126 void GetGridFaceEdges(const int grid, int *face_edges) override {
+
127 // As per BMI docs:
+
128 // "The length of the array returned is the sum of the values of get_grid_nodes_per_face."
+
129 int nodes_per_face_sum = get_sum_of_grid_nodes_per_face(grid);
+
130 get_and_copy_grid_array<int>("get_grid_face_edges", grid, face_edges, nodes_per_face_sum, "int");
+
131 }
+
132
+
133 void GetGridFaceNodes(const int grid, int *face_nodes) override {
+
134 int nodes_per_face_sum = get_sum_of_grid_nodes_per_face(grid);
+
135 get_and_copy_grid_array<int>("get_grid_face_nodes", grid, face_nodes, nodes_per_face_sum, "int");
+
136 }
+
137
+
138 int GetGridNodeCount(const int grid) override {
+
139 return py::int_(bmi_model->attr("get_grid_node_count")(grid));
+
140 }
+
141
+
142 void GetGridNodesPerFace(const int grid, int *nodes_per_face) override {
+
143 get_and_copy_grid_array<int>(
+
144 "get_grid_nodes_per_face", grid, nodes_per_face, GetGridFaceCount(grid), "int");
+
145 }
+
146
+
147 void GetGridOrigin(const int grid, double *origin) override {
+
148 get_and_copy_grid_array<double>("get_grid_origin", grid, origin, GetGridRank(grid), "double");
+
149 }
+
150
+
151 int GetGridRank(const int grid) override {
+
152 return py::int_(bmi_model->attr("get_grid_rank")(grid));
+
153 }
+
154
+
155 void GetGridShape(const int grid, int *shape) override {
+
156 get_and_copy_grid_array<int>("get_grid_shape", grid, shape, GetGridRank(grid), "int");
+
157 }
+
158
+
159 int GetGridSize(const int grid) override {
+
160 return py::int_(bmi_model->attr("get_grid_size")(grid));
+
161 }
+
162
+
163 void GetGridSpacing(const int grid, double *spacing) override {
+
164 get_and_copy_grid_array<double>("get_grid_spacing", grid, spacing, GetGridRank(grid), "float");
+
165 }
+
166
+
167 std::string GetGridType(const int grid) override {
+
168 return py::str(bmi_model->attr("get_grid_type")(grid));
+
169 }
+
170
+
171 void GetGridX(const int grid, double *x) override {
+
172 // From the BMI docs:
+
173 // "The length of the resulting one-dimensional array depends on the grid type. (It will have either
+
174 // get_grid_rank or get_grid_size elements.) See Model grids for more information."
+
175 // Leaving this not implemented for now, since it is probably not yet needed, to make sure a proper
+
176 // solution to determining the array length is used.
+
177 // FIXME adjust comment
+
178 get_grid_coordinates("get_grid_x", grid, 0, x);
+
179 }
+
180
+
181 void GetGridY(const int grid, double *y) override {
+
182 // From the BMI docs:
+
183 // "The length of the resulting one-dimensional array depends on the grid type. (It will have either
+
184 // get_grid_rank or get_grid_size elements.) See Model grids for more information."
+
185 // Leaving this not implemented for now, since it is probably not yet needed, to make sure a proper
+
186 // solution to determining the array length is used.
+
187 // FIXME adjust comment
+
188 get_grid_coordinates("get_grid_y", grid, 1, y);
+
189 }
+
190
+
191 void GetGridZ(const int grid, double *z) override {
+
192 // From the BMI docs:
+
193 // "The length of the resulting one-dimensional array depends on the grid type. (It will have either
+
194 // get_grid_rank or get_grid_size elements.) See Model grids for more information."
+
195 // Leaving this not implemented for now, since it is probably not yet needed, to make sure a proper
+
196 // solution to determining the array length is used.
+
197 // FIXME adjust comment
+
198 get_grid_coordinates("get_grid_z", grid, 2, z);
+
199 }
200
-
201 std::string GetTimeUnits() override;
+
201 double GetStartTime() override;
202
-
203 double GetTimeStep() override;
+
203 std::string GetTimeUnits() override;
204
-
205 std::string GetVarType(std::string name) override;
+
205 double GetTimeStep() override;
206
-
207 std::string GetVarUnits(std::string name) override;
+
207 std::string GetVarType(std::string name) override;
208
-
209 int GetVarGrid(std::string name) override;
+
209 std::string GetVarUnits(std::string name) override;
210
-
211 int GetVarItemsize(std::string name) override;
+
211 int GetVarGrid(std::string name) override;
212
-
213 int GetVarNbytes(std::string name) override;
+
213 int GetVarItemsize(std::string name) override;
214
-
215 std::string GetVarLocation(std::string name) override;
+
215 int GetVarNbytes(std::string name) override;
216
-
217 void GetValue(std::string name, void *dest) override;
+
217 std::string GetVarLocation(std::string name) override;
218
-
219 void GetValueAtIndices(std::string name, void *dest, int *inds, int count) override;
+
219 void GetValue(std::string name, void *dest) override;
220
-
221 void *GetValuePtr(std::string name) override;
+
221 void GetValueAtIndices(std::string name, void *dest, int *inds, int count) override;
222
-
233 const std::string get_analogous_cxx_type(const std::string &py_type_name, const size_t item_size) override {
-
234 /*
-
235 * Note that an implementation using a "switch" statement would be problematic. It could be done by
-
236 * rewriting to separate the integer and non-integer type, then having cases based on size. However,
-
237 * this might cause trouble on certain systems, since (depending on the particular sizes of types) that
-
238 * could produce duplicate "case" values.
-
239 */
-
240 //TODO: include other numpy type strings, https://numpy.org/doc/stable/user/basics.types.html
-
241 if ( (py_type_name == "int" || py_type_name == "int16") && item_size == sizeof(short)) {
-
242 return "short";
-
243 } else if ( (py_type_name == "int" || py_type_name == "int32" )&& item_size == sizeof(int)) {
-
244 return "int";
-
245 } else if (py_type_name == "int" && item_size == sizeof(long)) {
-
246 return "long";
-
247 } else if ( (py_type_name == "int" || py_type_name == "int64") && item_size == sizeof(long long)) {
-
248 return "long long";
-
249 } else if (py_type_name == "longlong" && item_size == sizeof(long long)) {
-
250 return "long long"; //numpy type
-
251 } else if ( (py_type_name == "float" || py_type_name == "float32" || py_type_name == "np.float32" ||
-
252 py_type_name == "numpy.float32" || py_type_name == "np.single" || py_type_name == "numpy.single") && item_size == sizeof(float)) {
-
253 return "float";
-
254 } else if ((py_type_name == "float" || py_type_name == "float64" || py_type_name == "np.float64" ||
-
255 py_type_name == "numpy.float64") && item_size == sizeof(double)) {
-
256 return "double";
-
257 } else if (py_type_name == "float" && item_size == sizeof(long double)) {
-
258 return "long double";
-
259 } else {
-
260 throw std::runtime_error(
-
261 "(Bmi_Py_Adapter) Failed determining analogous C++ type for Python model '" + py_type_name +
-
262 "' type with size " + std::to_string(item_size) + " bytes.");
-
263 }
-
264 }
-
265
-
266
-
273 inline std::string get_analog_python_builtin(const std::string &cxx_type_name) {
-
274 if (cxx_type_name == "short" || cxx_type_name == "int" || cxx_type_name == "long" ||
-
275 cxx_type_name == "long long") {
-
276 return "int";
-
277 } else if (cxx_type_name == "float" || cxx_type_name == "double" || cxx_type_name == "long double") {
-
278 return "double";
-
279 } else {
-
280 throw std::runtime_error("(Bmi_Py_Adapter) Failed determining analogous built-in Python type for C++ '" +
-
281 cxx_type_name + "' type");
-
282 }
-
283 }
-
284
-
292 inline std::string get_analog_python_dtype(const std::string &cxx_type_name, const size_t item_size) {
-
293 // TODO: figure out how to correctly get this
-
294 std::string numpy_module_name = "numpy";
-
295
-
296 if (cxx_type_name == "short" || cxx_type_name == "int" || cxx_type_name == "long" ||
-
297 cxx_type_name == "long long")
-
298 {
-
299 switch (item_size) {
-
300 case 1: return numpy_module_name + ".int8";
-
301 case 2: return numpy_module_name + ".int16";
-
302 case 4: return numpy_module_name + ".int32";
-
303 case 8: return numpy_module_name + ".int64";
-
304 default: break;
-
305 }
-
306 }
-
307
-
308 if (cxx_type_name == "float" || cxx_type_name == "double" || cxx_type_name == "long double") {
-
309 switch (item_size) {
-
310 case 2: return numpy_module_name + ".float16";
-
311 case 4: return numpy_module_name + ".float32";
-
312 case 8: return numpy_module_name + ".float64";
-
313 default: break;
-
314 }
-
315 }
-
316
-
317 throw std::runtime_error("(Bmi_Py_Adapter) Failed determining analogous Python dtype for C++ '" +
-
318 cxx_type_name + "' type with size " + std::to_string(item_size) + " bytes.");
-
319 }
-
320
-
332 inline std::string get_analog_python_type(const std::string &cxx_type_name, const size_t item_size,
-
333 const bool is_dtype)
-
334 {
-
335 return is_dtype ? get_analog_python_dtype(cxx_type_name, item_size) : get_analog_python_builtin(
-
336 cxx_type_name);
-
337 }
-
338
-
350 inline std::string get_analog_python_type(const std::string &cxx_type_name, const size_t item_size) {
-
351 return get_analog_python_type(cxx_type_name, item_size, false);
-
352 }
-
353
-
354 template <typename T>
-
355 void get_and_copy_grid_array(const char* grid_func_name, const int grid, T* dest, int dest_length,
-
356 const char* np_dtype)
-
357 {
-
358 //This is required here because grid info can be a non dimensional `np.zeros( () )`
-
359 py::array_t<T> np_array;
-
360 if( dest_length == 0 ){
-
361 np_array = np.attr("zeros")(1, "dtype"_a = np_dtype);
-
362 } else{
-
363 np_array = np.attr("zeros")(dest_length, "dtype"_a = np_dtype);
-
364 }
-
365 bmi_model->attr(grid_func_name)(grid, np_array);
-
366 auto np_array_direct = np_array.template unchecked<1>();
-
367 if( dest_length == 0 ){
-
368 dest[0] = np_array_direct(0);
-
369 }
-
370 else{
-
371 for (int i = 0; i < dest_length; ++i)
-
372 dest[i] = np_array_direct(i);
-
373 }
-
374 }
-
375
-
381 std::string get_bmi_type_package() const;
-
382
-
388 std::string get_bmi_type_simple_name() const;
-
389
-
400 int get_sum_of_grid_nodes_per_face(const int grid) {
-
401 int grid_node_face_count = GetGridFaceCount(grid);
-
402 std::vector<int> grid_nodes_per_face(grid_node_face_count);
-
403 GetGridNodesPerFace(grid, grid_nodes_per_face.data());
-
404 int nodes_per_face_sum = 0;
-
405 for (int i = 0; i < grid_node_face_count; ++i)
-
406 nodes_per_face_sum += grid_nodes_per_face[i];
-
407 return nodes_per_face_sum;
-
408 }
-
409
-
430 void get_value_at_indices(const std::string& name, void *dest, int *inds, int count, bool is_all_indices) {
-
431 std::string val_type = GetVarType(name);
-
432 size_t val_item_size = (size_t)GetVarItemsize(name);
-
433 std::vector<std::string> in_v = GetInputVarNames();
-
434
-
435 // The available types and how they are handled here should match what is in SetValueAtIndices
-
436 if (val_type == "int" && val_item_size == sizeof(short))
-
437 get_via_numpy_array<short>(name, dest, inds, count, val_item_size, is_all_indices);
-
438 else if (val_type == "int" && val_item_size == sizeof(int))
-
439 get_via_numpy_array<int>(name, dest, inds, count, val_item_size, is_all_indices);
-
440 else if (val_type == "int" && val_item_size == sizeof(long))
-
441 get_via_numpy_array<long>(name, dest, inds, count, val_item_size, is_all_indices);
-
442 else if (val_type == "int" && val_item_size == sizeof(long long))
-
443 get_via_numpy_array<long long>(name, dest, inds, count, val_item_size, is_all_indices);
-
444 else if (val_type == "float" || val_type == "float16" || val_type == "float32" || val_type == "float64") {
-
445 if (val_item_size == sizeof(float))
-
446 get_via_numpy_array<float>(name, dest, inds, count, val_item_size, is_all_indices);
-
447 else if (val_item_size == sizeof(double))
-
448 get_via_numpy_array<double>(name, dest, inds, count, val_item_size, is_all_indices);
-
449 else if (val_item_size == sizeof(long double))
-
450 get_via_numpy_array<long double>(name, dest, inds, count, val_item_size, is_all_indices);
-
451 }
-
452 else
-
453 throw std::runtime_error(
-
454 "(Bmi_Py_Adapter) Failed attempt to GET values of BMI variable '" + name + "' from '" +
-
455 model_name + "' model: model advertises unsupported combination of type (" + val_type +
-
456 ") and size (" + std::to_string(val_item_size) + ").");
-
457 }
-
458
-
480 template <typename T>
-
481 py::array_t<T> get_via_numpy_array(const std::string& name, void *dest, const int *indices, int item_count,
-
482 size_t item_size, bool is_all_indices)
-
483 {
-
484 std::string val_type = GetVarType(name);
-
485 py::array_t<T, py::array::c_style> dest_array
-
486 = np.attr("zeros")(item_count, "dtype"_a = val_type, "order"_a = "C");
-
487 if (is_all_indices) {
-
488 bmi_model->attr("get_value")(name, dest_array);
-
489 }
-
490 else {
-
491 py::array_t<int, py::array::c_style> indices_np_array
-
492 = np.attr("zeros")(item_count, "dtype"_a = "int32", "order"_a = "C");
-
493 auto indices_mut_direct = indices_np_array.mutable_unchecked<1>();
-
494 for (py::size_t i = 0; i < (py::size_t) item_count; ++i)
-
495 indices_mut_direct(i) = indices[i];
-
496 /* Leaving this here for now in case mutable_unchecked method doesn't behave as expected in testing
-
497 py::buffer_info buffer_info = indices_np_array.request();
-
498 int *indices_np_arr_ptr = (int*)buffer_info.ptr;
-
499 for (int i = 0; i < item_count; ++i)
-
500 indices_np_arr_ptr[i] = indices[i];
-
501 */
-
502 bmi_model->attr("get_value_at_indices")(name, dest_array, indices_np_array);
-
503 }
-
504
-
505 auto direct_access = dest_array.template unchecked<1>();
-
506 for (py::size_t i = 0; i < (py::size_t) item_count; ++i)
-
507 ((T *) dest)[i] = direct_access(i);
-
508
-
509 return dest_array;
-
510 }
-
511
-
517 inline bool is_model_initialized() override {
-
518 return model_initialized;
-
519 }
-
520
-
521 void Update() override;
+
223 void *GetValuePtr(std::string name) override;
+
224
+
235 const std::string get_analogous_cxx_type(const std::string &py_type_name, const size_t item_size) override {
+
236 /*
+
237 * Note that an implementation using a "switch" statement would be problematic. It could be done by
+
238 * rewriting to separate the integer and non-integer type, then having cases based on size. However,
+
239 * this might cause trouble on certain systems, since (depending on the particular sizes of types) that
+
240 * could produce duplicate "case" values.
+
241 */
+
242 //TODO: include other numpy type strings, https://numpy.org/doc/stable/user/basics.types.html
+
243 if ( (py_type_name == "int" || py_type_name == "int16") && item_size == sizeof(short)) {
+
244 return "short";
+
245 } else if ( (py_type_name == "int" || py_type_name == "int32" )&& item_size == sizeof(int)) {
+
246 return "int";
+
247 } else if (py_type_name == "int" && item_size == sizeof(long)) {
+
248 return "long";
+
249 } else if ( (py_type_name == "int" || py_type_name == "int64") && item_size == sizeof(long long)) {
+
250 return "long long";
+
251 } else if (py_type_name == "longlong" && item_size == sizeof(long long)) {
+
252 return "long long"; //numpy type
+
253 } else if ( (py_type_name == "float" || py_type_name == "float32" || py_type_name == "np.float32" ||
+
254 py_type_name == "numpy.float32" || py_type_name == "np.single" || py_type_name == "numpy.single") && item_size == sizeof(float)) {
+
255 return "float";
+
256 } else if ((py_type_name == "float" || py_type_name == "float64" || py_type_name == "np.float64" ||
+
257 py_type_name == "numpy.float64") && item_size == sizeof(double)) {
+
258 return "double";
+
259 } else if (py_type_name == "float" && item_size == sizeof(long double)) {
+
260 return "long double";
+
261 } else {
+
262 throw std::runtime_error(
+
263 "(Bmi_Py_Adapter) Failed determining analogous C++ type for Python model '" + py_type_name +
+
264 "' type with size " + std::to_string(item_size) + " bytes.");
+
265 }
+
266 }
+
267
+
268
+
275 inline std::string get_analog_python_builtin(const std::string &cxx_type_name) {
+
276 if (cxx_type_name == "short" || cxx_type_name == "int" || cxx_type_name == "long" ||
+
277 cxx_type_name == "long long") {
+
278 return "int";
+
279 } else if (cxx_type_name == "float" || cxx_type_name == "double" || cxx_type_name == "long double") {
+
280 return "double";
+
281 } else {
+
282 throw std::runtime_error("(Bmi_Py_Adapter) Failed determining analogous built-in Python type for C++ '" +
+
283 cxx_type_name + "' type");
+
284 }
+
285 }
+
286
+
294 inline std::string get_analog_python_dtype(const std::string &cxx_type_name, const size_t item_size) {
+
295 // TODO: figure out how to correctly get this
+
296 std::string numpy_module_name = "numpy";
+
297
+
298 if (cxx_type_name == "short" || cxx_type_name == "int" || cxx_type_name == "long" ||
+
299 cxx_type_name == "long long")
+
300 {
+
301 switch (item_size) {
+
302 case 1: return numpy_module_name + ".int8";
+
303 case 2: return numpy_module_name + ".int16";
+
304 case 4: return numpy_module_name + ".int32";
+
305 case 8: return numpy_module_name + ".int64";
+
306 default: break;
+
307 }
+
308 }
+
309
+
310 if (cxx_type_name == "float" || cxx_type_name == "double" || cxx_type_name == "long double") {
+
311 switch (item_size) {
+
312 case 2: return numpy_module_name + ".float16";
+
313 case 4: return numpy_module_name + ".float32";
+
314 case 8: return numpy_module_name + ".float64";
+
315 default: break;
+
316 }
+
317 }
+
318
+
319 throw std::runtime_error("(Bmi_Py_Adapter) Failed determining analogous Python dtype for C++ '" +
+
320 cxx_type_name + "' type with size " + std::to_string(item_size) + " bytes.");
+
321 }
+
322
+
334 inline std::string get_analog_python_type(const std::string &cxx_type_name, const size_t item_size,
+
335 const bool is_dtype)
+
336 {
+
337 return is_dtype ? get_analog_python_dtype(cxx_type_name, item_size) : get_analog_python_builtin(
+
338 cxx_type_name);
+
339 }
+
340
+
352 inline std::string get_analog_python_type(const std::string &cxx_type_name, const size_t item_size) {
+
353 return get_analog_python_type(cxx_type_name, item_size, false);
+
354 }
+
355
+
356 template <typename T>
+
357 void get_and_copy_grid_array(const char* grid_func_name, const int grid, T* dest, int dest_length,
+
358 const char* np_dtype)
+
359 {
+
360 //This is required here because grid info can be a non dimensional `np.zeros( () )`
+
361 py::array_t<T> np_array;
+
362 if( dest_length == 0 ){
+
363 np_array = np.attr("zeros")(1, "dtype"_a = np_dtype);
+
364 } else{
+
365 np_array = np.attr("zeros")(dest_length, "dtype"_a = np_dtype);
+
366 }
+
367 bmi_model->attr(grid_func_name)(grid, np_array);
+
368 auto np_array_direct = np_array.template unchecked<1>();
+
369 if( dest_length == 0 ){
+
370 dest[0] = np_array_direct(0);
+
371 }
+
372 else{
+
373 for (int i = 0; i < dest_length; ++i)
+
374 dest[i] = np_array_direct(i);
+
375 }
+
376 }
+
377
+
383 std::string get_bmi_type_package() const;
+
384
+
390 std::string get_bmi_type_simple_name() const;
+
391
+
402 int get_sum_of_grid_nodes_per_face(const int grid) {
+
403 int grid_node_face_count = GetGridFaceCount(grid);
+
404 std::vector<int> grid_nodes_per_face(grid_node_face_count);
+
405 GetGridNodesPerFace(grid, grid_nodes_per_face.data());
+
406 int nodes_per_face_sum = 0;
+
407 for (int i = 0; i < grid_node_face_count; ++i)
+
408 nodes_per_face_sum += grid_nodes_per_face[i];
+
409 return nodes_per_face_sum;
+
410 }
+
411
+
432 void get_value_at_indices(const std::string& name, void *dest, int *inds, int count, bool is_all_indices) {
+
433 std::string val_type = GetVarType(name);
+
434 size_t val_item_size = (size_t)GetVarItemsize(name);
+
435 std::vector<std::string> in_v = GetInputVarNames();
+
436
+
437 // The available types and how they are handled here should match what is in SetValueAtIndices
+
438 if (val_type == "int" && val_item_size == sizeof(short))
+
439 get_via_numpy_array<short>(name, dest, inds, count, val_item_size, is_all_indices);
+
440 else if (val_type == "int" && val_item_size == sizeof(int))
+
441 get_via_numpy_array<int>(name, dest, inds, count, val_item_size, is_all_indices);
+
442 else if (val_type == "int" && val_item_size == sizeof(long))
+
443 get_via_numpy_array<long>(name, dest, inds, count, val_item_size, is_all_indices);
+
444 else if (val_type == "int" && val_item_size == sizeof(long long))
+
445 get_via_numpy_array<long long>(name, dest, inds, count, val_item_size, is_all_indices);
+
446 else if (val_type == "float" || val_type == "float16" || val_type == "float32" || val_type == "float64") {
+
447 if (val_item_size == sizeof(float))
+
448 get_via_numpy_array<float>(name, dest, inds, count, val_item_size, is_all_indices);
+
449 else if (val_item_size == sizeof(double))
+
450 get_via_numpy_array<double>(name, dest, inds, count, val_item_size, is_all_indices);
+
451 else if (val_item_size == sizeof(long double))
+
452 get_via_numpy_array<long double>(name, dest, inds, count, val_item_size, is_all_indices);
+
453 }
+
454 else
+
455 throw std::runtime_error(
+
456 "(Bmi_Py_Adapter) Failed attempt to GET values of BMI variable '" + name + "' from '" +
+
457 model_name + "' model: model advertises unsupported combination of type (" + val_type +
+
458 ") and size (" + std::to_string(val_item_size) + ").");
+
459 }
+
460
+
482 template <typename T>
+
483 py::array_t<T> get_via_numpy_array(const std::string& name, void *dest, const int *indices, int item_count,
+
484 size_t item_size, bool is_all_indices)
+
485 {
+
486 std::string val_type = GetVarType(name);
+
487 py::array_t<T, py::array::c_style> dest_array
+
488 = np.attr("zeros")(item_count, "dtype"_a = val_type, "order"_a = "C");
+
489 if (is_all_indices) {
+
490 bmi_model->attr("get_value")(name, dest_array);
+
491 }
+
492 else {
+
493 py::array_t<int, py::array::c_style> indices_np_array
+
494 = np.attr("zeros")(item_count, "dtype"_a = "int32", "order"_a = "C");
+
495 auto indices_mut_direct = indices_np_array.mutable_unchecked<1>();
+
496 for (py::size_t i = 0; i < (py::size_t) item_count; ++i)
+
497 indices_mut_direct(i) = indices[i];
+
498 /* Leaving this here for now in case mutable_unchecked method doesn't behave as expected in testing
+
499 py::buffer_info buffer_info = indices_np_array.request();
+
500 int *indices_np_arr_ptr = (int*)buffer_info.ptr;
+
501 for (int i = 0; i < item_count; ++i)
+
502 indices_np_arr_ptr[i] = indices[i];
+
503 */
+
504 bmi_model->attr("get_value_at_indices")(name, dest_array, indices_np_array);
+
505 }
+
506
+
507 auto direct_access = dest_array.template unchecked<1>();
+
508 for (py::size_t i = 0; i < (py::size_t) item_count; ++i)
+
509 ((T *) dest)[i] = direct_access(i);
+
510
+
511 return dest_array;
+
512 }
+
513
+
519 inline bool is_model_initialized() override {
+
520 return model_initialized;
+
521 }
522
-
523 void UpdateUntil(double time) override;
+
523 void Update() override;
524
-
525 void SetValue(std::string name, void *src) override {
-
526 int itemSize = GetVarItemsize(name);
-
527 std::string py_type = GetVarType(name);
-
528 std::string cxx_type = get_analogous_cxx_type(py_type, (size_t) itemSize);
-
529
-
530 if (cxx_type == "short") {
-
531 set_value<short>(name, (short *) src);
-
532 } else if (cxx_type == "int") {
-
533 set_value<int>(name, (int *) src);
-
534 } else if (cxx_type == "long") {
-
535 set_value<long>(name, (long *) src);
-
536 } else if (cxx_type == "long long") {
-
537 //FIXME this gets dicey -- if a python numpy array is of type np.int64 (long long),
-
538 //but a c++ int* is passed to this function as src, it will fail in undefined ways...
-
539 //the template type overload may be perferred for doing SetValue from framework components
-
540 //such as forcing providers...
-
541 set_value<long long>(name, (long long *) src);
-
542 } else if (cxx_type == "float") {
-
543 set_value<float>(name, (float *) src);
-
544 } else if (cxx_type == "double") {
-
545 set_value<double>(name, (double *) src);
-
546 } else if (cxx_type == "long double") {
-
547 set_value<long double>(name, (long double *) src);
-
548 } else {
-
549 throw std::runtime_error("Bmi_Py_Adapter cannot set values for variable '" + name +
-
550 "' that has unrecognized C++ type '" + cxx_type + "'");
-
551 }
-
552 }
-
553
-
562 template <typename T>
-
563 void set_value(const std::string &name, std::vector<T> src) {
-
564 int nbytes = GetVarNbytes(name);
-
565 int itemSize = GetVarItemsize(name);
-
566 int length = nbytes / itemSize;
-
567
-
568 if (length != src.size()) {
-
569 throw std::runtime_error(
-
570 "Bmi_Py_Adapter mismatch of lengths setting variable array (" + std::to_string(length) +
-
571 " expected but " + std::to_string(src.size()) + " received)");
-
572 }
-
573
-
574 py::array_t<T> model_var_array = bmi_model->attr("get_value_ptr")(name);
-
575 auto mutable_unchecked_proxy = model_var_array.template mutable_unchecked<1>();
-
576 for (size_t i = 0; i < length; ++i) {
-
577 mutable_unchecked_proxy(i) = src[i];
-
578 }
-
579 }
-
580
-
598 void SetValueAtIndices(std::string name, int *inds, int count, void *src) override;
-
599
-
619 template <typename T>
-
620 void set_value_at_indices(const std::string &name, const int *inds, int count, void* cxx_array,
-
621 const std::string &np_type)
-
622 {
-
623 py::array_t<int> index_array(py::buffer_info(inds, count));
-
624 py::array_t<T> src_array(py::buffer_info((T*)cxx_array, count));
-
625 bmi_model->attr("set_value_at_indices")(name, index_array, src_array);
-
626 }
-
627
-
628 protected:
-
629 std::string model_name = "BMI Python model";
-
630
-
639 void construct_and_init_backing_model() override {
-
640 construct_and_init_backing_model_for_py_adapter();
-
641 }
-
642
-
643 private:
+
525 void UpdateUntil(double time) override;
+
526
+
527 void SetValue(std::string name, void *src) override {
+
528 int itemSize = GetVarItemsize(name);
+
529 std::string py_type = GetVarType(name);
+
530 std::string cxx_type = get_analogous_cxx_type(py_type, (size_t) itemSize);
+
531
+
532 if (cxx_type == "short") {
+
533 set_value<short>(name, (short *) src);
+
534 } else if (cxx_type == "int") {
+
535 set_value<int>(name, (int *) src);
+
536 } else if (cxx_type == "long") {
+
537 set_value<long>(name, (long *) src);
+
538 } else if (cxx_type == "long long") {
+
539 //FIXME this gets dicey -- if a python numpy array is of type np.int64 (long long),
+
540 //but a c++ int* is passed to this function as src, it will fail in undefined ways...
+
541 //the template type overload may be perferred for doing SetValue from framework components
+
542 //such as forcing providers...
+
543 set_value<long long>(name, (long long *) src);
+
544 } else if (cxx_type == "float") {
+
545 set_value<float>(name, (float *) src);
+
546 } else if (cxx_type == "double") {
+
547 set_value<double>(name, (double *) src);
+
548 } else if (cxx_type == "long double") {
+
549 set_value<long double>(name, (long double *) src);
+
550 } else {
+
551 throw std::runtime_error("Bmi_Py_Adapter cannot set values for variable '" + name +
+
552 "' that has unrecognized C++ type '" + cxx_type + "'");
+
553 }
+
554 }
+
555
+
564 template <typename T>
+
565 void set_value(const std::string &name, std::vector<T> src) {
+
566 int nbytes = GetVarNbytes(name);
+
567 int itemSize = GetVarItemsize(name);
+
568 int length = nbytes / itemSize;
+
569
+
570 if (length != src.size()) {
+
571 throw std::runtime_error(
+
572 "Bmi_Py_Adapter mismatch of lengths setting variable array (" + std::to_string(length) +
+
573 " expected but " + std::to_string(src.size()) + " received)");
+
574 }
+
575
+
576 py::array_t<T> model_var_array = bmi_model->attr("get_value_ptr")(name);
+
577 auto mutable_unchecked_proxy = model_var_array.template mutable_unchecked<1>();
+
578 for (size_t i = 0; i < length; ++i) {
+
579 mutable_unchecked_proxy(i) = src[i];
+
580 }
+
581 }
+
582
+
600 void SetValueAtIndices(std::string name, int *inds, int count, void *src) override;
+
601
+
621 template <typename T>
+
622 void set_value_at_indices(const std::string &name, const int *inds, int count, void* cxx_array,
+
623 const std::string &np_type)
+
624 {
+
625 py::array_t<int> index_array(py::buffer_info(inds, count));
+
626 py::array_t<T> src_array(py::buffer_info((T*)cxx_array, count));
+
627 bmi_model->attr("set_value_at_indices")(name, index_array, src_array);
+
628 }
+
629
+
630 protected:
+
631 std::string model_name = "BMI Python model";
+
632
+
641 void construct_and_init_backing_model() override {
+
642 construct_and_init_backing_model_for_py_adapter();
+
643 }
644
-
646 std::string bmi_type_py_full_name;
-
648 py::object np;
-
650 std::shared_ptr<std::string> bmi_type_py_module_name;
-
652 std::shared_ptr<std::string> bmi_type_py_class_name;
-
653
-
664 inline void construct_and_init_backing_model_for_py_adapter() {
-
665 if (model_initialized)
-
666 return;
-
667 try {
-
668 separate_package_and_simple_name();
-
669 std::vector<std::string> moduleComponents = {*bmi_type_py_module_name, *bmi_type_py_class_name};
-
670 // This is a class object for the BMI module Python class
-
671 py::object bmi_py_class = utils::ngenPy::InterpreterUtil::getPyModule(moduleComponents);
-
672 // This is the actual backing model object
-
673 bmi_model = std::make_shared<py::object>(bmi_py_class());
-
674 bmi_model->attr("initialize")(bmi_init_config);
-
675 }
-
676 catch (std::runtime_error& e){ //Catch specific exception types so the type/message don't get erased
-
677 throw e;
-
678 }
-
679 // Record the exception message before re-throwing to handle subsequent function calls properly
-
680 // TODO: handle exceptions in better detail, without losing type information
-
681 catch (std::exception& e) {
-
682 init_exception_msg = std::string(e.what());
-
683 // Make sure this is non-empty to be consistent with the above logic
-
684 if (init_exception_msg.empty()) {
-
685 init_exception_msg = "Unknown Python model initialization exception.";
-
686 }
-
687 //This message is lost and often contains valuable info. Either need to break up and catch
-
688 //other possible exceptions, wrap all these in a custom exception, or at the very least, print
-
689 //the original messge before it gets lost in this re-throw.
-
690 std::cerr<<init_exception_msg<<std::endl;
-
691 throw e;
-
692 }
-
693 }
-
694
-
711 void get_grid_coordinates(const char* name, const int grid, const int index, double* dest){
-
712 std::string grid_type = GetGridType(grid);
-
713 if( grid_type == "uniform_rectilinear" || grid_type == "rectilinear"){
-
714 int rank = GetGridRank(grid);
-
715 std::vector<int> shape(rank);
-
716 GetGridShape(grid, shape.data());
-
717 get_and_copy_grid_array<double>(name, grid, dest, shape[rank-index-1], "float");
-
718 return;
-
719 }else{
-
720 throw std::runtime_error("GetGrid<X|Y|Z> coordinates not yet implemented for Python BMI adapter for grid type "+grid_type);
-
721 }
-
722
-
723 }
+
645 private:
+
646
+
648 std::string bmi_type_py_full_name;
+
650 py::object np;
+
652 std::shared_ptr<std::string> bmi_type_py_module_name;
+
654 std::shared_ptr<std::string> bmi_type_py_class_name;
+
655
+
666 inline void construct_and_init_backing_model_for_py_adapter() {
+
667 if (model_initialized)
+
668 return;
+
669 try {
+
670 separate_package_and_simple_name();
+
671 std::vector<std::string> moduleComponents = {*bmi_type_py_module_name, *bmi_type_py_class_name};
+
672 // This is a class object for the BMI module Python class
+
673 py::object bmi_py_class = utils::ngenPy::InterpreterUtil::getPyModule(moduleComponents);
+
674 // This is the actual backing model object
+
675 bmi_model = std::make_shared<py::object>(bmi_py_class());
+
676 bmi_model->attr("initialize")(bmi_init_config);
+
677 }
+
678 catch (std::runtime_error& e){ //Catch specific exception types so the type/message don't get erased
+
679 throw e;
+
680 }
+
681 // Record the exception message before re-throwing to handle subsequent function calls properly
+
682 // TODO: handle exceptions in better detail, without losing type information
+
683 catch (std::exception& e) {
+
684 init_exception_msg = std::string(e.what());
+
685 // Make sure this is non-empty to be consistent with the above logic
+
686 if (init_exception_msg.empty()) {
+
687 init_exception_msg = "Unknown Python model initialization exception.";
+
688 }
+
689 //This message is lost and often contains valuable info. Either need to break up and catch
+
690 //other possible exceptions, wrap all these in a custom exception, or at the very least, print
+
691 //the original messge before it gets lost in this re-throw.
+
692 std::cerr<<init_exception_msg<<std::endl;
+
693 throw e;
+
694 }
+
695 }
+
696
+
713 void get_grid_coordinates(const char* name, const int grid, const int index, double* dest){
+
714 std::string grid_type = GetGridType(grid);
+
715 if( grid_type == "uniform_rectilinear" || grid_type == "rectilinear"){
+
716 int rank = GetGridRank(grid);
+
717 std::vector<int> shape(rank);
+
718 GetGridShape(grid, shape.data());
+
719 get_and_copy_grid_array<double>(name, grid, dest, shape[rank-index-1], "float");
+
720 return;
+
721 }else{
+
722 throw std::runtime_error("GetGrid<X|Y|Z> coordinates not yet implemented for Python BMI adapter for grid type "+grid_type);
+
723 }
724
-
733 inline void separate_package_and_simple_name() {
-
734 if (!model_initialized) {
-
735 std::vector<std::string> split_name;
-
736 std::string delimiter = ".";
-
737 std::string name_string = bmi_type_py_full_name;
-
738
-
739 size_t pos = 0;
-
740 std::string token;
-
741 while ((pos = name_string.find(delimiter)) != std::string::npos) {
-
742 token = name_string.substr(0, pos);
-
743 split_name.emplace_back(token);
-
744 name_string.erase(0, pos + delimiter.length());
-
745 }
-
746 if (split_name.empty()) {
-
747 throw std::runtime_error("Cannot interpret BMI Python model type '" + bmi_type_py_full_name
-
748 + "'; expected format is <python_module>.<python_class>");
-
749 }
-
750 // What's left should be the class name
-
751 bmi_type_py_class_name = std::make_shared<std::string>(name_string);
-
752 //split_name.pop_back();
-
753 // And then the split name should contain the module
-
754 // TODO: going to need to look at this again in the future; right now, assuming the format
-
755 // <python_module>.<python_class> works fine as long as a model class is always in a top-level
-
756 // module, but the current logic is going to interpret any complex parent module name as a single
-
757 // top-level namespace package; e.g., ngen.namespacepackage.model works if ngen.namespacepackage is
-
758 // a namespace package, but there would be problems with something like ngenpkg.innermodule1.model.
-
759 bmi_type_py_module_name = std::make_shared<std::string>(boost::algorithm::join(split_name, delimiter));
-
760 }
-
761 }
-
762
-
771 template <typename T>
-
772 void set_value(const std::string &name, T *src) {
-
773 // Because all BMI arrays are flattened, we can just use the size/length in the buffer info
-
774 int length = GetVarNbytes(name) / GetVarItemsize(name);
-
775 py::array_t<T> src_array(py::buffer_info(src, length));
-
776 bmi_model->attr("set_value")(name, src_array);
-
777 }
-
778
-
779 // For unit testing
-
780 friend class ::Bmi_Py_Adapter_Test;
-
781
-
782 protected:
-
784 std::shared_ptr<py::object> bmi_model = nullptr;
-
785
-
786 };
+
725 }
+
726
+
735 inline void separate_package_and_simple_name() {
+
736 if (!model_initialized) {
+
737 std::vector<std::string> split_name;
+
738 std::string delimiter = ".";
+
739 std::string name_string = bmi_type_py_full_name;
+
740
+
741 size_t pos = 0;
+
742 std::string token;
+
743 while ((pos = name_string.find(delimiter)) != std::string::npos) {
+
744 token = name_string.substr(0, pos);
+
745 split_name.emplace_back(token);
+
746 name_string.erase(0, pos + delimiter.length());
+
747 }
+
748 if (split_name.empty()) {
+
749 throw std::runtime_error("Cannot interpret BMI Python model type '" + bmi_type_py_full_name
+
750 + "'; expected format is <python_module>.<python_class>");
+
751 }
+
752 // What's left should be the class name
+
753 bmi_type_py_class_name = std::make_shared<std::string>(name_string);
+
754 //split_name.pop_back();
+
755 // And then the split name should contain the module
+
756 // TODO: going to need to look at this again in the future; right now, assuming the format
+
757 // <python_module>.<python_class> works fine as long as a model class is always in a top-level
+
758 // module, but the current logic is going to interpret any complex parent module name as a single
+
759 // top-level namespace package; e.g., ngen.namespacepackage.model works if ngen.namespacepackage is
+
760 // a namespace package, but there would be problems with something like ngenpkg.innermodule1.model.
+
761 bmi_type_py_module_name = std::make_shared<std::string>(boost::algorithm::join(split_name, delimiter));
+
762 }
+
763 }
+
764
+
773 template <typename T>
+
774 void set_value(const std::string &name, T *src) {
+
775 // Because all BMI arrays are flattened, we can just use the size/length in the buffer info
+
776 int length = GetVarNbytes(name) / GetVarItemsize(name);
+
777 py::array_t<T> src_array(py::buffer_info(src, length));
+
778 bmi_model->attr("set_value")(name, src_array);
+
779 }
+
780
+
781 // For unit testing
+
782 friend class ::Bmi_Py_Adapter_Test;
+
783
+
784 protected:
+
786 std::shared_ptr<py::object> bmi_model = nullptr;
787
-
788 }
-
789}
-
790
-
791#endif //ACTIVATE_PYTHON
+
788 };
+
789
+
790 }
+
791}
792
-
793#endif //NGEN_BMI_PY_ADAPTER_H
+
793#endif //NGEN_WITH_PYTHON
+
794
+
795#endif //NGEN_BMI_PY_ADAPTER_H
This class provides a copyable interface to a std::ostream or std::ostream like object that may not s...
Definition StreamHandler.hpp:14
Definition bmi.hpp:16
std::vector< T > GetValue(Bmi_Adapter &model, const std::string &name)
Copy values from a BMI model adapter and box them into a vector.
Definition bmi_utilities.hpp:41
@@ -671,7 +673,7 @@ diff --git a/_bmi___py___formulation_8hpp_source.html b/_bmi___py___formulation_8hpp_source.html index 32cd570aeb..8d063de777 100644 --- a/_bmi___py___formulation_8hpp_source.html +++ b/_bmi___py___formulation_8hpp_source.html @@ -100,65 +100,67 @@
1#ifndef NGEN_BMI_PY_FORMULATION_H
2#define NGEN_BMI_PY_FORMULATION_H
3
-
4#ifdef ACTIVATE_PYTHON
+
4#include <NGenConfig.h>
5
-
6#include <memory>
-
7#include <string>
-
8#include "Bmi_Module_Formulation.hpp"
-
9#include "Bmi_Py_Adapter.hpp"
-
10#include "GenericDataProvider.hpp"
-
11#include "pybind11/pybind11.h"
-
12#include "pybind11/pytypes.h"
-
13#include "pybind11/numpy.h"
-
14
-
15// Forward declaration to provide access to protected items in testing
-
16class Bmi_Py_Formulation_Test;
-
17
-
18namespace realization {
+
6#if NGEN_WITH_PYTHON
+
7
+
8#include <memory>
+
9#include <string>
+
10#include "Bmi_Module_Formulation.hpp"
+
11#include "Bmi_Py_Adapter.hpp"
+
12#include "GenericDataProvider.hpp"
+
13#include "pybind11/pybind11.h"
+
14#include "pybind11/pytypes.h"
+
15#include "pybind11/numpy.h"
+
16
+
17// Forward declaration to provide access to protected items in testing
+
18class Bmi_Py_Formulation_Test;
19
-
20 class Bmi_Py_Formulation : public Bmi_Module_Formulation {
+
20namespace realization {
21
-
22 public:
+
22 class Bmi_Py_Formulation : public Bmi_Module_Formulation {
23
-
24 Bmi_Py_Formulation(std::string id, std::shared_ptr<data_access::GenericDataProvider> forcing, utils::StreamHandler output_stream);
+
24 public:
25
-
26 const std::vector<std::string> get_bmi_input_variables() override;
+
26 Bmi_Py_Formulation(std::string id, std::shared_ptr<data_access::GenericDataProvider> forcing, utils::StreamHandler output_stream);
27
-
28 const std::vector<std::string> get_bmi_output_variables() override;
+
28 const std::vector<std::string> get_bmi_input_variables() override;
29
-
30 std::string get_formulation_type() override;
+
30 const std::vector<std::string> get_bmi_output_variables() override;
31
-
66 double get_response(time_step_t t_index, time_step_t t_delta) override;
-
67
-
68 bool is_bmi_input_variable(const std::string &var_name) override;
+
32 std::string get_formulation_type() override;
+
33
+
68 double get_response(time_step_t t_index, time_step_t t_delta) override;
69
-
70 bool is_bmi_output_variable(const std::string &var_name) override;
+
70 bool is_bmi_input_variable(const std::string &var_name) override;
71
-
72 protected:
+
72 bool is_bmi_output_variable(const std::string &var_name) override;
73
-
74 std::shared_ptr<models::bmi::Bmi_Adapter> construct_model(const geojson::PropertyMap &properties) override;
+
74 protected:
75
-
76 time_t convert_model_time(const double &model_time) override;
+
76 std::shared_ptr<models::bmi::Bmi_Adapter> construct_model(const geojson::PropertyMap &properties) override;
77
-
78 double get_var_value_as_double(const std::string &var_name) override;
+
78 time_t convert_model_time(const double &model_time) override;
79
-
80 double get_var_value_as_double(const int &index, const std::string &var_name) override;
+
80 double get_var_value_as_double(const std::string &var_name) override;
81
-
92 bool is_model_initialized() override;
-
93
-
94 friend class Bmi_Multi_Formulation;
+
82 double get_var_value_as_double(const int &index, const std::string &var_name) override;
+
83
+
94 bool is_model_initialized() override;
95
-
96 // Unit test access
-
97 friend class ::Bmi_Formulation_Test;
-
98 friend class ::Bmi_Py_Formulation_Test;
-
99 friend class ::Bmi_Multi_Formulation_Test;
-
100 };
-
101
-
102}
+
96 friend class Bmi_Multi_Formulation;
+
97
+
98 // Unit test access
+
99 friend class ::Bmi_Formulation_Test;
+
100 friend class ::Bmi_Py_Formulation_Test;
+
101 friend class ::Bmi_Multi_Formulation_Test;
+
102 };
103
-
104#endif //ACTIVATE_PYTHON
+
104}
105
-
106#endif //NGEN_BMI_PY_FORMULATION_H
+
106#endif //NGEN_WITH_PYTHON
+
107
+
108#endif //NGEN_BMI_PY_FORMULATION_H
This class provides a copyable interface to a std::ostream or std::ostream like object that may not s...
Definition StreamHandler.hpp:14
std::map< std::string, JSONProperty > PropertyMap
Shorthand for a mapping between strings and properties.
Definition JSONProperty.hpp:21
Definition Bmi_C_Formulation.hpp:11
@@ -168,7 +170,7 @@ diff --git a/_c_s_v___reader_8h_source.html b/_c_s_v___reader_8h_source.html index 1f0ce6cec0..fcf8c98926 100644 --- a/_c_s_v___reader_8h_source.html +++ b/_c_s_v___reader_8h_source.html @@ -183,7 +183,7 @@ diff --git a/_catchment___formulation_8hpp_source.html b/_catchment___formulation_8hpp_source.html index 3b6f49ec82..e4a4c6909b 100644 --- a/_catchment___formulation_8hpp_source.html +++ b/_catchment___formulation_8hpp_source.html @@ -214,7 +214,7 @@ diff --git a/_collection_feature_8hpp_source.html b/_collection_feature_8hpp_source.html index 6d5449362e..937bfb5ff1 100644 --- a/_collection_feature_8hpp_source.html +++ b/_collection_feature_8hpp_source.html @@ -393,7 +393,7 @@ diff --git a/_configuration_exception_8hpp_source.html b/_configuration_exception_8hpp_source.html index 5c87923524..4d97b65d26 100644 --- a/_configuration_exception_8hpp_source.html +++ b/_configuration_exception_8hpp_source.html @@ -150,7 +150,7 @@ diff --git a/_constants_8h_source.html b/_constants_8h_source.html index 8f00460565..6b4973abc7 100644 --- a/_constants_8h_source.html +++ b/_constants_8h_source.html @@ -115,7 +115,7 @@ diff --git a/_csv_per_feature_forcing_provider_8hpp_source.html b/_csv_per_feature_forcing_provider_8hpp_source.html index b51359d852..25daf5d839 100644 --- a/_csv_per_feature_forcing_provider_8hpp_source.html +++ b/_csv_per_feature_forcing_provider_8hpp_source.html @@ -519,7 +519,7 @@ diff --git a/_data_provider_8hpp_source.html b/_data_provider_8hpp_source.html index d72bc97de4..0a6382f38d 100644 --- a/_data_provider_8hpp_source.html +++ b/_data_provider_8hpp_source.html @@ -170,7 +170,7 @@ diff --git a/_data_provider_selectors_8hpp_source.html b/_data_provider_selectors_8hpp_source.html index 18a78f6a95..40a73ec448 100644 --- a/_data_provider_selectors_8hpp_source.html +++ b/_data_provider_selectors_8hpp_source.html @@ -182,7 +182,7 @@ diff --git a/_deferred_wrapped_provider_8hpp_source.html b/_deferred_wrapped_provider_8hpp_source.html index 44e924eae5..55d226468d 100644 --- a/_deferred_wrapped_provider_8hpp_source.html +++ b/_deferred_wrapped_provider_8hpp_source.html @@ -216,7 +216,7 @@ diff --git a/_domain_layer_8hpp_source.html b/_domain_layer_8hpp_source.html index 25b8ffb939..76e16125c9 100644 --- a/_domain_layer_8hpp_source.html +++ b/_domain_layer_8hpp_source.html @@ -173,11 +173,11 @@
DomainLayer(const LayerDescription &desc, const Simulation_Time &s_t, feature_type &features, long idx, std::shared_ptr< realization::Catchment_Formulation > formulation)
Construct a new Domain Layer object.
Definition DomainLayer.hpp:38
void update_models() override
Run one simulation timestep for this model associated with the domain.
Definition DomainLayer.hpp:59
DomainLayer()=delete
-
Definition Layer.hpp:18
-
long output_time_index
Definition Layer.hpp:180
-
feature_type & features
Definition Layer.hpp:177
-
const LayerDescription description
Definition Layer.hpp:172
-
Simulation_Time simulation_time
Definition Layer.hpp:176
+
Definition Layer.hpp:20
+
long output_time_index
Definition Layer.hpp:182
+
feature_type & features
Definition Layer.hpp:179
+
const LayerDescription description
Definition Layer.hpp:174
+
Simulation_Time simulation_time
Definition Layer.hpp:178
Definition DomainLayer.hpp:9
A simple structure to hold meta data related to a computational layer.
Definition LayerData.hpp:18
std::string name
Definition LayerData.hpp:19
@@ -188,7 +188,7 @@ diff --git a/_endian_copy_8hpp_source.html b/_endian_copy_8hpp_source.html index 52fdf5f874..978db03324 100644 --- a/_endian_copy_8hpp_source.html +++ b/_endian_copy_8hpp_source.html @@ -156,7 +156,7 @@ diff --git a/_external_integration_exception_8hpp_source.html b/_external_integration_exception_8hpp_source.html index a7124e6111..3a0aacbbef 100644 --- a/_external_integration_exception_8hpp_source.html +++ b/_external_integration_exception_8hpp_source.html @@ -150,7 +150,7 @@ diff --git a/_feature_base_8hpp_source.html b/_feature_base_8hpp_source.html index 41bfe6e7aa..bb6701c2ba 100644 --- a/_feature_base_8hpp_source.html +++ b/_feature_base_8hpp_source.html @@ -883,7 +883,7 @@ diff --git a/_feature_builder_8hpp_source.html b/_feature_builder_8hpp_source.html index 3757558971..33e6f01e86 100644 --- a/_feature_builder_8hpp_source.html +++ b/_feature_builder_8hpp_source.html @@ -603,7 +603,7 @@ diff --git a/_feature_collection_8hpp_source.html b/_feature_collection_8hpp_source.html index 7f64ec0373..36c1c3b05d 100644 --- a/_feature_collection_8hpp_source.html +++ b/_feature_collection_8hpp_source.html @@ -297,7 +297,7 @@ diff --git a/_feature_visitor_8hpp_source.html b/_feature_visitor_8hpp_source.html index 92d1576270..9b5eb69b1b 100644 --- a/_feature_visitor_8hpp_source.html +++ b/_feature_visitor_8hpp_source.html @@ -145,7 +145,7 @@ diff --git a/_features_8hpp_source.html b/_features_8hpp_source.html index 943256d4b0..784d80a68a 100644 --- a/_features_8hpp_source.html +++ b/_features_8hpp_source.html @@ -116,7 +116,7 @@ diff --git a/_file_checker_8h_source.html b/_file_checker_8h_source.html index fa9e8bb944..bcf18e061b 100644 --- a/_file_checker_8h_source.html +++ b/_file_checker_8h_source.html @@ -236,7 +236,7 @@ diff --git a/_file_stream_handler_8hpp_source.html b/_file_stream_handler_8hpp_source.html index 71d53eed48..528b389390 100644 --- a/_file_stream_handler_8hpp_source.html +++ b/_file_stream_handler_8hpp_source.html @@ -137,7 +137,7 @@ diff --git a/_formulation___constructors_8hpp_source.html b/_formulation___constructors_8hpp_source.html index fd986a537e..10b9f48fa5 100644 --- a/_formulation___constructors_8hpp_source.html +++ b/_formulation___constructors_8hpp_source.html @@ -100,99 +100,101 @@
1#ifndef NGEN_FORMULATION_CONSTRUCTORS_H
2#define NGEN_FORMULATION_CONSTRUCTORS_H
3
-
4#include "Formulation.hpp"
-
5#include <JSONProperty.hpp>
-
6#include <exception>
-
7
-
8#include <boost/property_tree/ptree.hpp>
-
9#include <boost/optional.hpp>
-
10
-
11// Formulations
-
12#include "Bmi_Formulation.hpp"
-
13#include <GenericDataProvider.hpp>
-
14#include "CsvPerFeatureForcingProvider.hpp"
-
15#include "NullForcingProvider.hpp"
-
16#ifdef NETCDF_ACTIVE
-
17 #include "NetCDFPerFeatureDataProvider.hpp"
-
18#endif
-
19
-
20namespace realization {
-
21 using constructor = std::shared_ptr<Catchment_Formulation> (*)(std::string, shared_ptr<data_access::GenericDataProvider>, utils::StreamHandler);
-
22
-
23 extern std::map<std::string, constructor> formulations;
+
4#include <NGenConfig.h>
+
5
+
6#include "Formulation.hpp"
+
7#include <JSONProperty.hpp>
+
8#include <exception>
+
9
+
10#include <boost/property_tree/ptree.hpp>
+
11#include <boost/optional.hpp>
+
12
+
13// Formulations
+
14#include "Bmi_Formulation.hpp"
+
15#include <GenericDataProvider.hpp>
+
16#include "CsvPerFeatureForcingProvider.hpp"
+
17#include "NullForcingProvider.hpp"
+
18#if NGEN_WITH_NETCDF
+
19 #include "NetCDFPerFeatureDataProvider.hpp"
+
20#endif
+
21
+
22namespace realization {
+
23 using constructor = std::shared_ptr<Catchment_Formulation> (*)(std::string, shared_ptr<data_access::GenericDataProvider>, utils::StreamHandler);
24
-
-
25 static std::string valid_formulation_keys(){
-
26 std::string keys = "";
-
27 for(const auto& kv : formulations){
-
28 keys.append(kv.first+" ");
-
29 }
-
30 return keys;
-
31 }
+
25 extern std::map<std::string, constructor> formulations;
+
26
+
+
27 static std::string valid_formulation_keys(){
+
28 std::string keys = "";
+
29 for(const auto& kv : formulations){
+
30 keys.append(kv.first+" ");
+
31 }
+
32 return keys;
+
33 }
-
32
-
-
33 static bool formulation_exists(std::string formulation_type) {
-
34 return formulations.count(formulation_type) > 0;
-
35 }
+
34
+
+
35 static bool formulation_exists(std::string formulation_type) {
+
36 return formulations.count(formulation_type) > 0;
+
37 }
-
36
-
-
37 static std::shared_ptr<Catchment_Formulation> construct_formulation(
-
38 std::string formulation_type,
-
39 std::string identifier,
-
40 forcing_params &forcing_config,
-
41 utils::StreamHandler output_stream
-
42 ) {
-
43 constructor formulation_constructor = formulations.at(formulation_type);
-
44 std::shared_ptr<data_access::GenericDataProvider> fp;
-
45 if (forcing_config.provider == "CsvPerFeature" || forcing_config.provider == ""){
-
46 fp = std::make_shared<CsvPerFeatureForcingProvider>(forcing_config);
-
47 }
-
48#ifdef NETCDF_ACTIVE
-
49 else if (forcing_config.provider == "NetCDF"){
-
50 fp = data_access::NetCDFPerFeatureDataProvider::get_shared_provider(forcing_config.path, forcing_config.simulation_start_t, forcing_config.simulation_end_t, output_stream);
-
51 }
-
52#endif
-
53 else if (forcing_config.provider == "NullForcingProvider"){
-
54 fp = std::make_shared<NullForcingProvider>();
-
55 }
-
56 else { // Some unknown string in the provider field?
-
57 throw std::runtime_error(
-
58 "Invalid formulation forcing provider configuration! identifier: \"" + identifier +
-
59 "\", formulation_type: \"" + formulation_type +
-
60 "\", provider: \"" + forcing_config.provider + "\"");
-
61 }
-
62 return formulation_constructor(identifier, fp, output_stream);
-
63 }
+
38
+
+
39 static std::shared_ptr<Catchment_Formulation> construct_formulation(
+
40 std::string formulation_type,
+
41 std::string identifier,
+
42 forcing_params &forcing_config,
+
43 utils::StreamHandler output_stream
+
44 ) {
+
45 constructor formulation_constructor = formulations.at(formulation_type);
+
46 std::shared_ptr<data_access::GenericDataProvider> fp;
+
47 if (forcing_config.provider == "CsvPerFeature" || forcing_config.provider == ""){
+
48 fp = std::make_shared<CsvPerFeatureForcingProvider>(forcing_config);
+
49 }
+
50#if NGEN_WITH_NETCDF
+
51 else if (forcing_config.provider == "NetCDF"){
+
52 fp = data_access::NetCDFPerFeatureDataProvider::get_shared_provider(forcing_config.path, forcing_config.simulation_start_t, forcing_config.simulation_end_t, output_stream);
+
53 }
+
54#endif
+
55 else if (forcing_config.provider == "NullForcingProvider"){
+
56 fp = std::make_shared<NullForcingProvider>();
+
57 }
+
58 else { // Some unknown string in the provider field?
+
59 throw std::runtime_error(
+
60 "Invalid formulation forcing provider configuration! identifier: \"" + identifier +
+
61 "\", formulation_type: \"" + formulation_type +
+
62 "\", provider: \"" + forcing_config.provider + "\"");
+
63 }
+
64 return formulation_constructor(identifier, fp, output_stream);
+
65 }
-
64
-
-
65 static std::string get_formulation_key(const boost::property_tree::ptree &tree) {
-
66 /*for (auto &node : tree) {
-
67 if (formulation_exists(node.first)) {
-
68 return node.first;
-
69 }
-
70 }*/
-
71 boost::optional<std::string> key = tree.get_optional<std::string>("name");
-
72 if(key && formulation_exists(*key)){
-
73 return *key;
-
74 }
-
75
-
76 throw std::runtime_error("No valid formulation for " + *key + " was described in the passed in tree.");
-
77 }
+
66
+
+
67 static std::string get_formulation_key(const boost::property_tree::ptree &tree) {
+
68 /*for (auto &node : tree) {
+
69 if (formulation_exists(node.first)) {
+
70 return node.first;
+
71 }
+
72 }*/
+
73 boost::optional<std::string> key = tree.get_optional<std::string>("name");
+
74 if(key && formulation_exists(*key)){
+
75 return *key;
+
76 }
+
77
+
78 throw std::runtime_error("No valid formulation for " + *key + " was described in the passed in tree.");
+
79 }
-
78}
-
79
-
80#endif // NGEN_FORMULATION_CONSTRUCTORS_H
+
80}
+
81
+
82#endif // NGEN_FORMULATION_CONSTRUCTORS_H
This class provides a copyable interface to a std::ostream or std::ostream like object that may not s...
Definition StreamHandler.hpp:14
Definition Bmi_C_Formulation.hpp:11
-
static bool formulation_exists(std::string formulation_type)
Definition Formulation_Constructors.hpp:33
-
std::shared_ptr< Catchment_Formulation >(*)(std::string, shared_ptr< data_access::GenericDataProvider >, utils::StreamHandler) constructor
Definition Formulation_Constructors.hpp:21
-
static std::string get_formulation_key(const boost::property_tree::ptree &tree)
Definition Formulation_Constructors.hpp:65
-
std::map< std::string, constructor > formulations
Definition Formulation_Constructors.cpp:30
-
static std::string valid_formulation_keys()
Definition Formulation_Constructors.hpp:25
-
static std::shared_ptr< Catchment_Formulation > construct_formulation(std::string formulation_type, std::string identifier, forcing_params &forcing_config, utils::StreamHandler output_stream)
Definition Formulation_Constructors.hpp:37
+
static bool formulation_exists(std::string formulation_type)
Definition Formulation_Constructors.hpp:35
+
std::shared_ptr< Catchment_Formulation >(*)(std::string, shared_ptr< data_access::GenericDataProvider >, utils::StreamHandler) constructor
Definition Formulation_Constructors.hpp:23
+
static std::string get_formulation_key(const boost::property_tree::ptree &tree)
Definition Formulation_Constructors.hpp:67
+
std::map< std::string, constructor > formulations
Definition Formulation_Constructors.cpp:32
+
static std::string valid_formulation_keys()
Definition Formulation_Constructors.hpp:27
+
static std::shared_ptr< Catchment_Formulation > construct_formulation(std::string formulation_type, std::string identifier, forcing_params &forcing_config, utils::StreamHandler output_stream)
Definition Formulation_Constructors.hpp:39
forcing_params providing configuration information for forcing time period and source.
Definition AorcForcing.hpp:35
time_t simulation_start_t
Definition AorcForcing.hpp:41
std::string path
Definition AorcForcing.hpp:36
@@ -204,7 +206,7 @@ diff --git a/_formulation___manager_8hpp_source.html b/_formulation___manager_8hpp_source.html index 59865ca0a8..53bbac6942 100644 --- a/_formulation___manager_8hpp_source.html +++ b/_formulation___manager_8hpp_source.html @@ -100,657 +100,659 @@
1#ifndef NGEN_FORMULATION_MANAGER_H
2#define NGEN_FORMULATION_MANAGER_H
3
-
4#include <memory>
-
5#include <sstream>
-
6#include <tuple>
-
7#include <functional>
-
8#include <dirent.h>
-
9#include <sys/stat.h>
-
10#include <regex>
-
11
-
12#include <boost/property_tree/ptree.hpp>
-
13#include <boost/property_tree/json_parser.hpp>
-
14#include <FeatureBuilder.hpp>
-
15#include "features/Features.hpp"
-
16#include "Formulation_Constructors.hpp"
-
17#include "LayerData.hpp"
-
18#include "realizations/config/time.hpp"
-
19#include "realizations/config/routing.hpp"
-
20#include "realizations/config/config.hpp"
-
21#include "realizations/config/layer.hpp"
-
22
-
23namespace realization {
+
4#include <NGenConfig.h>
+
5
+
6#include <memory>
+
7#include <sstream>
+
8#include <tuple>
+
9#include <functional>
+
10#include <dirent.h>
+
11#include <sys/stat.h>
+
12#include <regex>
+
13
+
14#include <boost/property_tree/ptree.hpp>
+
15#include <boost/property_tree/json_parser.hpp>
+
16#include <FeatureBuilder.hpp>
+
17#include "features/Features.hpp"
+
18#include "Formulation_Constructors.hpp"
+
19#include "LayerData.hpp"
+
20#include "realizations/config/time.hpp"
+
21#include "realizations/config/routing.hpp"
+
22#include "realizations/config/config.hpp"
+
23#include "realizations/config/layer.hpp"
24
-
- -
26 typedef std::tuple<std::string, std::string> dual_keys;
-
27
-
28 public:
+
25namespace realization {
+
26
+
+ +
28 typedef std::tuple<std::string, std::string> dual_keys;
29
-
30 std::shared_ptr<Simulation_Time> Simulation_Time_Object;
+
30 public:
31
-
-
32 Formulation_Manager(std::stringstream &data) {
-
33 boost::property_tree::ptree loaded_tree;
-
34 boost::property_tree::json_parser::read_json(data, loaded_tree);
-
35 this->tree = loaded_tree;
-
36 }
+
32 std::shared_ptr<Simulation_Time> Simulation_Time_Object;
+
33
+
+
34 Formulation_Manager(std::stringstream &data) {
+
35 boost::property_tree::ptree loaded_tree;
+
36 boost::property_tree::json_parser::read_json(data, loaded_tree);
+
37 this->tree = loaded_tree;
+
38 }
-
37
-
-
38 Formulation_Manager(const std::string &file_path) {
-
39 boost::property_tree::ptree loaded_tree;
-
40 boost::property_tree::json_parser::read_json(file_path, loaded_tree);
-
41 this->tree = loaded_tree;
-
42 }
+
39
+
+
40 Formulation_Manager(const std::string &file_path) {
+
41 boost::property_tree::ptree loaded_tree;
+
42 boost::property_tree::json_parser::read_json(file_path, loaded_tree);
+
43 this->tree = loaded_tree;
+
44 }
-
43
-
-
44 Formulation_Manager(boost::property_tree::ptree &loaded_tree) {
-
45 this->tree = loaded_tree;
-
46 }
+
45
+
+
46 Formulation_Manager(boost::property_tree::ptree &loaded_tree) {
+
47 this->tree = loaded_tree;
+
48 }
-
47
-
- -
49#ifdef NETCDF_ACTIVE
-
50 data_access::NetCDFPerFeatureDataProvider::cleanup_shared_providers();
-
51#endif
-
52 };
+
49
+
+ +
51#if NGEN_WITH_NETCDF
+
52 data_access::NetCDFPerFeatureDataProvider::cleanup_shared_providers();
+
53#endif
+
54 };
-
53
-
-
54 virtual void read(geojson::GeoJSON fabric, utils::StreamHandler output_stream) {
-
55 //TODO seperate the parsing of configuration options like time
-
56 //and routing and other non feature specific tasks from this main function
-
57 //which has to iterate the entire hydrofabric.
-
58 auto possible_global_config = tree.get_child_optional("global");
-
59
-
60 if (possible_global_config) {
-
61 global_config = realization::config::Config(*possible_global_config);
-
62 }
-
63
-
64 auto possible_simulation_time = tree.get_child_optional("time");
+
55
+
+
56 virtual void read(geojson::GeoJSON fabric, utils::StreamHandler output_stream) {
+
57 //TODO seperate the parsing of configuration options like time
+
58 //and routing and other non feature specific tasks from this main function
+
59 //which has to iterate the entire hydrofabric.
+
60 auto possible_global_config = tree.get_child_optional("global");
+
61
+
62 if (possible_global_config) {
+
63 global_config = realization::config::Config(*possible_global_config);
+
64 }
65
-
66 if (!possible_simulation_time) {
-
67 throw std::runtime_error("ERROR: No simulation time period defined.");
-
68 }
-
69 config::Time time = config::Time(*possible_simulation_time);
-
70 auto simulation_time_config = time.make_params();
-
74 this->Simulation_Time_Object = std::make_shared<Simulation_Time>(simulation_time_config);
-
75
-
80 // try to get the json node
-
81 auto layers_json_array = tree.get_child_optional("layers");
-
82 //Create the default surface layer
-
83 config::Layer layer;
-
84 // layer description struct
-
85 ngen::LayerDescription layer_desc;
-
86 layer_desc = layer.get_descriptor();
-
87 // add the default surface layer to storage
-
88 layer_storage.put_layer(layer_desc, layer_desc.id);
-
89
-
90 if(layers_json_array){
-
91
-
92 for (std::pair<std::string, boost::property_tree::ptree> layer_config : *layers_json_array)
-
93 {
-
94 layer = config::Layer(layer_config.second);
-
95 layer_desc = layer.get_descriptor();
-
96
-
97 // add the layer to storage
-
98 layer_storage.put_layer(layer_desc, layer_desc.id);
-
99 if(layer.has_formulation() && layer.get_domain()=="catchments"){
-
100 double c_value = UnitsHelper::get_converted_value(layer_desc.time_step_units,layer_desc.time_step,"s");
-
101 // make a new simulation time object with a different output interval
-
102 Simulation_Time sim_time(*Simulation_Time_Object, c_value);
-
103 domain_formulations.emplace(
-
104 layer_desc.id,
-
105 construct_formulation_from_config(simulation_time_config,
-
106 "layer-"+std::to_string(layer_desc.id),
-
107 layer.formulation,
-
108 output_stream
-
109 )
-
110 );
-
111 domain_formulations.at(layer_desc.id)->set_output_stream(get_output_root() + layer_desc.name + "_layer_"+std::to_string(layer_desc.id) + ".csv");
-
112 }
-
113 //TODO for each layer, create deferred providers for use by other layers
-
114 //VERY SIMILAR TO NESTED MODULE INIT
-
115 }
-
116 }
-
117
-
118 //TODO use the set of layer providers as input for catchments to lookup from
+
66 auto possible_simulation_time = tree.get_child_optional("time");
+
67
+
68 if (!possible_simulation_time) {
+
69 throw std::runtime_error("ERROR: No simulation time period defined.");
+
70 }
+
71 config::Time time = config::Time(*possible_simulation_time);
+
72 auto simulation_time_config = time.make_params();
+
76 this->Simulation_Time_Object = std::make_shared<Simulation_Time>(simulation_time_config);
+
77
+
82 // try to get the json node
+
83 auto layers_json_array = tree.get_child_optional("layers");
+
84 //Create the default surface layer
+
85 config::Layer layer;
+
86 // layer description struct
+
87 ngen::LayerDescription layer_desc;
+
88 layer_desc = layer.get_descriptor();
+
89 // add the default surface layer to storage
+
90 layer_storage.put_layer(layer_desc, layer_desc.id);
+
91
+
92 if(layers_json_array){
+
93
+
94 for (std::pair<std::string, boost::property_tree::ptree> layer_config : *layers_json_array)
+
95 {
+
96 layer = config::Layer(layer_config.second);
+
97 layer_desc = layer.get_descriptor();
+
98
+
99 // add the layer to storage
+
100 layer_storage.put_layer(layer_desc, layer_desc.id);
+
101 if(layer.has_formulation() && layer.get_domain()=="catchments"){
+
102 double c_value = UnitsHelper::get_converted_value(layer_desc.time_step_units,layer_desc.time_step,"s");
+
103 // make a new simulation time object with a different output interval
+
104 Simulation_Time sim_time(*Simulation_Time_Object, c_value);
+
105 domain_formulations.emplace(
+
106 layer_desc.id,
+
107 construct_formulation_from_config(simulation_time_config,
+
108 "layer-"+std::to_string(layer_desc.id),
+
109 layer.formulation,
+
110 output_stream
+
111 )
+
112 );
+
113 domain_formulations.at(layer_desc.id)->set_output_stream(get_output_root() + layer_desc.name + "_layer_"+std::to_string(layer_desc.id) + ".csv");
+
114 }
+
115 //TODO for each layer, create deferred providers for use by other layers
+
116 //VERY SIMILAR TO NESTED MODULE INIT
+
117 }
+
118 }
119
-
123 auto possible_routing_configs = tree.get_child_optional("routing");
-
124
-
125 if (possible_routing_configs) {
-
126 //Since it is possible to build NGEN without routing support, if we see it in the config
-
127 //but it isn't enabled in the build, we should at least put up a warning
-
128 #ifdef NGEN_ROUTING_ACTIVE
-
129 this->routing_config = (config::Routing(*possible_routing_configs)).params;
-
130 using_routing = true;
-
131 #else
-
132 using_routing = false;
-
133 std::cerr<<"WARNING: Formulation Manager found routing configuration"
-
134 <<", but routing support isn't enabled. No routing will occur."<<std::endl;
-
135 #endif //NGEN_ROUTING_ACTIVE
-
136 }
-
137
-
141 auto possible_catchment_configs = tree.get_child_optional("catchments");
-
142
-
143 if (possible_catchment_configs) {
-
144 for (std::pair<std::string, boost::property_tree::ptree> catchment_config : *possible_catchment_configs) {
-
145 int catchment_index = fabric->find(catchment_config.first);
-
146 if( catchment_index == -1 )
-
147 {
-
148 #ifndef NGEN_QUIET
-
149 std::cerr<<"WARNING Formulation_Manager::read: Cannot create formulation for catchment "
-
150 <<catchment_config.first
-
151 <<" that isn't identified in the hydrofabric or requested subset"<<std::endl;
-
152 #endif
-
153 continue;
-
154 }
-
155 realization::config::Config catchment_formulation(catchment_config.second);
-
156
-
157 if(!catchment_formulation.has_formulation()){
-
158 throw std::runtime_error("ERROR: No formulations defined for "+catchment_config.first+".");
-
159 }
-
160 // Parse catchment-specific model_params
-
161 auto catchment_feature = fabric->get_feature(catchment_index);
-
162 catchment_formulation.formulation.link_external(catchment_feature);
-
163 this->add_formulation(
- -
165 simulation_time_config,
-
166 catchment_config.first,
-
167 catchment_formulation,
-
168 output_stream
-
169 )
-
170 );
-
171 // break; //only construct one for now FIXME
-
172 // } //end for formulaitons
-
173 }//end for catchments
-
174
-
175
-
176 }//end if possible_catchment_configs
+
120 //TODO use the set of layer providers as input for catchments to lookup from
+
121
+
125 auto possible_routing_configs = tree.get_child_optional("routing");
+
126
+
127 if (possible_routing_configs) {
+
128 //Since it is possible to build NGEN without routing support, if we see it in the config
+
129 //but it isn't enabled in the build, we should at least put up a warning
+
130 #if NGEN_WITH_ROUTING
+
131 this->routing_config = (config::Routing(*possible_routing_configs)).params;
+
132 using_routing = true;
+
133 #else
+
134 using_routing = false;
+
135 std::cerr<<"WARNING: Formulation Manager found routing configuration"
+
136 <<", but routing support isn't enabled. No routing will occur."<<std::endl;
+
137 #endif //NGEN_WITH_ROUTING
+
138 }
+
139
+
143 auto possible_catchment_configs = tree.get_child_optional("catchments");
+
144
+
145 if (possible_catchment_configs) {
+
146 for (std::pair<std::string, boost::property_tree::ptree> catchment_config : *possible_catchment_configs) {
+
147 int catchment_index = fabric->find(catchment_config.first);
+
148 if( catchment_index == -1 )
+
149 {
+
150 #ifndef NGEN_QUIET
+
151 std::cerr<<"WARNING Formulation_Manager::read: Cannot create formulation for catchment "
+
152 <<catchment_config.first
+
153 <<" that isn't identified in the hydrofabric or requested subset"<<std::endl;
+
154 #endif
+
155 continue;
+
156 }
+
157 realization::config::Config catchment_formulation(catchment_config.second);
+
158
+
159 if(!catchment_formulation.has_formulation()){
+
160 throw std::runtime_error("ERROR: No formulations defined for "+catchment_config.first+".");
+
161 }
+
162 // Parse catchment-specific model_params
+
163 auto catchment_feature = fabric->get_feature(catchment_index);
+
164 catchment_formulation.formulation.link_external(catchment_feature);
+
165 this->add_formulation(
+ +
167 simulation_time_config,
+
168 catchment_config.first,
+
169 catchment_formulation,
+
170 output_stream
+
171 )
+
172 );
+
173 // break; //only construct one for now FIXME
+
174 // } //end for formulaitons
+
175 }//end for catchments
+
176
177
-
178 for (geojson::Feature location : *fabric) {
-
179 if (not this->contains(location->get_id())) {
-
180 std::shared_ptr<Catchment_Formulation> missing_formulation = this->construct_missing_formulation(
-
181 location, output_stream, simulation_time_config);
-
182 this->add_formulation(missing_formulation);
-
183 }
-
184 }
-
185 }
+
178 }//end if possible_catchment_configs
+
179
+
180 for (geojson::Feature location : *fabric) {
+
181 if (not this->contains(location->get_id())) {
+
182 std::shared_ptr<Catchment_Formulation> missing_formulation = this->construct_missing_formulation(
+
183 location, output_stream, simulation_time_config);
+
184 this->add_formulation(missing_formulation);
+
185 }
+
186 }
+
187 }
-
186
-
-
187 virtual void add_formulation(std::shared_ptr<Catchment_Formulation> formulation) {
-
188 this->formulations.emplace(formulation->get_id(), formulation);
-
189 }
+
188
+
+
189 virtual void add_formulation(std::shared_ptr<Catchment_Formulation> formulation) {
+
190 this->formulations.emplace(formulation->get_id(), formulation);
+
191 }
-
190
-
-
191 virtual std::shared_ptr<Catchment_Formulation> get_formulation(std::string id) const {
-
192 // TODO: Implement on-the-fly formulation creation using global parameters
-
193 return this->formulations.at(id);
-
194 }
+
192
+
+
193 virtual std::shared_ptr<Catchment_Formulation> get_formulation(std::string id) const {
+
194 // TODO: Implement on-the-fly formulation creation using global parameters
+
195 return this->formulations.at(id);
+
196 }
-
195
-
-
196 virtual std::shared_ptr<Catchment_Formulation> get_domain_formulation(long id) const {
-
197 return this->domain_formulations.at(id);
-
198 }
+
197
+
+
198 virtual std::shared_ptr<Catchment_Formulation> get_domain_formulation(long id) const {
+
199 return this->domain_formulations.at(id);
+
200 }
-
199
-
-
200 virtual bool has_domain_formulation(int id) const {
-
201 return this->domain_formulations.count( id ) > 0;
-
202 }
+
201
+
+
202 virtual bool has_domain_formulation(int id) const {
+
203 return this->domain_formulations.count( id ) > 0;
+
204 }
-
203
-
-
204 virtual bool contains(std::string identifier) const {
-
205 return this->formulations.count(identifier) > 0;
-
206 }
+
205
+
+
206 virtual bool contains(std::string identifier) const {
+
207 return this->formulations.count(identifier) > 0;
+
208 }
-
207
-
-
211 virtual int get_size() {
-
212 return this->formulations.size();
-
213 }
+
209
+
+
213 virtual int get_size() {
+
214 return this->formulations.size();
+
215 }
-
214
-
-
218 virtual bool is_empty() {
-
219 return this->formulations.empty();
-
220 }
+
216
+
+
220 virtual bool is_empty() {
+
221 return this->formulations.empty();
+
222 }
-
221
-
-
222 virtual typename std::map<std::string, std::shared_ptr<Catchment_Formulation>>::const_iterator begin() const {
-
223 return this->formulations.cbegin();
-
224 }
+
223
+
+
224 virtual typename std::map<std::string, std::shared_ptr<Catchment_Formulation>>::const_iterator begin() const {
+
225 return this->formulations.cbegin();
+
226 }
-
225
-
-
226 virtual typename std::map<std::string, std::shared_ptr<Catchment_Formulation>>::const_iterator end() const {
-
227 return this->formulations.cend();
-
228 }
+
227
+
+
228 virtual typename std::map<std::string, std::shared_ptr<Catchment_Formulation>>::const_iterator end() const {
+
229 return this->formulations.cend();
+
230 }
-
229
-
- -
234 return this->using_routing;
-
235 }
+
231
+
+ +
236 return this->using_routing;
+
237 }
-
236
-
- -
241 if(this->routing_config != nullptr)
-
242 return this->routing_config->t_route_config_file_with_path;
-
243 else
-
244 return "";
-
245 }
+
238
+
+ +
243 if(this->routing_config != nullptr)
+
244 return this->routing_config->t_route_config_file_with_path;
+
245 else
+
246 return "";
+
247 }
-
246
-
-
262 std::string get_output_root() const noexcept {
-
263 const auto output_root = this->tree.get_optional<std::string>("output_root");
-
264 if (output_root != boost::none && *output_root != "") {
-
265 // Check if the path ends with a trailing slash,
-
266 // otherwise add it.
-
267 return output_root->back() == '/'
-
268 ? *output_root
-
269 : *output_root + "/";
-
270 }
-
271
-
272 return "./";
-
273 }
+
248
+
+
264 std::string get_output_root() const noexcept {
+
265 const auto output_root = this->tree.get_optional<std::string>("output_root");
+
266 if (output_root != boost::none && *output_root != "") {
+
267 // Check if the path ends with a trailing slash,
+
268 // otherwise add it.
+
269 return output_root->back() == '/'
+
270 ? *output_root
+
271 : *output_root + "/";
+
272 }
+
273
+
274 return "./";
+
275 }
-
274
- -
280
-
281
-
282 protected:
-
-
283 std::shared_ptr<Catchment_Formulation> construct_formulation_from_config(
-
284 simulation_time_params &simulation_time_config,
-
285 std::string identifier,
-
286 const realization::config::Config& catchment_formulation,
-
287 utils::StreamHandler output_stream
-
288 ) {
-
289 if(!formulation_exists(catchment_formulation.formulation.type)){
-
290 throw std::runtime_error("Catchment " + identifier + " failed initialization: '" +
-
291 catchment_formulation.formulation.type + "' is not a valid formulation. Options are: "+valid_formulation_keys());
-
292 }
-
293
-
294 if(catchment_formulation.forcing.parameters.empty()){
-
295 throw std::runtime_error("No forcing definition was found for " + identifier);
-
296 }
-
297
-
298 std::vector<std::string> missing_parameters;
-
299
-
300 if (!catchment_formulation.forcing.has_key("path")) {
-
301 missing_parameters.push_back("path");
-
302 }
-
303
-
304 if (missing_parameters.size() > 0) {
-
305 std::string message = "A forcing configuration cannot be created for '" + identifier + "'; the following parameters are missing: ";
-
306
-
307 for (int missing_parameter_index = 0; missing_parameter_index < missing_parameters.size(); missing_parameter_index++) {
-
308 message += missing_parameters[missing_parameter_index];
-
309
-
310 if (missing_parameter_index < missing_parameters.size() - 1) {
-
311 message += ", ";
-
312 }
-
313 }
-
314
-
315 throw std::runtime_error(message);
-
316 }
-
317
-
318 forcing_params forcing_config = this->get_forcing_params(catchment_formulation.forcing.parameters, identifier, simulation_time_config);
-
319 std::shared_ptr<Catchment_Formulation> constructed_formulation = construct_formulation(catchment_formulation.formulation.type, identifier, forcing_config, output_stream);
-
320 //, geometry);
-
321
-
322 constructed_formulation->create_formulation(catchment_formulation.formulation.parameters);
-
323 return constructed_formulation;
-
324 }
+
276
+ +
282
+
283
+
284 protected:
+
+
285 std::shared_ptr<Catchment_Formulation> construct_formulation_from_config(
+
286 simulation_time_params &simulation_time_config,
+
287 std::string identifier,
+
288 const realization::config::Config& catchment_formulation,
+
289 utils::StreamHandler output_stream
+
290 ) {
+
291 if(!formulation_exists(catchment_formulation.formulation.type)){
+
292 throw std::runtime_error("Catchment " + identifier + " failed initialization: '" +
+
293 catchment_formulation.formulation.type + "' is not a valid formulation. Options are: "+valid_formulation_keys());
+
294 }
+
295
+
296 if(catchment_formulation.forcing.parameters.empty()){
+
297 throw std::runtime_error("No forcing definition was found for " + identifier);
+
298 }
+
299
+
300 std::vector<std::string> missing_parameters;
+
301
+
302 if (!catchment_formulation.forcing.has_key("path")) {
+
303 missing_parameters.push_back("path");
+
304 }
+
305
+
306 if (missing_parameters.size() > 0) {
+
307 std::string message = "A forcing configuration cannot be created for '" + identifier + "'; the following parameters are missing: ";
+
308
+
309 for (int missing_parameter_index = 0; missing_parameter_index < missing_parameters.size(); missing_parameter_index++) {
+
310 message += missing_parameters[missing_parameter_index];
+
311
+
312 if (missing_parameter_index < missing_parameters.size() - 1) {
+
313 message += ", ";
+
314 }
+
315 }
+
316
+
317 throw std::runtime_error(message);
+
318 }
+
319
+
320 forcing_params forcing_config = this->get_forcing_params(catchment_formulation.forcing.parameters, identifier, simulation_time_config);
+
321 std::shared_ptr<Catchment_Formulation> constructed_formulation = construct_formulation(catchment_formulation.formulation.type, identifier, forcing_config, output_stream);
+
322 //, geometry);
+
323
+
324 constructed_formulation->create_formulation(catchment_formulation.formulation.parameters);
+
325 return constructed_formulation;
+
326 }
-
325
-
-
326 std::shared_ptr<Catchment_Formulation> construct_missing_formulation(geojson::Feature& feature, utils::StreamHandler output_stream, simulation_time_params &simulation_time_config){
-
327 const std::string identifier = feature->get_id();
-
328
-
329 forcing_params forcing_config = this->get_forcing_params(global_config.forcing.parameters, identifier, simulation_time_config);
-
330 std::shared_ptr<Catchment_Formulation> missing_formulation = construct_formulation(global_config.formulation.type, identifier, forcing_config, output_stream);
-
331 // Need to work with a copy, since it is altered in-place
- - -
334 BMI_REALIZATION_CFG_PARAM_REQ__INIT_CONFIG, "{{id}}",
-
335 identifier);
-
336 //Some helpful debugging prints, commented out, but left for later
-
337 //because they will eventually be used by someone, someday, looking at configurations
-
338 //being turned into concrecte formulations...
-
339 // geojson::JSONProperty::print_property(global_config.formulation.parameters.at("modules"));
- +
327
+
+
328 std::shared_ptr<Catchment_Formulation> construct_missing_formulation(geojson::Feature& feature, utils::StreamHandler output_stream, simulation_time_params &simulation_time_config){
+
329 const std::string identifier = feature->get_id();
+
330
+
331 forcing_params forcing_config = this->get_forcing_params(global_config.forcing.parameters, identifier, simulation_time_config);
+
332 std::shared_ptr<Catchment_Formulation> missing_formulation = construct_formulation(global_config.formulation.type, identifier, forcing_config, output_stream);
+
333 // Need to work with a copy, since it is altered in-place
+ + +
336 BMI_REALIZATION_CFG_PARAM_REQ__INIT_CONFIG, "{{id}}",
+
337 identifier);
+
338 //Some helpful debugging prints, commented out, but left for later
+
339 //because they will eventually be used by someone, someday, looking at configurations
+
340 //being turned into concrecte formulations...
341 // geojson::JSONProperty::print_property(global_config.formulation.parameters.at("modules"));
-
342 missing_formulation->create_formulation(global_config.formulation.parameters);
-
343
-
344 return missing_formulation;
-
345 }
+ +
343 // geojson::JSONProperty::print_property(global_config.formulation.parameters.at("modules"));
+
344 missing_formulation->create_formulation(global_config.formulation.parameters);
+
345
+
346 return missing_formulation;
+
347 }
-
346
-
-
347 forcing_params get_forcing_params(const geojson::PropertyMap &forcing_prop_map, std::string identifier, simulation_time_params &simulation_time_config) {
-
348 std::string path = "";
-
349 if(forcing_prop_map.count("path") != 0){
-
350 path = forcing_prop_map.at("path").as_string();
-
351 }
-
352 std::string provider;
-
353 if(forcing_prop_map.count("provider") != 0){
-
354 provider = forcing_prop_map.at("provider").as_string();
-
355 }
-
356 if (forcing_prop_map.count("file_pattern") == 0) {
-
357 return forcing_params(
-
358 path,
-
359 provider,
-
360 simulation_time_config.start_time,
-
361 simulation_time_config.end_time
-
362 );
-
363 }
-
364
-
365 if (path.empty()) {
-
366 throw std::runtime_error("Error with NGEN config - 'path' in forcing params must be set to a "
-
367 "non-empty parent directory path when 'file_pattern' is used.");
-
368 }
-
369
-
370 // Since we are given a pattern, we need to identify the directory and pull out anything that matches the pattern
-
371 if (path.compare(path.size() - 1, 1, "/") != 0) {
-
372 path += "/";
-
373 }
-
374
-
375 std::string filepattern = forcing_prop_map.at("file_pattern").as_string();
+
348
+
+
349 forcing_params get_forcing_params(const geojson::PropertyMap &forcing_prop_map, std::string identifier, simulation_time_params &simulation_time_config) {
+
350 std::string path = "";
+
351 if(forcing_prop_map.count("path") != 0){
+
352 path = forcing_prop_map.at("path").as_string();
+
353 }
+
354 std::string provider;
+
355 if(forcing_prop_map.count("provider") != 0){
+
356 provider = forcing_prop_map.at("provider").as_string();
+
357 }
+
358 if (forcing_prop_map.count("file_pattern") == 0) {
+
359 return forcing_params(
+
360 path,
+
361 provider,
+
362 simulation_time_config.start_time,
+
363 simulation_time_config.end_time
+
364 );
+
365 }
+
366
+
367 if (path.empty()) {
+
368 throw std::runtime_error("Error with NGEN config - 'path' in forcing params must be set to a "
+
369 "non-empty parent directory path when 'file_pattern' is used.");
+
370 }
+
371
+
372 // Since we are given a pattern, we need to identify the directory and pull out anything that matches the pattern
+
373 if (path.compare(path.size() - 1, 1, "/") != 0) {
+
374 path += "/";
+
375 }
376
-
377 int id_index = filepattern.find("{{id}}");
+
377 std::string filepattern = forcing_prop_map.at("file_pattern").as_string();
378
-
379 // If an index for '{{id}}' was found, we can count on that being where the id for this realization can be found.
-
380 // For instance, if we have a pattern of '.*{{id}}_14_15.csv' and this is named 'cat-87',
-
381 // this will match on 'stuff_example_cat-87_14_15.csv'
-
382 if (id_index != std::string::npos) {
-
383 filepattern = filepattern.replace(id_index, sizeof("{{id}}") - 1, identifier);
-
384 }
-
385
-
386 // Create a regular expression used to identify proper file names
-
387 std::regex pattern(filepattern);
-
388
-
389 // A stream providing the functions necessary for evaluating a directory:
-
390 // https://www.gnu.org/software/libc/manual/html_node/Opening-a-Directory.html#Opening-a-Directory
-
391 DIR *directory = nullptr;
-
392
-
393 // structure representing the member of a directory: https://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html
-
394 struct dirent *entry = nullptr;
-
395
-
396 // Attempt to open the directory for evaluation
-
397 directory = opendir(path.c_str());
-
398 // Allow for a few retries in certain failure situations
-
399 size_t attemptCount = 0;
-
400 std::string errMsg;
-
401 while (directory == nullptr && attemptCount++ < 5) {
-
402 // For several error codes, we should break immediately and not retry
-
403 if (errno == ENOENT) {
-
404 errMsg = "No such file or directory.";
-
405 break;
-
406 }
-
407 if (errno == ENXIO) {
-
408 errMsg = "No such device or address.";
-
409 break;
-
410 }
-
411 if (errno == EACCES) {
-
412 errMsg = "Permission denied.";
-
413 break;
-
414 }
-
415 if (errno == EPERM) {
-
416 errMsg = "Operation not permitted.";
-
417 break;
-
418 }
-
419 if (errno == ENOTDIR) {
-
420 errMsg = "File at provided path is not a directory.";
-
421 break;
-
422 }
-
423 if (errno == EMFILE) {
-
424 errMsg = "The current process has too many open files.";
-
425 break;
-
426 }
-
427 if (errno == ENFILE) {
-
428 errMsg = "The system has too many open files.";
-
429 break;
-
430 }
-
431 sleep(2);
-
432 directory = opendir(path.c_str());
-
433 errMsg = "Received system error number " + std::to_string(errno);
-
434 }
-
435
-
436 // If the directory could be found and opened, we can go ahead and iterate
-
437 if (directory != nullptr) {
-
438 bool match;
-
439 while ((entry = readdir(directory))) {
-
440 match = std::regex_match(entry->d_name, pattern);
-
441 if( match ) {
-
442 // If the entry is a regular file or symlink AND the name matches the pattern,
-
443 // we can consider this ready to be interpretted as valid forcing data (even if it isn't)
-
444 #ifdef _DIRENT_HAVE_D_TYPE
-
445 if ( entry->d_type == DT_REG or entry->d_type == DT_LNK ) {
-
446 return forcing_params(
-
447 path + entry->d_name,
-
448 provider,
-
449 simulation_time_config.start_time,
-
450 simulation_time_config.end_time
-
451 );
-
452 }
-
453 else if ( entry->d_type == DT_UNKNOWN )
-
454 #endif
-
455 {
-
456 //dirent is not guaranteed to provide propoer file type identification in d_type
-
457 //so if a system returns unknown or it isn't supported, need to use stat to determine if it is a file
-
458 struct stat st;
-
459 if( stat((path+entry->d_name).c_str(), &st) != 0) {
-
460 throw std::runtime_error("Could not stat file "+path+entry->d_name);
-
461 }
-
462 if( S_ISREG(st.st_mode) ) {
-
463 //Sinde we used stat and not lstat, we get the result of the target of links as well
-
464 //so this covers both cases we are interested in.
-
465 return forcing_params(
-
466 path + entry->d_name,
-
467 provider,
-
468 simulation_time_config.start_time,
-
469 simulation_time_config.end_time
-
470 );
-
471 }
-
472 throw std::runtime_error("Forcing data is path "+path+entry->d_name+" is not a file");
-
473 }
-
474 } //no match found, try next entry
-
475 } // end while iter dir
-
476 } //end if directory
-
477 else {
-
478 // The directory wasn't found or otherwise couldn't be opened; forcing data cannot be retrieved
-
479 throw std::runtime_error("Error opening forcing data dir '" + path + "' after " + std::to_string(attemptCount) + " attempts: " + errMsg);
-
480 }
-
481
-
482 closedir(directory);
+
379 int id_index = filepattern.find("{{id}}");
+
380
+
381 // If an index for '{{id}}' was found, we can count on that being where the id for this realization can be found.
+
382 // For instance, if we have a pattern of '.*{{id}}_14_15.csv' and this is named 'cat-87',
+
383 // this will match on 'stuff_example_cat-87_14_15.csv'
+
384 if (id_index != std::string::npos) {
+
385 filepattern = filepattern.replace(id_index, sizeof("{{id}}") - 1, identifier);
+
386 }
+
387
+
388 // Create a regular expression used to identify proper file names
+
389 std::regex pattern(filepattern);
+
390
+
391 // A stream providing the functions necessary for evaluating a directory:
+
392 // https://www.gnu.org/software/libc/manual/html_node/Opening-a-Directory.html#Opening-a-Directory
+
393 DIR *directory = nullptr;
+
394
+
395 // structure representing the member of a directory: https://www.gnu.org/software/libc/manual/html_node/Directory-Entries.html
+
396 struct dirent *entry = nullptr;
+
397
+
398 // Attempt to open the directory for evaluation
+
399 directory = opendir(path.c_str());
+
400 // Allow for a few retries in certain failure situations
+
401 size_t attemptCount = 0;
+
402 std::string errMsg;
+
403 while (directory == nullptr && attemptCount++ < 5) {
+
404 // For several error codes, we should break immediately and not retry
+
405 if (errno == ENOENT) {
+
406 errMsg = "No such file or directory.";
+
407 break;
+
408 }
+
409 if (errno == ENXIO) {
+
410 errMsg = "No such device or address.";
+
411 break;
+
412 }
+
413 if (errno == EACCES) {
+
414 errMsg = "Permission denied.";
+
415 break;
+
416 }
+
417 if (errno == EPERM) {
+
418 errMsg = "Operation not permitted.";
+
419 break;
+
420 }
+
421 if (errno == ENOTDIR) {
+
422 errMsg = "File at provided path is not a directory.";
+
423 break;
+
424 }
+
425 if (errno == EMFILE) {
+
426 errMsg = "The current process has too many open files.";
+
427 break;
+
428 }
+
429 if (errno == ENFILE) {
+
430 errMsg = "The system has too many open files.";
+
431 break;
+
432 }
+
433 sleep(2);
+
434 directory = opendir(path.c_str());
+
435 errMsg = "Received system error number " + std::to_string(errno);
+
436 }
+
437
+
438 // If the directory could be found and opened, we can go ahead and iterate
+
439 if (directory != nullptr) {
+
440 bool match;
+
441 while ((entry = readdir(directory))) {
+
442 match = std::regex_match(entry->d_name, pattern);
+
443 if( match ) {
+
444 // If the entry is a regular file or symlink AND the name matches the pattern,
+
445 // we can consider this ready to be interpretted as valid forcing data (even if it isn't)
+
446 #ifdef _DIRENT_HAVE_D_TYPE
+
447 if ( entry->d_type == DT_REG or entry->d_type == DT_LNK ) {
+
448 return forcing_params(
+
449 path + entry->d_name,
+
450 provider,
+
451 simulation_time_config.start_time,
+
452 simulation_time_config.end_time
+
453 );
+
454 }
+
455 else if ( entry->d_type == DT_UNKNOWN )
+
456 #endif
+
457 {
+
458 //dirent is not guaranteed to provide propoer file type identification in d_type
+
459 //so if a system returns unknown or it isn't supported, need to use stat to determine if it is a file
+
460 struct stat st;
+
461 if( stat((path+entry->d_name).c_str(), &st) != 0) {
+
462 throw std::runtime_error("Could not stat file "+path+entry->d_name);
+
463 }
+
464 if( S_ISREG(st.st_mode) ) {
+
465 //Sinde we used stat and not lstat, we get the result of the target of links as well
+
466 //so this covers both cases we are interested in.
+
467 return forcing_params(
+
468 path + entry->d_name,
+
469 provider,
+
470 simulation_time_config.start_time,
+
471 simulation_time_config.end_time
+
472 );
+
473 }
+
474 throw std::runtime_error("Forcing data is path "+path+entry->d_name+" is not a file");
+
475 }
+
476 } //no match found, try next entry
+
477 } // end while iter dir
+
478 } //end if directory
+
479 else {
+
480 // The directory wasn't found or otherwise couldn't be opened; forcing data cannot be retrieved
+
481 throw std::runtime_error("Error opening forcing data dir '" + path + "' after " + std::to_string(attemptCount) + " attempts: " + errMsg);
+
482 }
483
-
484 throw std::runtime_error("Forcing data could not be found for '" + identifier + "'");
-
485 }
+
484 closedir(directory);
+
485
+
486 throw std::runtime_error("Forcing data could not be found for '" + identifier + "'");
+
487 }
-
486
-
-
494 void parse_external_model_params(boost::property_tree::ptree& model_params, const geojson::Feature catchment_feature) {
-
495 boost::property_tree::ptree attr {};
-
496 for (decltype(auto) param : model_params) {
-
497 if (param.second.count("source") == 0) {
-
498 attr.put_child(param.first, param.second);
-
499 continue;
-
500 }
-
501
-
502 decltype(auto) param_source = param.second.get_child("source");
-
503 decltype(auto) param_source_name = param_source.get_value<std::string>();
-
504 if (param_source_name != "hydrofabric") {
-
505 // temporary until the logic for alternative sources is designed
-
506 throw std::logic_error("ERROR: 'model_params' source `" + param_source_name + "` not currently supported. Only `hydrofabric` is supported.");
-
507 }
-
508
-
509 decltype(auto) param_name = param.second.find("from") == param.second.not_found()
-
510 ? param.first
-
511 : param.second.get_child("from").get_value<std::string>();
-
512
-
513 if (catchment_feature->has_property(param_name)) {
-
514 auto catchment_attribute = catchment_feature->get_property(param_name);
-
515 switch (catchment_attribute.get_type()) {
- -
517 attr.put(param.first, catchment_attribute.as_natural_number());
-
518 break;
- -
520 attr.put(param.first, catchment_attribute.as_boolean());
-
521 break;
- -
523 attr.put(param.first, catchment_attribute.as_real_number());
-
524 break;
- -
526 attr.put(param.first, catchment_attribute.as_string());
-
527 break;
-
528
- - -
531 default:
-
532 std::cerr << "WARNING: property type " << static_cast<int>(catchment_attribute.get_type()) << " not allowed as model parameter. "
-
533 << "Must be one of: Natural (int), Real (double), Boolean, or String" << '\n';
-
534 break;
-
535 }
-
536 } else {
-
537 std::cerr << "WARNING Failed to parse external parameter: catchment `"
-
538 << catchment_feature->get_id()
-
539 << "` does not contain the property `"
-
540 << param_name << "`\n";
-
541 }
-
542 }
-
543
-
544 model_params.swap(attr);
-
545 }
+
488
+
+
496 void parse_external_model_params(boost::property_tree::ptree& model_params, const geojson::Feature catchment_feature) {
+
497 boost::property_tree::ptree attr {};
+
498 for (decltype(auto) param : model_params) {
+
499 if (param.second.count("source") == 0) {
+
500 attr.put_child(param.first, param.second);
+
501 continue;
+
502 }
+
503
+
504 decltype(auto) param_source = param.second.get_child("source");
+
505 decltype(auto) param_source_name = param_source.get_value<std::string>();
+
506 if (param_source_name != "hydrofabric") {
+
507 // temporary until the logic for alternative sources is designed
+
508 throw std::logic_error("ERROR: 'model_params' source `" + param_source_name + "` not currently supported. Only `hydrofabric` is supported.");
+
509 }
+
510
+
511 decltype(auto) param_name = param.second.find("from") == param.second.not_found()
+
512 ? param.first
+
513 : param.second.get_child("from").get_value<std::string>();
+
514
+
515 if (catchment_feature->has_property(param_name)) {
+
516 auto catchment_attribute = catchment_feature->get_property(param_name);
+
517 switch (catchment_attribute.get_type()) {
+ +
519 attr.put(param.first, catchment_attribute.as_natural_number());
+
520 break;
+ +
522 attr.put(param.first, catchment_attribute.as_boolean());
+
523 break;
+ +
525 attr.put(param.first, catchment_attribute.as_real_number());
+
526 break;
+ +
528 attr.put(param.first, catchment_attribute.as_string());
+
529 break;
+
530
+ + +
533 default:
+
534 std::cerr << "WARNING: property type " << static_cast<int>(catchment_attribute.get_type()) << " not allowed as model parameter. "
+
535 << "Must be one of: Natural (int), Real (double), Boolean, or String" << '\n';
+
536 break;
+
537 }
+
538 } else {
+
539 std::cerr << "WARNING Failed to parse external parameter: catchment `"
+
540 << catchment_feature->get_id()
+
541 << "` does not contain the property `"
+
542 << param_name << "`\n";
+
543 }
+
544 }
+
545
+
546 model_params.swap(attr);
+
547 }
-
546
-
-
554 void parse_external_model_params(geojson::PropertyMap& model_params, const geojson::Feature catchment_feature) {
-
555 geojson::PropertyMap attr {};
-
556 for (decltype(auto) param : model_params) {
-
557 // Check for type to short-circuit. If param.second is not an object, `.has_key()` will throw
-
558 if (param.second.get_type() != geojson::PropertyType::Object || !param.second.has_key("source")) {
-
559 attr.emplace(param.first, param.second);
-
560 continue;
-
561 }
-
562
-
563 decltype(auto) param_source = param.second.at("source");
-
564 decltype(auto) param_source_name = param_source.as_string();
-
565 if (param_source_name != "hydrofabric") {
-
566 // TODO: temporary until the logic for alternative sources is designed
-
567 throw std::logic_error("ERROR: 'model_params' source `" + param_source_name + "` not currently supported. Only `hydrofabric` is supported.");
-
568 }
-
569
-
570 // Property name in the feature properties is either
-
571 // the value of key "from", or has the same name as
-
572 // the expected model parameter key
-
573 decltype(auto) param_name = param.second.has_key("from")
-
574 ? param.second.at("from").as_string()
-
575 : param.first;
-
576
-
577 if (catchment_feature->has_property(param_name)) {
-
578 auto catchment_attribute = catchment_feature->get_property(param_name);
-
579
-
580 // Use param.first in the `.emplace` calls instead of param_name since
-
581 // the expected name is given by the key of the model_params values.
-
582 switch (catchment_attribute.get_type()) {
- -
584 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_natural_number()));
-
585 break;
- -
587 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_boolean()));
-
588 break;
- -
590 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_real_number()));
-
591 break;
- -
593 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_string()));
-
594 break;
-
595
- - -
598 default:
-
599 // TODO: Should list/object values be passed to model parameters?
-
600 // Typically, feature properties *should* be scalars.
-
601 std::cerr << "WARNING: property type " << static_cast<int>(catchment_attribute.get_type()) << " not allowed as model parameter. "
-
602 << "Must be one of: Natural (int), Real (double), Boolean, or String" << '\n';
-
603 break;
-
604 }
-
605 }
-
606 }
-
607
-
608 model_params.swap(attr);
-
609 }
+
548
+
+
556 void parse_external_model_params(geojson::PropertyMap& model_params, const geojson::Feature catchment_feature) {
+
557 geojson::PropertyMap attr {};
+
558 for (decltype(auto) param : model_params) {
+
559 // Check for type to short-circuit. If param.second is not an object, `.has_key()` will throw
+
560 if (param.second.get_type() != geojson::PropertyType::Object || !param.second.has_key("source")) {
+
561 attr.emplace(param.first, param.second);
+
562 continue;
+
563 }
+
564
+
565 decltype(auto) param_source = param.second.at("source");
+
566 decltype(auto) param_source_name = param_source.as_string();
+
567 if (param_source_name != "hydrofabric") {
+
568 // TODO: temporary until the logic for alternative sources is designed
+
569 throw std::logic_error("ERROR: 'model_params' source `" + param_source_name + "` not currently supported. Only `hydrofabric` is supported.");
+
570 }
+
571
+
572 // Property name in the feature properties is either
+
573 // the value of key "from", or has the same name as
+
574 // the expected model parameter key
+
575 decltype(auto) param_name = param.second.has_key("from")
+
576 ? param.second.at("from").as_string()
+
577 : param.first;
+
578
+
579 if (catchment_feature->has_property(param_name)) {
+
580 auto catchment_attribute = catchment_feature->get_property(param_name);
+
581
+
582 // Use param.first in the `.emplace` calls instead of param_name since
+
583 // the expected name is given by the key of the model_params values.
+
584 switch (catchment_attribute.get_type()) {
+ +
586 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_natural_number()));
+
587 break;
+ +
589 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_boolean()));
+
590 break;
+ +
592 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_real_number()));
+
593 break;
+ +
595 attr.emplace(param.first, geojson::JSONProperty(param.first, catchment_attribute.as_string()));
+
596 break;
+
597
+ + +
600 default:
+
601 // TODO: Should list/object values be passed to model parameters?
+
602 // Typically, feature properties *should* be scalars.
+
603 std::cerr << "WARNING: property type " << static_cast<int>(catchment_attribute.get_type()) << " not allowed as model parameter. "
+
604 << "Must be one of: Natural (int), Real (double), Boolean, or String" << '\n';
+
605 break;
+
606 }
+
607 }
+
608 }
+
609
+
610 model_params.swap(attr);
+
611 }
-
610
-
611 boost::property_tree::ptree tree;
612
- +
613 boost::property_tree::ptree tree;
614
-
615 std::map<std::string, std::shared_ptr<Catchment_Formulation>> formulations;
+
616
-
617 //Store global layer formulation pointers
-
618 std::map<int, std::shared_ptr<Catchment_Formulation> > domain_formulations;
-
619
-
620 std::shared_ptr<routing_params> routing_config;
+
617 std::map<std::string, std::shared_ptr<Catchment_Formulation>> formulations;
+
618
+
619 //Store global layer formulation pointers
+
620 std::map<int, std::shared_ptr<Catchment_Formulation> > domain_formulations;
621
-
622 bool using_routing = false;
+
622 std::shared_ptr<routing_params> routing_config;
623
- -
625 };
+
624 bool using_routing = false;
+
625
+ +
627 };
-
626}
-
627#endif // NGEN_FORMULATION_MANAGER_H
+
628}
+
629#endif // NGEN_FORMULATION_MANAGER_H
Simulation Time class providing time-series variables and methods to the model.
Definition Simulation_Time.hpp:48
static double get_converted_value(const std::string &in_units, const double &value, const std::string &out_units)
Definition UnitsHelper.cpp:58
@TODO: Convert JSONProperty into a variant of the supported types
Definition JSONProperty.hpp:165
A class to hold and manage layer metadata for the system.
Definition LayerData.hpp:32
void put_layer(const LayerDescription &desc, int id)
store a new layer description in the indicated id slot
Definition LayerData.hpp:52
static void config_pattern_substitution(geojson::PropertyMap &properties, const std::string &key, const std::string &pattern, const std::string &replacement)
Perform in-place substitution on the given config property item, if the item and the pattern are pres...
Definition Catchment_Formulation.hpp:38
-
Definition Formulation_Manager.hpp:25
-
Formulation_Manager(const std::string &file_path)
Definition Formulation_Manager.hpp:38
-
ngen::LayerDataStorage layer_storage
Definition Formulation_Manager.hpp:624
-
bool using_routing
Definition Formulation_Manager.hpp:622
-
realization::config::Config global_config
Definition Formulation_Manager.hpp:613
-
std::string get_output_root() const noexcept
Get the formatted output root.
Definition Formulation_Manager.hpp:262
-
forcing_params get_forcing_params(const geojson::PropertyMap &forcing_prop_map, std::string identifier, simulation_time_params &simulation_time_config)
Definition Formulation_Manager.hpp:347
-
void parse_external_model_params(geojson::PropertyMap &model_params, const geojson::Feature catchment_feature)
Parse a model_params property map and replace external parameters with values from a catchment's prop...
Definition Formulation_Manager.hpp:554
-
std::shared_ptr< Catchment_Formulation > construct_missing_formulation(geojson::Feature &feature, utils::StreamHandler output_stream, simulation_time_params &simulation_time_config)
Definition Formulation_Manager.hpp:326
-
virtual int get_size()
Definition Formulation_Manager.hpp:211
-
std::shared_ptr< Catchment_Formulation > construct_formulation_from_config(simulation_time_params &simulation_time_config, std::string identifier, const realization::config::Config &catchment_formulation, utils::StreamHandler output_stream)
Definition Formulation_Manager.hpp:283
-
Formulation_Manager(boost::property_tree::ptree &loaded_tree)
Definition Formulation_Manager.hpp:44
-
bool get_using_routing()
Definition Formulation_Manager.hpp:233
-
std::map< int, std::shared_ptr< Catchment_Formulation > > domain_formulations
Definition Formulation_Manager.hpp:618
-
virtual bool has_domain_formulation(int id) const
Definition Formulation_Manager.hpp:200
-
virtual std::shared_ptr< Catchment_Formulation > get_domain_formulation(long id) const
Definition Formulation_Manager.hpp:196
-
virtual std::map< std::string, std::shared_ptr< Catchment_Formulation > >::const_iterator end() const
Definition Formulation_Manager.hpp:226
-
std::shared_ptr< Simulation_Time > Simulation_Time_Object
Definition Formulation_Manager.hpp:30
-
virtual std::map< std::string, std::shared_ptr< Catchment_Formulation > >::const_iterator begin() const
Definition Formulation_Manager.hpp:222
-
Formulation_Manager(std::stringstream &data)
Definition Formulation_Manager.hpp:32
-
std::tuple< std::string, std::string > dual_keys
Definition Formulation_Manager.hpp:26
-
virtual void read(geojson::GeoJSON fabric, utils::StreamHandler output_stream)
Definition Formulation_Manager.hpp:54
-
virtual std::shared_ptr< Catchment_Formulation > get_formulation(std::string id) const
Definition Formulation_Manager.hpp:191
-
virtual void add_formulation(std::shared_ptr< Catchment_Formulation > formulation)
Definition Formulation_Manager.hpp:187
-
ngen::LayerDataStorage & get_layer_metadata()
return the layer storage used for formulations
Definition Formulation_Manager.hpp:279
-
void parse_external_model_params(boost::property_tree::ptree &model_params, const geojson::Feature catchment_feature)
Parse a model_params property tree and replace external parameters with values from a catchment's pro...
Definition Formulation_Manager.hpp:494
-
virtual bool contains(std::string identifier) const
Definition Formulation_Manager.hpp:204
-
boost::property_tree::ptree tree
Definition Formulation_Manager.hpp:611
-
virtual bool is_empty()
Definition Formulation_Manager.hpp:218
-
std::map< std::string, std::shared_ptr< Catchment_Formulation > > formulations
Definition Formulation_Manager.hpp:615
-
virtual ~Formulation_Manager()
Definition Formulation_Manager.hpp:48
-
std::string get_t_route_config_file_with_path()
Definition Formulation_Manager.hpp:240
-
std::shared_ptr< routing_params > routing_config
Definition Formulation_Manager.hpp:620
+
Definition Formulation_Manager.hpp:27
+
Formulation_Manager(const std::string &file_path)
Definition Formulation_Manager.hpp:40
+
ngen::LayerDataStorage layer_storage
Definition Formulation_Manager.hpp:626
+
bool using_routing
Definition Formulation_Manager.hpp:624
+
realization::config::Config global_config
Definition Formulation_Manager.hpp:615
+
std::string get_output_root() const noexcept
Get the formatted output root.
Definition Formulation_Manager.hpp:264
+
forcing_params get_forcing_params(const geojson::PropertyMap &forcing_prop_map, std::string identifier, simulation_time_params &simulation_time_config)
Definition Formulation_Manager.hpp:349
+
void parse_external_model_params(geojson::PropertyMap &model_params, const geojson::Feature catchment_feature)
Parse a model_params property map and replace external parameters with values from a catchment's prop...
Definition Formulation_Manager.hpp:556
+
std::shared_ptr< Catchment_Formulation > construct_missing_formulation(geojson::Feature &feature, utils::StreamHandler output_stream, simulation_time_params &simulation_time_config)
Definition Formulation_Manager.hpp:328
+
virtual int get_size()
Definition Formulation_Manager.hpp:213
+
std::shared_ptr< Catchment_Formulation > construct_formulation_from_config(simulation_time_params &simulation_time_config, std::string identifier, const realization::config::Config &catchment_formulation, utils::StreamHandler output_stream)
Definition Formulation_Manager.hpp:285
+
Formulation_Manager(boost::property_tree::ptree &loaded_tree)
Definition Formulation_Manager.hpp:46
+
bool get_using_routing()
Definition Formulation_Manager.hpp:235
+
std::map< int, std::shared_ptr< Catchment_Formulation > > domain_formulations
Definition Formulation_Manager.hpp:620
+
virtual bool has_domain_formulation(int id) const
Definition Formulation_Manager.hpp:202
+
virtual std::shared_ptr< Catchment_Formulation > get_domain_formulation(long id) const
Definition Formulation_Manager.hpp:198
+
virtual std::map< std::string, std::shared_ptr< Catchment_Formulation > >::const_iterator end() const
Definition Formulation_Manager.hpp:228
+
std::shared_ptr< Simulation_Time > Simulation_Time_Object
Definition Formulation_Manager.hpp:32
+
virtual std::map< std::string, std::shared_ptr< Catchment_Formulation > >::const_iterator begin() const
Definition Formulation_Manager.hpp:224
+
Formulation_Manager(std::stringstream &data)
Definition Formulation_Manager.hpp:34
+
std::tuple< std::string, std::string > dual_keys
Definition Formulation_Manager.hpp:28
+
virtual void read(geojson::GeoJSON fabric, utils::StreamHandler output_stream)
Definition Formulation_Manager.hpp:56
+
virtual std::shared_ptr< Catchment_Formulation > get_formulation(std::string id) const
Definition Formulation_Manager.hpp:193
+
virtual void add_formulation(std::shared_ptr< Catchment_Formulation > formulation)
Definition Formulation_Manager.hpp:189
+
ngen::LayerDataStorage & get_layer_metadata()
return the layer storage used for formulations
Definition Formulation_Manager.hpp:281
+
void parse_external_model_params(boost::property_tree::ptree &model_params, const geojson::Feature catchment_feature)
Parse a model_params property tree and replace external parameters with values from a catchment's pro...
Definition Formulation_Manager.hpp:496
+
virtual bool contains(std::string identifier) const
Definition Formulation_Manager.hpp:206
+
boost::property_tree::ptree tree
Definition Formulation_Manager.hpp:613
+
virtual bool is_empty()
Definition Formulation_Manager.hpp:220
+
std::map< std::string, std::shared_ptr< Catchment_Formulation > > formulations
Definition Formulation_Manager.hpp:617
+
virtual ~Formulation_Manager()
Definition Formulation_Manager.hpp:50
+
std::string get_t_route_config_file_with_path()
Definition Formulation_Manager.hpp:242
+
std::shared_ptr< routing_params > routing_config
Definition Formulation_Manager.hpp:622
This class provides a copyable interface to a std::ostream or std::ostream like object that may not s...
Definition StreamHandler.hpp:14
std::shared_ptr< FeatureCollection > GeoJSON
Easy short-hand for a smart pointer to a FeatureCollection.
Definition FeatureBuilder.hpp:21
std::map< std::string, JSONProperty > PropertyMap
Shorthand for a mapping between strings and properties.
Definition JSONProperty.hpp:21
@@ -762,9 +764,9 @@
std::shared_ptr< FeatureBase > Feature
An easy name for a smart pointer for FeatureBase and its children.
Definition FeatureBase.hpp:34
Definition Bmi_C_Formulation.hpp:11
-
static bool formulation_exists(std::string formulation_type)
Definition Formulation_Constructors.hpp:33
-
static std::string valid_formulation_keys()
Definition Formulation_Constructors.hpp:25
-
static std::shared_ptr< Catchment_Formulation > construct_formulation(std::string formulation_type, std::string identifier, forcing_params &forcing_config, utils::StreamHandler output_stream)
Definition Formulation_Constructors.hpp:37
+
static bool formulation_exists(std::string formulation_type)
Definition Formulation_Constructors.hpp:35
+
static std::string valid_formulation_keys()
Definition Formulation_Constructors.hpp:27
+
static std::shared_ptr< Catchment_Formulation > construct_formulation(std::string formulation_type, std::string identifier, forcing_params &forcing_config, utils::StreamHandler output_stream)
Definition Formulation_Constructors.hpp:39
forcing_params providing configuration information for forcing time period and source.
Definition AorcForcing.hpp:35
A simple structure to hold meta data related to a computational layer.
Definition LayerData.hpp:18
std::string time_step_units
Definition LayerData.hpp:20
@@ -797,7 +799,7 @@ diff --git a/_g_m___object_8hpp_source.html b/_g_m___object_8hpp_source.html index 7aede01040..ad82e36e96 100644 --- a/_g_m___object_8hpp_source.html +++ b/_g_m___object_8hpp_source.html @@ -129,7 +129,7 @@ diff --git a/_generic_data_provider_8hpp_source.html b/_generic_data_provider_8hpp_source.html index da2e607edb..92e80549b2 100644 --- a/_generic_data_provider_8hpp_source.html +++ b/_generic_data_provider_8hpp_source.html @@ -125,7 +125,7 @@ diff --git a/_grid_polygon_8hpp_source.html b/_grid_polygon_8hpp_source.html index 093163add4..9e45683b5b 100644 --- a/_grid_polygon_8hpp_source.html +++ b/_grid_polygon_8hpp_source.html @@ -199,7 +199,7 @@ diff --git a/_h_y___cartographic_realization_8hpp_source.html b/_h_y___cartographic_realization_8hpp_source.html index f2527043fa..acde59aa9e 100644 --- a/_h_y___cartographic_realization_8hpp_source.html +++ b/_h_y___cartographic_realization_8hpp_source.html @@ -127,7 +127,7 @@ diff --git a/_h_y___catchment_8hpp_source.html b/_h_y___catchment_8hpp_source.html index f1a73304d4..5886a5fd72 100644 --- a/_h_y___catchment_8hpp_source.html +++ b/_h_y___catchment_8hpp_source.html @@ -206,7 +206,7 @@ diff --git a/_h_y___catchment_aggregate_8hpp_source.html b/_h_y___catchment_aggregate_8hpp_source.html index d41f9d9e4d..aee5d43d6d 100644 --- a/_h_y___catchment_aggregate_8hpp_source.html +++ b/_h_y___catchment_aggregate_8hpp_source.html @@ -127,7 +127,7 @@ diff --git a/_h_y___catchment_area_8hpp_source.html b/_h_y___catchment_area_8hpp_source.html index 32b008024a..3720748d53 100644 --- a/_h_y___catchment_area_8hpp_source.html +++ b/_h_y___catchment_area_8hpp_source.html @@ -150,7 +150,7 @@ diff --git a/_h_y___catchment_divide_8hpp_source.html b/_h_y___catchment_divide_8hpp_source.html index 2b243def19..935f6b2732 100644 --- a/_h_y___catchment_divide_8hpp_source.html +++ b/_h_y___catchment_divide_8hpp_source.html @@ -149,7 +149,7 @@ diff --git a/_h_y___catchment_realization_8hpp_source.html b/_h_y___catchment_realization_8hpp_source.html index e07472b4de..0dad1c603c 100644 --- a/_h_y___catchment_realization_8hpp_source.html +++ b/_h_y___catchment_realization_8hpp_source.html @@ -163,7 +163,7 @@ diff --git a/_h_y___dendritic_catchment_8hpp_source.html b/_h_y___dendritic_catchment_8hpp_source.html index dccb171e19..18979edfec 100644 --- a/_h_y___dendritic_catchment_8hpp_source.html +++ b/_h_y___dendritic_catchment_8hpp_source.html @@ -127,7 +127,7 @@ diff --git a/_h_y___distance_discription_8hpp_source.html b/_h_y___distance_discription_8hpp_source.html index b9c9e882c8..ca428e7c23 100644 --- a/_h_y___distance_discription_8hpp_source.html +++ b/_h_y___distance_discription_8hpp_source.html @@ -119,7 +119,7 @@ diff --git a/_h_y___features_8hpp_source.html b/_h_y___features_8hpp_source.html index 573ba7a06a..45068ad74f 100644 --- a/_h_y___features_8hpp_source.html +++ b/_h_y___features_8hpp_source.html @@ -232,7 +232,7 @@
auto catchments()
An iterator of only the catchment feature ids.
Definition HY_Features.hpp:120
std::unordered_map< std::string, std::shared_ptr< HY_Catchment > > _catchments
Internal mapping of catchment id -> HY_Catchment pointer.
Definition HY_Features.hpp:205
A lightweight, graph based index of hydrologic features.
Definition network.hpp:146
-
Definition Formulation_Manager.hpp:25
+
Definition Formulation_Manager.hpp:27
std::shared_ptr< FeatureCollection > GeoJSON
Easy short-hand for a smart pointer to a FeatureCollection.
Definition FeatureBuilder.hpp:21
static const std::string nexus
Definition HY_Features_Ids.hpp:12
static const std::string catchment
Definition HY_Features_Ids.hpp:15
@@ -244,7 +244,7 @@ diff --git a/_h_y___features___ids_8hpp_source.html b/_h_y___features___ids_8hpp_source.html index cf3a50f263..f1290fe80b 100644 --- a/_h_y___features___ids_8hpp_source.html +++ b/_h_y___features___ids_8hpp_source.html @@ -153,7 +153,7 @@ diff --git a/_h_y___features___m_p_i_8hpp_source.html b/_h_y___features___m_p_i_8hpp_source.html index aae9fbc3e6..405276a454 100644 --- a/_h_y___features___m_p_i_8hpp_source.html +++ b/_h_y___features___m_p_i_8hpp_source.html @@ -99,104 +99,106 @@
1#ifndef HY_FEATURES_MPI_H
2#define HY_FEATURES_MPI_H
-
3//Only need this unit when using MPI. It won't compile without other MPI dependent code.
-
4#ifdef NGEN_MPI_ACTIVE
-
5
-
6#include <unordered_map>
-
7#include <set>
-
8
-
9#include <HY_Catchment.hpp>
-
10#include <HY_PointHydroNexusRemote.hpp>
-
11#include <network.hpp>
-
12#include <Formulation_Manager.hpp>
-
13#include <Partition_Parser.hpp>
-
14
-
15namespace hy_features {
+
3
+
4//Only need this unit when using MPI. It won't compile without other MPI dependent code.
+
5#include <NGenConfig.h>
+
6#if NGEN_WITH_MPI
+
7
+
8#include <unordered_map>
+
9#include <set>
+
10
+
11#include <HY_Catchment.hpp>
+
12#include <HY_PointHydroNexusRemote.hpp>
+
13#include <network.hpp>
+
14#include <Formulation_Manager.hpp>
+
15#include <Partition_Parser.hpp>
16
-
17 class HY_Features_MPI {
-
18 public:
-
19
-
20 using Formulation_Manager = realization::Formulation_Manager;
+
17namespace hy_features {
+
18
+
19 class HY_Features_MPI {
+
20 public:
21
-
22 HY_Features_MPI(PartitionData partition_data, geojson::GeoJSON linked_hydro_fabric,
-
23 std::shared_ptr<Formulation_Manager> formulations, int mpi_rank, int mpi_num_procs);
-
24
-
25 std::shared_ptr<HY_CatchmentRealization> catchment_at(std::string id) {
-
26 return (_catchments.find(id) != _catchments.end()) ? _catchments[id]->realization : nullptr;
-
27 }
-
28
-
29 inline auto catchments() {
-
30 return network.filter("cat");
-
31 }
-
32
-
33 inline bool is_remote_sender_nexus(const std::string& id) {
-
34 return _nexuses.find(id) != _nexuses.end() && _nexuses[id]->is_remote_sender();
-
35 }
-
36
-
37 inline auto catchments(long lyr) {
-
38 return network.filter("cat",lyr);
-
39 }
-
40
-
45 inline const auto& layers() { return hf_layers; }
-
46
-
47 inline std::vector<std::shared_ptr<HY_HydroNexus>> destination_nexuses(const std::string& id) {
-
48 std::vector<std::shared_ptr<HY_HydroNexus>> downstream;
-
49 if (_catchments.find(id) != _catchments.end()) {
-
50 for(const auto& nex_id : _catchments[id]->get_outflow_nexuses()) {
-
51 downstream.push_back(_nexuses[nex_id]);
-
52 }
-
53 }
-
54 return downstream;
-
55 }
-
56
-
57 std::shared_ptr<HY_HydroNexus> nexus_at(const std::string& id) {
-
58 return (_nexuses.find(id) != _nexuses.end()) ? _nexuses[id] : nullptr;
-
59 }
-
60
-
61 inline auto nexuses() {
-
62 return network.filter("nex");
-
63 }
-
64
-
65 void validate_dendritic() {
-
66 for(const auto& id : catchments()) {
-
67 auto downstream = network.get_destination_ids(id);
-
68 if(downstream.size() > 1) {
-
69 std::cerr << "Catchment " << id << " has more than one downstream connection." << std::endl;
-
70 std::cerr << "Downstreams are: ";
-
71 for(const auto& id : downstream){
-
72 std::cerr <<id<<" ";
-
73 }
-
74 std::cerr << std::endl;
-
75 assert( false );
-
76 }
-
77 else if (downstream.size() == 0) {
-
78 std::cerr << "Catchment " << id << " has 0 downstream connections, must have 1." << std::endl;
-
79 assert( false );
-
80 }
-
81 }
-
82 std::cout<<"Catchment topology is dendritic."<<std::endl;
-
83 }
-
84
-
85 private:
-
86
-
87 std::unordered_map<std::string, std::shared_ptr<HY_Catchment>> _catchments;
-
88 std::unordered_map<std::string, std::shared_ptr<HY_PointHydroNexusRemote>> _nexuses;
- -
90 std::shared_ptr<Formulation_Manager> formulations;
-
91 std::set<long> hf_layers;
-
92 int mpi_rank;
-
93 int mpi_num_procs;
-
94
-
95 };
-
96}
-
97#endif //NGEN_MPI_ACTIVE
-
98#endif //HY_FEATURES_MPI_H
+
22 using Formulation_Manager = realization::Formulation_Manager;
+
23
+
24 HY_Features_MPI(PartitionData partition_data, geojson::GeoJSON linked_hydro_fabric,
+
25 std::shared_ptr<Formulation_Manager> formulations, int mpi_rank, int mpi_num_procs);
+
26
+
27 std::shared_ptr<HY_CatchmentRealization> catchment_at(std::string id) {
+
28 return (_catchments.find(id) != _catchments.end()) ? _catchments[id]->realization : nullptr;
+
29 }
+
30
+
31 inline auto catchments() {
+
32 return network.filter("cat");
+
33 }
+
34
+
35 inline bool is_remote_sender_nexus(const std::string& id) {
+
36 return _nexuses.find(id) != _nexuses.end() && _nexuses[id]->is_remote_sender();
+
37 }
+
38
+
39 inline auto catchments(long lyr) {
+
40 return network.filter("cat",lyr);
+
41 }
+
42
+
47 inline const auto& layers() { return hf_layers; }
+
48
+
49 inline std::vector<std::shared_ptr<HY_HydroNexus>> destination_nexuses(const std::string& id) {
+
50 std::vector<std::shared_ptr<HY_HydroNexus>> downstream;
+
51 if (_catchments.find(id) != _catchments.end()) {
+
52 for(const auto& nex_id : _catchments[id]->get_outflow_nexuses()) {
+
53 downstream.push_back(_nexuses[nex_id]);
+
54 }
+
55 }
+
56 return downstream;
+
57 }
+
58
+
59 std::shared_ptr<HY_HydroNexus> nexus_at(const std::string& id) {
+
60 return (_nexuses.find(id) != _nexuses.end()) ? _nexuses[id] : nullptr;
+
61 }
+
62
+
63 inline auto nexuses() {
+
64 return network.filter("nex");
+
65 }
+
66
+
67 void validate_dendritic() {
+
68 for(const auto& id : catchments()) {
+
69 auto downstream = network.get_destination_ids(id);
+
70 if(downstream.size() > 1) {
+
71 std::cerr << "Catchment " << id << " has more than one downstream connection." << std::endl;
+
72 std::cerr << "Downstreams are: ";
+
73 for(const auto& id : downstream){
+
74 std::cerr <<id<<" ";
+
75 }
+
76 std::cerr << std::endl;
+
77 assert( false );
+
78 }
+
79 else if (downstream.size() == 0) {
+
80 std::cerr << "Catchment " << id << " has 0 downstream connections, must have 1." << std::endl;
+
81 assert( false );
+
82 }
+
83 }
+
84 std::cout<<"Catchment topology is dendritic."<<std::endl;
+
85 }
+
86
+
87 private:
+
88
+
89 std::unordered_map<std::string, std::shared_ptr<HY_Catchment>> _catchments;
+
90 std::unordered_map<std::string, std::shared_ptr<HY_PointHydroNexusRemote>> _nexuses;
+ +
92 std::shared_ptr<Formulation_Manager> formulations;
+
93 std::set<long> hf_layers;
+
94 int mpi_rank;
+
95 int mpi_num_procs;
+
96
+
97 };
+
98}
+
99#endif //NGEN_WITH_MPI
+
100#endif //HY_FEATURES_MPI_H
A lightweight, graph based index of hydrologic features.
Definition network.hpp:146
-
Definition Formulation_Manager.hpp:25
+
Definition Formulation_Manager.hpp:27
std::shared_ptr< FeatureCollection > GeoJSON
Easy short-hand for a smart pointer to a FeatureCollection.
Definition FeatureBuilder.hpp:21
HY_HydroLocation: class representing a hydrologic position.
Definition HY_Features.hpp:13
Definition network.hpp:22
-
std::map< std::string, constructor > formulations
Definition Formulation_Constructors.cpp:30
+
std::map< std::string, constructor > formulations
Definition Formulation_Constructors.cpp:32
Definition Partition_Data.hpp:5
@@ -204,7 +206,7 @@ diff --git a/_h_y___flow_path_8hpp_source.html b/_h_y___flow_path_8hpp_source.html index a981c05cb0..14249b97fa 100644 --- a/_h_y___flow_path_8hpp_source.html +++ b/_h_y___flow_path_8hpp_source.html @@ -148,7 +148,7 @@ diff --git a/_h_y___hydro_feature_8hpp_source.html b/_h_y___hydro_feature_8hpp_source.html index 1e2f18af92..fb5e366078 100644 --- a/_h_y___hydro_feature_8hpp_source.html +++ b/_h_y___hydro_feature_8hpp_source.html @@ -124,7 +124,7 @@ diff --git a/_h_y___hydro_location_8hpp_source.html b/_h_y___hydro_location_8hpp_source.html index fb06b20799..493c60c533 100644 --- a/_h_y___hydro_location_8hpp_source.html +++ b/_h_y___hydro_location_8hpp_source.html @@ -182,7 +182,7 @@ diff --git a/_h_y___hydro_location_type_8hpp_source.html b/_h_y___hydro_location_type_8hpp_source.html index fc7d330c11..c52f79df33 100644 --- a/_h_y___hydro_location_type_8hpp_source.html +++ b/_h_y___hydro_location_type_8hpp_source.html @@ -166,7 +166,7 @@ diff --git a/_h_y___hydro_network_8hpp_source.html b/_h_y___hydro_network_8hpp_source.html index a8427e2b1e..e0229bcd7d 100644 --- a/_h_y___hydro_network_8hpp_source.html +++ b/_h_y___hydro_network_8hpp_source.html @@ -163,7 +163,7 @@ diff --git a/_h_y___hydro_nexus_8hpp_source.html b/_h_y___hydro_nexus_8hpp_source.html index d0994b9b13..85b00dd250 100644 --- a/_h_y___hydro_nexus_8hpp_source.html +++ b/_h_y___hydro_nexus_8hpp_source.html @@ -213,7 +213,7 @@ diff --git a/_h_y___indirect_position_8hpp_source.html b/_h_y___indirect_position_8hpp_source.html index a548f2ea1a..974e3c7e5e 100644 --- a/_h_y___indirect_position_8hpp_source.html +++ b/_h_y___indirect_position_8hpp_source.html @@ -189,7 +189,7 @@ diff --git a/_h_y___interior_catchment_8hpp_source.html b/_h_y___interior_catchment_8hpp_source.html index 07678c99cc..3c3885b338 100644 --- a/_h_y___interior_catchment_8hpp_source.html +++ b/_h_y___interior_catchment_8hpp_source.html @@ -127,7 +127,7 @@ diff --git a/_h_y___point_hydro_nexus_8hpp_source.html b/_h_y___point_hydro_nexus_8hpp_source.html index 27c7022930..a034869848 100644 --- a/_h_y___point_hydro_nexus_8hpp_source.html +++ b/_h_y___point_hydro_nexus_8hpp_source.html @@ -168,7 +168,7 @@ diff --git a/_h_y___point_hydro_nexus_remote_8hpp_source.html b/_h_y___point_hydro_nexus_remote_8hpp_source.html index 2ec9b5d7ee..987a6f2384 100644 --- a/_h_y___point_hydro_nexus_remote_8hpp_source.html +++ b/_h_y___point_hydro_nexus_remote_8hpp_source.html @@ -100,130 +100,131 @@
1#ifndef HY_POINTHDRONEXUSREMOTE_H
2#define HY_POINTHDRONEXUSREMOTE_H
3
-
4#ifdef NGEN_MPI_ACTIVE
-
5
-
6#include <HY_PointHydroNexus.hpp>
-
7#include <HY_Features_Ids.hpp>
-
8#include <mpi.h>
-
9#include <vector>
-
10
-
11#include <unordered_map>
-
12#include <string>
-
13#include <list>
-
14#include <exception>
-
15
-
23class HY_PointHydroNexusRemote : public HY_PointHydroNexus
-
24{
-
25 public:
-
29 typedef std::unordered_map <std::string, long> catcment_location_map_t;
-
30
-
31 HY_PointHydroNexusRemote(std::string nexus_id, Catchments receiving_catchments, catcment_location_map_t loc_map);
-
32 HY_PointHydroNexusRemote(std::string nexus_id, Catchments receiving_catchments, Catchments contributing_catchments, catcment_location_map_t loc_map);
-
33
-
34 virtual ~HY_PointHydroNexusRemote();
-
35
-
38 double get_downstream_flow(std::string catchment_id, time_step_t t, double percent_flow);
-
39
-
41 void add_upstream_flow(double val, std::string catchment_id, time_step_t t);
-
42
-
44 static long extract(std::string s) { return std::stoi( s.substr( s.find(hy_features::identifiers::seperator)+1 ) ); }
-
45
-
46 const Catchments& get_local_contributing_catchments(){
-
47 return local_contributers;
-
48 };
-
49
-
51 bool is_remote_sender()
-
52 {
-
53 return type == sender || type == sender_receiver;
-
54 }
-
55
+
4#include <NGenConfig.h>
+
5#if NGEN_WITH_MPI
+
6
+
7#include <HY_PointHydroNexus.hpp>
+
8#include <HY_Features_Ids.hpp>
+
9#include <mpi.h>
+
10#include <vector>
+
11
+
12#include <unordered_map>
+
13#include <string>
+
14#include <list>
+
15#include <exception>
+
16
+
24class HY_PointHydroNexusRemote : public HY_PointHydroNexus
+
25{
+
26 public:
+
30 typedef std::unordered_map <std::string, long> catcment_location_map_t;
+
31
+
32 HY_PointHydroNexusRemote(std::string nexus_id, Catchments receiving_catchments, catcment_location_map_t loc_map);
+
33 HY_PointHydroNexusRemote(std::string nexus_id, Catchments receiving_catchments, Catchments contributing_catchments, catcment_location_map_t loc_map);
+
34
+
35 virtual ~HY_PointHydroNexusRemote();
+
36
+
39 double get_downstream_flow(std::string catchment_id, time_step_t t, double percent_flow);
+
40
+
42 void add_upstream_flow(double val, std::string catchment_id, time_step_t t);
+
43
+
45 static long extract(std::string s) { return std::stoi( s.substr( s.find(hy_features::identifiers::seperator)+1 ) ); }
+
46
+
47 const Catchments& get_local_contributing_catchments(){
+
48 return local_contributers;
+
49 };
+
50
+
52 bool is_remote_sender()
+
53 {
+
54 return type == sender || type == sender_receiver;
+
55 }
56
-
57 int get_world_rank();
-
58
-
59 long get_time_step();
-
60
-
61 enum communication_type
-
62 {
-
63 local,
-
64 sender,
-
65 receiver,
-
66 sender_receiver
-
67 };
-
68
-
70 communication_type get_communicator_type() { return type; }
-
71
-
72 private:
-
73 void process_communications();
-
74
-
75 int world_rank;
-
76
-
77 long time_step;
-
78
-
79 catcment_location_map_t catchment_id_to_mpi_rank;
-
80
-
81 // Create the datatype
-
82 MPI_Datatype time_step_and_flow_type;
-
83 MPI_Datatype time_step_and_flow_precent_type;
-
84
-
85 struct time_step_and_flow_t
-
86 {
-
87 long time_step;
-
88 long catchment_id;
-
89 double flow;
-
90 };
-
91
-
92 struct async_request
-
93 {
-
94 std::shared_ptr<time_step_and_flow_t> buffer;
-
95 MPI_Request mpi_request;
-
96 };
-
97
-
98 std::list<async_request> stored_recieves;
-
99 std::list<async_request> stored_sends;
-
100
-
101 std::string nexus_prefix = "cat-";
-
102
-
106 communication_type type;
-
111 std::unordered_set<int> downstream_ranks; //Set
-
115 std::unordered_set<int> upstream_ranks; //Set
-
119 Catchments local_contributers;
-
123 Catchments remote_contributers;
-
127 Catchments local_receivers;
-
131 Catchments remote_receivers;
-
132};
-
133
-
134namespace std
-
135{
-
136 inline std::string to_string(HY_PointHydroNexusRemote::communication_type t)
-
137 {
-
138 switch(t)
-
139 {
-
140 case HY_PointHydroNexusRemote::communication_type::local:
-
141
-
142 return std::string("local");
-
143 break;
-
144
-
145 case HY_PointHydroNexusRemote::communication_type::sender:
-
146
-
147 return std::string("sender");
-
148 break;
-
149
-
150 case HY_PointHydroNexusRemote::communication_type::receiver:
-
151
-
152 return std::string("receiver");
-
153 break;
-
154
-
155 case HY_PointHydroNexusRemote::communication_type::sender_receiver:
-
156
-
157 return std::string("sender_receiver");
-
158 break;
-
159 }
-
160 throw std::runtime_error("Unhandled value of communication_type");
-
161 }
-
162}
-
163
-
164#endif // NGEN_MPI_ACTIVE
-
165#endif // HY_POINTHYDRONEXUSREMOTEDOWNSTREAM_H
+
57
+
58 int get_world_rank();
+
59
+
60 long get_time_step();
+
61
+
62 enum communication_type
+
63 {
+
64 local,
+
65 sender,
+
66 receiver,
+
67 sender_receiver
+
68 };
+
69
+
71 communication_type get_communicator_type() { return type; }
+
72
+
73 private:
+
74 void process_communications();
+
75
+
76 int world_rank;
+
77
+
78 long time_step;
+
79
+
80 catcment_location_map_t catchment_id_to_mpi_rank;
+
81
+
82 // Create the datatype
+
83 MPI_Datatype time_step_and_flow_type;
+
84 MPI_Datatype time_step_and_flow_precent_type;
+
85
+
86 struct time_step_and_flow_t
+
87 {
+
88 long time_step;
+
89 long catchment_id;
+
90 double flow;
+
91 };
+
92
+
93 struct async_request
+
94 {
+
95 std::shared_ptr<time_step_and_flow_t> buffer;
+
96 MPI_Request mpi_request;
+
97 };
+
98
+
99 std::list<async_request> stored_recieves;
+
100 std::list<async_request> stored_sends;
+
101
+
102 std::string nexus_prefix = "cat-";
+
103
+
107 communication_type type;
+
112 std::unordered_set<int> downstream_ranks; //Set
+
116 std::unordered_set<int> upstream_ranks; //Set
+
120 Catchments local_contributers;
+
124 Catchments remote_contributers;
+
128 Catchments local_receivers;
+
132 Catchments remote_receivers;
+
133};
+
134
+
135namespace std
+
136{
+
137 inline std::string to_string(HY_PointHydroNexusRemote::communication_type t)
+
138 {
+
139 switch(t)
+
140 {
+
141 case HY_PointHydroNexusRemote::communication_type::local:
+
142
+
143 return std::string("local");
+
144 break;
+
145
+
146 case HY_PointHydroNexusRemote::communication_type::sender:
+
147
+
148 return std::string("sender");
+
149 break;
+
150
+
151 case HY_PointHydroNexusRemote::communication_type::receiver:
+
152
+
153 return std::string("receiver");
+
154 break;
+
155
+
156 case HY_PointHydroNexusRemote::communication_type::sender_receiver:
+
157
+
158 return std::string("sender_receiver");
+
159 break;
+
160 }
+
161 throw std::runtime_error("Unhandled value of communication_type");
+
162 }
+
163}
+
164
+
165#endif // NGEN_WITH_MPI
+
166#endif // HY_POINTHYDRONEXUSREMOTEDOWNSTREAM_H
Definition HY_PointHydroNexus.hpp:10
void add_upstream_flow(double val, std::string catchment_id, time_step_t t)
add flow to this nexus for timestep t.
Definition HY_PointHydroNexus.cpp:135
double get_downstream_flow(std::string catchment_id, time_step_t t, double percent_flow)
get the request percentage of downstream flow through this nexus at timestep t.
Definition HY_PointHydroNexus.cpp:47
@@ -234,7 +235,7 @@ diff --git a/_hydrofabric_subsetter_8hpp_source.html b/_hydrofabric_subsetter_8hpp_source.html index 7adae05f83..d604fb4f8a 100644 --- a/_hydrofabric_subsetter_8hpp_source.html +++ b/_hydrofabric_subsetter_8hpp_source.html @@ -100,123 +100,125 @@
1#ifndef NGEN_HYDROFABRICSUBSETTER_HPP
2#define NGEN_HYDROFABRICSUBSETTER_HPP
3
-
4#ifdef ACTIVATE_PYTHON
+
4#include <NGenConfig.h>
5
-
6#include <pybind11/embed.h>
-
7#include "InterpreterUtil.hpp"
-
8
-
9namespace py = pybind11;
+
6#if NGEN_WITH_PYTHON
+
7
+
8#include <pybind11/embed.h>
+
9#include "InterpreterUtil.hpp"
10
-
11#include "FileChecker.h"
+
11namespace py = pybind11;
12
-
13namespace utils {
-
14 namespace ngenPy {
-
15 using namespace pybind11::literals; // to bring in the `_a` literal
-
16
-
20 class HydrofabricSubsetter {
-
21
-
22 public:
+
13#include "FileChecker.h"
+
14
+
15namespace utils {
+
16 namespace ngenPy {
+
17 using namespace pybind11::literals; // to bring in the `_a` literal
+
18
+
22 class HydrofabricSubsetter {
23
-
24 HydrofabricSubsetter(const std::string &catchmentDataFile, const std::string &nexusDataFile,
-
25 const std::string &crosswalkDataFile, const std::string &partitionsConfigFile)
-
26 : catchmentDataFile(catchmentDataFile), nexusDataFile(nexusDataFile),
-
27 crosswalkDataFile(crosswalkDataFile), partitionsConfigFile(partitionsConfigFile)
-
28 {
-
29
-
30 if (!FileChecker::file_is_readable(catchmentDataFile)) {
-
31 throw std::runtime_error(
-
32 "Cannot subdivided hydrofabric files: base catchment file " + catchmentDataFile +
-
33 " does not exist");
-
34 }
-
35 if (!FileChecker::file_is_readable(nexusDataFile)) {
-
36 throw std::runtime_error(
-
37 "Cannot subdivided hydrofabric files: base nexus file " + nexusDataFile + " does not exist");
-
38 }
-
39 #ifdef ACTIVATE_PYTHON
-
40 py::object Cli_Class = InterpreterUtil::getPyModule("dmod.subsetservice").attr("Cli");
-
41 py::object crosswalk_arg;
-
42 if (crosswalkDataFile.empty()) {
-
43 crosswalk_arg = py::none();
-
44 }
-
45 else {
-
46 crosswalk_arg = py::str(crosswalkDataFile);
-
47 }
-
48
-
49 py_cli = Cli_Class("catchment_geojson"_a=catchmentDataFile,
-
50 "nexus_geojson"_a=nexusDataFile,
-
51 "crosswalk_json"_a=crosswalk_arg,
-
52 "partition_file_str"_a=partitionsConfigFile);
-
53
-
54 if (crosswalkDataFile.empty()) {
-
55 this->crosswalkDataFile = py::str(py_cli.attr("crosswalk"));
-
56 }
-
57 #else
-
58 throw std::runtime_error("Cannot use Python hydrofabric subsetter tool unless Python support is active");
-
59 #endif
-
60
-
61 }
+
24 public:
+
25
+
26 HydrofabricSubsetter(const std::string &catchmentDataFile, const std::string &nexusDataFile,
+
27 const std::string &crosswalkDataFile, const std::string &partitionsConfigFile)
+
28 : catchmentDataFile(catchmentDataFile), nexusDataFile(nexusDataFile),
+
29 crosswalkDataFile(crosswalkDataFile), partitionsConfigFile(partitionsConfigFile)
+
30 {
+
31
+
32 if (!FileChecker::file_is_readable(catchmentDataFile)) {
+
33 throw std::runtime_error(
+
34 "Cannot subdivided hydrofabric files: base catchment file " + catchmentDataFile +
+
35 " does not exist");
+
36 }
+
37 if (!FileChecker::file_is_readable(nexusDataFile)) {
+
38 throw std::runtime_error(
+
39 "Cannot subdivided hydrofabric files: base nexus file " + nexusDataFile + " does not exist");
+
40 }
+
41 #if NGEN_WITH_PYTHON
+
42 py::object Cli_Class = InterpreterUtil::getPyModule("dmod.subsetservice").attr("Cli");
+
43 py::object crosswalk_arg;
+
44 if (crosswalkDataFile.empty()) {
+
45 crosswalk_arg = py::none();
+
46 }
+
47 else {
+
48 crosswalk_arg = py::str(crosswalkDataFile);
+
49 }
+
50
+
51 py_cli = Cli_Class("catchment_geojson"_a=catchmentDataFile,
+
52 "nexus_geojson"_a=nexusDataFile,
+
53 "crosswalk_json"_a=crosswalk_arg,
+
54 "partition_file_str"_a=partitionsConfigFile);
+
55
+
56 if (crosswalkDataFile.empty()) {
+
57 this->crosswalkDataFile = py::str(py_cli.attr("crosswalk"));
+
58 }
+
59 #else
+
60 throw std::runtime_error("Cannot use Python hydrofabric subsetter tool unless Python support is active");
+
61 #endif
62
-
63 HydrofabricSubsetter(const std::string &catchmentDataFile, const std::string &nexusDataFile,
-
64 const std::string &partitionsConfigFile)
-
65 : HydrofabricSubsetter(catchmentDataFile, nexusDataFile, "", partitionsConfigFile) { }
-
66
-
67 #ifdef ACTIVATE_PYTHON
-
73 HydrofabricSubsetter(HydrofabricSubsetter &p) : catchmentDataFile(p.catchmentDataFile),
-
74 nexusDataFile(p.nexusDataFile),
-
75 crosswalkDataFile(p.crosswalkDataFile),
-
76 py_cli(p.py_cli),
-
77 partitionsConfigFile(p.partitionsConfigFile) { }
-
78
-
84 HydrofabricSubsetter(HydrofabricSubsetter &&p) : catchmentDataFile(std::move(p.catchmentDataFile)),
-
85 nexusDataFile(std::move(p.nexusDataFile)),
-
86 crosswalkDataFile(std::move(p.crosswalkDataFile)),
-
87 py_cli(std::move(p.py_cli)),
-
88 partitionsConfigFile(std::move(p.partitionsConfigFile)) { }
-
89
-
90 virtual bool execSubdivision() {
-
91 bool result;
-
92 try {
-
93 py::bool_ bool_result = py_cli.attr("divide_hydrofabric")();
-
94 result = bool_result;
-
95 }
-
96 catch (const std::exception &e) {
-
97 std::cerr << "Failed to subdivide hydrofabric: " << e.what() << std::endl;
-
98 result = false;
-
99 }
-
100 return result;
-
101 }
-
102
-
103 virtual bool execSubdivision(int index) {
-
104 bool result;
-
105 try {
-
106 py::bool_ bool_result = py_cli.attr("divide_hydrofabric")(index);
-
107 result = bool_result;
-
108 }
-
109 catch (const std::exception &e) {
-
110 std::cerr << "Failed to subdivide hydrofabric for index " << index << ": " << e.what() << std::endl;
-
111 result = false;
-
112 }
-
113 return result;
-
114 }
-
115
-
116 #endif // ACTIVATE_PYTHON
+
63 }
+
64
+
65 HydrofabricSubsetter(const std::string &catchmentDataFile, const std::string &nexusDataFile,
+
66 const std::string &partitionsConfigFile)
+
67 : HydrofabricSubsetter(catchmentDataFile, nexusDataFile, "", partitionsConfigFile) { }
+
68
+
69 #if NGEN_WITH_PYTHON
+
75 HydrofabricSubsetter(HydrofabricSubsetter &p) : catchmentDataFile(p.catchmentDataFile),
+
76 nexusDataFile(p.nexusDataFile),
+
77 crosswalkDataFile(p.crosswalkDataFile),
+
78 py_cli(p.py_cli),
+
79 partitionsConfigFile(p.partitionsConfigFile) { }
+
80
+
86 HydrofabricSubsetter(HydrofabricSubsetter &&p) : catchmentDataFile(std::move(p.catchmentDataFile)),
+
87 nexusDataFile(std::move(p.nexusDataFile)),
+
88 crosswalkDataFile(std::move(p.crosswalkDataFile)),
+
89 py_cli(std::move(p.py_cli)),
+
90 partitionsConfigFile(std::move(p.partitionsConfigFile)) { }
+
91
+
92 virtual bool execSubdivision() {
+
93 bool result;
+
94 try {
+
95 py::bool_ bool_result = py_cli.attr("divide_hydrofabric")();
+
96 result = bool_result;
+
97 }
+
98 catch (const std::exception &e) {
+
99 std::cerr << "Failed to subdivide hydrofabric: " << e.what() << std::endl;
+
100 result = false;
+
101 }
+
102 return result;
+
103 }
+
104
+
105 virtual bool execSubdivision(int index) {
+
106 bool result;
+
107 try {
+
108 py::bool_ bool_result = py_cli.attr("divide_hydrofabric")(index);
+
109 result = bool_result;
+
110 }
+
111 catch (const std::exception &e) {
+
112 std::cerr << "Failed to subdivide hydrofabric for index " << index << ": " << e.what() << std::endl;
+
113 result = false;
+
114 }
+
115 return result;
+
116 }
117
-
118 private:
-
119 std::string catchmentDataFile;
-
120 std::string crosswalkDataFile;
-
121 std::string nexusDataFile;
-
122 std::string partitionsConfigFile;
-
123 #ifdef ACTIVATE_PYTHON
-
124 py::object py_cli;
-
125 #endif
-
126
-
127 };
-
128 }
-
129}
-
130
-
131#endif // ACTIVATE_PYTHON
+
118 #endif // NGEN_WITH_PYTHON
+
119
+
120 private:
+
121 std::string catchmentDataFile;
+
122 std::string crosswalkDataFile;
+
123 std::string nexusDataFile;
+
124 std::string partitionsConfigFile;
+
125 #if NGEN_WITH_PYTHON
+
126 py::object py_cli;
+
127 #endif
+
128
+
129 };
+
130 }
+
131}
132
-
133#endif //NGEN_HYDROFABRICSUBSETTER_HPP
+
133#endif // NGEN_WITH_PYTHON
+
134
+
135#endif //NGEN_HYDROFABRICSUBSETTER_HPP
Definition EndianCopy.hpp:7
@@ -224,7 +226,7 @@ diff --git a/_interpreter_util_8hpp_source.html b/_interpreter_util_8hpp_source.html index d5611782c3..702eea6ebf 100644 --- a/_interpreter_util_8hpp_source.html +++ b/_interpreter_util_8hpp_source.html @@ -100,216 +100,218 @@
1#ifndef NGEN_INTERPRETERUTIL_HPP
2#define NGEN_INTERPRETERUTIL_HPP
3
-
4#ifdef ACTIVATE_PYTHON
+
4#include <NGenConfig.h>
5
-
6#include <cstdlib>
-
7#include <map>
-
8#include <pybind11/embed.h>
-
9#include <pybind11/stl.h>
-
10#include <pybind11/numpy.h>
-
11#include <vector>
-
12#include <tuple>
-
13namespace py = pybind11;
-
14
-
15namespace utils {
-
16 namespace ngenPy {
-
17
-
18 using namespace pybind11::literals; // to bring in the `_a` literal
+
6#if NGEN_WITH_PYTHON
+
7
+
8#include <cstdlib>
+
9#include <map>
+
10#include <pybind11/embed.h>
+
11#include <pybind11/stl.h>
+
12#include <pybind11/numpy.h>
+
13#include <vector>
+
14#include <tuple>
+
15namespace py = pybind11;
+
16
+
17namespace utils {
+
18 namespace ngenPy {
19
-
30 class InterpreterUtil {
-
31
-
32 public:
-
33 static std::shared_ptr<InterpreterUtil> getInstance() {
-
55 //Functionally, a global instance variable
-
56 //This can be made a class attribute, but would need to find a place to put a single definition
-
57 //e.g. make a .cpp file
-
58 static std::weak_ptr<InterpreterUtil> _instance;
-
59 std::shared_ptr<InterpreterUtil> instance = _instance.lock();
-
60 if(!instance){
-
61 //instance is null
-
62 InterpreterUtil* pt = new InterpreterUtil();
-
63 instance = std::shared_ptr<InterpreterUtil>(pt, Deleter{});
-
64 //update the weak ref
-
65 _instance = instance;
-
66 }
-
67 return instance;
-
68 }
-
69
-
70 struct Deleter {
-
78 void operator()(InterpreterUtil* ptr){delete ptr;}
-
79 };
-
80 friend Deleter;
-
81
-
82 private:
-
83 InterpreterUtil() {
-
84 guardPtr = std::make_shared<py::scoped_interpreter>();
-
85 // Go ahead and do these
-
86 importTopLevelModule("pathlib");
-
87 importTopLevelModule("sys");
-
88 Path = importedTopLevelModules["pathlib"].attr("Path");
-
89
-
90 py::list venv_package_dirs = getVenvPackagesDirOptions();
-
91 // Add any found options
-
92 for (auto &opt : venv_package_dirs) {
-
93 addToPath(std::string(py::str(opt.attr("parent"))));
-
94 addToPath(std::string(py::str(opt)));
-
95 }
-
96
-
97 py::object python_version_info = importedTopLevelModules["sys"].attr("version_info");
-
98 py::str runtime_python_version = importedTopLevelModules["sys"].attr("version");
-
99 int major = py::int_(python_version_info.attr("major"));
-
100 int minor = py::int_(python_version_info.attr("minor"));
-
101 int patch = py::int_(python_version_info.attr("micro"));
-
102 if (major != python_major
-
103 || minor != python_minor
-
104 || patch != python_patch) {
-
105 throw std::runtime_error("Python version mismatch between configure/build ("
-
106 + std::string(python_version)
-
107 + ") and runtime (" + std::string(runtime_python_version) + ")");
-
108 }
-
109
-
110 importTopLevelModule("numpy");
-
111 py::str runtime_numpy_version = importedTopLevelModules["numpy"].attr("version").attr("version");
-
112 if(std::string(runtime_numpy_version) != numpy_version) {
-
113 throw std::runtime_error("NumPy version mismatch between configure/build ("
-
114 + std::string(numpy_version)
-
115 + ") and runtime (" + std::string(runtime_numpy_version) + ")");
-
116 }
-
117 }
-
118
-
119 ~InterpreterUtil() = default;
+
20 using namespace pybind11::literals; // to bring in the `_a` literal
+
21
+
32 class InterpreterUtil {
+
33
+
34 public:
+
35 static std::shared_ptr<InterpreterUtil> getInstance() {
+
57 //Functionally, a global instance variable
+
58 //This can be made a class attribute, but would need to find a place to put a single definition
+
59 //e.g. make a .cpp file
+
60 static std::weak_ptr<InterpreterUtil> _instance;
+
61 std::shared_ptr<InterpreterUtil> instance = _instance.lock();
+
62 if(!instance){
+
63 //instance is null
+
64 InterpreterUtil* pt = new InterpreterUtil();
+
65 instance = std::shared_ptr<InterpreterUtil>(pt, Deleter{});
+
66 //update the weak ref
+
67 _instance = instance;
+
68 }
+
69 return instance;
+
70 }
+
71
+
72 struct Deleter {
+
80 void operator()(InterpreterUtil* ptr){delete ptr;}
+
81 };
+
82 friend Deleter;
+
83
+
84 private:
+
85 InterpreterUtil() {
+
86 guardPtr = std::make_shared<py::scoped_interpreter>();
+
87 // Go ahead and do these
+
88 importTopLevelModule("pathlib");
+
89 importTopLevelModule("sys");
+
90 Path = importedTopLevelModules["pathlib"].attr("Path");
+
91
+
92 py::list venv_package_dirs = getVenvPackagesDirOptions();
+
93 // Add any found options
+
94 for (auto &opt : venv_package_dirs) {
+
95 addToPath(std::string(py::str(opt.attr("parent"))));
+
96 addToPath(std::string(py::str(opt)));
+
97 }
+
98
+
99 py::object python_version_info = importedTopLevelModules["sys"].attr("version_info");
+
100 py::str runtime_python_version = importedTopLevelModules["sys"].attr("version");
+
101 int major = py::int_(python_version_info.attr("major"));
+
102 int minor = py::int_(python_version_info.attr("minor"));
+
103 int patch = py::int_(python_version_info.attr("micro"));
+
104 if (major != python_major
+
105 || minor != python_minor
+
106 || patch != python_patch) {
+
107 throw std::runtime_error("Python version mismatch between configure/build ("
+
108 + std::string(python_version)
+
109 + ") and runtime (" + std::string(runtime_python_version) + ")");
+
110 }
+
111
+
112 importTopLevelModule("numpy");
+
113 py::str runtime_numpy_version = importedTopLevelModules["numpy"].attr("version").attr("version");
+
114 if(std::string(runtime_numpy_version) != numpy_version) {
+
115 throw std::runtime_error("NumPy version mismatch between configure/build ("
+
116 + std::string(numpy_version)
+
117 + ") and runtime (" + std::string(runtime_numpy_version) + ")");
+
118 }
+
119 }
120
-
121 public:
+
121 ~InterpreterUtil() = default;
122
-
123 InterpreterUtil(InterpreterUtil const &instance) = delete;
+
123 public:
124
-
125 void operator=(InterpreterUtil const &instance) = delete;
+
125 InterpreterUtil(InterpreterUtil const &instance) = delete;
126
-
132 static void addToPyPath(const std::string &directoryPath) {
-
133 getInstance()->addToPath(directoryPath);
-
134 }
-
135
-
141 void addToPath(const std::string &directoryPath) {
-
142 std::tuple<py::list, std::vector<std::string>> sysPathTuple = getSystemPath();
-
143 py::list sys_path = std::get<0>(sysPathTuple);
-
144 std::vector<std::string> sys_path_vector = std::get<1>(sysPathTuple);
-
145
-
146 py::object requestedDirPath = Path(directoryPath);
-
147 if (py::bool_(requestedDirPath.attr("is_dir")())) {
-
148 if (std::find(sys_path_vector.begin(), sys_path_vector.end(), directoryPath) == sys_path_vector.end()) {
-
149#ifdef __APPLE__
-
150 sys_path.attr("insert")(1, py::str(directoryPath));
-
151#else
-
152 sys_path.attr("insert")(sys_path_vector.size(), py::str(directoryPath));
-
153#endif
-
154 }
-
155 }
-
156 else {
-
157 std::string dirPath = py::str(requestedDirPath);
-
158 throw std::runtime_error("Cannot add non-existing directory '" + dirPath + "' to Python PATH");
-
159 }
-
160 }
-
161
-
172 static py::object getPyModule(const std::string &name) {
-
173 return getInstance()->getModule(name);
-
174 }
-
175
-
190 static py::object getPyModule(const std::vector<std::string> &moduleLevelNames) {
-
191 return getInstance()->getModule(moduleLevelNames);
-
192 }
-
193
-
204 py::object getModule(const std::string &name) {
-
205 if (!isImported(name)) {
-
206 importTopLevelModule(name);
-
207 }
-
208 return importedTopLevelModules.find(name)->second;
-
209 }
-
210
-
221 py::object getModule(const std::vector<std::string> &moduleLevelNames) {
-
222 // Start with top-level module name, then descend through attributes as needed
-
223 py::object module = getModule(moduleLevelNames[0]);
-
224 for (size_t i = 1; i < moduleLevelNames.size(); ++i) {
-
225 module = module.attr(moduleLevelNames[i].c_str());
-
226 }
-
227 return module;
-
228 }
-
229
-
230 protected:
+
127 void operator=(InterpreterUtil const &instance) = delete;
+
128
+
134 static void addToPyPath(const std::string &directoryPath) {
+
135 getInstance()->addToPath(directoryPath);
+
136 }
+
137
+
143 void addToPath(const std::string &directoryPath) {
+
144 std::tuple<py::list, std::vector<std::string>> sysPathTuple = getSystemPath();
+
145 py::list sys_path = std::get<0>(sysPathTuple);
+
146 std::vector<std::string> sys_path_vector = std::get<1>(sysPathTuple);
+
147
+
148 py::object requestedDirPath = Path(directoryPath);
+
149 if (py::bool_(requestedDirPath.attr("is_dir")())) {
+
150 if (std::find(sys_path_vector.begin(), sys_path_vector.end(), directoryPath) == sys_path_vector.end()) {
+
151#ifdef __APPLE__
+
152 sys_path.attr("insert")(1, py::str(directoryPath));
+
153#else
+
154 sys_path.attr("insert")(sys_path_vector.size(), py::str(directoryPath));
+
155#endif
+
156 }
+
157 }
+
158 else {
+
159 std::string dirPath = py::str(requestedDirPath);
+
160 throw std::runtime_error("Cannot add non-existing directory '" + dirPath + "' to Python PATH");
+
161 }
+
162 }
+
163
+
174 static py::object getPyModule(const std::string &name) {
+
175 return getInstance()->getModule(name);
+
176 }
+
177
+
192 static py::object getPyModule(const std::vector<std::string> &moduleLevelNames) {
+
193 return getInstance()->getModule(moduleLevelNames);
+
194 }
+
195
+
206 py::object getModule(const std::string &name) {
+
207 if (!isImported(name)) {
+
208 importTopLevelModule(name);
+
209 }
+
210 return importedTopLevelModules.find(name)->second;
+
211 }
+
212
+
223 py::object getModule(const std::vector<std::string> &moduleLevelNames) {
+
224 // Start with top-level module name, then descend through attributes as needed
+
225 py::object module = getModule(moduleLevelNames[0]);
+
226 for (size_t i = 1; i < moduleLevelNames.size(); ++i) {
+
227 module = module.attr(moduleLevelNames[i].c_str());
+
228 }
+
229 return module;
+
230 }
231
-
237 py::list getVenvPackagesDirOptions() {
-
238 // Look for a local virtual environment directory also, if there is one
-
239 const char* env_var_venv = std::getenv("VIRTUAL_ENV");
-
240 py::object venv_dir = env_var_venv != nullptr ? Path(env_var_venv): py::none();
-
241
-
242 if (!venv_dir.is_none() && py::bool_(venv_dir.attr("is_dir")())) {
-
243 // Resolve the full path
-
244 venv_dir = venv_dir.attr("resolve")();
-
245 // Get options for the packages dir
-
246 py::list site_packages_options = py::list(venv_dir.attr("glob")("**/site-packages/"));
-
247 return site_packages_options;
-
248 }
-
249
-
250 return py::list();
-
251 }
-
252
-
253 public:
-
260 inline std::tuple<py::list, std::vector<std::string>> getSystemPath() {
-
261 py::list sys_path = importedTopLevelModules.find("sys")->second.attr("path");
-
262 std::vector<std::string> sys_path_vector(sys_path.size());
-
263 size_t i = 0;
-
264 for (auto item : sys_path) {
-
265 sys_path_vector[i++] = py::str(item);
-
266 }
-
267 return std::make_tuple(sys_path, sys_path_vector);
-
268 }
-
274 std::string getDiscoveredVenvPath() {
-
275 // Look for a local virtual environment directory also, if there is one
-
276 const char* env_var_venv = std::getenv("VIRTUAL_ENV");
-
277 if(env_var_venv != nullptr){
-
278 //std::string r(env_var_venv);
-
279 return std::string(env_var_venv);
-
280 }
-
281 return std::string("None");
-
282 }
-
283
-
284 protected:
-
296 inline bool isImported(const std::vector<std::string> &moduleLevelNames) {
-
297 return isImported(moduleLevelNames[0]);
-
298 }
-
299
-
306 inline bool isImported(const std::string &name) {
-
307 return importedTopLevelModules.find(name) != importedTopLevelModules.end();
-
308 }
-
309
-
310 private:
-
311 //List this FIRST, to ensure it isn't destroyed before anything else (e.g. Path) that might
-
312 //need a valid interpreter in its destructor calls.
-
313 // This is required for the Python interpreter and must be kept alive
-
314 std::shared_ptr<py::scoped_interpreter> guardPtr;
-
315
-
316 std::map<std::string, py::object> importedTopLevelModules;
+
232 protected:
+
233
+
239 py::list getVenvPackagesDirOptions() {
+
240 // Look for a local virtual environment directory also, if there is one
+
241 const char* env_var_venv = std::getenv("VIRTUAL_ENV");
+
242 py::object venv_dir = env_var_venv != nullptr ? Path(env_var_venv): py::none();
+
243
+
244 if (!venv_dir.is_none() && py::bool_(venv_dir.attr("is_dir")())) {
+
245 // Resolve the full path
+
246 venv_dir = venv_dir.attr("resolve")();
+
247 // Get options for the packages dir
+
248 py::list site_packages_options = py::list(venv_dir.attr("glob")("**/site-packages/"));
+
249 return site_packages_options;
+
250 }
+
251
+
252 return py::list();
+
253 }
+
254
+
255 public:
+
262 inline std::tuple<py::list, std::vector<std::string>> getSystemPath() {
+
263 py::list sys_path = importedTopLevelModules.find("sys")->second.attr("path");
+
264 std::vector<std::string> sys_path_vector(sys_path.size());
+
265 size_t i = 0;
+
266 for (auto item : sys_path) {
+
267 sys_path_vector[i++] = py::str(item);
+
268 }
+
269 return std::make_tuple(sys_path, sys_path_vector);
+
270 }
+
276 std::string getDiscoveredVenvPath() {
+
277 // Look for a local virtual environment directory also, if there is one
+
278 const char* env_var_venv = std::getenv("VIRTUAL_ENV");
+
279 if(env_var_venv != nullptr){
+
280 //std::string r(env_var_venv);
+
281 return std::string(env_var_venv);
+
282 }
+
283 return std::string("None");
+
284 }
+
285
+
286 protected:
+
298 inline bool isImported(const std::vector<std::string> &moduleLevelNames) {
+
299 return isImported(moduleLevelNames[0]);
+
300 }
+
301
+
308 inline bool isImported(const std::string &name) {
+
309 return importedTopLevelModules.find(name) != importedTopLevelModules.end();
+
310 }
+
311
+
312 private:
+
313 //List this FIRST, to ensure it isn't destroyed before anything else (e.g. Path) that might
+
314 //need a valid interpreter in its destructor calls.
+
315 // This is required for the Python interpreter and must be kept alive
+
316 std::shared_ptr<py::scoped_interpreter> guardPtr;
317
-
318 py::object Path;
+
318 std::map<std::string, py::object> importedTopLevelModules;
319
-
320 static const int python_major;
-
321 static const int python_minor;
-
322 static const int python_patch;
-
323 static const char* python_version;
-
324
-
325 // NumPy version is not broken down by CMake
-
326 static const char* numpy_version;
-
327
-
335 inline void importTopLevelModule(const std::string &topLevelName) {
-
336 importedTopLevelModules[topLevelName] = py::module_::import(topLevelName.c_str());
-
337 }
-
338
-
339 };
-
340 }
-
341}
-
342
-
343#endif // ACTIVATE_PYTHON
+
320 py::object Path;
+
321
+
322 static const int python_major;
+
323 static const int python_minor;
+
324 static const int python_patch;
+
325 static const char* python_version;
+
326
+
327 // NumPy version is not broken down by CMake
+
328 static const char* numpy_version;
+
329
+
337 inline void importTopLevelModule(const std::string &topLevelName) {
+
338 importedTopLevelModules[topLevelName] = py::module_::import(topLevelName.c_str());
+
339 }
+
340
+
341 };
+
342 }
+
343}
344
-
345#endif // NGEN_INTERPRETERUTIL_HPP
+
345#endif // NGEN_WITH_PYTHON
+
346
+
347#endif // NGEN_INTERPRETERUTIL_HPP
Definition EndianCopy.hpp:7
@@ -317,7 +319,7 @@ diff --git a/_j_s_o_n_geometry_8hpp_source.html b/_j_s_o_n_geometry_8hpp_source.html index fc5c403e36..24e70045dc 100644 --- a/_j_s_o_n_geometry_8hpp_source.html +++ b/_j_s_o_n_geometry_8hpp_source.html @@ -306,7 +306,7 @@ diff --git a/_j_s_o_n_property_8hpp_source.html b/_j_s_o_n_property_8hpp_source.html index e248d7b12e..ee71503c68 100644 --- a/_j_s_o_n_property_8hpp_source.html +++ b/_j_s_o_n_property_8hpp_source.html @@ -701,7 +701,7 @@ diff --git a/_layer_data_8hpp_source.html b/_layer_data_8hpp_source.html index 88a200b3aa..2d6b2c6ecd 100644 --- a/_layer_data_8hpp_source.html +++ b/_layer_data_8hpp_source.html @@ -180,7 +180,7 @@ diff --git a/_line_string_feature_8hpp_source.html b/_line_string_feature_8hpp_source.html index 0e1b52cfb3..60f245591a 100644 --- a/_line_string_feature_8hpp_source.html +++ b/_line_string_feature_8hpp_source.html @@ -176,7 +176,7 @@ diff --git a/_multi_line_string_feature_8hpp_source.html b/_multi_line_string_feature_8hpp_source.html index 2b716e6215..24a974c668 100644 --- a/_multi_line_string_feature_8hpp_source.html +++ b/_multi_line_string_feature_8hpp_source.html @@ -176,7 +176,7 @@ diff --git a/_multi_point_feature_8hpp_source.html b/_multi_point_feature_8hpp_source.html index 48d5652bba..d1cd8c0f95 100644 --- a/_multi_point_feature_8hpp_source.html +++ b/_multi_point_feature_8hpp_source.html @@ -176,7 +176,7 @@ diff --git a/_multi_polygon_feature_8hpp_source.html b/_multi_polygon_feature_8hpp_source.html index 15ddcadfbb..c42ab98252 100644 --- a/_multi_polygon_feature_8hpp_source.html +++ b/_multi_polygon_feature_8hpp_source.html @@ -175,7 +175,7 @@ diff --git a/_net_c_d_f_per_feature_data_provider_8hpp_source.html b/_net_c_d_f_per_feature_data_provider_8hpp_source.html index 9232ddc7f8..b84ac1c78f 100644 --- a/_net_c_d_f_per_feature_data_provider_8hpp_source.html +++ b/_net_c_d_f_per_feature_data_provider_8hpp_source.html @@ -97,119 +97,122 @@
NetCDFPerFeatureDataProvider.hpp
-
1#ifdef NETCDF_ACTIVE
-
2#ifndef NGEN_NETCDF_PER_FEATURE_DATAPROVIDER_HPP
-
3#define NGEN_NETCDF_PER_FEATURE_DATAPROVIDER_HPP
-
4
-
5#include "GenericDataProvider.hpp"
-
6#include "DataProviderSelectors.hpp"
+
1#ifndef NGEN_NETCDF_PER_FEATURE_DATAPROVIDER_HPP
+
2#define NGEN_NETCDF_PER_FEATURE_DATAPROVIDER_HPP
+
3
+
4#include <NGenConfig.h>
+
5
+
6#if NGEN_WITH_NETCDF
7
-
8#include <string>
-
9#include <algorithm>
-
10#include <map>
-
11#include <memory>
-
12#include <string>
-
13#include <sstream>
-
14#include <exception>
-
15#include <mutex>
-
16#include "assert.h"
-
17#include <iomanip>
-
18#include <boost/compute/detail/lru_cache.hpp>
-
19
-
20#include <UnitsHelper.hpp>
-
21#include <StreamHandler.hpp>
+
8#include "GenericDataProvider.hpp"
+
9#include "DataProviderSelectors.hpp"
+
10
+
11#include <string>
+
12#include <algorithm>
+
13#include <map>
+
14#include <memory>
+
15#include <string>
+
16#include <sstream>
+
17#include <exception>
+
18#include <mutex>
+
19#include "assert.h"
+
20#include <iomanip>
+
21#include <boost/compute/detail/lru_cache.hpp>
22
-
23#include "AorcForcing.hpp"
-
24
-
25namespace netCDF {
-
26 class NcVar;
-
27 class NcFile;
-
28}
-
29
-
30namespace data_access
-
31{
-
32 class NetCDFPerFeatureDataProvider : public GenericDataProvider
-
33 {
-
34
-
35 public:
-
36
-
37 enum TimeUnit
-
38 {
-
39 TIME_HOURS,
-
40 TIME_MINUTES,
-
41 TIME_SECONDS,
-
42 TIME_MILLISECONDS,
-
43 TIME_MICROSECONDS,
-
44 TIME_NANOSECONDS
-
45 };
-
46
-
53 static std::shared_ptr<NetCDFPerFeatureDataProvider> get_shared_provider(std::string input_path, time_t sim_start, time_t sim_end, utils::StreamHandler log_s);
-
54
-
58 static void cleanup_shared_providers();
-
59
-
60 NetCDFPerFeatureDataProvider(std::string input_path, time_t sim_start, time_t sim_end, utils::StreamHandler log_s);
-
61
-
62 // Default implementation defined in the .cpp file so that
-
63 // client code doesn't need to have the full definition of
-
64 // NcFile visible for the compiler to implicitly generate
-
65 // ~NetCDFPerFeatureDataProvider() = default;
-
66 // for every file that uses this class
-
67 ~NetCDFPerFeatureDataProvider();
-
68
-
70 boost::span<const std::string> get_available_variable_names() override;
+
23#include <UnitsHelper.hpp>
+
24#include <StreamHandler.hpp>
+
25
+
26#include "AorcForcing.hpp"
+
27
+
28namespace netCDF {
+
29 class NcVar;
+
30 class NcFile;
+
31}
+
32
+
33namespace data_access
+
34{
+
35 class NetCDFPerFeatureDataProvider : public GenericDataProvider
+
36 {
+
37
+
38 public:
+
39
+
40 enum TimeUnit
+
41 {
+
42 TIME_HOURS,
+
43 TIME_MINUTES,
+
44 TIME_SECONDS,
+
45 TIME_MILLISECONDS,
+
46 TIME_MICROSECONDS,
+
47 TIME_NANOSECONDS
+
48 };
+
49
+
56 static std::shared_ptr<NetCDFPerFeatureDataProvider> get_shared_provider(std::string input_path, time_t sim_start, time_t sim_end, utils::StreamHandler log_s);
+
57
+
61 static void cleanup_shared_providers();
+
62
+
63 NetCDFPerFeatureDataProvider(std::string input_path, time_t sim_start, time_t sim_end, utils::StreamHandler log_s);
+
64
+
65 // Default implementation defined in the .cpp file so that
+
66 // client code doesn't need to have the full definition of
+
67 // NcFile visible for the compiler to implicitly generate
+
68 // ~NetCDFPerFeatureDataProvider() = default;
+
69 // for every file that uses this class
+
70 ~NetCDFPerFeatureDataProvider();
71
-
73 const std::vector<std::string>& get_ids() const;
+
73 boost::span<const std::string> get_available_variable_names() override;
74
-
76 long get_data_start_time() override;
+
76 const std::vector<std::string>& get_ids() const;
77
-
79 long get_data_stop_time() override;
+
79 long get_data_start_time() override;
80
-
81 long record_duration() override;
-
82
-
92 size_t get_ts_index_for_time(const time_t &epoch_time) override;
-
93
-
104 double get_value(const CatchmentAggrDataSelector& selector, ReSampleMethod m) override;
-
105
-
106 virtual std::vector<double> get_values(const CatchmentAggrDataSelector& selector, data_access::ReSampleMethod m) override;
-
107
-
108 private:
-
109
-
110 time_t sim_start_date_time_epoch;
-
111 time_t sim_end_date_time_epoch;
-
112 time_t sim_to_data_time_offset; // Deliberately signed--sim should never start before data, yes?
-
113
-
114 static std::mutex shared_providers_mutex;
-
115 static std::map<std::string, std::shared_ptr<NetCDFPerFeatureDataProvider>> shared_providers;
+
82 long get_data_stop_time() override;
+
83
+
84 long record_duration() override;
+
85
+
95 size_t get_ts_index_for_time(const time_t &epoch_time) override;
+
96
+
107 double get_value(const CatchmentAggrDataSelector& selector, ReSampleMethod m) override;
+
108
+
109 virtual std::vector<double> get_values(const CatchmentAggrDataSelector& selector, data_access::ReSampleMethod m) override;
+
110
+
111 private:
+
112
+
113 time_t sim_start_date_time_epoch;
+
114 time_t sim_end_date_time_epoch;
+
115 time_t sim_to_data_time_offset; // Deliberately signed--sim should never start before data, yes?
116
-
117 std::vector<std::string> variable_names;
-
118 std::vector<std::string> loc_ids;
-
119 std::vector<double> time_vals;
-
120 std::map<std::string, std::size_t> id_pos;
-
121 double start_time; // the begining of the first time for which data is stored
-
122 double stop_time; // the end of the last time for which data is stored
-
123 TimeUnit time_unit; // the unit that time was stored as in the file
-
124 double time_stride; // the amount of time between stored time values
-
125 utils::StreamHandler log_stream;
-
126
-
127
-
128 std::shared_ptr<netCDF::NcFile> nc_file;
+
117 static std::mutex shared_providers_mutex;
+
118 static std::map<std::string, std::shared_ptr<NetCDFPerFeatureDataProvider>> shared_providers;
+
119
+
120 std::vector<std::string> variable_names;
+
121 std::vector<std::string> loc_ids;
+
122 std::vector<double> time_vals;
+
123 std::map<std::string, std::size_t> id_pos;
+
124 double start_time; // the begining of the first time for which data is stored
+
125 double stop_time; // the end of the last time for which data is stored
+
126 TimeUnit time_unit; // the unit that time was stored as in the file
+
127 double time_stride; // the amount of time between stored time values
+
128 utils::StreamHandler log_stream;
129
-
130 std::map<std::string,netCDF::NcVar> ncvar_cache;
-
131 std::map<std::string,std::string> units_cache;
-
132 boost::compute::detail::lru_cache<std::string, std::shared_ptr<std::vector<double>>> value_cache;
-
133 size_t cache_slice_t_size = 1;
-
134 size_t cache_slice_c_size = 1;
-
135
-
136 const netCDF::NcVar& get_ncvar(const std::string& name);
-
137
-
138 const std::string& get_ncvar_units(const std::string& name);
-
139
-
140 };
-
141}
+
130
+
131 std::shared_ptr<netCDF::NcFile> nc_file;
+
132
+
133 std::map<std::string,netCDF::NcVar> ncvar_cache;
+
134 std::map<std::string,std::string> units_cache;
+
135 boost::compute::detail::lru_cache<std::string, std::shared_ptr<std::vector<double>>> value_cache;
+
136 size_t cache_slice_t_size = 1;
+
137 size_t cache_slice_c_size = 1;
+
138
+
139 const netCDF::NcVar& get_ncvar(const std::string& name);
+
140
+
141 const std::string& get_ncvar_units(const std::string& name);
142
-
143
-
144#endif // NGEN_NETCDF_PER_FEATURE_DATAPROVIDER_HPP
-
145#endif
+
143 };
+
144}
+
145
+
146
+
147#endif // NGEN_WITH_NETCDF
+
148#endif // NGEN_NETCDF_PER_FEATURE_DATAPROVIDER_HPP
Definition DataProviderSelectors.hpp:7
This class provides a copyable interface to a std::ostream or std::ostream like object that may not s...
Definition StreamHandler.hpp:14
Definition AorcForcing.hpp:75
@@ -220,7 +223,7 @@ diff --git a/_nexus___manager_8hpp_source.html b/_nexus___manager_8hpp_source.html index 8e4e4dab9b..93dc34014a 100644 --- a/_nexus___manager_8hpp_source.html +++ b/_nexus___manager_8hpp_source.html @@ -280,7 +280,7 @@ diff --git a/_null_forcing_provider_8hpp_source.html b/_null_forcing_provider_8hpp_source.html index 695aca3b02..6abb50f8cb 100644 --- a/_null_forcing_provider_8hpp_source.html +++ b/_null_forcing_provider_8hpp_source.html @@ -187,7 +187,7 @@ diff --git a/_optional_wrapped_data_provider_8hpp_source.html b/_optional_wrapped_data_provider_8hpp_source.html index cfe200ae1e..94c921ec92 100644 --- a/_optional_wrapped_data_provider_8hpp_source.html +++ b/_optional_wrapped_data_provider_8hpp_source.html @@ -399,7 +399,7 @@ diff --git a/_partition___data_8hpp_source.html b/_partition___data_8hpp_source.html index ec1f27ef45..a45e27f359 100644 --- a/_partition___data_8hpp_source.html +++ b/_partition___data_8hpp_source.html @@ -124,7 +124,7 @@ diff --git a/_partition___one_8hpp_source.html b/_partition___one_8hpp_source.html index ecc366baad..0b9cadd041 100644 --- a/_partition___one_8hpp_source.html +++ b/_partition___one_8hpp_source.html @@ -147,7 +147,7 @@ diff --git a/_partition___parser_8hpp_source.html b/_partition___parser_8hpp_source.html index 8d591ee3fd..57443daf21 100644 --- a/_partition___parser_8hpp_source.html +++ b/_partition___parser_8hpp_source.html @@ -100,191 +100,213 @@
1#ifndef PARTITION_PARSER_H
2#define PARTITION_PARSER_H
3
-
4#ifdef NGEN_MPI_ACTIVE
-
5
-
6//#include <mpi.h>
-
7
-
8#include <memory>
-
9#include <sstream>
-
10#include <tuple>
-
11#include <functional>
-
12#include <string>
-
13#include <unordered_map>
-
14#include <vector>
-
15#include <unordered_set>
-
16
-
17#include <boost/property_tree/ptree.hpp>
-
18#include <boost/property_tree/json_parser.hpp>
-
19#include <FeatureBuilder.hpp>
-
20#include "features/Features.hpp"
-
21#include <FeatureCollection.hpp>
-
22#include "JSONProperty.hpp"
-
23#include "Partition_Data.hpp"
-
24
-
25class Partitions_Parser {
-
26
-
27 public:
-
28 //Constructor that takes an input json file path and points to the root of the tree in json file
-
29 Partitions_Parser(const std::string &file_path) {
-
30 boost::property_tree::ptree loaded_tree;
-
31 boost::property_tree::json_parser::read_json(file_path, loaded_tree);
-
32 std::cout << "file read success" << std::endl;
-
33 this->tree = loaded_tree;
-
34 std::cout << "file_path: " << file_path << std::endl;
-
35 };
+
4#include <memory>
+
5#include <sstream>
+
6#include <tuple>
+
7#include <functional>
+
8#include <string>
+
9#include <unordered_map>
+
10#include <vector>
+
11#include <unordered_set>
+
12
+
13#include <boost/property_tree/ptree.hpp>
+
14#include <boost/property_tree/json_parser.hpp>
+
15#include <FeatureBuilder.hpp>
+
16#include "features/Features.hpp"
+
17#include <FeatureCollection.hpp>
+
18#include "JSONProperty.hpp"
+
19#include "Partition_Data.hpp"
+
20
+
+ +
22
+
23 public:
+
24 //Constructor that takes an input json file path and points to the root of the tree in json file
+
+
25 Partitions_Parser(const std::string &file_path) {
+
26 boost::property_tree::ptree loaded_tree;
+
27 boost::property_tree::json_parser::read_json(file_path, loaded_tree);
+
28 std::cout << "file read success" << std::endl;
+
29 this->tree = loaded_tree;
+
30 std::cout << "file_path: " << file_path << std::endl;
+
31 };
+
+
32
+
+
33 Partitions_Parser(const boost::property_tree::ptree tree){
+
34 this->tree = tree;
+
35 }
+
36
-
37 Partitions_Parser(const boost::property_tree::ptree tree){
-
38 this->tree = tree;
-
39 }
-
40
-
41 virtual ~Partitions_Parser(){};
+
37 virtual ~Partitions_Parser(){};
+
38
+
39 //The function that parses the json file and build a unordered set and vector of structs for each line in the json list
+
+ +
41 std::cout << "\nroot_tree: " << tree.size() << std::endl;
42
-
43 //The function that parses the json file and build a unordered set and vector of structs for each line in the json list
-
44 void parse_partition_file() {
-
45 std::cout << "\nroot_tree: " << tree.size() << std::endl;
-
46
-
47 //Declare two partition_data type structs
-
48 PartitionData part_data;
-
49
-
50 //The outter loop iterating through the list of partitions
-
51 int remote_mpi_rank;
-
52 std::string remote_nex_id;
-
53 std::string remote_cat_id;
-
54 std::string direction;
-
55 PartitionData::Tuple tmp_tuple;
-
56 std::vector<PartitionData::Tuple> remote_conn_vec;
-
57 int part_counter = 0;
-
58 for(auto &partition: tree.get_child("partitions")) {
-
59 //Get partition id
-
60 std::string part_id = (partition.second).get<std::string>("id");
+
43 //Declare two partition_data type structs
+
44 PartitionData part_data;
+
45
+
46 //The outter loop iterating through the list of partitions
+
47 int remote_mpi_rank;
+
48 std::string remote_nex_id;
+
49 std::string remote_cat_id;
+
50 std::string direction;
+
51 PartitionData::Tuple tmp_tuple;
+
52 std::vector<PartitionData::Tuple> remote_conn_vec;
+
53 int part_counter = 0;
+
54 for(auto &partition: tree.get_child("partitions")) {
+
55 //Get partition id
+
56 std::string part_id = (partition.second).get<std::string>("id");
+
57
+
58 //Get mpi_world_rank and set the corresponding part_data struct member
+
59 int mpi_rank = std::stoi(part_id);
+
60 part_data.mpi_world_rank = mpi_rank;
61
-
62 //Get mpi_world_rank and set the corresponding part_data struct member
-
63 int mpi_rank = std::stoi(part_id);
-
64 part_data.mpi_world_rank = mpi_rank;
-
65
-
66 geojson::JSONProperty part = geojson::JSONProperty(part_id, partition.second);
-
67
-
68 //Get cat_ids list and insert the elements into the unordered_set catchment_ids in part_data struct
-
69 for (auto &cat_id : part.at("cat-ids").as_list())
-
70 {
-
71 //cat_ids.push_back(remote.as_string());
-
72 catchment_ids.emplace(cat_id.as_string());
-
73 }
-
74 part_data.catchment_ids = catchment_ids;
-
75 catchment_ids.clear();
-
76
-
77 //Get nex_ids list and insert the elements into the unordered_set nexus_ids in part_data struct
-
78 for (auto &nex_id: part.at("nex-ids").as_list())
-
79 {
-
80 //nex_ids.push_back(nex_id.as_string());
-
81 nexus_ids.emplace(nex_id.as_string());
-
82 }
-
83 part_data.nexus_ids = nexus_ids;
-
84 nexus_ids.clear();
-
85
-
86 if( part.at("remote-connections").get_type() == geojson::PropertyType::List )
-
87 {
-
88 //It is valid to have no remote connections, but the backend property tree parser
-
89 //can't represent empty lists/objects, so it turns into an empty string (which is iterable)
-
90 //so we check to ensure the remote connections are a list type (not string) before we attempt
-
91 //to process the remote-connections. If they are empty, this step gets skipped entirely.
-
92 //Get remote-connections and set the corresponding part_data struct member
-
93
-
94 for (auto &remote_conn : part.at("remote-connections").as_list())
-
95 {
-
96 if ( remote_conn.get_type() != geojson::PropertyType::String )
-
97 {
-
98 remote_mpi_rank = remote_conn.at("mpi-rank").as_natural_number();
-
99 remote_nex_id = remote_conn.at("nex-id").as_string();
-
100 remote_cat_id = remote_conn.at("cat-id").as_string();
-
101 direction = remote_conn.at("cat-direction").as_string();
-
102 tmp_tuple = std::make_tuple(remote_mpi_rank, remote_nex_id, remote_cat_id, direction);
-
103 remote_conn_vec.push_back(tmp_tuple);
-
104 }
-
105 }
-
106 }
-
107
-
108 part_data.remote_connections = remote_conn_vec;
-
109 remote_conn_vec.clear();
-
110
-
111 //Push part_data struct the vector
-
112 partition_ranks.push_back(part_data);
-
113
-
114 part_counter++;
-
115
-
116 }
-
117 };
-
118
-
119 //The function retrieve an arbitrary struct based on the part_id passed to it
-
120 PartitionData get_partition_struct(int part_id)
-
121 {
-
122 //TODO The output codes are for test only. They can be removed for application code.
-
123 /*
-
124 * The function takes a partition id and return the corresponding struct from the set and remote_connections.
-
125 * @param part_id The input parameter identify a specific partition struct
-
126 * @return part_data The whole struct identified by part_id
-
127 */
-
128 PartitionData part_data;
-
129 part_data = partition_ranks[part_id];
-
130
-
131 // the following blocks of codes write out the data for validation
-
132 /*
-
133 std::cout << "\nget_partition_struct, part_id: " << part_data.mpi_world_rank << std::endl;
+
62 geojson::JSONProperty part = geojson::JSONProperty(part_id, partition.second);
+
63
+
64 //Get cat_ids list and insert the elements into the unordered_set catchment_ids in part_data struct
+
65 for (auto &cat_id : part.at("cat-ids").as_list())
+
66 {
+
67 //cat_ids.push_back(remote.as_string());
+
68 catchment_ids.emplace(cat_id.as_string());
+
69 }
+
70 part_data.catchment_ids = catchment_ids;
+
71 catchment_ids.clear();
+
72
+
73 //Get nex_ids list and insert the elements into the unordered_set nexus_ids in part_data struct
+
74 for (auto &nex_id: part.at("nex-ids").as_list())
+
75 {
+
76 //nex_ids.push_back(nex_id.as_string());
+
77 nexus_ids.emplace(nex_id.as_string());
+
78 }
+
79 part_data.nexus_ids = nexus_ids;
+
80 nexus_ids.clear();
+
81
+
82 if( part.at("remote-connections").get_type() == geojson::PropertyType::List )
+
83 {
+
84 //It is valid to have no remote connections, but the backend property tree parser
+
85 //can't represent empty lists/objects, so it turns into an empty string (which is iterable)
+
86 //so we check to ensure the remote connections are a list type (not string) before we attempt
+
87 //to process the remote-connections. If they are empty, this step gets skipped entirely.
+
88 //Get remote-connections and set the corresponding part_data struct member
+
89
+
90 for (auto &remote_conn : part.at("remote-connections").as_list())
+
91 {
+
92 if ( remote_conn.get_type() != geojson::PropertyType::String )
+
93 {
+
94 remote_mpi_rank = remote_conn.at("mpi-rank").as_natural_number();
+
95 remote_nex_id = remote_conn.at("nex-id").as_string();
+
96 remote_cat_id = remote_conn.at("cat-id").as_string();
+
97 direction = remote_conn.at("cat-direction").as_string();
+
98 tmp_tuple = std::make_tuple(remote_mpi_rank, remote_nex_id, remote_cat_id, direction);
+
99 remote_conn_vec.push_back(tmp_tuple);
+
100 }
+
101 }
+
102 }
+
103
+
104 part_data.remote_connections = remote_conn_vec;
+
105 remote_conn_vec.clear();
+
106
+
107 //Push part_data struct the vector
+
108 partition_ranks.push_back(part_data);
+
109
+
110 part_counter++;
+
111
+
112 }
+
113 };
+
+
114
+
115 //The function retrieve an arbitrary struct based on the part_id passed to it
+
+ +
117 {
+
118 //TODO The output codes are for test only. They can be removed for application code.
+
119 /*
+
120 * The function takes a partition id and return the corresponding struct from the set and remote_connections.
+
121 * @param part_id The input parameter identify a specific partition struct
+
122 * @return part_data The whole struct identified by part_id
+
123 */
+
124 PartitionData part_data;
+
125 part_data = partition_ranks[part_id];
+
126
+
127 // the following blocks of codes write out the data for validation
+
128 /*
+
129 std::cout << "\nget_partition_struct, part_id: " << part_data.mpi_world_rank << std::endl;
+
130
+
131 for (auto i = (part_data.catchment_ids).cbegin(); i != (part_data.catchment_ids).cend(); ++i)
+
132 std::cout << "\nget_partition_struct, catchment_ids: " << *i << " ";
+
133 std::cout << std::endl;
134
-
135 for (auto i = (part_data.catchment_ids).cbegin(); i != (part_data.catchment_ids).cend(); ++i)
-
136 std::cout << "\nget_partition_struct, catchment_ids: " << *i << " ";
+
135 for (auto i = (part_data.nexus_ids).cbegin(); i != (part_data.nexus_ids).cend(); ++i)
+
136 std::cout << "\nget_partition_struct, nexus_ids: " << *i << " ";
137 std::cout << std::endl;
138
-
139 for (auto i = (part_data.nexus_ids).cbegin(); i != (part_data.nexus_ids).cend(); ++i)
-
140 std::cout << "\nget_partition_struct, nexus_ids: " << *i << " ";
-
141 std::cout << std::endl;
-
142
-
143 for (auto i = part_data.remote_connections.cbegin(); i != part_data.remote_connections.cend(); ++i)
-
144 {
-
145 std::tuple<int, std::string, std::string> remote_conn = *i;
-
146 int mpi_rank = std::get<0>(remote_conn);
-
147 std::string nex_id = std::get<1>(remote_conn);
-
148 std::string cat_id = std::get<2>(remote_conn);
-
149
-
150 std::cout << "\nget_partition_struct, remote_mpi_ranks: " << mpi_rank;
-
151 std::cout << "\nget_partition_struct, remote_nexus: " << nex_id;
-
152 std::cout << "\nget_partition_struct, remote_catchment: " << cat_id;
-
153 }
-
154 std::cout << "\n--------------------" << std::endl;
-
155 */
-
156
-
157 return part_data;
-
158 }
-
159
-
160 //This example function shows how to get a specific member of the struct
-
161 int get_mpi_rank(int part_id)
-
162 {
-
163 //An example code for getting individual member of the struct identified by part_id
-
164 PartitionData part_data;
-
165 part_data = partition_ranks[part_id];
-
166 int mpi_world_rank = part_data.mpi_world_rank;
+
139 for (auto i = part_data.remote_connections.cbegin(); i != part_data.remote_connections.cend(); ++i)
+
140 {
+
141 std::tuple<int, std::string, std::string> remote_conn = *i;
+
142 int mpi_rank = std::get<0>(remote_conn);
+
143 std::string nex_id = std::get<1>(remote_conn);
+
144 std::string cat_id = std::get<2>(remote_conn);
+
145
+
146 std::cout << "\nget_partition_struct, remote_mpi_ranks: " << mpi_rank;
+
147 std::cout << "\nget_partition_struct, remote_nexus: " << nex_id;
+
148 std::cout << "\nget_partition_struct, remote_catchment: " << cat_id;
+
149 }
+
150 std::cout << "\n--------------------" << std::endl;
+
151 */
+
152
+
153 return part_data;
+
154 }
+
+
155
+
156 //This example function shows how to get a specific member of the struct
+
+
157 int get_mpi_rank(int part_id)
+
158 {
+
159 //An example code for getting individual member of the struct identified by part_id
+
160 PartitionData part_data;
+
161 part_data = partition_ranks[part_id];
+
162 int mpi_world_rank = part_data.mpi_world_rank;
+
163
+
164 std::cout << "mpi_world_rank: " << mpi_world_rank << std::endl;
+
165 return mpi_world_rank;
+
166 }
+
167
-
168 std::cout << "mpi_world_rank: " << mpi_world_rank << std::endl;
-
169 return mpi_world_rank;
-
170 }
-
171
-
172 // partition_ranks is a vector of struct: PartitionData
-
173 std::vector<PartitionData> partition_ranks;
-
174
-
175 private:
-
176 int mpi_world_rank;
-
177 std::unordered_set<std::string> catchment_ids;
-
178 std::unordered_set<std::string> nexus_ids;
-
179 std::vector<std::tuple<int, std::string, std::string> > remote_connections;
-
180 std::tuple<int, std::string, std::string> remote_tuple;
-
181
-
182 boost::property_tree::ptree tree;
-
183};
-
184
-
185#endif // NGEN_MPI_ACTIVE
-
186#endif // PARTITION_PARSER_H
+
168 // partition_ranks is a vector of struct: PartitionData
+
169 std::vector<PartitionData> partition_ranks;
+
170
+
171 private:
+ +
173 std::unordered_set<std::string> catchment_ids;
+
174 std::unordered_set<std::string> nexus_ids;
+
175 std::vector<std::tuple<int, std::string, std::string> > remote_connections;
+
176 std::tuple<int, std::string, std::string> remote_tuple;
+
177
+
178 boost::property_tree::ptree tree;
+
179};
+
+
180
+
181#endif // PARTITION_PARSER_H
+
Definition Partition_Parser.hpp:21
+
int mpi_world_rank
Definition Partition_Parser.hpp:172
+
void parse_partition_file()
Definition Partition_Parser.hpp:40
+
virtual ~Partitions_Parser()
Definition Partition_Parser.hpp:37
+
Partitions_Parser(const std::string &file_path)
Definition Partition_Parser.hpp:25
+
std::unordered_set< std::string > nexus_ids
Definition Partition_Parser.hpp:174
+
PartitionData get_partition_struct(int part_id)
Definition Partition_Parser.hpp:116
+
std::vector< PartitionData > partition_ranks
Definition Partition_Parser.hpp:169
+
int get_mpi_rank(int part_id)
Definition Partition_Parser.hpp:157
+
std::unordered_set< std::string > catchment_ids
Definition Partition_Parser.hpp:173
+
std::tuple< int, std::string, std::string > remote_tuple
Definition Partition_Parser.hpp:176
+
boost::property_tree::ptree tree
Definition Partition_Parser.hpp:178
+
Partitions_Parser(const boost::property_tree::ptree tree)
Definition Partition_Parser.hpp:33
+
std::vector< std::tuple< int, std::string, std::string > > remote_connections
Definition Partition_Parser.hpp:175
@TODO: Convert JSONProperty into a variant of the supported types
Definition JSONProperty.hpp:165
JSONProperty at(std::string key) const
Definition JSONProperty.cpp:136
+
std::vector< JSONProperty > as_list() const
Definition JSONProperty.cpp:54
PropertyType get_type() const
Get the type of the property (Natural, Real, String, etc)
Definition JSONProperty.cpp:28
@@ -300,7 +322,7 @@ diff --git a/_point_feature_8hpp_source.html b/_point_feature_8hpp_source.html index f968d8690c..3574bf4994 100644 --- a/_point_feature_8hpp_source.html +++ b/_point_feature_8hpp_source.html @@ -176,7 +176,7 @@ diff --git a/_polygon_feature_8hpp_source.html b/_polygon_feature_8hpp_source.html index 90b5ceb3be..4a0dd4b541 100644 --- a/_polygon_feature_8hpp_source.html +++ b/_polygon_feature_8hpp_source.html @@ -167,7 +167,7 @@ diff --git a/_routing___params_8h_source.html b/_routing___params_8h_source.html index 13a5d1271f..39b997cba1 100644 --- a/_routing___params_8h_source.html +++ b/_routing___params_8h_source.html @@ -136,7 +136,7 @@ diff --git a/_routing___py___adapter_8hpp_source.html b/_routing___py___adapter_8hpp_source.html index a85d176333..6ff6cf22d9 100644 --- a/_routing___py___adapter_8hpp_source.html +++ b/_routing___py___adapter_8hpp_source.html @@ -100,78 +100,80 @@
1#ifndef NGEN_ROUTING_PY_ADAPTER_H
2#define NGEN_ROUTING_PY_ADAPTER_H
3
-
4#ifdef ACTIVATE_PYTHON
+
4#include <NGenConfig.h>
5
-
6#include <exception>
-
7#include <memory>
-
8#include <string>
-
9#include "pybind11/pybind11.h"
-
10#include "pybind11/pytypes.h"
-
11#include "pybind11/numpy.h"
-
12#include <pybind11/stl.h>
-
13#include "python/InterpreterUtil.hpp"
-
14
-
15namespace py = pybind11;
+
6#if NGEN_WITH_PYTHON
+
7
+
8#include <exception>
+
9#include <memory>
+
10#include <string>
+
11#include "pybind11/pybind11.h"
+
12#include "pybind11/pytypes.h"
+
13#include "pybind11/numpy.h"
+
14#include <pybind11/stl.h>
+
15#include "python/InterpreterUtil.hpp"
16
-
17namespace routing_py_adapter {
+
17namespace py = pybind11;
18
-
19 class Routing_Py_Adapter {
+
19namespace routing_py_adapter {
20
-
21 public:
-
27 Routing_Py_Adapter(std::string t_route_config_file_with_path);
-
28
-
51 void route(int number_of_timesteps, int delta_time,
-
52 const std::vector<double> &flow_vector);
-
53
-
54
-
75 void route(int number_of_timesteps, int delta_time);
-
76
-
77
-
78 template <typename T>
-
79 void convert_vector_to_numpy_array(const std::vector<T> &flow_vector)
-
80 {
-
91 //Allocate py::array (to pass the result of the C++ function to Python)
-
92 auto result = py::array_t<T>(flow_vector.size());
-
93 auto result_buffer = result.request();
-
94 T *result_ptr = (T *) result_buffer.ptr;
-
95
-
96 //Copy std::vector -> py::array
-
97 std::memcpy(result_ptr, flow_vector.data(), flow_vector.size()*sizeof(T));
-
98
-
99 //Create object for receive_flow_values subroutine
-
100 py::object receive_flow_values = t_route_module.attr("receive_flow_values");
-
101
-
102 //Call receive_flow_values subroutine
-
103 receive_flow_values(result);
-
104
-
105 }
+
21 class Routing_Py_Adapter {
+
22
+
23 public:
+
29 Routing_Py_Adapter(std::string t_route_config_file_with_path);
+
30
+
53 void route(int number_of_timesteps, int delta_time,
+
54 const std::vector<double> &flow_vector);
+
55
+
56
+
77 void route(int number_of_timesteps, int delta_time);
+
78
+
79
+
80 template <typename T>
+
81 void convert_vector_to_numpy_array(const std::vector<T> &flow_vector)
+
82 {
+
93 //Allocate py::array (to pass the result of the C++ function to Python)
+
94 auto result = py::array_t<T>(flow_vector.size());
+
95 auto result_buffer = result.request();
+
96 T *result_ptr = (T *) result_buffer.ptr;
+
97
+
98 //Copy std::vector -> py::array
+
99 std::memcpy(result_ptr, flow_vector.data(), flow_vector.size()*sizeof(T));
+
100
+
101 //Create object for receive_flow_values subroutine
+
102 py::object receive_flow_values = t_route_module.attr("receive_flow_values");
+
103
+
104 //Call receive_flow_values subroutine
+
105 receive_flow_values(result);
106
-
107
-
108 private:
+
107 }
+
108
109
-
110
-
116 std::shared_ptr<utils::ngenPy::InterpreterUtil> interperter;
-
117
-
119 py::object np;
-
120
-
122 py::object t_route_module;
-
123
-
125 std::string t_route_config_path;
-
126 };
-
127
-
128}
+
110 private:
+
111
+
112
+
118 std::shared_ptr<utils::ngenPy::InterpreterUtil> interperter;
+
119
+
121 py::object np;
+
122
+
124 py::object t_route_module;
+
125
+
127 std::string t_route_config_path;
+
128 };
129
-
130
-
131#endif //ACTIVATE_PYTHON
+
130}
+
131
132
-
133#endif //NGEN_ROUTING_PY_ADAPTER_H
+
133#endif //NGEN_WITH_PYTHON
+
134
+
135#endif //NGEN_ROUTING_PY_ADAPTER_H
diff --git a/_simulation___time_8hpp_source.html b/_simulation___time_8hpp_source.html index fbe39a49b8..3111ceaa24 100644 --- a/_simulation___time_8hpp_source.html +++ b/_simulation___time_8hpp_source.html @@ -299,7 +299,7 @@ diff --git a/_state___exception_8hpp_source.html b/_state___exception_8hpp_source.html index 3136e2ffb4..dc347b6a35 100644 --- a/_state___exception_8hpp_source.html +++ b/_state___exception_8hpp_source.html @@ -158,7 +158,7 @@ diff --git a/_stream_handler_8hpp_source.html b/_stream_handler_8hpp_source.html index 1fc8116801..859c0aec4a 100644 --- a/_stream_handler_8hpp_source.html +++ b/_stream_handler_8hpp_source.html @@ -239,7 +239,7 @@ diff --git a/_surface_layer_8hpp_source.html b/_surface_layer_8hpp_source.html index 0a32148ff8..80bc8ce8f9 100644 --- a/_surface_layer_8hpp_source.html +++ b/_surface_layer_8hpp_source.html @@ -141,7 +141,7 @@
40#endif
Simulation Time class providing time-series variables and methods to the model.
Definition Simulation_Time.hpp:48
Collection interface to HY_Features objects and their associated model formulations.
Definition HY_Features.hpp:41
-
Definition Layer.hpp:18
+
Definition Layer.hpp:20
Definition SurfaceLayer.hpp:9
std::vector< std::string > nexus_ids
Definition SurfaceLayer.hpp:35
SurfaceLayer(const LayerDescription &desc, const std::vector< std::string > &p_u, const Simulation_Time &s_t, feature_type &f, geojson::GeoJSON cd, long idx, const std::vector< std::string > &n_u, std::unordered_map< std::string, std::ofstream > &output_files)
Definition SurfaceLayer.hpp:12
@@ -156,7 +156,7 @@ diff --git a/_units_helper_8hpp_source.html b/_units_helper_8hpp_source.html index cc23cb2c18..00a2e15461 100644 --- a/_units_helper_8hpp_source.html +++ b/_units_helper_8hpp_source.html @@ -178,7 +178,7 @@ diff --git a/_wrapped_data_provider_8hpp_source.html b/_wrapped_data_provider_8hpp_source.html index 1991519b89..68eb6b813b 100644 --- a/_wrapped_data_provider_8hpp_source.html +++ b/_wrapped_data_provider_8hpp_source.html @@ -214,7 +214,7 @@ diff --git a/all_8h_source.html b/all_8h_source.html index 6c2fd763bd..a4215a7049 100644 --- a/all_8h_source.html +++ b/all_8h_source.html @@ -109,7 +109,7 @@ diff --git a/annotated.html b/annotated.html index 59ecbd5681..8a94abef8f 100644 --- a/annotated.html +++ b/annotated.html @@ -232,15 +232,16 @@  CNullForcingProviderForcing class that returns no variables to the simulation–use this e.g  CPartition_One  CPartitionData - Crequest_from_empty_nexus - CReservoirKernelTest - CReservoirTimelessKernelTest - Crouting_paramsRouting_params providing configuration information for routing - CSimulation_TimeSimulation Time class providing time-series variables and methods to the model - Csimulation_time_paramsSimulation_time_params providing configuration information for simulation time period - CUnitsHelper - CUnitsHelper_Test - CVisitor + CPartitions_Parser + Crequest_from_empty_nexus + CReservoirKernelTest + CReservoirTimelessKernelTest + Crouting_paramsRouting_params providing configuration information for routing + CSimulation_TimeSimulation Time class providing time-series variables and methods to the model + Csimulation_time_paramsSimulation_time_params providing configuration information for simulation time period + CUnitsHelper + CUnitsHelper_Test + CVisitor
@@ -248,7 +249,7 @@ diff --git a/annotated_dup.js b/annotated_dup.js index 55d267df60..b7e15a36eb 100644 --- a/annotated_dup.js +++ b/annotated_dup.js @@ -151,6 +151,7 @@ var annotated_dup = [ "NullForcingProvider", "class_null_forcing_provider.html", "class_null_forcing_provider" ], [ "Partition_One", "class_partition___one.html", "class_partition___one" ], [ "PartitionData", "struct_partition_data.html", "struct_partition_data" ], + [ "Partitions_Parser", "class_partitions___parser.html", "class_partitions___parser" ], [ "request_from_empty_nexus", "structrequest__from__empty__nexus.html", "structrequest__from__empty__nexus" ], [ "ReservoirKernelTest", "class_reservoir_kernel_test.html", "class_reservoir_kernel_test" ], [ "ReservoirTimelessKernelTest", "class_reservoir_timeless_kernel_test.html", "class_reservoir_timeless_kernel_test" ], diff --git a/bmi_8h_source.html b/bmi_8h_source.html index 74ff0278fa..d4ba9b4a12 100644 --- a/bmi_8h_source.html +++ b/bmi_8h_source.html @@ -271,7 +271,7 @@ diff --git a/bmi_8hpp_source.html b/bmi_8hpp_source.html index f15a6e2af8..6c6e3f8221 100644 --- a/bmi_8hpp_source.html +++ b/bmi_8hpp_source.html @@ -250,7 +250,7 @@ diff --git a/bmi__utilities_8hpp_source.html b/bmi__utilities_8hpp_source.html index 5bcb0c0e78..11930808e9 100644 --- a/bmi__utilities_8hpp_source.html +++ b/bmi__utilities_8hpp_source.html @@ -225,7 +225,7 @@ diff --git a/catchment_2formulation_8hpp_source.html b/catchment_2formulation_8hpp_source.html index 1ff17da33d..5dd237e3c3 100644 --- a/catchment_2formulation_8hpp_source.html +++ b/catchment_2formulation_8hpp_source.html @@ -238,7 +238,7 @@ diff --git a/class_c_s_v_reader-members.html b/class_c_s_v_reader-members.html index 141756bec3..f31698c282 100644 --- a/class_c_s_v_reader-members.html +++ b/class_c_s_v_reader-members.html @@ -104,7 +104,7 @@ diff --git a/class_c_s_v_reader.html b/class_c_s_v_reader.html index d3eeaa3f01..5d22e4ee4f 100644 --- a/class_c_s_v_reader.html +++ b/class_c_s_v_reader.html @@ -247,7 +247,7 @@

    - +

diff --git a/class_catchment_aggr_data_selector-members.html b/class_catchment_aggr_data_selector-members.html index 5cf914dcd5..f0acae2675 100644 --- a/class_catchment_aggr_data_selector-members.html +++ b/class_catchment_aggr_data_selector-members.html @@ -117,7 +117,7 @@ diff --git a/class_catchment_aggr_data_selector.html b/class_catchment_aggr_data_selector.html index e39126a8bf..b469c3c1e2 100644 --- a/class_catchment_aggr_data_selector.html +++ b/class_catchment_aggr_data_selector.html @@ -735,7 +735,7 @@

    - +

diff --git a/class_csv_per_feature_forcing_provider-members.html b/class_csv_per_feature_forcing_provider-members.html index 1cc4ad3166..b21975aba8 100644 --- a/class_csv_per_feature_forcing_provider-members.html +++ b/class_csv_per_feature_forcing_provider-members.html @@ -132,7 +132,7 @@ diff --git a/class_csv_per_feature_forcing_provider.html b/class_csv_per_feature_forcing_provider.html index 817115f1dd..bbe7fddb3d 100644 --- a/class_csv_per_feature_forcing_provider.html +++ b/class_csv_per_feature_forcing_provider.html @@ -1147,7 +1147,7 @@

diff --git a/class_feature___test-members.html b/class_feature___test-members.html index 66e8bf1155..a579f030a3 100644 --- a/class_feature___test-members.html +++ b/class_feature___test-members.html @@ -104,7 +104,7 @@ diff --git a/class_feature___test.html b/class_feature___test.html index 5c79d70a34..ba139373d9 100644 --- a/class_feature___test.html +++ b/class_feature___test.html @@ -232,7 +232,7 @@

    - +

diff --git a/class_feature_collection___test-members.html b/class_feature_collection___test-members.html index aba8bd2c63..5d13661fa1 100644 --- a/class_feature_collection___test-members.html +++ b/class_feature_collection___test-members.html @@ -104,7 +104,7 @@ diff --git a/class_feature_collection___test.html b/class_feature_collection___test.html index 0b04fba91b..4802d5490d 100644 --- a/class_feature_collection___test.html +++ b/class_feature_collection___test.html @@ -232,7 +232,7 @@

    - +

diff --git a/class_g_m___object-members.html b/class_g_m___object-members.html index 1190fbf53f..1654db64b1 100644 --- a/class_g_m___object-members.html +++ b/class_g_m___object-members.html @@ -102,7 +102,7 @@ diff --git a/class_g_m___object.html b/class_g_m___object.html index ccecfdfd38..5f4908a6d2 100644 --- a/class_g_m___object.html +++ b/class_g_m___object.html @@ -172,7 +172,7 @@

    - +

diff --git a/class_h_y___cartographic_realization-members.html b/class_h_y___cartographic_realization-members.html index 793749474b..0975915327 100644 --- a/class_h_y___cartographic_realization-members.html +++ b/class_h_y___cartographic_realization-members.html @@ -111,7 +111,7 @@ diff --git a/class_h_y___cartographic_realization.html b/class_h_y___cartographic_realization.html index 2e79c4e595..01298eedb1 100644 --- a/class_h_y___cartographic_realization.html +++ b/class_h_y___cartographic_realization.html @@ -368,7 +368,7 @@

    - +

diff --git a/class_h_y___catchment-members.html b/class_h_y___catchment-members.html index 07a7e099f8..f6d490ca39 100644 --- a/class_h_y___catchment-members.html +++ b/class_h_y___catchment-members.html @@ -129,7 +129,7 @@ diff --git a/class_h_y___catchment.html b/class_h_y___catchment.html index d92d89794c..afe2fe888e 100644 --- a/class_h_y___catchment.html +++ b/class_h_y___catchment.html @@ -806,7 +806,7 @@

    - +

diff --git a/class_h_y___catchment_aggregate-members.html b/class_h_y___catchment_aggregate-members.html index abb5bec30d..5cc2155916 100644 --- a/class_h_y___catchment_aggregate-members.html +++ b/class_h_y___catchment_aggregate-members.html @@ -131,7 +131,7 @@ diff --git a/class_h_y___catchment_aggregate.html b/class_h_y___catchment_aggregate.html index 271bd17d3b..5c251eef20 100644 --- a/class_h_y___catchment_aggregate.html +++ b/class_h_y___catchment_aggregate.html @@ -814,7 +814,7 @@

    - +

diff --git a/class_h_y___catchment_area-members.html b/class_h_y___catchment_area-members.html index c87f539cd5..cd9400692e 100644 --- a/class_h_y___catchment_area-members.html +++ b/class_h_y___catchment_area-members.html @@ -118,7 +118,7 @@ diff --git a/class_h_y___catchment_area.html b/class_h_y___catchment_area.html index 0a0c524bf8..183558a524 100644 --- a/class_h_y___catchment_area.html +++ b/class_h_y___catchment_area.html @@ -508,7 +508,7 @@

    - +

diff --git a/class_h_y___catchment_divide-members.html b/class_h_y___catchment_divide-members.html index b8739137a8..231b604365 100644 --- a/class_h_y___catchment_divide-members.html +++ b/class_h_y___catchment_divide-members.html @@ -117,7 +117,7 @@ diff --git a/class_h_y___catchment_divide.html b/class_h_y___catchment_divide.html index 9137c11ea6..34d526867b 100644 --- a/class_h_y___catchment_divide.html +++ b/class_h_y___catchment_divide.html @@ -457,7 +457,7 @@

    - +

diff --git a/class_h_y___catchment_realization-members.html b/class_h_y___catchment_realization-members.html index cf977c72c1..60a882fcb5 100644 --- a/class_h_y___catchment_realization-members.html +++ b/class_h_y___catchment_realization-members.html @@ -109,7 +109,7 @@ diff --git a/class_h_y___catchment_realization.html b/class_h_y___catchment_realization.html index 07550e5eff..823bd85f31 100644 --- a/class_h_y___catchment_realization.html +++ b/class_h_y___catchment_realization.html @@ -388,7 +388,7 @@

    - +

diff --git a/class_h_y___dendritic_catchment-members.html b/class_h_y___dendritic_catchment-members.html index ebebe87e0b..d987562048 100644 --- a/class_h_y___dendritic_catchment-members.html +++ b/class_h_y___dendritic_catchment-members.html @@ -131,7 +131,7 @@ diff --git a/class_h_y___dendritic_catchment.html b/class_h_y___dendritic_catchment.html index e2bde899ef..108e5005cd 100644 --- a/class_h_y___dendritic_catchment.html +++ b/class_h_y___dendritic_catchment.html @@ -814,7 +814,7 @@

    - +

diff --git a/class_h_y___flow_path-members.html b/class_h_y___flow_path-members.html index 36f95deb3a..3926834b90 100644 --- a/class_h_y___flow_path-members.html +++ b/class_h_y___flow_path-members.html @@ -116,7 +116,7 @@ diff --git a/class_h_y___flow_path.html b/class_h_y___flow_path.html index 43877d8e24..8e87b12580 100644 --- a/class_h_y___flow_path.html +++ b/class_h_y___flow_path.html @@ -433,7 +433,7 @@

    - +

diff --git a/class_h_y___hydro_feature-members.html b/class_h_y___hydro_feature-members.html index cd127d58a9..b80fb630bf 100644 --- a/class_h_y___hydro_feature-members.html +++ b/class_h_y___hydro_feature-members.html @@ -102,7 +102,7 @@ diff --git a/class_h_y___hydro_feature.html b/class_h_y___hydro_feature.html index ee3efb5749..dfc0150da8 100644 --- a/class_h_y___hydro_feature.html +++ b/class_h_y___hydro_feature.html @@ -172,7 +172,7 @@

    - +

diff --git a/class_h_y___hydro_network-members.html b/class_h_y___hydro_network-members.html index 1332a32b16..68e08f526d 100644 --- a/class_h_y___hydro_network-members.html +++ b/class_h_y___hydro_network-members.html @@ -117,7 +117,7 @@ diff --git a/class_h_y___hydro_network.html b/class_h_y___hydro_network.html index 3b55d3af88..76916c4222 100644 --- a/class_h_y___hydro_network.html +++ b/class_h_y___hydro_network.html @@ -468,7 +468,7 @@

    - +

diff --git a/class_h_y___hydro_nexus-members.html b/class_h_y___hydro_nexus-members.html index 8d9caff27c..abbe921bde 100644 --- a/class_h_y___hydro_nexus-members.html +++ b/class_h_y___hydro_nexus-members.html @@ -120,7 +120,7 @@ diff --git a/class_h_y___hydro_nexus.html b/class_h_y___hydro_nexus.html index ada21db216..894f76bcb7 100644 --- a/class_h_y___hydro_nexus.html +++ b/class_h_y___hydro_nexus.html @@ -732,7 +732,7 @@

    - +

diff --git a/class_h_y___interior_catchment-members.html b/class_h_y___interior_catchment-members.html index f722d49c46..466d06334a 100644 --- a/class_h_y___interior_catchment-members.html +++ b/class_h_y___interior_catchment-members.html @@ -131,7 +131,7 @@ diff --git a/class_h_y___interior_catchment.html b/class_h_y___interior_catchment.html index 50ed4204cb..f6a12ffb36 100644 --- a/class_h_y___interior_catchment.html +++ b/class_h_y___interior_catchment.html @@ -814,7 +814,7 @@

    - +

diff --git a/class_h_y___point_hydro_nexus-members.html b/class_h_y___point_hydro_nexus-members.html index e80f1d9991..2f088cc0b2 100644 --- a/class_h_y___point_hydro_nexus-members.html +++ b/class_h_y___point_hydro_nexus-members.html @@ -132,7 +132,7 @@ diff --git a/class_h_y___point_hydro_nexus.html b/class_h_y___point_hydro_nexus.html index 627fc370f4..f62adcaeca 100644 --- a/class_h_y___point_hydro_nexus.html +++ b/class_h_y___point_hydro_nexus.html @@ -958,7 +958,7 @@

    - +

diff --git a/class_j_s_o_n_geometry___test-members.html b/class_j_s_o_n_geometry___test-members.html index 233f0fedc4..2af967bbf2 100644 --- a/class_j_s_o_n_geometry___test-members.html +++ b/class_j_s_o_n_geometry___test-members.html @@ -104,7 +104,7 @@ diff --git a/class_j_s_o_n_geometry___test.html b/class_j_s_o_n_geometry___test.html index 5e0685edfa..31ed9e0160 100644 --- a/class_j_s_o_n_geometry___test.html +++ b/class_j_s_o_n_geometry___test.html @@ -232,7 +232,7 @@

    - +

diff --git a/class_j_s_o_n_property___test-members.html b/class_j_s_o_n_property___test-members.html index a999b22c40..0f93f0be09 100644 --- a/class_j_s_o_n_property___test-members.html +++ b/class_j_s_o_n_property___test-members.html @@ -104,7 +104,7 @@ diff --git a/class_j_s_o_n_property___test.html b/class_j_s_o_n_property___test.html index d3a80af10d..bc73782ad9 100644 --- a/class_j_s_o_n_property___test.html +++ b/class_j_s_o_n_property___test.html @@ -232,7 +232,7 @@

    - +

diff --git a/class_multi_layer_parser_test-members.html b/class_multi_layer_parser_test-members.html index e719014897..8f127692a0 100644 --- a/class_multi_layer_parser_test-members.html +++ b/class_multi_layer_parser_test-members.html @@ -112,7 +112,7 @@ diff --git a/class_multi_layer_parser_test.html b/class_multi_layer_parser_test.html index d31f302446..2e31b0da5f 100644 --- a/class_multi_layer_parser_test.html +++ b/class_multi_layer_parser_test.html @@ -475,7 +475,7 @@

    - +

diff --git a/class_network___test-members.html b/class_network___test-members.html index 44bb8348d1..f7839e8310 100644 --- a/class_network___test-members.html +++ b/class_network___test-members.html @@ -109,7 +109,7 @@ diff --git a/class_network___test.html b/class_network___test.html index 18e2bf9131..1c19b45ea8 100644 --- a/class_network___test.html +++ b/class_network___test.html @@ -400,7 +400,7 @@

    - +

diff --git a/class_network___test1-members.html b/class_network___test1-members.html index 5f91331d40..4694978f9a 100644 --- a/class_network___test1-members.html +++ b/class_network___test1-members.html @@ -112,7 +112,7 @@ diff --git a/class_network___test1.html b/class_network___test1.html index 2d16154e9f..e948555c56 100644 --- a/class_network___test1.html +++ b/class_network___test1.html @@ -433,7 +433,7 @@

    - +

diff --git a/class_network___test2-members.html b/class_network___test2-members.html index 9df20a4b98..f1539bd9bb 100644 --- a/class_network___test2-members.html +++ b/class_network___test2-members.html @@ -111,7 +111,7 @@ diff --git a/class_network___test2.html b/class_network___test2.html index 4fb66e9d42..6c966f2772 100644 --- a/class_network___test2.html +++ b/class_network___test2.html @@ -406,7 +406,7 @@

    - +

diff --git a/class_nexus___remote___test-members.html b/class_nexus___remote___test-members.html index bea0114e6a..49e40e0edd 100644 --- a/class_nexus___remote___test-members.html +++ b/class_nexus___remote___test-members.html @@ -109,7 +109,7 @@ diff --git a/class_nexus___remote___test.html b/class_nexus___remote___test.html index 3605f54ff1..db33a34054 100644 --- a/class_nexus___remote___test.html +++ b/class_nexus___remote___test.html @@ -383,7 +383,7 @@

    - +

diff --git a/class_nexus___test-members.html b/class_nexus___test-members.html index d4efab0656..deb3227d3d 100644 --- a/class_nexus___test-members.html +++ b/class_nexus___test-members.html @@ -107,7 +107,7 @@ diff --git a/class_nexus___test.html b/class_nexus___test.html index c22124604d..0a9a1c1f48 100644 --- a/class_nexus___test.html +++ b/class_nexus___test.html @@ -309,7 +309,7 @@

    - +

diff --git a/class_null_forcing_provider-members.html b/class_null_forcing_provider-members.html index 8264773892..88f584eed6 100644 --- a/class_null_forcing_provider-members.html +++ b/class_null_forcing_provider-members.html @@ -110,7 +110,7 @@ diff --git a/class_null_forcing_provider.html b/class_null_forcing_provider.html index 56818fc729..2be15733e8 100644 --- a/class_null_forcing_provider.html +++ b/class_null_forcing_provider.html @@ -483,7 +483,7 @@

diff --git a/class_partition___one-members.html b/class_partition___one-members.html index 3347f843b1..04cb7df72f 100644 --- a/class_partition___one-members.html +++ b/class_partition___one-members.html @@ -102,7 +102,7 @@ diff --git a/class_partition___one.html b/class_partition___one.html index f885073e4b..a3da5e3371 100644 --- a/class_partition___one.html +++ b/class_partition___one.html @@ -180,7 +180,7 @@

    - +
diff --git a/class_partitions___parser-members.html b/class_partitions___parser-members.html new file mode 100644 index 0000000000..6c17a4f209 --- /dev/null +++ b/class_partitions___parser-members.html @@ -0,0 +1,120 @@ + + + + + + + +NGen: Member List + + + + + + + + + + + + + +
+
+ + + + + + +
+
NGen +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
Partitions_Parser Member List
+
+
+ +

This is the complete list of members for Partitions_Parser, including all inherited members.

+ + + + + + + + + + + + + + +
catchment_idsPartitions_Parserprivate
get_mpi_rank(int part_id)Partitions_Parserinline
get_partition_struct(int part_id)Partitions_Parserinline
mpi_world_rankPartitions_Parserprivate
nexus_idsPartitions_Parserprivate
parse_partition_file()Partitions_Parserinline
partition_ranksPartitions_Parser
Partitions_Parser(const std::string &file_path)Partitions_Parserinline
Partitions_Parser(const boost::property_tree::ptree tree)Partitions_Parserinline
remote_connectionsPartitions_Parserprivate
remote_tuplePartitions_Parserprivate
treePartitions_Parserprivate
~Partitions_Parser()Partitions_Parserinlinevirtual
+
+ + + + diff --git a/class_partitions___parser.html b/class_partitions___parser.html new file mode 100644 index 0000000000..6d0968c694 --- /dev/null +++ b/class_partitions___parser.html @@ -0,0 +1,481 @@ + + + + + + + +NGen: Partitions_Parser Class Reference + + + + + + + + + + + + + +
+
+ + + + + + +
+
NGen +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
Partitions_Parser Class Reference
+
+
+ +

#include <Partition_Parser.hpp>

+
+ + Collaboration diagram for Partitions_Parser:
+
+
+ + + + + + + + + + + + + + + +

+Public Member Functions

 Partitions_Parser (const std::string &file_path)
 
 Partitions_Parser (const boost::property_tree::ptree tree)
 
virtual ~Partitions_Parser ()
 
void parse_partition_file ()
 
PartitionData get_partition_struct (int part_id)
 
int get_mpi_rank (int part_id)
 
+ + + +

+Public Attributes

std::vector< PartitionDatapartition_ranks
 
+ + + + + + + + + + + + + +

+Private Attributes

int mpi_world_rank
 
std::unordered_set< std::string > catchment_ids
 
std::unordered_set< std::string > nexus_ids
 
std::vector< std::tuple< int, std::string, std::string > > remote_connections
 
std::tuple< int, std::string, std::string > remote_tuple
 
boost::property_tree::ptree tree
 
+

Constructor & Destructor Documentation

+ +

◆ Partitions_Parser() [1/2]

+ +
+
+ + + + + +
+ + + + + + + + +
Partitions_Parser::Partitions_Parser (const std::string & file_path)
+
+inline
+
+ +

References tree.

+ +
+
+ +

◆ Partitions_Parser() [2/2]

+ +
+
+ + + + + +
+ + + + + + + + +
Partitions_Parser::Partitions_Parser (const boost::property_tree::ptree tree)
+
+inline
+
+ +

References tree.

+ +
+
+ +

◆ ~Partitions_Parser()

+ +
+
+ + + + + +
+ + + + + + + +
virtual Partitions_Parser::~Partitions_Parser ()
+
+inlinevirtual
+
+ +
+
+

Member Function Documentation

+ +

◆ get_mpi_rank()

+ +
+
+ + + + + +
+ + + + + + + + +
int Partitions_Parser::get_mpi_rank (int part_id)
+
+inline
+
+
+ +

◆ get_partition_struct()

+ +
+
+ + + + + +
+ + + + + + + + +
PartitionData Partitions_Parser::get_partition_struct (int part_id)
+
+inline
+
+ +

References partition_ranks.

+ +
+
+ +

◆ parse_partition_file()

+ + +

Member Data Documentation

+ +

◆ catchment_ids

+ +
+
+ + + + + +
+ + + + +
std::unordered_set<std::string> Partitions_Parser::catchment_ids
+
+private
+
+ +

Referenced by parse_partition_file().

+ +
+
+ +

◆ mpi_world_rank

+ +
+
+ + + + + +
+ + + + +
int Partitions_Parser::mpi_world_rank
+
+private
+
+ +

Referenced by get_mpi_rank().

+ +
+
+ +

◆ nexus_ids

+ +
+
+ + + + + +
+ + + + +
std::unordered_set<std::string> Partitions_Parser::nexus_ids
+
+private
+
+ +

Referenced by parse_partition_file().

+ +
+
+ +

◆ partition_ranks

+ +
+
+ + + + +
std::vector<PartitionData> Partitions_Parser::partition_ranks
+
+
+ +

◆ remote_connections

+ +
+
+ + + + + +
+ + + + +
std::vector<std::tuple<int, std::string, std::string> > Partitions_Parser::remote_connections
+
+private
+
+ +
+
+ +

◆ remote_tuple

+ +
+
+ + + + + +
+ + + + +
std::tuple<int, std::string, std::string> Partitions_Parser::remote_tuple
+
+private
+
+ +
+
+ +

◆ tree

+ +
+
+ + + + + +
+ + + + +
boost::property_tree::ptree Partitions_Parser::tree
+
+private
+
+
+
The documentation for this class was generated from the following file: +
+
+ + + + diff --git a/class_partitions___parser.js b/class_partitions___parser.js new file mode 100644 index 0000000000..0b7e85b5b2 --- /dev/null +++ b/class_partitions___parser.js @@ -0,0 +1,16 @@ +var class_partitions___parser = +[ + [ "Partitions_Parser", "class_partitions___parser.html#a499e4585ca462c14892b788bf2da10f9", null ], + [ "Partitions_Parser", "class_partitions___parser.html#ae7a44cd17e24bc06fec1aec7bc49f233", null ], + [ "~Partitions_Parser", "class_partitions___parser.html#a31cd926a275c0d00b45b14d076231234", null ], + [ "get_mpi_rank", "class_partitions___parser.html#a772bbf34bdcb23c6156981080e87f9f1", null ], + [ "get_partition_struct", "class_partitions___parser.html#a72cddafaad8fa12aa5a5a344d8dcc0c7", null ], + [ "parse_partition_file", "class_partitions___parser.html#a1667ab474aa0daa3530a42f31d89da45", null ], + [ "catchment_ids", "class_partitions___parser.html#a83284ac74ac5813cba05b0dada2d3003", null ], + [ "mpi_world_rank", "class_partitions___parser.html#a08d58c929fc40cc52b9a8337a6f9a9d2", null ], + [ "nexus_ids", "class_partitions___parser.html#a6a46163b60b747bae3140e7a0725012b", null ], + [ "partition_ranks", "class_partitions___parser.html#a77192e7019935a3740a6d275b3912ad7", null ], + [ "remote_connections", "class_partitions___parser.html#af72e01eb6a3d712e2d8e5ccd9e94de87", null ], + [ "remote_tuple", "class_partitions___parser.html#aa37cfde3d5f16a122f81a9f44cf7e491", null ], + [ "tree", "class_partitions___parser.html#aa8a46b738112a567324898164372cce9", null ] +]; \ No newline at end of file diff --git a/class_partitions___parser__coll__graph.map b/class_partitions___parser__coll__graph.map new file mode 100644 index 0000000000..8cdbe413a0 --- /dev/null +++ b/class_partitions___parser__coll__graph.map @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/class_partitions___parser__coll__graph.md5 b/class_partitions___parser__coll__graph.md5 new file mode 100644 index 0000000000..ebc01a3323 --- /dev/null +++ b/class_partitions___parser__coll__graph.md5 @@ -0,0 +1 @@ +5e2eafe7cf815a040b7a0f778f2d4e3c \ No newline at end of file diff --git a/class_partitions___parser__coll__graph.svg b/class_partitions___parser__coll__graph.svg new file mode 100644 index 0000000000..d79a382165 --- /dev/null +++ b/class_partitions___parser__coll__graph.svg @@ -0,0 +1,431 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Partitions_Parser + + +Node1 + + +Partitions_Parser +- +mpi_world_rank +- +remote_tuple +- +tree ++ +Partitions_Parser() ++ +Partitions_Parser() ++ +~Partitions_Parser() ++ +parse_partition_file() ++ +get_partition_struct() ++ +get_mpi_rank() + + + + + + + + + +Node2 + + +std::vector< PartitionData > +  +  + + + + + + + + +Node2->Node1 + + + + + + +partition_ranks + + + +Node3 + + +PartitionData ++ +mpi_world_rank +  + + + + + + + + + +Node3->Node2 + + + + + + +elements + + + +Node4 + + +std::unordered_set +< std::string > +  +  + + + + + + + + +Node4->Node1 + + + + + + -catchment_ids +-nexus_ids + + + +Node4->Node3 + + + + + + +catchment_ids ++nexus_ids + + + +Node5 + + +std::string +  +  + + + + + + + + +Node5->Node4 + + + + + + +keys + + + +Node6 + + +std::basic_string< + Char > +  +  + + + + + + + + +Node6->Node5 + + + + + + + + +Node7 + + +std::unordered_set< K > +  +  + + + + + + + + +Node7->Node4 + + + + + + < std::string > + + + +Node8 + + +K +  +  + + + + + + + + +Node8->Node7 + + + + + + +keys + + + +Node9 + + +std::vector< Tuple > ++ +elements +  + + + + + + + + + +Node9->Node3 + + + + + + +remote_connections + + + +Node10 + + +std::vector< T > +  +  + + + + + + + + +Node10->Node2 + + + + + + < PartitionData > + + + +Node10->Node9 + + + + + + < Tuple > + + + +Node12 + + +std::vector< std::tuple +< int, std::string, std +::string > > ++ +elements +  + + + + + + + + + +Node10->Node12 + + + + + + < std::tuple< int, + std::string, std::string > > + + + +Node11 + + +T +  +  + + + + + + + + +Node11->Node10 + + + + + + +elements + + + +Node12->Node1 + + + + + + -remote_connections + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/class_partitions___parser__coll__graph_org.svg b/class_partitions___parser__coll__graph_org.svg new file mode 100644 index 0000000000..2799bb2e58 --- /dev/null +++ b/class_partitions___parser__coll__graph_org.svg @@ -0,0 +1,349 @@ + + + + + + +Partitions_Parser + + +Node1 + + +Partitions_Parser +- +mpi_world_rank +- +remote_tuple +- +tree ++ +Partitions_Parser() ++ +Partitions_Parser() ++ +~Partitions_Parser() ++ +parse_partition_file() ++ +get_partition_struct() ++ +get_mpi_rank() + + + + + + + + + +Node2 + + +std::vector< PartitionData > +  +  + + + + + + + + +Node2->Node1 + + + + + + +partition_ranks + + + +Node3 + + +PartitionData ++ +mpi_world_rank +  + + + + + + + + + +Node3->Node2 + + + + + + +elements + + + +Node4 + + +std::unordered_set +< std::string > +  +  + + + + + + + + +Node4->Node1 + + + + + + -catchment_ids +-nexus_ids + + + +Node4->Node3 + + + + + + +catchment_ids ++nexus_ids + + + +Node5 + + +std::string +  +  + + + + + + + + +Node5->Node4 + + + + + + +keys + + + +Node6 + + +std::basic_string< + Char > +  +  + + + + + + + + +Node6->Node5 + + + + + + + + +Node7 + + +std::unordered_set< K > +  +  + + + + + + + + +Node7->Node4 + + + + + + < std::string > + + + +Node8 + + +K +  +  + + + + + + + + +Node8->Node7 + + + + + + +keys + + + +Node9 + + +std::vector< Tuple > ++ +elements +  + + + + + + + + + +Node9->Node3 + + + + + + +remote_connections + + + +Node10 + + +std::vector< T > +  +  + + + + + + + + +Node10->Node2 + + + + + + < PartitionData > + + + +Node10->Node9 + + + + + + < Tuple > + + + +Node12 + + +std::vector< std::tuple +< int, std::string, std +::string > > ++ +elements +  + + + + + + + + + +Node10->Node12 + + + + + + < std::tuple< int, + std::string, std::string > > + + + +Node11 + + +T +  +  + + + + + + + + +Node11->Node10 + + + + + + +elements + + + +Node12->Node1 + + + + + + -remote_connections + + + diff --git a/class_reservoir_kernel_test-members.html b/class_reservoir_kernel_test-members.html index f33540234b..47eb9550dc 100644 --- a/class_reservoir_kernel_test-members.html +++ b/class_reservoir_kernel_test-members.html @@ -136,7 +136,7 @@ diff --git a/class_reservoir_kernel_test.html b/class_reservoir_kernel_test.html index 1c7037b1df..3cbf06631b 100644 --- a/class_reservoir_kernel_test.html +++ b/class_reservoir_kernel_test.html @@ -1109,7 +1109,7 @@

    - +
diff --git a/class_reservoir_timeless_kernel_test-members.html b/class_reservoir_timeless_kernel_test-members.html index 8752c9c822..dfacac7839 100644 --- a/class_reservoir_timeless_kernel_test-members.html +++ b/class_reservoir_timeless_kernel_test-members.html @@ -136,7 +136,7 @@ diff --git a/class_reservoir_timeless_kernel_test.html b/class_reservoir_timeless_kernel_test.html index 36ca29affb..917fc31d43 100644 --- a/class_reservoir_timeless_kernel_test.html +++ b/class_reservoir_timeless_kernel_test.html @@ -1109,7 +1109,7 @@

    - +
diff --git a/class_simulation___time-members.html b/class_simulation___time-members.html index b24c6b36eb..7bcf18e95f 100644 --- a/class_simulation___time-members.html +++ b/class_simulation___time-members.html @@ -118,7 +118,7 @@ diff --git a/class_simulation___time.html b/class_simulation___time.html index 044ce8219d..451408d6db 100644 --- a/class_simulation___time.html +++ b/class_simulation___time.html @@ -699,7 +699,7 @@

    - +
diff --git a/class_units_helper-members.html b/class_units_helper-members.html index 7019f7e126..4136e02456 100644 --- a/class_units_helper-members.html +++ b/class_units_helper-members.html @@ -108,7 +108,7 @@ diff --git a/class_units_helper.html b/class_units_helper.html index 6d3f0e758a..e12bfdb1c3 100644 --- a/class_units_helper.html +++ b/class_units_helper.html @@ -425,7 +425,7 @@

    - +
diff --git a/class_units_helper___test-members.html b/class_units_helper___test-members.html index 057304774e..a457e8f709 100644 --- a/class_units_helper___test-members.html +++ b/class_units_helper___test-members.html @@ -103,7 +103,7 @@ diff --git a/class_units_helper___test.html b/class_units_helper___test.html index f6f3d05f0d..70743c56bb 100644 --- a/class_units_helper___test.html +++ b/class_units_helper___test.html @@ -209,7 +209,7 @@

    - +
diff --git a/class_visitor-members.html b/class_visitor-members.html index 56f3dd0102..88547d6451 100644 --- a/class_visitor-members.html +++ b/class_visitor-members.html @@ -109,7 +109,7 @@ diff --git a/class_visitor.html b/class_visitor.html index f3023b565c..3d660e9722 100644 --- a/class_visitor.html +++ b/class_visitor.html @@ -417,7 +417,7 @@

    - +
diff --git a/classbmi_1_1_bmi-members.html b/classbmi_1_1_bmi-members.html index fd76659c4f..650ddec555 100644 --- a/classbmi_1_1_bmi-members.html +++ b/classbmi_1_1_bmi-members.html @@ -141,7 +141,7 @@ diff --git a/classbmi_1_1_bmi.html b/classbmi_1_1_bmi.html index fbe1c755ab..e95509749d 100644 --- a/classbmi_1_1_bmi.html +++ b/classbmi_1_1_bmi.html @@ -1517,7 +1517,7 @@

    - +
diff --git a/classdata__access_1_1_data_provider-members.html b/classdata__access_1_1_data_provider-members.html index 1b893da304..334d1fb20c 100644 --- a/classdata__access_1_1_data_provider-members.html +++ b/classdata__access_1_1_data_provider-members.html @@ -109,7 +109,7 @@ diff --git a/classdata__access_1_1_data_provider.html b/classdata__access_1_1_data_provider.html index 5fe3e745db..9dad64997d 100644 --- a/classdata__access_1_1_data_provider.html +++ b/classdata__access_1_1_data_provider.html @@ -514,7 +514,7 @@

    - +
diff --git a/classdata__access_1_1_deferred_wrapped_provider-members.html b/classdata__access_1_1_deferred_wrapped_provider-members.html index 3794ed6f48..69c34f934f 100644 --- a/classdata__access_1_1_deferred_wrapped_provider-members.html +++ b/classdata__access_1_1_deferred_wrapped_provider-members.html @@ -122,7 +122,7 @@ diff --git a/classdata__access_1_1_deferred_wrapped_provider.html b/classdata__access_1_1_deferred_wrapped_provider.html index ba927c6e4d..9929e8117d 100644 --- a/classdata__access_1_1_deferred_wrapped_provider.html +++ b/classdata__access_1_1_deferred_wrapped_provider.html @@ -853,7 +853,7 @@

diff --git a/classdata__access_1_1_generic_data_provider-members.html b/classdata__access_1_1_generic_data_provider-members.html index d7ac424c9c..a226965099 100644 --- a/classdata__access_1_1_generic_data_provider-members.html +++ b/classdata__access_1_1_generic_data_provider-members.html @@ -109,7 +109,7 @@ diff --git a/classdata__access_1_1_generic_data_provider.html b/classdata__access_1_1_generic_data_provider.html index 849d15a146..ca65d511dc 100644 --- a/classdata__access_1_1_generic_data_provider.html +++ b/classdata__access_1_1_generic_data_provider.html @@ -449,7 +449,7 @@

diff --git a/classdata__access_1_1_optional_wrapped_data_provider-members.html b/classdata__access_1_1_optional_wrapped_data_provider-members.html index f8a3c36fb0..dbab0e4961 100644 --- a/classdata__access_1_1_optional_wrapped_data_provider-members.html +++ b/classdata__access_1_1_optional_wrapped_data_provider-members.html @@ -136,7 +136,7 @@ diff --git a/classdata__access_1_1_optional_wrapped_data_provider.html b/classdata__access_1_1_optional_wrapped_data_provider.html index 0321119808..00653d91f3 100644 --- a/classdata__access_1_1_optional_wrapped_data_provider.html +++ b/classdata__access_1_1_optional_wrapped_data_provider.html @@ -1366,7 +1366,7 @@

diff --git a/classdata__access_1_1_wrapped_data_provider-members.html b/classdata__access_1_1_wrapped_data_provider-members.html index a160f8ad43..7ca81789e9 100644 --- a/classdata__access_1_1_wrapped_data_provider-members.html +++ b/classdata__access_1_1_wrapped_data_provider-members.html @@ -113,7 +113,7 @@ diff --git a/classdata__access_1_1_wrapped_data_provider.html b/classdata__access_1_1_wrapped_data_provider.html index f55df3672d..3ffa4f095c 100644 --- a/classdata__access_1_1_wrapped_data_provider.html +++ b/classdata__access_1_1_wrapped_data_provider.html @@ -632,7 +632,7 @@

diff --git a/classes.html b/classes.html index 9620743142..4284a12401 100644 --- a/classes.html +++ b/classes.html @@ -138,7 +138,7 @@
Object (geojson)
OptionalWrappedDataProvider (data_access)
P
-
Partition_One
PartitionData
PointFeature (geojson)
PolygonFeature (geojson)
preorder_visitor (network)
+
Partition_One
PartitionData
Partitions_Parser
PointFeature (geojson)
PolygonFeature (geojson)
preorder_visitor (network)
R
request_from_empty_nexus
ReservoirKernelTest
ReservoirTimelessKernelTest
Routing (realization::config)
routing_params
@@ -163,7 +163,7 @@ diff --git a/classexternal_1_1_external_integration_exception-members.html b/classexternal_1_1_external_integration_exception-members.html index f96a1d622f..05d9c40cba 100644 --- a/classexternal_1_1_external_integration_exception-members.html +++ b/classexternal_1_1_external_integration_exception-members.html @@ -106,7 +106,7 @@ diff --git a/classexternal_1_1_external_integration_exception.html b/classexternal_1_1_external_integration_exception.html index 1972e7a4db..1bbf98d69b 100644 --- a/classexternal_1_1_external_integration_exception.html +++ b/classexternal_1_1_external_integration_exception.html @@ -304,7 +304,7 @@

diff --git a/classgeojson_1_1_collection_feature-members.html b/classgeojson_1_1_collection_feature-members.html index 86954a9586..b027f8d64e 100644 --- a/classgeojson_1_1_collection_feature-members.html +++ b/classgeojson_1_1_collection_feature-members.html @@ -178,7 +178,7 @@ diff --git a/classgeojson_1_1_collection_feature.html b/classgeojson_1_1_collection_feature.html index ea4a724e3c..941f7d01d1 100644 --- a/classgeojson_1_1_collection_feature.html +++ b/classgeojson_1_1_collection_feature.html @@ -2650,7 +2650,7 @@

    - +
diff --git a/classgeojson_1_1_feature_base-members.html b/classgeojson_1_1_feature_base-members.html index 3fb8803f91..ecb262e899 100644 --- a/classgeojson_1_1_feature_base-members.html +++ b/classgeojson_1_1_feature_base-members.html @@ -162,7 +162,7 @@ diff --git a/classgeojson_1_1_feature_base.html b/classgeojson_1_1_feature_base.html index 266e586eac..ac4f4d16c5 100644 --- a/classgeojson_1_1_feature_base.html +++ b/classgeojson_1_1_feature_base.html @@ -2289,7 +2289,7 @@

    - +
diff --git a/classgeojson_1_1_feature_collection-members.html b/classgeojson_1_1_feature_collection-members.html index 689fd40915..175fdf10fa 100644 --- a/classgeojson_1_1_feature_collection-members.html +++ b/classgeojson_1_1_feature_collection-members.html @@ -138,7 +138,7 @@ diff --git a/classgeojson_1_1_feature_collection.html b/classgeojson_1_1_feature_collection.html index 7b51fd28c6..09250fef03 100644 --- a/classgeojson_1_1_feature_collection.html +++ b/classgeojson_1_1_feature_collection.html @@ -1290,7 +1290,7 @@

    - +
diff --git a/classgeojson_1_1_feature_visitor-members.html b/classgeojson_1_1_feature_visitor-members.html index 70fc580f0d..8227d75c06 100644 --- a/classgeojson_1_1_feature_visitor-members.html +++ b/classgeojson_1_1_feature_visitor-members.html @@ -107,7 +107,7 @@ diff --git a/classgeojson_1_1_feature_visitor.html b/classgeojson_1_1_feature_visitor.html index b78eca888f..38690818bd 100644 --- a/classgeojson_1_1_feature_visitor.html +++ b/classgeojson_1_1_feature_visitor.html @@ -351,7 +351,7 @@

    - +
diff --git a/classgeojson_1_1_j_s_o_n_property-members.html b/classgeojson_1_1_j_s_o_n_property-members.html index 6f977d7b0a..cdd477eba0 100644 --- a/classgeojson_1_1_j_s_o_n_property-members.html +++ b/classgeojson_1_1_j_s_o_n_property-members.html @@ -138,7 +138,7 @@ diff --git a/classgeojson_1_1_j_s_o_n_property.html b/classgeojson_1_1_j_s_o_n_property.html index 15273fe21b..3240288054 100644 --- a/classgeojson_1_1_j_s_o_n_property.html +++ b/classgeojson_1_1_j_s_o_n_property.html @@ -869,7 +869,7 @@

References geojson::get_propertytype_name(), get_type(), key, geojson::List, geojson::Object, type, and value_list.

-

Referenced by print_property().

+

Referenced by Partitions_Parser::parse_partition_file(), and print_property().

@@ -1069,7 +1069,7 @@

References at(), geojson::get_propertytype_name(), get_type(), key, geojson::Object, type, and values.

-

Referenced by at(), nexus::Nexus_Manager::construct_nexus(), realization::Bmi_Multi_Formulation::create_multi_formulation(), geojson::FeatureBase::get(), geojson::FeatureCollection::get(), and operator==().

+

Referenced by at(), nexus::Nexus_Manager::construct_nexus(), realization::Bmi_Multi_Formulation::create_multi_formulation(), geojson::FeatureBase::get(), geojson::FeatureCollection::get(), operator==(), and Partitions_Parser::parse_partition_file().

@@ -1112,7 +1112,7 @@

References type.

-

Referenced by as_boolean(), as_list(), as_natural_number(), as_real_number(), as_string(), at(), get_values(), keys(), and print_property().

+

Referenced by as_boolean(), as_list(), as_natural_number(), as_real_number(), as_string(), at(), get_values(), keys(), Partitions_Parser::parse_partition_file(), and print_property().

@@ -1426,7 +1426,7 @@

    - +
diff --git a/classgeojson_1_1_line_string_feature-members.html b/classgeojson_1_1_line_string_feature-members.html index af367bd18f..188cba3534 100644 --- a/classgeojson_1_1_line_string_feature-members.html +++ b/classgeojson_1_1_line_string_feature-members.html @@ -163,7 +163,7 @@ diff --git a/classgeojson_1_1_line_string_feature.html b/classgeojson_1_1_line_string_feature.html index 345bb6eebf..a6bb5a501d 100644 --- a/classgeojson_1_1_line_string_feature.html +++ b/classgeojson_1_1_line_string_feature.html @@ -2212,7 +2212,7 @@

    - +
diff --git a/classgeojson_1_1_multi_line_string_feature-members.html b/classgeojson_1_1_multi_line_string_feature-members.html index 87c34969d8..6b70937437 100644 --- a/classgeojson_1_1_multi_line_string_feature-members.html +++ b/classgeojson_1_1_multi_line_string_feature-members.html @@ -163,7 +163,7 @@ diff --git a/classgeojson_1_1_multi_line_string_feature.html b/classgeojson_1_1_multi_line_string_feature.html index e0376e428d..c96f57535c 100644 --- a/classgeojson_1_1_multi_line_string_feature.html +++ b/classgeojson_1_1_multi_line_string_feature.html @@ -2212,7 +2212,7 @@

diff --git a/classgeojson_1_1_multi_point_feature-members.html b/classgeojson_1_1_multi_point_feature-members.html index abd8e24135..c9bc602dbf 100644 --- a/classgeojson_1_1_multi_point_feature-members.html +++ b/classgeojson_1_1_multi_point_feature-members.html @@ -163,7 +163,7 @@ diff --git a/classgeojson_1_1_multi_point_feature.html b/classgeojson_1_1_multi_point_feature.html index 9503918ad9..f027016b36 100644 --- a/classgeojson_1_1_multi_point_feature.html +++ b/classgeojson_1_1_multi_point_feature.html @@ -2212,7 +2212,7 @@

    - +
diff --git a/classgeojson_1_1_multi_polygon_feature-members.html b/classgeojson_1_1_multi_polygon_feature-members.html index e2fa5ecc39..ab67a2fe5c 100644 --- a/classgeojson_1_1_multi_polygon_feature-members.html +++ b/classgeojson_1_1_multi_polygon_feature-members.html @@ -163,7 +163,7 @@ diff --git a/classgeojson_1_1_multi_polygon_feature.html b/classgeojson_1_1_multi_polygon_feature.html index 96c545a037..a506ae37ee 100644 --- a/classgeojson_1_1_multi_polygon_feature.html +++ b/classgeojson_1_1_multi_polygon_feature.html @@ -2212,7 +2212,7 @@

    - +
diff --git a/classgeojson_1_1_point_feature-members.html b/classgeojson_1_1_point_feature-members.html index 1af3a9fdb0..c422ea8591 100644 --- a/classgeojson_1_1_point_feature-members.html +++ b/classgeojson_1_1_point_feature-members.html @@ -163,7 +163,7 @@ diff --git a/classgeojson_1_1_point_feature.html b/classgeojson_1_1_point_feature.html index b6ef7b74b6..2406cdf7ac 100644 --- a/classgeojson_1_1_point_feature.html +++ b/classgeojson_1_1_point_feature.html @@ -2212,7 +2212,7 @@

    - +
diff --git a/classgeojson_1_1_polygon_feature-members.html b/classgeojson_1_1_polygon_feature-members.html index 7e6f096875..2739378781 100644 --- a/classgeojson_1_1_polygon_feature-members.html +++ b/classgeojson_1_1_polygon_feature-members.html @@ -162,7 +162,7 @@ diff --git a/classgeojson_1_1_polygon_feature.html b/classgeojson_1_1_polygon_feature.html index 08bfd519e3..4f952f8a90 100644 --- a/classgeojson_1_1_polygon_feature.html +++ b/classgeojson_1_1_polygon_feature.html @@ -2209,7 +2209,7 @@

    - +
diff --git a/classhy__features_1_1_h_y___features-members.html b/classhy__features_1_1_h_y___features-members.html index f6730227df..ef53e766e6 100644 --- a/classhy__features_1_1_h_y___features-members.html +++ b/classhy__features_1_1_h_y___features-members.html @@ -119,7 +119,7 @@ diff --git a/classhy__features_1_1_h_y___features.html b/classhy__features_1_1_h_y___features.html index 59c05b6d4a..ca48ead80c 100644 --- a/classhy__features_1_1_h_y___features.html +++ b/classhy__features_1_1_h_y___features.html @@ -821,7 +821,7 @@

    - +
diff --git a/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location-members.html b/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location-members.html index 7c00813d97..97d92205ed 100644 --- a/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location-members.html +++ b/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location-members.html @@ -117,7 +117,7 @@ diff --git a/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location.html b/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location.html index 4f2ef8ef14..69e32ca17c 100644 --- a/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location.html +++ b/classhy__features_1_1hydrolocation_1_1_h_y___hydro_location.html @@ -620,7 +620,7 @@

diff --git a/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position-members.html b/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position-members.html index fd6cd434f9..441ca16774 100644 --- a/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position-members.html +++ b/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position-members.html @@ -105,7 +105,7 @@ diff --git a/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position.html b/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position.html index e1dae64d5f..63ad9f0b31 100644 --- a/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position.html +++ b/classhy__features_1_1hydrolocation_1_1_h_y___indirect_position.html @@ -241,7 +241,7 @@

diff --git a/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter-members.html b/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter-members.html index ab20a3f6a4..4ea1c8e81e 100644 --- a/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter-members.html +++ b/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter-members.html @@ -178,7 +178,7 @@ diff --git a/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter.html b/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter.html index 979357e8ae..2c11f25a3d 100644 --- a/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter.html +++ b/classmodels_1_1bmi_1_1_abstract_c_lib_bmi_adapter.html @@ -2750,7 +2750,7 @@

diff --git a/classmodels_1_1bmi_1_1_bmi___adapter-members.html b/classmodels_1_1bmi_1_1_bmi___adapter-members.html index 6735e4724a..8e685dd923 100644 --- a/classmodels_1_1bmi_1_1_bmi___adapter-members.html +++ b/classmodels_1_1bmi_1_1_bmi___adapter-members.html @@ -167,7 +167,7 @@ diff --git a/classmodels_1_1bmi_1_1_bmi___adapter.html b/classmodels_1_1bmi_1_1_bmi___adapter.html index c58dee170c..8526feded4 100644 --- a/classmodels_1_1bmi_1_1_bmi___adapter.html +++ b/classmodels_1_1bmi_1_1_bmi___adapter.html @@ -2367,7 +2367,7 @@

    - +
diff --git a/classmodels_1_1bmi_1_1_bmi___c___adapter-members.html b/classmodels_1_1bmi_1_1_bmi___c___adapter-members.html index 0a35888edc..1e970a3f93 100644 --- a/classmodels_1_1bmi_1_1_bmi___c___adapter-members.html +++ b/classmodels_1_1bmi_1_1_bmi___c___adapter-members.html @@ -198,7 +198,7 @@ diff --git a/classmodels_1_1bmi_1_1_bmi___c___adapter.html b/classmodels_1_1bmi_1_1_bmi___c___adapter.html index dc92d6816c..a6cc59bab0 100644 --- a/classmodels_1_1bmi_1_1_bmi___c___adapter.html +++ b/classmodels_1_1bmi_1_1_bmi___c___adapter.html @@ -3805,7 +3805,7 @@

    - +
diff --git a/classmodels_1_1bmi_1_1_bmi___cpp___adapter-members.html b/classmodels_1_1bmi_1_1_bmi___cpp___adapter-members.html index 67e7f2d9c0..8d2df85c9d 100644 --- a/classmodels_1_1bmi_1_1_bmi___cpp___adapter-members.html +++ b/classmodels_1_1bmi_1_1_bmi___cpp___adapter-members.html @@ -196,7 +196,7 @@ diff --git a/classmodels_1_1bmi_1_1_bmi___cpp___adapter.html b/classmodels_1_1bmi_1_1_bmi___cpp___adapter.html index 20e4b418af..5f41208d96 100644 --- a/classmodels_1_1bmi_1_1_bmi___cpp___adapter.html +++ b/classmodels_1_1bmi_1_1_bmi___cpp___adapter.html @@ -3565,7 +3565,7 @@

    - +
diff --git a/classmodels_1_1external_1_1_state___exception-members.html b/classmodels_1_1external_1_1_state___exception-members.html index 400feae8e6..30c3069fd5 100644 --- a/classmodels_1_1external_1_1_state___exception-members.html +++ b/classmodels_1_1external_1_1_state___exception-members.html @@ -106,7 +106,7 @@ diff --git a/classmodels_1_1external_1_1_state___exception.html b/classmodels_1_1external_1_1_state___exception.html index e8a18fe716..ef847732e8 100644 --- a/classmodels_1_1external_1_1_state___exception.html +++ b/classmodels_1_1external_1_1_state___exception.html @@ -306,7 +306,7 @@

diff --git a/classnetwork_1_1_network-members.html b/classnetwork_1_1_network-members.html index 6567ce73fd..25e3bcf14f 100644 --- a/classnetwork_1_1_network-members.html +++ b/classnetwork_1_1_network-members.html @@ -124,7 +124,7 @@ diff --git a/classnetwork_1_1_network.html b/classnetwork_1_1_network.html index feb2c7c31c..eb929a14ab 100644 --- a/classnetwork_1_1_network.html +++ b/classnetwork_1_1_network.html @@ -936,7 +936,7 @@

    - +
diff --git a/classnexus_1_1_nexus___manager-members.html b/classnexus_1_1_nexus___manager-members.html index 30a3358ef9..66041f4987 100644 --- a/classnexus_1_1_nexus___manager-members.html +++ b/classnexus_1_1_nexus___manager-members.html @@ -112,7 +112,7 @@ diff --git a/classnexus_1_1_nexus___manager.html b/classnexus_1_1_nexus___manager.html index e1c14bfc3f..b581bde225 100644 --- a/classnexus_1_1_nexus___manager.html +++ b/classnexus_1_1_nexus___manager.html @@ -507,7 +507,7 @@

    - +
diff --git a/classngen_1_1_domain_layer-members.html b/classngen_1_1_domain_layer-members.html index 5199ffaf61..d1fafb0faa 100644 --- a/classngen_1_1_domain_layer-members.html +++ b/classngen_1_1_domain_layer-members.html @@ -120,7 +120,7 @@ diff --git a/classngen_1_1_domain_layer.html b/classngen_1_1_domain_layer.html index 913687d2c5..2818925f98 100644 --- a/classngen_1_1_domain_layer.html +++ b/classngen_1_1_domain_layer.html @@ -675,7 +675,7 @@

    - +
diff --git a/classngen_1_1_layer-members.html b/classngen_1_1_layer-members.html index d64badcb07..d8ca80a6f0 100644 --- a/classngen_1_1_layer-members.html +++ b/classngen_1_1_layer-members.html @@ -117,7 +117,7 @@ diff --git a/classngen_1_1_layer.html b/classngen_1_1_layer.html index bae84d3f8c..0f2906efd2 100644 --- a/classngen_1_1_layer.html +++ b/classngen_1_1_layer.html @@ -687,7 +687,7 @@

    - +
diff --git a/classngen_1_1_layer_data_storage-members.html b/classngen_1_1_layer_data_storage-members.html index b94640e148..355521dc2e 100644 --- a/classngen_1_1_layer_data_storage-members.html +++ b/classngen_1_1_layer_data_storage-members.html @@ -108,7 +108,7 @@ diff --git a/classngen_1_1_layer_data_storage.html b/classngen_1_1_layer_data_storage.html index ac102a4a2b..3b44a40dbd 100644 --- a/classngen_1_1_layer_data_storage.html +++ b/classngen_1_1_layer_data_storage.html @@ -376,7 +376,7 @@

    - +
diff --git a/classngen_1_1_surface_layer-members.html b/classngen_1_1_surface_layer-members.html index 8591678738..63dddd25e9 100644 --- a/classngen_1_1_surface_layer-members.html +++ b/classngen_1_1_surface_layer-members.html @@ -120,7 +120,7 @@ diff --git a/classngen_1_1_surface_layer.html b/classngen_1_1_surface_layer.html index fa8bc5894a..e87cdbbdc5 100644 --- a/classngen_1_1_surface_layer.html +++ b/classngen_1_1_surface_layer.html @@ -463,7 +463,7 @@

Run one simulation timestep for each model in this layer.

-

@breif Run one simulation timestep for each model in this layer, then gather catchment output

+

Run one simulation timestep for each model in this layer, then gather catchment output.

Reimplemented from ngen::Layer.

@@ -672,7 +672,7 @@

    - +
diff --git a/classngen_1_1mdarray-members.html b/classngen_1_1mdarray-members.html index 224386031f..9fd566c05c 100644 --- a/classngen_1_1mdarray-members.html +++ b/classngen_1_1mdarray-members.html @@ -129,7 +129,7 @@ diff --git a/classngen_1_1mdarray.html b/classngen_1_1mdarray.html index a2fd6d1276..f80d3d2a17 100644 --- a/classngen_1_1mdarray.html +++ b/classngen_1_1mdarray.html @@ -1044,7 +1044,7 @@

    - +
diff --git a/classngen_1_1mdframe-members.html b/classngen_1_1mdframe-members.html index de9afb69c3..fde0dda307 100644 --- a/classngen_1_1mdframe-members.html +++ b/classngen_1_1mdframe-members.html @@ -112,15 +112,16 @@ operator[](const std::string &name) noexceptngen::mdframeinline size_type typedefngen::mdframe to_csv(const std::string &path, bool header=true) constngen::mdframe - types typedefngen::mdframe - variable typedefngen::mdframe - variable_map typedefngen::mdframe + to_netcdf(const std::string &path) constngen::mdframe + types typedefngen::mdframe + variable typedefngen::mdframe + variable_map typedefngen::mdframe diff --git a/classngen_1_1mdframe.html b/classngen_1_1mdframe.html index e6ceccfee1..12c66b8015 100644 --- a/classngen_1_1mdframe.html +++ b/classngen_1_1mdframe.html @@ -159,6 +159,9 @@ void to_csv (const std::string &path, bool header=true) const  Write this mdframe to a CSV file.
  +void to_netcdf (const std::string &path) const + Write this mdframe to a NetCDF file.
+  @@ -771,6 +774,32 @@

References ngen::cartesian_indices(), m_dimensions, and m_variables.

+ + + +

◆ to_netcdf()

+ +
+
+

Private Member Functions

+ + + + + + + +
void ngen::mdframe::to_netcdf (const std::string & path) const
+
+ +

Write this mdframe to a NetCDF file.

+
Parameters
+ + +
pathFile path to the output NetCDF
+
+
+

Member Data Documentation

@@ -825,6 +854,7 @@

mdframe.hpp
  • src/utilities/mdframe/handler_csv.cpp
  • +
  • src/utilities/mdframe/handler_netcdf.cpp
  • @@ -832,7 +862,7 @@

      - +
    diff --git a/classngen_1_1mdframe.js b/classngen_1_1mdframe.js index e6d8d7908a..54e4bcd2af 100644 --- a/classngen_1_1mdframe.js +++ b/classngen_1_1mdframe.js @@ -18,6 +18,7 @@ var classngen_1_1mdframe = [ "has_variable", "classngen_1_1mdframe.html#a5325430ba075edd56a7d833e5be45ad1", null ], [ "operator[]", "classngen_1_1mdframe.html#a2bfacbe7fd8dcbb8319b2431d03de743", null ], [ "to_csv", "classngen_1_1mdframe.html#ade3c60063140451b4b609319ed52fa23", null ], + [ "to_netcdf", "classngen_1_1mdframe.html#a5937e85231da22f6fa6d8502601c1ed4", null ], [ "m_dimensions", "classngen_1_1mdframe.html#ac164cdeb2a28669afa33ad1af2beeea5", null ], [ "m_variables", "classngen_1_1mdframe.html#a791692f9692232df311ad1bf01f797f3", null ] ]; \ No newline at end of file diff --git a/classngen_1_1mdframe__coll__graph.map b/classngen_1_1mdframe__coll__graph.map index e76cae5c1b..da38717b06 100644 --- a/classngen_1_1mdframe__coll__graph.map +++ b/classngen_1_1mdframe__coll__graph.map @@ -1,7 +1,7 @@ - + - + @@ -20,7 +20,7 @@ - + diff --git a/classngen_1_1mdframe__coll__graph.md5 b/classngen_1_1mdframe__coll__graph.md5 index 72b8628d87..04d86a5562 100644 --- a/classngen_1_1mdframe__coll__graph.md5 +++ b/classngen_1_1mdframe__coll__graph.md5 @@ -1 +1 @@ -1e122784614a23e042c1144be32b5601 \ No newline at end of file +4ea5a09050359c01450ca02bda320935 \ No newline at end of file diff --git a/classngen_1_1mdframe__coll__graph.svg b/classngen_1_1mdframe__coll__graph.svg index 07b1a376bc..fab6664680 100644 --- a/classngen_1_1mdframe__coll__graph.svg +++ b/classngen_1_1mdframe__coll__graph.svg @@ -4,7 +4,7 @@ - +