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 
108  double foumax; /* Maximum Fourier number (when idtvar is different from 0). */
109 
110  double varrdt; /* Relative allowed variation of dt (when idtvar is
111  different from 0). */
112 
113  double dtmin; /* Minimum value of dt (when idtvar is different from 0).
114  Take
115  dtmin = min(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
116 
117  double dtmax; /* Maximum value of dt (when idtvar is different from 0).
118  Take
119  dtmax = max(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
120 
121  double relxst; /* Relaxation coefficient for the steady algorithm. */
122 
124 
125 /*============================================================================
126  * Static global variables
127  *============================================================================*/
128 
129 /* Pointer to main time step structure */
130 
131 extern const cs_time_step_t *cs_glob_time_step;
132 
134 
135 /*=============================================================================
136  * Public function prototypes
137  *============================================================================*/
138 
139 /*----------------------------------------------------------------------------
140  * Define whether time step is variable or not
141  *
142  * parameters:
143  * is_variable <-- 0 if time step is variable in time, 1 if it is fixed
144  *----------------------------------------------------------------------------*/
145 
146 void
147 cs_time_step_define_variable(int is_variable);
148 
149 /*----------------------------------------------------------------------------
150  * Define whether time step is local in space or not
151  *
152  * parameters:
153  * is_local <-- 0 if time step is uniform in space, 1 if it is local
154  *----------------------------------------------------------------------------*/
155 
156 void
157 cs_time_step_define_local(int is_local);
158 
159 /*----------------------------------------------------------------------------
160  * Define maximum time step number
161  *
162  * parameters:
163  * nt_max <-- maximum time step number (unlimited if negative)
164  *----------------------------------------------------------------------------*/
165 
166 void
167 cs_time_step_define_nt_max(int nt_max);
168 
169 /*----------------------------------------------------------------------------
170  * Define maximum time value
171  *
172  * parameters:
173  * t_max <-- maximum time value (unlimited if negative)
174  *----------------------------------------------------------------------------*/
175 
176 void
177 cs_time_step_define_t_max(double t_max);
178 
179 /*----------------------------------------------------------------------------
180  * Set time values from previous (usually restarted) calculations
181  *
182  * parameters:
183  * nt_prev <-- previous time step number
184  * t_prev <-- previous physical time
185  *----------------------------------------------------------------------------*/
186 
187 void
188 cs_time_step_define_prev(int nt_prev,
189  double t_prev);
190 
191 /*----------------------------------------------------------------------------
192  * Increment the global time step.
193  *
194  * parameters:
195  * dt <-- time step value to increment
196  *----------------------------------------------------------------------------*/
197 
198 void
199 cs_time_step_increment(double dt);
200 
201 /*----------------------------------------------------------------------------
202  * Redefine the current time values.
203  *
204  * Remark: Using cs_time_step_increment() is preferred, but this function
205  * may be required for reverting to a previous time step.
206  *
207  * parameters:
208  * nt_cur <-- current time step number
209  * t_cur <-- current physical time
210  *----------------------------------------------------------------------------*/
211 
212 void
213 cs_time_step_redefine_cur(int nt_cur,
214  double t_cur);
215 
216 /*----------------------------------------------------------------------------*/
217 
219 
220 #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:356
time step descriptor
Definition: cs_time_step.h:51
double varrdt
Definition: cs_time_step.h:110
double relxst
Definition: cs_time_step.h:121
void cs_time_step_increment(double dt)
Increment the global time step.
Definition: cs_time_step.c:403
double foumax
Definition: cs_time_step.h:108
void cs_time_step_define_local(int is_local)
Define whether time step is local in space or not.
Definition: cs_time_step.c:339
double dtref
Definition: cs_time_step.h:99
#define BEGIN_C_DECLS
Definition: cs_defs.h:419
double coumax
Definition: cs_time_step.h:101
double dtmax
Definition: cs_time_step.h:117
double t_max
Definition: cs_time_step.h:68
int inpdt0
Definition: cs_time_step.h:79
double dtmin
Definition: cs_time_step.h:113
void cs_time_step_redefine_cur(int nt_cur, double t_cur)
Redefine the current time values.
Definition: cs_time_step.c:422
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:322
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:420
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
void cs_time_step_define_t_max(double t_max)
Define maximum time value.
Definition: cs_time_step.c:370
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:385
const cs_time_step_options_t * cs_glob_time_step_options
double t_prev
Definition: cs_time_step.h:65