Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
sub_simulation_control.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5
6#include <cmath>
7
8
11 const double time_interval,
12 const unsigned int coupling_frequency,
22{
23 Assert(this->time_interval > 0,
24 ExcMessage("The time interval must be strictly positive"));
25
26
27 if (this->iteration_logic == DEMSubIterationLogic::fixed_number_of_iterations)
28 {
29 Assert(
30 this->coupling_frequency > 0,
31 ExcMessage(
32 "The coupling frequency must be positive. A value of zero or a negative value was encountered. The simulation will stop."));
33
34 // A fixed number of iterations is requested, the time step is fixed
35 // using the coupling frequency and the time interval.
36 time_step = this->time_interval / this->coupling_frequency;
37 total_number_of_iterations = this->coupling_frequency;
38 }
39 else //(iteration_logic ==
40 // DEMSubIterationLogic::fixed_fraction_of_rayleigh_time_step)
41 {
42 Assert(this->rayleigh_characteristic_time > 0,
43 ExcMessage(
44 "The Rayleigh characteristic time must be strictly positive"));
45 Assert(
46 this->fraction_of_rayleigh_characteristic_time > 0,
47 ExcMessage(
48 "The fraction of the Rayleigh characteristic time must be strictly positive"));
49
50 // A fixed fraction of the Rayleigh time step is used. The number of
51 // iterations will be manually calculated
52 time_step = this->fraction_of_rayleigh_characteristic_time *
53 this->rayleigh_characteristic_time;
54
55 // We calculate the total number of iterations with the proposed time step
56 // We then take the ceiling of it to have a integer number of time steps
58 static_cast<unsigned int>(std::ceil(this->time_interval / time_step));
59
60 // Since the total number of iterations needs to be an integer, the actual
61 // value of the time step may have changed as a result of the previous
62 // calculations. We then recalculate the time step.
63 time_step = this->time_interval / double(total_number_of_iterations);
64
65 Assert(
67 ExcMessage(
68 "The total number of iterations for the DEM sub simulation control is below 0."
69 " Something went wrong with either the fraction of the Rayleigh characteristic time or the Rayleigh characteristic time provided."));
70 }
71}
72
73bool
75{
77 return false;
78
80 return true;
81}
double time_step
Time step value of the sub time stepping.
unsigned int iteration_number
Current value of the sub iteration number. This is initialized to zero.
const DEMSubIterationLogic iteration_logic
Logic used for the DEM iterations.
const double rayleigh_characteristic_time
Rayleigh characteristic time for the particles.
SubSimulationControlDEM(const DEMSubIterationLogic iteration_logic, const double time_interval, const unsigned int coupling_frequency, const double rayleigh_characteristic_time, const double fraction_of_rayleigh_characteristic_time)
Construct a SubSimulationControlDEM object.
DEMSubIterationLogic
Type of iteration method for DEM sub simulation control.
@ fixed_number_of_iterations
Fixed number of DEM iterations per CFD time step.
const double time_interval
Time interval over which the time integration is to be carried out.
const double fraction_of_rayleigh_characteristic_time
const unsigned int coupling_frequency
bool iterate()
Advance the DEM sub simulation by one iteration.
Controls smaller simulation blocks within simulations.