8#include <deal.II/base/exceptions.h>
31 ExcMessage(
"The 'flow direction' of the 'flow control' subsection is " +
33 ", but it must be smaller than the dimension of the problem (" +
34 std::to_string(dim) +
"). Set it to 0 for x, 1 for y" +
35 (dim == 3 ?
" or 2 for z." :
".")));
41 const double &dt)
const
49 const double &dt)
const
51 const double new_beta =
71 const unsigned int &step_number)
95 double new_beta = 0.0;
104 else if (step_number == 1)
123 else if (step_number == 2)
158 const std::string filename = prefix +
".flowcontrol";
159 std::ofstream output(filename);
163 output << std::setprecision(std::numeric_limits<double>::max_digits10);
164 output <<
"Flow control" << std::endl;
176 const std::string filename = prefix +
".flowcontrol";
178 "checkpoint file of the dynamic flow control, given by "
179 "'subsection restart' - 'set filename'");
180 std::ifstream input(filename);
183 std::getline(input, buffer);
189 AssertThrow(!input.fail(),
191 "The checkpoint file of the dynamic flow control <" + filename +
192 "> could not be read: it is truncated or does not have the "
193 "expected format. Restart from a complete checkpoint written "
194 "by a simulation with the flow control enabled."));
Dynamic flow controller that drives the average velocity of the flow towards a target value.
double alpha
Relaxation coefficient of the controllers.
double force_free_velocity_band_factor
double previous_average_velocity
Average velocity of the previous time step.
void read(const std::string &prefix)
Read the state of the flow controller from a checkpoint file.
unsigned int flow_direction
Direction of the flow (0 for x, 1 for y and 2 for z).
bool force_free_deceleration_is_allowed
double main_flow_controller(const double &average_velocity_n, const double &dt) const
Calculate a beta force from the previous beta force and the average velocities of the last two time s...
static constexpr double zero_beta_tolerance
Below this magnitude, a beta force is considered to be zero.
double proportional_flow_controller(const double &average_velocity_n, const double &dt) const
Calculate a beta force from the last average velocity only. It is used for the first and second time ...
double target_average_velocity
Target average velocity.
void calculate_beta(const double &average_velocity_n, const double &dt, const unsigned int &step_number)
Calculate the beta force coefficient applied during the current time step.
double previous_beta
Beta force applied during the previous time step.
void save(const std::string &prefix) const
Save the state of the flow controller to a checkpoint file.
static constexpr double minimum_force_free_velocity_band_factor
FlowControl(const Parameters::DynamicFlowControl &flow_control)
Constructor of the flow controller.
void check_file_exists(const std::string &file_name, const std::string &file_description)
Verify that a file that Lethe must read exists and can be opened, and raise an error stated in the us...
FlowControl - Set average velocity on a boundary (CFD) or the domain (CFD-DEM).