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 }
62}
63
70template <typename T>
72{
73 T q_sol{this->m_sim->getFieldValue(
74 "QSol", this->m_facet_number)}; // It would be more efficient to not save them to a
75 // variable, but I think code readability could suffer too
76 // much, if I only used temporaries :(
77 for (int i{0}; i < this->m_boundary_points.size(); i++)
78 {
79 int number_of_boundary_points{this->m_boundary_points[i]};
80 T surface_temperature{this->m_sim->getFieldValue(m_temperature_type, this->m_facet_number)};
81 T emissivity{this->m_sim->getFieldValue("Emissivity", this->m_facet_number)};
82 for (auto& val : this->m_capacitance_matrix_elements[i])
83 {
84 val *= 0.0;
85 }
86 this->m_stiffness_matrix_elements[i][0] += 4 * m_stefan_boltzmann_const * emissivity
87 * std::pow(surface_temperature, 3)
88 * m_area; // G_rad_fo * area
89 this->m_forcing_vector_elements[i] +=
90 (3 * m_stefan_boltzmann_const * emissivity * std::pow(surface_temperature, 4) + q_sol)
91 * m_area; // Q_sol * area - G_rad_const * area
92 }
93}
94
95#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:71
~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:35
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:92
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:118
constexpr double stefan_boltzmann_const
Definition PhysicalConstants.h:6