7.0
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-2021 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 
52 typedef enum {
53 
58 
60 
61 /* time step descriptor */
62 /*----------------------*/
63 
64 typedef 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 
92 typedef 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 
132 extern const cs_time_step_t *cs_glob_time_step;
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 
167 void
168 cs_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 
177 void
178 cs_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 
187 void
188 cs_time_step_define_nt_max(int nt_max);
189 
190 /*----------------------------------------------------------------------------
191  * Define maximum time value
192  *
193  * parameters:
194  * t_max <-- maximum time value (unlimited if negative)
195  *----------------------------------------------------------------------------*/
196 
197 void
198 cs_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 
208 void
209 cs_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 
219 void
220 cs_time_step_increment(double dt);
221 
222 /*----------------------------------------------------------------------------
223  * Redefine the current time values.
224  *
225  * Remark: Using cs_time_step_increment() is preferred, but this function
226  * may be required for reverting to a previous time step.
227  *
228  * parameters:
229  * nt_cur <-- current time step number
230  * t_cur <-- current physical time
231  *----------------------------------------------------------------------------*/
232 
233 void
234 cs_time_step_redefine_cur(int nt_cur,
235  double t_cur);
236 
237 /*----------------------------------------------------------------------------*
238  * Print the time stepping options to setup.log.
239  *----------------------------------------------------------------------------*/
240 
241 void
243 
244 /*----------------------------------------------------------------------------*/
245 
247 
248 #endif /* __CS_TIME_STEP_H__ */
int is_local
Definition: cs_time_step.h:68
int is_variable
Definition: cs_time_step.h:66
void cs_time_step_define_nt_max(int nt_max)
Define maximum time step number.
Definition: cs_time_step.c:495
time step descriptor
Definition: cs_time_step.h:64
double varrdt
Definition: cs_time_step.h:109
double relxst
Definition: cs_time_step.h:122
Definition: cs_time_step.h:54
void cs_time_step_increment(double dt)
Increment the global time step.
Definition: cs_time_step.c:544
double foumax
Definition: cs_time_step.h:106
void cs_time_step_define_local(int is_local)
Define whether time step is local in space or not.
Definition: cs_time_step.c:478
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
double coumax
Definition: cs_time_step.h:100
Definition: cs_time_step.h:55
double dtmax
Definition: cs_time_step.h:117
double dt_ref
Definition: cs_time_step.h:84
double t_max
Definition: cs_time_step.h:81
Definition: cs_time_step.h:57
double dtmin
Definition: cs_time_step.h:112
void cs_time_step_redefine_cur(int nt_cur, double t_cur)
Redefine the current time values.
Definition: cs_time_step.c:579
void cs_time_step_log_setup(void)
Print the time stepping options to setup.log.
Definition: cs_time_step.c:593
cs_time_step_type_t idtvar
Definition: cs_time_step.h:98
Definition: cs_field_pointer.h:65
double t_cur
Definition: cs_time_step.h:80
double cflmmx
Definition: cs_time_step.h:103
double dt_next
Definition: cs_time_step.h:85
cs_time_step_type_t
Time step type.
Definition: cs_time_step.h:52
void cs_time_step_define_variable(int is_variable)
Define whether time step is variable or not.
Definition: cs_time_step.c:461
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.c:447
int nt_max
Definition: cs_time_step.h:75
const cs_time_step_t * cs_glob_time_step
time step options descriptor
Definition: cs_time_step.h:92
#define END_C_DECLS
Definition: cs_defs.h:496
int nt_ini
Definition: cs_time_step.h:76
int nt_prev
Definition: cs_time_step.h:72
int nt_cur
Definition: cs_time_step.h:74
cs_time_step_t * cs_get_glob_time_step(void)
Provide read/write access to cs_glob_time_step.
Definition: cs_time_step.c:433
void cs_time_step_define_t_max(double t_max)
Define maximum time value.
Definition: cs_time_step.c:510
int iptlro
Definition: cs_time_step.h:94
void cs_time_step_define_prev(int nt_prev, double t_prev)
Set time values from previous (usually restarted) calculations.
Definition: cs_time_step.c:526
Definition: cs_time_step.h:56
const cs_time_step_options_t * cs_glob_time_step_options
double t_prev
Definition: cs_time_step.h:78