1#ifndef FLUX_SMOOTHING_TOOL_H
2#define FLUX_SMOOTHING_TOOL_H
4#define FLUX_SMOOTHING_TOOL_VERSION "7"
11#include "../../src/GenericManagingModule.h"
12#include "../../src/ModuleFactory.h"
44 static bool m_registered;
45 std::string m_ini_filepath{
"tools/FluxSmoothingTool.ini"};
46 std::valarray<T> m_temp_previous_timestep;
48 int m_smoothing_counter{0};
49 T m_upper_threshold{};
50 T m_lower_threshold{};
51 bool m_flux_smoothing_active{
false};
52 bool m_pre_iter{
true};
59 bool exec(std::string_view
param)
override;
61 bool init()
override {
return true; };
65 bool output()
override {
return true; };
73 return std::make_shared<FluxSmoothingTool<T>>(
sim);
75 static std::string
getName() {
return "FluxSmoothingTool"; };
76 std::string_view
getNameLocal()
const override {
return "FluxSmoothingTool"; };
87 this->sim->m_simulation_config.getStringParameters(
"ini_folder_path")};
93 std::cerr <<
"[FluxSmoothingTool]: " <<
e.what() <<
'\n';
94 throw BadInput(
static_cast<std::string
>(
"[FluxSmoothingTool]: ")
95 +
static_cast<std::string
>(
e.what()));
104 this->m_generic_submodules = this->ini_file_data.getStringVectorParameters(
"submodules");
106 m_upper_threshold = this->ini_file_data.getDoubleParameters(
"upper_threshold");
107 m_lower_threshold = this->ini_file_data.getDoubleParameters(
"lower_threshold");
108 m_initial_dt = this->sim->m_simulation_config.getDoubleParameters(
"time_delta");
112 std::cerr <<
"[FluxSmoothingTool]: " <<
e.what() <<
'\n';
113 throw BadInput(
static_cast<std::string
>(
"[FluxSmoothingTool]: ")
114 +
static_cast<std::string
>(
e.what()));
122 if (
param ==
"InitChain")
126 if (
param ==
"PreTimeStepChain")
128 return preTimeStep();
130 if (
param ==
"PostNonLinIterChain")
132 return postNonLinIter();
134 if (
param ==
"PostTimeStepChain")
136 return postTimeStep();
138 if (
param ==
"OutputChain")
153 m_temp_previous_timestep = this->sim->getField(
"Temperature");
182 if (!m_flux_smoothing_active
183 && (this->sim->getFieldValue(
"Temperature", 0)
184 > m_upper_threshold * m_temp_previous_timestep[0]
185 ||
this->sim->getFieldValue(
"Temperature", 0)
186 < m_lower_threshold * m_temp_previous_timestep[0]))
188 if (m_flux_smoothing_active)
190 throw std::runtime_error(
191 "Double smoothing needed, which is not implemented! Please choose a smaller "
194 this->sim->m_field_map[
"Temperature"] = m_temp_previous_timestep;
195 this->sim->m_simulation_config.forceValueOverwrite(
"time_delta",
196 std::to_string(m_initial_dt / 5));
197 this->sim->elapsed_time -= m_initial_dt;
198 this->sim->time_step =
199 (this->sim->time_step - 1)
201 m_flux_smoothing_active =
true;
202 m_smoothing_counter = 0;
205 if (m_flux_smoothing_active)
207 if (m_smoothing_counter == 5)
209 this->sim->m_simulation_config.forceValueOverwrite(
"time_delta",
210 std::to_string(m_initial_dt));
211 this->sim->time_step /= 5;
212 m_flux_smoothing_active =
false;
213 m_smoothing_counter = 0;
215 m_smoothing_counter++;
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
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:76