1#ifndef FLUX_SMOOTHING_TOOL_H
2#define FLUX_SMOOTHING_TOOL_H
11#include "../../src/GenericManagingModule.h"
12#include "../../src/ModuleFactory.h"
43 static bool m_registered;
44 std::string m_ini_filepath{
"tools/FluxSmoothingTool.ini"};
45 std::valarray<T> m_temp_previous_timestep;
47 int m_smoothing_counter{0};
48 T m_upper_threshold{};
49 T m_lower_threshold{};
50 bool m_flux_smoothing_active{
false};
51 bool m_pre_iter{
true};
58 bool exec(std::string_view
param)
override;
60 bool init()
override {
return true; };
64 bool output()
override {
return true; };
72 return std::make_shared<FluxSmoothingTool<T>>(
sim);
74 static std::string
getName() {
return "FluxSmoothingTool"; };
75 std::string_view
getNameLocal()
const override {
return "FluxSmoothingTool"; };
86 this->sim->m_simulation_config.getStringParameters(
"ini_folder_path")};
92 std::cerr <<
e.what() <<
'\n';
99 this->m_generic_submodules = this->ini_file_data.getStringVectorParameters(
"submodules");
101 m_upper_threshold = this->ini_file_data.getDoubleParameters(
"upper_threshold");
102 m_lower_threshold = this->ini_file_data.getDoubleParameters(
"lower_threshold");
103 m_initial_dt = this->sim->m_simulation_config.getDoubleParameters(
"time_delta");
111 if (
param ==
"InitChain")
115 if (
param ==
"PreTimeStepChain")
117 return preTimeStep();
119 if (
param ==
"PostNonLinIterChain")
121 return postNonLinIter();
123 if (
param ==
"PostTimeStepChain")
125 return postTimeStep();
127 if (
param ==
"OutputChain")
142 m_temp_previous_timestep = this->sim->getField(
"Temperature");
171 if (!m_flux_smoothing_active
172 && (this->sim->getFieldValue(
"Temperature", 0)
173 > m_upper_threshold * m_temp_previous_timestep[0]
174 ||
this->sim->getFieldValue(
"Temperature", 0)
175 < m_lower_threshold * m_temp_previous_timestep[0]))
177 if (m_flux_smoothing_active)
179 throw std::runtime_error(
180 "Double smoothing needed, which is not implemented! Please choose a smaller "
183 this->sim->m_field_map[
"Temperature"] = m_temp_previous_timestep;
184 this->sim->m_simulation_config.forceValueOverwrite(
"time_delta",
185 std::to_string(m_initial_dt / 5));
186 this->sim->elapsed_time -= m_initial_dt;
187 this->sim->time_step =
188 (this->sim->time_step - 1)
190 m_flux_smoothing_active =
true;
191 m_smoothing_counter = 0;
194 if (m_flux_smoothing_active)
196 if (m_smoothing_counter == 5)
198 this->sim->m_simulation_config.forceValueOverwrite(
"time_delta",
199 std::to_string(m_initial_dt));
200 this->sim->time_step /= 5;
201 m_flux_smoothing_active =
false;
202 m_smoothing_counter = 0;
204 m_smoothing_counter++;
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:35
Abstract base class for the managing modules. Managing modules are the highest tier of modules and ar...
Definition GenericManagingModule.h:29
InputManager ini_file_data
Definition GenericManagingModule.h:38
SimulationClassBase< T > * sim
Definition GenericManagingModule.h:31
std::vector< std::string > m_generic_submodules
Definition GenericManagingModule.h:36
static constexpr bool registerModule(std::string name, creation_method module) noexcept
Function that adds a module to the module registry map.
Definition ModuleFactory.h:68