9.2
general documentation
cs_time_step.h
Go to the documentation of this file.
1#ifndef CS_TIME_STEP_H
2#define CS_TIME_STEP_H
3
4/*============================================================================
5 * Base time step data.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30/*----------------------------------------------------------------------------
31 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "base/cs_defs.h"
35
36/*=============================================================================
37 * Macro definitions
38 *============================================================================*/
39
40/*============================================================================
41 * Type definitions
42 *============================================================================*/
43
44/*----------------------------------------------------------------------------
45 * Time stepping algorithme
46 *----------------------------------------------------------------------------*/
47
48typedef enum {
49
54
56
57/* time step descriptor */
58/*----------------------*/
59
61
62public:
63
64 int is_variable; /* 0 if time step is fixed in time,
65 1 if the time step is variable. */
66 int is_local; /* 0 if time step is uniform in space,
67 1 if it is local in space (in which case
68 the time value is only a reference. */
69
70 int nt_prev; /* absolute time step number reached by previous
71 computation */
72 int nt_cur; /* current absolute time step number */
73 int nt_max; /* maximum absolute time step number */
74 int nt_ini; /* Number of time steps for initialization */
75
76 double t_prev; /* physical time reached by previous
77 computation */
78 double t_cur; /* current absolute time */
79 double t_max; /* maximum absolute time */
80
81 double dt[3]; /* n, n-1, and n-2 time steps */
82 double dt_ref; /* reference time step. */
83 double dt_next; /* next (predicted) time step. */
84
85 /* Helper function to check if code needs to do at least one more iteration.
86 ------------------------------------------------------------------------ */
87
88 bool needs_iteration() const;
89
90};
91
92/* Time step options descriptor */
93/*------------------------------*/
94
95typedef struct {
96
97 int iptlro; /* Clip the time step with respect to the buoyant effects
98 - 0: false
99 - 1: true. */
100
101 cs_time_step_type_t idtvar; /* time step type (constant, adaptive, steady) */
102
103 double coumax; /* Maximum Courant number (when idtvar is
104 different from 0). */
105
106 double cflmmx; /* Maximum Courant number for the continuity equation
107 in compressible model. */
108
109 double foumax; /* Maximum Fourier number
110 (when idtvar is different from CS_TIME_STEP_CONSTANT). */
111
112 double varrdt; /* Relative allowed variation of dt
113 (when idtvar is different from CS_TIME_STEP_CONSTANT). */
114
115 double dtmin; /* Minimum value of dt
116 (when idtvar is different from CS_TIME_STEP_CONSTANT).
117 Take
118 dtmin = min(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
119
120 double dtmax; /* Maximum value of dt
121 (when idtvar is different from CS_TIME_STEP_CONSTANT).
122 Take
123 dtmax = max(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
124
125 double relxst; /* Relaxation coefficient for the steady algorithm. */
126
128
129/*============================================================================
130 * Static global variables
131 *============================================================================*/
132
133/* Pointer to main time step structure */
134
136
138
139/*=============================================================================
140 * Public function prototypes
141 *============================================================================*/
142
143/*----------------------------------------------------------------------------
144 * Provide read/write access to cs_glob_time_step
145 *
146 * returns:
147 * pointer to global time step structure
148 *----------------------------------------------------------------------------*/
149
152
153/*----------------------------------------------------------------------------
154 * Provide read/write access to cs_glob_time_step_options
155 *
156 * returns:
157 * pointer to global time step options structure
158 *----------------------------------------------------------------------------*/
159
162
163/*----------------------------------------------------------------------------
164 * Define whether time step is variable or not
165 *
166 * parameters:
167 * is_variable <-- 0 if time step is variable in time, 1 if it is fixed
168 *----------------------------------------------------------------------------*/
169
170void
171cs_time_step_define_variable(int is_variable);
172
173/*----------------------------------------------------------------------------
174 * Define whether time step is local in space or not
175 *
176 * parameters:
177 * is_local <-- 0 if time step is uniform in space, 1 if it is local
178 *----------------------------------------------------------------------------*/
179
180void
181cs_time_step_define_local(int is_local);
182
183/*----------------------------------------------------------------------------
184 * Define maximum time step number
185 *
186 * parameters:
187 * nt_max <-- maximum time step number (unlimited if negative)
188 *----------------------------------------------------------------------------*/
189
190void
192
193/*----------------------------------------------------------------------------
194 * Define maximum time value
195 *
196 * parameters:
197 * t_max <-- maximum time value (unlimited if negative)
198 *----------------------------------------------------------------------------*/
199
200void
201cs_time_step_define_t_max(double t_max);
202
203/*----------------------------------------------------------------------------
204 * Set time values from previous (usually restarted) calculations
205 *
206 * parameters:
207 * nt_prev <-- previous time step number
208 * t_prev <-- previous physical time
209 *----------------------------------------------------------------------------*/
210
211void
212cs_time_step_define_prev(int nt_prev,
213 double t_prev);
214
215/*----------------------------------------------------------------------------
216 * Increment the global time step.
217 *
218 * parameters:
219 * dt <-- time step value to increment
220 *----------------------------------------------------------------------------*/
221
222void
224
225/*----------------------------------------------------------------------------*/
234/*----------------------------------------------------------------------------*/
235
236void
238
239/*----------------------------------------------------------------------------
240 * Redefine the current time values.
241 *
242 * Remark: Using cs_time_step_increment() is preferred, but this function
243 * may be required for reverting to a previous time step.
244 *
245 * parameters:
246 * nt_cur <-- current time step number
247 * t_cur <-- current physical time
248 *----------------------------------------------------------------------------*/
249
250void
252 double t_cur);
253
254/*----------------------------------------------------------------------------*
255 * Print the time stepping options to setup.log.
256 *----------------------------------------------------------------------------*/
257
258void
260
261/*----------------------------------------------------------------------------*/
262
263#endif /* CS_TIME_STEP_H */
time step descriptor
Definition: cs_time_step.h:60
int nt_prev
Definition: cs_time_step.h:70
int is_variable
Definition: cs_time_step.h:64
int nt_ini
Definition: cs_time_step.h:74
double t_max
Definition: cs_time_step.h:79
double t_prev
Definition: cs_time_step.h:76
double dt_next
Definition: cs_time_step.h:83
int nt_cur
Definition: cs_time_step.h:72
int nt_max
Definition: cs_time_step.h:73
double t_cur
Definition: cs_time_step.h:78
int is_local
Definition: cs_time_step.h:66
double dt[3]
Definition: cs_time_step.h:81
bool needs_iteration() const
Check if at least another iteration is needed.
Definition: cs_time_step.cpp:681
double dt_ref
Definition: cs_time_step.h:82
@ dt
Definition: cs_field_pointer.h:61
const cs_time_step_t * cs_glob_time_step
cs_time_step_t * cs_get_glob_time_step(void)
Provide read/write access to cs_glob_time_step.
Definition: cs_time_step.cpp:372
cs_time_step_options_t * cs_get_glob_time_step_options(void)
Provide read/write access to cs_glob_time_step_options.
Definition: cs_time_step.cpp:386
void cs_time_step_redefine_cur(int nt_cur, double t_cur)
Redefine the current time values.
Definition: cs_time_step.cpp:553
const cs_time_step_options_t * cs_glob_time_step_options
void cs_time_step_define_nt_max(int nt_max)
Define maximum time step number.
Definition: cs_time_step.cpp:434
cs_time_step_type_t
Definition: cs_time_step.h:48
@ CS_TIME_STEP_LOCAL
Definition: cs_time_step.h:53
@ CS_TIME_STEP_STEADY
Definition: cs_time_step.h:50
@ CS_TIME_STEP_CONSTANT
Definition: cs_time_step.h:51
@ CS_TIME_STEP_ADAPTIVE
Definition: cs_time_step.h:52
void cs_time_step_define_prev(int nt_prev, double t_prev)
Set time values from previous (usually restarted) calculations.
Definition: cs_time_step.cpp:465
void cs_time_step_increment(double dt)
Increment the global time step.
Definition: cs_time_step.cpp:483
void cs_time_step_define_local(int is_local)
Define whether time step is local in space or not.
Definition: cs_time_step.cpp:417
void cs_time_step_define_variable(int is_variable)
Define whether time step is variable or not.
Definition: cs_time_step.cpp:400
void cs_time_step_define_t_max(double t_max)
Define maximum time value.
Definition: cs_time_step.cpp:449
void cs_time_step_update_dt(double dt)
Update global time step value for a time step in progress.
Definition: cs_time_step.cpp:524
void cs_time_step_log_setup(void)
Print the time stepping options to setup.log.
Definition: cs_time_step.cpp:567
time step options descriptor
Definition: cs_time_step.h:95
double foumax
Definition: cs_time_step.h:109
double cflmmx
Definition: cs_time_step.h:106
double relxst
Definition: cs_time_step.h:125
int iptlro
Definition: cs_time_step.h:97
double dtmin
Definition: cs_time_step.h:115
double coumax
Definition: cs_time_step.h:103
double dtmax
Definition: cs_time_step.h:120
cs_time_step_type_t idtvar
Definition: cs_time_step.h:101
double varrdt
Definition: cs_time_step.h:112