8.3
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-2024 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 "cs_defs.h"
35
36/*----------------------------------------------------------------------------*/
37
39
40/*=============================================================================
41 * Macro definitions
42 *============================================================================*/
43
44/*============================================================================
45 * Type definitions
46 *============================================================================*/
47
48/*----------------------------------------------------------------------------
49 * Time stepping algorithme
50 *----------------------------------------------------------------------------*/
51
52typedef enum {
53
58
60
61/* time step descriptor */
62/*----------------------*/
63
64typedef struct {
65
66 int is_variable; /* 0 if time step is fixed in time,
67 1 if the time step is variable. */
68 int is_local; /* 0 if time step is uniform in space,
69 1 if it is local in space (in which case
70 the time value is only a reference. */
71
72 int nt_prev; /* absolute time step number reached by previous
73 computation */
74 int nt_cur; /* current absolute time step number */
75 int nt_max; /* maximum absolute time step number */
76 int nt_ini; /* Number of time steps for initialization */
77
78 double t_prev; /* physical time reached by previous
79 computation */
80 double t_cur; /* current absolute time */
81 double t_max; /* maximum absolute time */
82
83 double dt[3]; /* n, n-1, and n-2 time steps */
84 double dt_ref; /* reference time step. */
85 double dt_next; /* next (predicted) time step. */
86
88
89/* Time step options descriptor */
90/*------------------------------*/
91
92typedef struct {
93
94 int iptlro; /* Clip the time step with respect to the buoyant effects
95 - 0: false
96 - 1: true. */
97
98 cs_time_step_type_t idtvar; /* time step type (constant, adaptive, steady) */
99
100 double coumax; /* Maximum Courant number (when idtvar is
101 different from 0). */
102
103 double cflmmx; /* Maximum Courant number for the continuity equation
104 in compressible model. */
105
106 double foumax; /* Maximum Fourier number
107 (when idtvar is different from CS_TIME_STEP_CONSTANT). */
108
109 double varrdt; /* Relative allowed variation of dt
110 (when idtvar is different from CS_TIME_STEP_CONSTANT). */
111
112 double dtmin; /* Minimum value of dt
113 (when idtvar is different from CS_TIME_STEP_CONSTANT).
114 Take
115 dtmin = min(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
116
117 double dtmax; /* Maximum value of dt
118 (when idtvar is different from CS_TIME_STEP_CONSTANT).
119 Take
120 dtmax = max(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
121
122 double relxst; /* Relaxation coefficient for the steady algorithm. */
123
125
126/*============================================================================
127 * Static global variables
128 *============================================================================*/
129
130/* Pointer to main time step structure */
131
133
135
136/*=============================================================================
137 * Public function prototypes
138 *============================================================================*/
139
140/*----------------------------------------------------------------------------
141 * Provide read/write access to cs_glob_time_step
142 *
143 * returns:
144 * pointer to global time step structure
145 *----------------------------------------------------------------------------*/
146
149
150/*----------------------------------------------------------------------------
151 * Provide read/write access to cs_glob_time_step_options
152 *
153 * returns:
154 * pointer to global time step options structure
155 *----------------------------------------------------------------------------*/
156
159
160/*----------------------------------------------------------------------------
161 * Define whether time step is variable or not
162 *
163 * parameters:
164 * is_variable <-- 0 if time step is variable in time, 1 if it is fixed
165 *----------------------------------------------------------------------------*/
166
167void
168cs_time_step_define_variable(int is_variable);
169
170/*----------------------------------------------------------------------------
171 * Define whether time step is local in space or not
172 *
173 * parameters:
174 * is_local <-- 0 if time step is uniform in space, 1 if it is local
175 *----------------------------------------------------------------------------*/
176
177void
178cs_time_step_define_local(int is_local);
179
180/*----------------------------------------------------------------------------
181 * Define maximum time step number
182 *
183 * parameters:
184 * nt_max <-- maximum time step number (unlimited if negative)
185 *----------------------------------------------------------------------------*/
186
187void
189
190/*----------------------------------------------------------------------------
191 * Define maximum time value
192 *
193 * parameters:
194 * t_max <-- maximum time value (unlimited if negative)
195 *----------------------------------------------------------------------------*/
196
197void
198cs_time_step_define_t_max(double t_max);
199
200/*----------------------------------------------------------------------------
201 * Set time values from previous (usually restarted) calculations
202 *
203 * parameters:
204 * nt_prev <-- previous time step number
205 * t_prev <-- previous physical time
206 *----------------------------------------------------------------------------*/
207
208void
209cs_time_step_define_prev(int nt_prev,
210 double t_prev);
211
212/*----------------------------------------------------------------------------
213 * Increment the global time step.
214 *
215 * parameters:
216 * dt <-- time step value to increment
217 *----------------------------------------------------------------------------*/
218
219void
221
222/*----------------------------------------------------------------------------*/
231/*----------------------------------------------------------------------------*/
232
233void
235
236/*----------------------------------------------------------------------------
237 * Redefine the current time values.
238 *
239 * Remark: Using cs_time_step_increment() is preferred, but this function
240 * may be required for reverting to a previous time step.
241 *
242 * parameters:
243 * nt_cur <-- current time step number
244 * t_cur <-- current physical time
245 *----------------------------------------------------------------------------*/
246
247void
249 double t_cur);
250
251/*----------------------------------------------------------------------------*
252 * Print the time stepping options to setup.log.
253 *----------------------------------------------------------------------------*/
254
255void
257
258/*----------------------------------------------------------------------------*/
259
261
262#endif /* __CS_TIME_STEP_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
#define END_C_DECLS
Definition: cs_defs.h:543
@ dt
Definition: cs_field_pointer.h:65
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:401
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:415
void cs_time_step_redefine_cur(int nt_cur, double t_cur)
Redefine the current time values.
Definition: cs_time_step.cpp:582
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:463
cs_time_step_type_t
Definition: cs_time_step.h:52
@ CS_TIME_STEP_LOCAL
Definition: cs_time_step.h:57
@ CS_TIME_STEP_STEADY
Definition: cs_time_step.h:54
@ CS_TIME_STEP_CONSTANT
Definition: cs_time_step.h:55
@ CS_TIME_STEP_ADAPTIVE
Definition: cs_time_step.h:56
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:494
void cs_time_step_increment(double dt)
Increment the global time step.
Definition: cs_time_step.cpp:512
void cs_time_step_define_local(int is_local)
Define whether time step is local in space or not.
Definition: cs_time_step.cpp:446
void cs_time_step_define_variable(int is_variable)
Define whether time step is variable or not.
Definition: cs_time_step.cpp:429
void cs_time_step_define_t_max(double t_max)
Define maximum time value.
Definition: cs_time_step.cpp:478
void cs_time_step_update_dt(double dt)
Update global time step value for a time step in progress.
Definition: cs_time_step.cpp:553
void cs_time_step_log_setup(void)
Print the time stepping options to setup.log.
Definition: cs_time_step.cpp:596
time step options descriptor
Definition: cs_time_step.h:92
double foumax
Definition: cs_time_step.h:106
double cflmmx
Definition: cs_time_step.h:103
double relxst
Definition: cs_time_step.h:122
int iptlro
Definition: cs_time_step.h:94
double dtmin
Definition: cs_time_step.h:112
double coumax
Definition: cs_time_step.h:100
double dtmax
Definition: cs_time_step.h:117
cs_time_step_type_t idtvar
Definition: cs_time_step.h:98
double varrdt
Definition: cs_time_step.h:109
time step descriptor
Definition: cs_time_step.h:64
int nt_prev
Definition: cs_time_step.h:72
int is_variable
Definition: cs_time_step.h:66
int nt_ini
Definition: cs_time_step.h:76
double t_max
Definition: cs_time_step.h:81
double t_prev
Definition: cs_time_step.h:78
double dt_next
Definition: cs_time_step.h:85
int nt_cur
Definition: cs_time_step.h:74
int nt_max
Definition: cs_time_step.h:75
double t_cur
Definition: cs_time_step.h:80
int is_local
Definition: cs_time_step.h:68
double dt_ref
Definition: cs_time_step.h:84