1.3.49
 
Loading...
Searching...
No Matches
InitializeEnergyBalance.cpp
1#include "InitializeEnergyBalance/InitializeEnergyBalance.h"
2
3using namespace helios;
4
5void InitializeEnergyBalance(const std::string &xml_input_file, BLConductanceModel *boundarylayerconductancemodel, EnergyBalanceModel *energybalancemodel, helios::Context *context_ptr) {
6
7 pugi::xml_document xmldoc;
8
9 std::string xml_error_string;
10 if (!open_xml_file(xml_input_file, xmldoc, xml_error_string)) {
11 helios_runtime_error(xml_error_string);
12 }
13
14 pugi::xml_node helios = xmldoc.child("helios");
15 pugi::xml_node node;
16
17 // *** Parsing of general inputs *** //
18
19 int energybalance_block_count = 0;
20 for (pugi::xml_node energybalance_block = helios.child("energybalance"); energybalance_block; energybalance_block = energybalance_block.next_sibling("energybalance")) {
21 energybalance_block_count++;
22
23 if (energybalance_block_count > 1) {
24 std::cout << "WARNING: Only one 'energybalance' block is allowed in the input file. Skipping any others..." << std::endl;
25 break;
26 }
27
28 // int direct_ray_count = 100;
29 // node = energybalance_block.child("direct_ray_count");
30 // if (node.empty()) {
31 // direct_ray_count = 0;
32 // } else {
33 //
34 // const char *direct_ray_count_str = node.child_value();
35 // if (!parse_int(direct_ray_count_str, direct_ray_count)) {
36 // helios_runtime_error("ERROR: Value given for 'direct_ray_count' could not be parsed.");
37 // } else if (direct_ray_count < 0) {
38 // helios_runtime_error("ERROR: Value given for 'direct_ray_count' must be greater than or equal to 0.");
39 // }
40 //
41 // }
42 }
43
44 energybalancemodel->addRadiationBand({"PAR", "NIR", "LW"});
45
46 std::vector<uint> ground_UUIDs;
47 try {
48 // assert( context_ptr->doesGlobalDataExist( "ground_UUIDs" ) );
49 context_ptr->getGlobalData("ground_UUIDs", ground_UUIDs);
50 boundarylayerconductancemodel->setBoundaryLayerModel(ground_UUIDs, "Ground");
51 } catch (...) {
52 std::cout << "WARNING: No ground UUIDs found" << std::endl;
53 }
54
55 if (energybalance_block_count == 0) {
56 context_ptr->setGlobalData("energybalance_enabled", false);
57 } else {
58 context_ptr->setGlobalData("energybalance_enabled", true);
59 }
60}