programmer's 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-2015 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 /* time step descriptor */
49 /*----------------------*/
50 
51 typedef struct {
52 
53  int is_variable; /* 0 if time step is fixed in time,
54  1 if the time step is variable. */
55  int is_local; /* 0 if time step is uniform in space,
56  1 if it is local in space (in which case
57  the time value is only a reference. */
58 
59  int nt_prev; /* absolute time step number reached by previous
60  computation */
61  int nt_cur; /* current absolute time step number */
62  int nt_max; /* maximum absolute time step number */
63  int nt_ini; /* Number of time steps for initialization */
64 
65  double t_prev; /* physical time reached by previous
66  computation */
67  double t_cur; /* current absolute time */
68  double t_max; /* maximum absolute time */
69 
71 
72 
73 /* Time step options descriptor */
74 /*------------------------------*/
75 
76 typedef struct {
77 
78 
79  int inpdt0; /* Indicator "zero time step"
80  - 0: standard calculation
81  - 1: to simulate no time step
82  - for non-restarted computations: only resolution
83  (Navier-Stokes, turbulence, scalars) is skipped
84  - for restarted computations: resolution, computation
85  of physical properties, and definition of boundary
86  conditions is skipped (values are read from checkpoint
87  file). */
88 
89  int iptlro; /* Clip the time step with respect to the buoyant effects
90  - 0: false
91  - 1: true. */
92 
93  int idtvar; /* Option for a variable time step
94  - -1: steady algorithm
95  - 0: constant time step
96  - 1: time step constant in space but variable in time
97  - 2: variable time step in space and in time. */
98 
99  double dtref; /* Reference time step. */
100 
101  double coumax; /* Maximum Courant number (when idtvar is
102  different from 0). */
103 
104  double cflmmx; /* Maximum Courant number for the continuity equation
105  in compressible model. */
106 
107  double foumax; /* Maximum Fourier number (when idtvar is different from 0). */
108 
109  double varrdt; /* Relative allowed variation of dt (when idtvar is
110  different from 0). */
111 
112  double dtmin; /* Minimum value of dt (when idtvar is different from 0).
113  Take
114  dtmin = min(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
115 
116  double dtmax; /* Maximum value of dt (when idtvar is different from 0).
117  Take
118  dtmax = max(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
119 
120  double relxst; /* Relaxation coefficient for the steady algorithm. */
121 
123 
124 /*============================================================================
125  * Static global variables
126  *============================================================================*/
127 
128 /* Pointer to main time step structure */
129 
130 extern const cs_time_step_t *cs_glob_time_step;
131 
133 
134 /*=============================================================================
135  * Public function prototypes
136  *============================================================================*/
137 
138 /*----------------------------------------------------------------------------
139  * Provide acces to cs_glob_time_step
140  *
141  * needed to initialize structure with GUI
142  *----------------------------------------------------------------------------*/
143 
146 
147 /*----------------------------------------------------------------------------
148  * Provide acces to cs_glob_time_step_options
149  *
150  * needed to initialize structure with GUI
151  *----------------------------------------------------------------------------*/
152 
155 
156 /*----------------------------------------------------------------------------
157  * Define whether time step is variable or not
158  *
159  * parameters:
160  * is_variable <-- 0 if time step is variable in time, 1 if it is fixed
161  *----------------------------------------------------------------------------*/
162 
163 void
164 cs_time_step_define_variable(int is_variable);
165 
166 /*----------------------------------------------------------------------------
167  * Define whether time step is local in space or not
168  *
169  * parameters:
170  * is_local <-- 0 if time step is uniform in space, 1 if it is local
171  *----------------------------------------------------------------------------*/
172 
173 void
174 cs_time_step_define_local(int is_local);
175 
176 /*----------------------------------------------------------------------------
177  * Define maximum time step number
178  *
179  * parameters:
180  * nt_max <-- maximum time step number (unlimited if negative)
181  *----------------------------------------------------------------------------*/
182 
183 void
184 cs_time_step_define_nt_max(int nt_max);
185 
186 /*----------------------------------------------------------------------------
187  * Define maximum time value
188  *
189  * parameters:
190  * t_max <-- maximum time value (unlimited if negative)
191  *----------------------------------------------------------------------------*/
192 
193 void
194 cs_time_step_define_t_max(double t_max);
195 
196 /*----------------------------------------------------------------------------
197  * Set time values from previous (usually restarted) calculations
198  *
199  * parameters:
200  * nt_prev <-- previous time step number
201  * t_prev <-- previous physical time
202  *----------------------------------------------------------------------------*/
203 
204 void
205 cs_time_step_define_prev(int nt_prev,
206  double t_prev);
207 
208 /*----------------------------------------------------------------------------
209  * Increment the global time step.
210  *
211  * parameters:
212  * dt <-- time step value to increment
213  *----------------------------------------------------------------------------*/
214 
215 void
216 cs_time_step_increment(double dt);
217 
218 /*----------------------------------------------------------------------------
219  * Redefine the current time values.
220  *
221  * Remark: Using cs_time_step_increment() is preferred, but this function
222  * may be required for reverting to a previous time step.
223  *
224  * parameters:
225  * nt_cur <-- current time step number
226  * t_cur <-- current physical time
227  *----------------------------------------------------------------------------*/
228 
229 void
230 cs_time_step_redefine_cur(int nt_cur,
231  double t_cur);
232 
233 /*----------------------------------------------------------------------------*/
234 
236 
237 #endif /* __CS_TIME_STEP_H__ */
int is_local
Definition: cs_time_step.h:55
int is_variable
Definition: cs_time_step.h:53
void cs_time_step_define_nt_max(int nt_max)
Define maximum time step number.
Definition: cs_time_step.c:382
time step descriptor
Definition: cs_time_step.h:51
double varrdt
Definition: cs_time_step.h:109
double relxst
Definition: cs_time_step.h:120
void cs_time_step_increment(double dt)
Increment the global time step.
Definition: cs_time_step.c:429
double foumax
Definition: cs_time_step.h:107
void cs_time_step_define_local(int is_local)
Define whether time step is local in space or not.
Definition: cs_time_step.c:365
double dtref
Definition: cs_time_step.h:99
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
double coumax
Definition: cs_time_step.h:101
double dtmax
Definition: cs_time_step.h:116
double t_max
Definition: cs_time_step.h:68
int inpdt0
Definition: cs_time_step.h:79
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:448
int idtvar
Definition: cs_time_step.h:93
Definition: cs_field_pointer.h:64
double t_cur
Definition: cs_time_step.h:67
double cflmmx
Definition: cs_time_step.h:104
void cs_time_step_define_variable(int is_variable)
Define whether time step is variable or not.
Definition: cs_time_step.c:348
cs_time_step_options_t * cs_get_glob_time_step_options(void)
Provide acces to cs_glob_time_step_options.
Definition: cs_time_step.c:334
int nt_max
Definition: cs_time_step.h:62
const cs_time_step_t * cs_glob_time_step
time step options descriptor
Definition: cs_time_step.h:76
#define END_C_DECLS
Definition: cs_defs.h:430
int nt_ini
Definition: cs_time_step.h:63
int nt_prev
Definition: cs_time_step.h:59
int nt_cur
Definition: cs_time_step.h:61
cs_time_step_t * cs_get_glob_time_step(void)
Provide acces to cs_glob_time_step.
Definition: cs_time_step.c:321
void cs_time_step_define_t_max(double t_max)
Define maximum time value.
Definition: cs_time_step.c:396
int iptlro
Definition: cs_time_step.h:89
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:411
const cs_time_step_options_t * cs_glob_time_step_options
double t_prev
Definition: cs_time_step.h:65