Skip to content
Snippets Groups Projects
Commit 33b1ca50 authored by Feliks Kiszkurno's avatar Feliks Kiszkurno Committed by Dmitri Naumov
Browse files

Linearly spaced time stepping option

parent 32da72c3
No related branches found
No related tags found
No related merge requests found
An optional parameter specifying the number of time steps.
All time steps will be of the same size \f$(t_{\rm end} - t_{\rm initial}) \over n\f$.
For more complex setups see the `timesteps` parameter documentation.
......@@ -28,6 +28,37 @@ FixedTimeSteppingParameters parseFixedTimeStepping(
auto const t_initial = config.getConfigParameter<double>("t_initial");
//! \ogs_file_param{prj__time_loop__processes__process__time_stepping__FixedTimeStepping__t_end}
auto const t_end = config.getConfigParameter<double>("t_end");
//! \ogs_file_param{prj__time_loop__processes__process__time_stepping__FixedTimeStepping__n_steps}
auto const n_steps = config.getConfigParameterOptional<int>("n_steps");
if (n_steps.has_value())
{
if (t_end <= t_initial)
{
OGS_FATAL(
"Creating linearly spaced time steps vector using "
"FixedTimeStepping algorithm failed! "
"User provided start value (t_initial) "
"{} is not smaller then end value (t_end) {}.",
t_initial, t_end);
}
if (*n_steps <= 0)
{
OGS_FATAL(
"Requested number of time steps in time steps vector "
"(n_steps) must be greater then 0. "
"{} time steps were requested",
*n_steps);
}
// Create the RepeatDtPair
std::size_t const t_step = static_cast<std::size_t>(
(t_end - t_initial) / static_cast<double>(*n_steps));
std::vector const repeat_pairs = {
RepeatDtPair{static_cast<std::size_t>(*n_steps), t_step}};
return {t_initial, t_end, repeat_pairs};
}
//! \ogs_file_param{prj__time_loop__processes__process__time_stepping__FixedTimeStepping__timesteps}
auto const delta_ts_config = config.getConfigSubtree("timesteps");
......
......@@ -53,12 +53,7 @@
<type>FixedTimeStepping</type>
<t_initial> 0.0 </t_initial>
<t_end> 39062500 </t_end>
<timesteps>
<pair>
<repeat>500</repeat>
<delta_t>78125</delta_t>
</pair>
</timesteps>
<n_steps>500</n_steps>
</time_stepping>
</process>
</processes>
......
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProjectDiff base_file="../line_60_heat.prj">
<remove sel="/*/time_loop/processes/process/time_stepping/timesteps"/>
<remove sel="/*/time_loop/processes/process/time_stepping/n_steps"/>
<add sel="/*/time_loop/processes/process/time_stepping">
<timesteps>
<pair>
......
......@@ -4,7 +4,7 @@
<linear>true</linear>
</add>
<remove sel="/*/time_loop/processes/process/time_stepping/timesteps"/>
<remove sel="/*/time_loop/processes/process/time_stepping/n_steps"/>
<add sel="/*/time_loop/processes/process/time_stepping">
<timesteps>
<pair>
......
......@@ -5,7 +5,7 @@
<linear_solver_compute_only_upon_timestep_change>true</linear_solver_compute_only_upon_timestep_change>
</add>
<remove sel="/*/time_loop/processes/process/time_stepping/timesteps"/>
<remove sel="/*/time_loop/processes/process/time_stepping/n_steps"/>
<add sel="/*/time_loop/processes/process/time_stepping">
<timesteps>
<pair>
......
......@@ -111,6 +111,20 @@ unit:
</time_stepping>
```
Fixed time stepping can be also used to create linearly spaced steps between `t_initial` and `t_end`.
The number of steps is defined by `n_steps`.
```xml
<time_stepping>
<type>FixedTimeStepping</type>
<t_initial>0</t_initial>
<t_end>10</t_end>
<n_steps>10</n_steps>
</time_stepping>
```
will result in 11 time steps at: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
As fixed time stepping is one of the simplest available, it is a good starting point.
#### Iteration number based time stepping
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment