My Project
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-2019 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 
70  double dt[3]; /* n, n-1, and n-2 time steps */
71  double dt_ref; /* reference time step. */
72  double dt_next; /* next (predicted) time step. */
73 
75 
76 
77 /* Time step options descriptor */
78 /*------------------------------*/
79 
80 typedef struct {
81 
82  int iptlro; /* Clip the time step with respect to the buoyant effects
83  - 0: false
84  - 1: true. */
85 
86  int idtvar; /* Option for a variable time step
87  - -1: steady algorithm
88  - 0: constant time step
89  - 1: time step constant in space but variable in time
90  - 2: variable time step in space and in time. */
91 
92  double coumax; /* Maximum Courant number (when idtvar is
93  different from 0). */
94 
95  double cflmmx; /* Maximum Courant number for the continuity equation
96  in compressible model. */
97 
98  double foumax; /* Maximum Fourier number (when idtvar is different from 0). */
99 
100  double varrdt; /* Relative allowed variation of dt (when idtvar is
101  different from 0). */
102 
103  double dtmin; /* Minimum value of dt (when idtvar is different from 0).
104  Take
105  dtmin = min(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
106 
107  double dtmax; /* Maximum value of dt (when idtvar is different from 0).
108  Take
109  dtmax = max(ld/ud, sqrt(lt/(gdelta rho/rho)), ...). */
110 
111  double relxst; /* Relaxation coefficient for the steady algorithm. */
112 
114 
115 /*============================================================================
116  * Static global variables
117  *============================================================================*/
118 
119 /* Pointer to main time step structure */
120 
121 extern const cs_time_step_t *cs_glob_time_step;
122 
124 
125 /*=============================================================================
126  * Public function prototypes
127  *============================================================================*/
128 
129 /*----------------------------------------------------------------------------
130  * Provide acces to cs_glob_time_step
131  *
132  * needed to initialize structure with GUI
133  *----------------------------------------------------------------------------*/
134 
137 
138 /*----------------------------------------------------------------------------
139  * Provide acces to cs_glob_time_step_options
140  *
141  * needed to initialize structure with GUI
142  *----------------------------------------------------------------------------*/
143 
146 
147 /*----------------------------------------------------------------------------
148  * Define whether time step is variable or not
149  *
150  * parameters:
151  * is_variable <-- 0 if time step is variable in time, 1 if it is fixed
152  *----------------------------------------------------------------------------*/
153 
154 void
155 cs_time_step_define_variable(int is_variable);
156 
157 /*----------------------------------------------------------------------------
158  * Define whether time step is local in space or not
159  *
160  * parameters:
161  * is_local <-- 0 if time step is uniform in space, 1 if it is local
162  *----------------------------------------------------------------------------*/
163 
164 void
165 cs_time_step_define_local(int is_local);
166 
167 /*----------------------------------------------------------------------------
168  * Define maximum time step number
169  *
170  * parameters:
171  * nt_max <-- maximum time step number (unlimited if negative)
172  *----------------------------------------------------------------------------*/
173 
174 void
175 cs_time_step_define_nt_max(int nt_max);
176 
177 /*----------------------------------------------------------------------------
178  * Define maximum time value
179  *
180  * parameters:
181  * t_max <-- maximum time value (unlimited if negative)
182  *----------------------------------------------------------------------------*/
183 
184 void
185 cs_time_step_define_t_max(double t_max);
186 
187 /*----------------------------------------------------------------------------
188  * Set time values from previous (usually restarted) calculations
189  *
190  * parameters:
191  * nt_prev <-- previous time step number
192  * t_prev <-- previous physical time
193  *----------------------------------------------------------------------------*/
194 
195 void
196 cs_time_step_define_prev(int nt_prev,
197  double t_prev);
198 
199 /*----------------------------------------------------------------------------
200  * Increment the global time step.
201  *
202  * parameters:
203  * dt <-- time step value to increment
204  *----------------------------------------------------------------------------*/
205 
206 void
207 cs_time_step_increment(double dt);
208 
209 /*----------------------------------------------------------------------------
210  * Redefine the current time values.
211  *
212  * Remark: Using cs_time_step_increment() is preferred, but this function
213  * may be required for reverting to a previous time step.
214  *
215  * parameters:
216  * nt_cur <-- current time step number
217  * t_cur <-- current physical time
218  *----------------------------------------------------------------------------*/
219 
220 void
221 cs_time_step_redefine_cur(int nt_cur,
222  double t_cur);
223 
224 /*----------------------------------------------------------------------------*
225  * Print the time stepping options to setup.log.
226  *----------------------------------------------------------------------------*/
227 
228 void
230 
231 /*----------------------------------------------------------------------------*/
232 
234 
235 #endif /* __CS_TIME_STEP_H__ */
cs_defs.h
cs_glob_time_step_options
const cs_time_step_options_t * cs_glob_time_step_options
cs_time_step_define_prev
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:493
cs_time_step_t::dt_ref
double dt_ref
Definition: cs_time_step.h:71
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_time_step_t::is_variable
int is_variable
Definition: cs_time_step.h:53
cs_time_step_define_nt_max
void cs_time_step_define_nt_max(int nt_max)
Define maximum time step number.
Definition: cs_time_step.c:462
cs_time_step_redefine_cur
void cs_time_step_redefine_cur(int nt_cur, double t_cur)
Redefine the current time values.
Definition: cs_time_step.c:542
cs_time_step_t::nt_cur
int nt_cur
Definition: cs_time_step.h:61
cs_time_step_log_setup
void cs_time_step_log_setup(void)
Print the time stepping options to setup.log.
Definition: cs_time_step.c:556
cs_time_step_options_t::iptlro
int iptlro
Definition: cs_time_step.h:82
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_time_step_define_local
void cs_time_step_define_local(int is_local)
Define whether time step is local in space or not.
Definition: cs_time_step.c:445
cs_time_step_options_t::coumax
double coumax
Definition: cs_time_step.h:92
cs_time_step_options_t::varrdt
double varrdt
Definition: cs_time_step.h:100
cs_get_glob_time_step_options
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:414
cs_get_glob_time_step
cs_time_step_t * cs_get_glob_time_step(void)
Provide acces to cs_glob_time_step.
Definition: cs_time_step.c:401
cs_time_step_t
time step descriptor
Definition: cs_time_step.h:51
cs_time_step_options_t
time step options descriptor
Definition: cs_time_step.h:80
cs_time_step_t::nt_ini
int nt_ini
Definition: cs_time_step.h:63
cs_time_step_options_t::relxst
double relxst
Definition: cs_time_step.h:111
cs_time_step_t::t_cur
double t_cur
Definition: cs_time_step.h:67
cs_time_step_t::nt_prev
int nt_prev
Definition: cs_time_step.h:59
cs_time_step_options_t::cflmmx
double cflmmx
Definition: cs_time_step.h:95
cs_time_step_t::dt_next
double dt_next
Definition: cs_time_step.h:72
cs_time_step_t::t_max
double t_max
Definition: cs_time_step.h:68
cs_time_step_define_t_max
void cs_time_step_define_t_max(double t_max)
Define maximum time value.
Definition: cs_time_step.c:477
cs_time_step_options_t::dtmin
double dtmin
Definition: cs_time_step.h:103
cs_time_step_options_t::foumax
double foumax
Definition: cs_time_step.h:98
cs_time_step_options_t::idtvar
int idtvar
Definition: cs_time_step.h:86
dt
Definition: cs_field_pointer.h:65
cs_time_step_define_variable
void cs_time_step_define_variable(int is_variable)
Define whether time step is variable or not.
Definition: cs_time_step.c:428
cs_time_step_t::t_prev
double t_prev
Definition: cs_time_step.h:65
cs_glob_time_step
const cs_time_step_t * cs_glob_time_step
cs_time_step_options_t::dtmax
double dtmax
Definition: cs_time_step.h:107
cs_time_step_t::is_local
int is_local
Definition: cs_time_step.h:55
cs_time_step_t::nt_max
int nt_max
Definition: cs_time_step.h:62
cs_time_step_increment
void cs_time_step_increment(double dt)
Increment the global time step.
Definition: cs_time_step.c:511