MoCSI API Reference
Loading...
Searching...
No Matches
BCTopSurfaceEnergyBalance.h
Go to the documentation of this file.
1#ifndef BOUNDARY_CONDITION_SURFACE_ENERGY_BALANCE
2#define BOUNDARY_CONDITION_SURFACE_ENERGY_BALANCE
3
4#include <cmath>
5#include <memory>
6#include <string>
7#include <valarray>
8#include <vector>
9
11#include "IniParser.h"
12#include "PhysicalConstants.h"
13#include "SimulationClassBase.h"
14
18template <typename T>
20{
21 private:
22 T m_area{};
23 T m_stefan_boltzmann_const{};
24 std::string m_temperature_type{"Temperature"};
25
26 public:
27 void writeBoundaryCondition() override;
28
30 std::vector<std::vector<int>> connected_points, int facet_nr,
31 T area, std::string face_prefix);
32 ~BCTopSurfaceEnergyBalance() override = default;
33};
34
46template <typename T>
48 SimulationClassBase<T>* sim, std::vector<int> boundary_points,
49 std::vector<std::vector<int>> connected_points, int facet_nr, T area, std::string face_prefix)
51 m_area{area},
52 m_stefan_boltzmann_const(PhysicalConstants::stefan_boltzmann_const)
53{
54 try
55 {
56 m_temperature_type =
57 this->m_sim->m_simulation_config.getStringParameters("boundary_temperature");
58 }
59 catch (const BadInput& e)
60 {
61 // This value is default set, therefor no error is propagated.
62 }
63}
64
71template <typename T>
73{
74 T q_sol;
75 try
76 {
77 q_sol = this->m_sim->getFieldValue(
78 "QSol", this->m_facet_number); // It would be more efficient to not save them to a
79 // variable, but I think code readability could suffer
80 // too much, if I only used temporaries :(
81 }
82 catch (const BadInput& e)
83 {
84 std::cerr << "[BCTopSurfaceEnergyBalance]: SolarFlux module not "
85 "loaded or accessable!\n "
86 "[BCTopSurfaceEnergyBalance]:"
87 << e.what() << '\n';
88 throw BadInput(static_cast<std::string>("[BCTopSurfaceEnergyBalance]: SolarFlux module not "
89 "loaded or accessable!\n "
90 "[BCTopSurfaceEnergyBalance]:")
91 + static_cast<std::string>(e.what()));
92 }
93 for (int i{0}; i < this->m_boundary_points.size(); i++)
94 {
95 int number_of_boundary_points{this->m_boundary_points[i]};
97 try
98 {
100 this->m_sim->getFieldValue(m_temperature_type, this->m_facet_number);
101 emissivity = this->m_sim->getFieldValue("Emissivity", this->m_facet_number);
102 }
103 catch (const BadInput& e)
104 {
105 std::cerr << "[BCTopSurfaceEnergyBalance]: Emissivity module not "
106 "loaded or accessable or wrong temperature_type name!\n "
107 "[BCTopSurfaceEnergyBalance]:"
108 << e.what() << '\n';
109 throw BadInput(
110 static_cast<std::string>("[BCTopSurfaceEnergyBalance]: Emissivity module not "
111 "loaded or accessable or wrong temperature_type name!\n "
112 "[BCTopSurfaceEnergyBalance]:")
113 + static_cast<std::string>(e.what()));
114 }
115 for (auto& val : this->m_capacitance_matrix_elements[i])
116 {
117 val *= 0.0;
118 }
119 this->m_stiffness_matrix_elements[i][0] += 4 * m_stefan_boltzmann_const * emissivity
120 * std::pow(surface_temperature, 3)
121 * m_area; // G_rad_fo * area
122 this->m_forcing_vector_elements[i] +=
123 (3 * m_stefan_boltzmann_const * emissivity * std::pow(surface_temperature, 4) + q_sol)
124 * m_area; // Q_sol * area - G_rad_const * area
125 }
126}
127
128#endif
Concrete implementation of a surface-energy-balance boundary condition in 1D.
Definition BCTopSurfaceEnergyBalance.h:20
void writeBoundaryCondition() override
Actual implementation of the boundary condition. Approximates the surface energy-balance-equation for...
Definition BCTopSurfaceEnergyBalance.h:72
~BCTopSurfaceEnergyBalance() override=default
BCTopSurfaceEnergyBalance(SimulationClassBase< T > *sim, std::vector< int > boundary_points, std::vector< std::vector< int > > connected_points, int facet_nr, T area, std::string face_prefix)
Constructor for a BCTopSurfaceEnergyBalance object.
Definition BCTopSurfaceEnergyBalance.h:47
This error class inherits from std::exception and marks faulty parameter or CL inputs....
Definition IniParser.h:71
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:94
Boundary condition abstract base class for the finite element method. All boundary condition implemen...
Definition GenericBoundaryCondition.h:18
std::pair< int, int > size() const
Function that returns the size of the matrix as a pair in (rows, columns) format.
Definition GenericMatrix.h:120
constexpr double stefan_boltzmann_const
Definition PhysicalConstants.h:6