My Project
programmer's documentation
cs_domain.h
Go to the documentation of this file.
1 #ifndef __CS_DOMAIN_H__
2 #define __CS_DOMAIN_H__
3 
4 /*============================================================================
5  * Manage a computational domain
6  * - equations, settings, fields, connectivities and geometrical quantities
7  *============================================================================*/
8 
9 /*
10  This file is part of Code_Saturne, a general-purpose CFD tool.
11 
12  Copyright (C) 1998-2019 EDF S.A.
13 
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22  details.
23 
24  You should have received a copy of the GNU General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26  Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28 
29 /*----------------------------------------------------------------------------
30  * Standard C library headers
31  *----------------------------------------------------------------------------*/
32 
33 #include <stdbool.h>
34 
35 /*----------------------------------------------------------------------------
36  * Local headers
37  *----------------------------------------------------------------------------*/
38 
39 #include "cs_boundary.h"
40 #include "cs_cdo_connect.h"
41 #include "cs_cdo_quantities.h"
42 #include "cs_mesh.h"
43 #include "cs_mesh_quantities.h"
44 #include "cs_time_step.h"
45 #include "cs_timer.h"
46 #include "cs_xdef.h"
47 
48 /*----------------------------------------------------------------------------*/
49 
51 
52 /*============================================================================
53  * Macro definitions
54  *============================================================================*/
55 
56 /* Flag related to the activation (or not) of the CDO schemes */
57 #define CS_DOMAIN_CDO_MODE_OFF -1 /* CDO schemes are not used */
58 #define CS_DOMAIN_CDO_MODE_WITH_FV 1 /* CDO and legacy FV schemes are used */
59 #define CS_DOMAIN_CDO_MODE_ONLY 2 /* CDO schemes are exclusively used */
60 
61 /*============================================================================
62  * Type definitions
63  *============================================================================*/
64 
69 typedef struct {
70 
71  /* Mode for CDO: activated, switched off... */
72  int mode;
73 
74  /* Flag to know if scalar or vector equations are requested and which kind
75  of numerical schemes is requested to solve these equations */
80 
82 
87 typedef struct {
88 
89  /* Code_Saturne mesh and mesh quantities structures already computed */
92 
93  /* CDO structures:
94  * - cs_cdo_connect_t contains additional information about connectivity
95  * - cs_cdo_quantities_t contains additional information on mesh quantities
96  */
99 
100  /* Boundary of the computational domain */
103 
104  /* Time step management */
106  bool is_last_iter; /* true or false */
107  cs_xdef_t *time_step_def; /* Definition of the time_step */
108  cs_time_step_t *time_step; /* time step descriptor */
109  cs_time_step_options_t time_options; /* time step options */
110 
111  /* Output options */
112  int output_nt; /* Logging done every nt iterations */
113  int restart_nt; /* Restart done every nt iterations */
114  int verbosity; /* Level of details given in log */
115 
116  /* Specific context structure related to the numerical schemes */
118 
119  /* Monitoring */
120  cs_timer_counter_t tcp; /* Cumulated elapsed time for extra-operations
121  and post-processing */
122  cs_timer_counter_t tcs; /* Cumulated elapsed time for setup operations */
123 
124 } cs_domain_t;
125 
126 /*============================================================================
127  * Static global variables
128  *============================================================================*/
129 
130 extern cs_domain_t *cs_glob_domain; /* Pointer to main computational domain */
131 
132 /*============================================================================
133  * Static inline public function prototypes
134  *============================================================================*/
135 
136 /*----------------------------------------------------------------------------*/
142 /*----------------------------------------------------------------------------*/
143 
144 static inline void
146 {
147  cs_time_step_t *ts = domain->time_step;
148 
149  /* Increment time iteration */
150  ts->nt_cur++;
151 }
152 
153 /*============================================================================
154  * Public function prototypes
155  *============================================================================*/
156 
157 /*----------------------------------------------------------------------------*/
163 /*----------------------------------------------------------------------------*/
164 
165 cs_domain_t *
166 cs_domain_create(void);
167 
168 /*----------------------------------------------------------------------------*/
174 /*----------------------------------------------------------------------------*/
175 
176 void
177 cs_domain_free(cs_domain_t **p_domain);
178 
179 /*----------------------------------------------------------------------------*/
187 /*----------------------------------------------------------------------------*/
188 
189 void
191  int mode);
192 
193 /*----------------------------------------------------------------------------*/
201 /*----------------------------------------------------------------------------*/
202 
203 int
204 cs_domain_get_cdo_mode(const cs_domain_t *domain);
205 
206 /*----------------------------------------------------------------------------*/
214 /*----------------------------------------------------------------------------*/
215 
216 bool
218 
219 /*----------------------------------------------------------------------------*/
227 /*----------------------------------------------------------------------------*/
228 
229 bool
230 cs_domain_needs_log(const cs_domain_t *domain);
231 
232 /*----------------------------------------------------------------------------*/
238 /*----------------------------------------------------------------------------*/
239 
240 void
242 
243 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 void
253 
254 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
262 void
263 cs_domain_cdo_log(const cs_domain_t *domain);
264 
265 /*----------------------------------------------------------------------------*/
266 
268 
269 #endif /* __CS_DOMAIN_H__ */
cs_domain_t
Structure storing the main features of the computational domain and pointers to the main geometrical ...
Definition: cs_domain.h:87
cs_xdef_t
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:126
cs_domain_set_cdo_mode
void cs_domain_set_cdo_mode(cs_domain_t *domain, int mode)
Set the global variable storing the mode of activation to apply to CDO/HHO schemes.
Definition: cs_domain.c:255
cs_domain_increment_time
void cs_domain_increment_time(cs_domain_t *domain)
Update time step after one temporal iteration.
Definition: cs_domain.c:442
cs_domain_t::tcp
cs_timer_counter_t tcp
Definition: cs_domain.h:120
cs_timer_counter_t
Definition: cs_timer.h:57
cs_boundary_t
Structure storing information related to the "physical" boundaries that one want to set on the comput...
Definition: cs_boundary.h:77
cs_domain_needs_iteration
bool cs_domain_needs_iteration(cs_domain_t *domain)
Check if one needs to continue iterations in time.
Definition: cs_domain.c:302
cs_domain_t::boundaries
cs_boundary_t * boundaries
Definition: cs_domain.h:101
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_domain_cdo_context_t
High-level metadata for handling CDO/HHO schemes.
Definition: cs_domain.h:69
cs_domain_t::connect
cs_cdo_connect_t * connect
Definition: cs_domain.h:97
cs_domain_t::time_step_def
cs_xdef_t * time_step_def
Definition: cs_domain.h:107
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_domain_get_cdo_mode
int cs_domain_get_cdo_mode(const cs_domain_t *domain)
Get the mode of activation for the CDO/HHO schemes.
Definition: cs_domain.c:281
cs_mesh_quantities.h
cs_mesh_quantities_t
Definition: cs_mesh_quantities.h:90
cs_domain_increment_time_step
static void cs_domain_increment_time_step(cs_domain_t *domain)
Update the time step after one temporal iteration.
Definition: cs_domain.h:145
cs_cdo_quantities.h
cs_domain_cdo_log
void cs_domain_cdo_log(const cs_domain_t *domain)
Print a welcome message indicating which mode of CDO is activated.
Definition: cs_domain.c:463
cs_domain_t::tcs
cs_timer_counter_t tcs
Definition: cs_domain.h:122
cs_domain_cdo_context_t::vb_scheme_flag
cs_flag_t vb_scheme_flag
Definition: cs_domain.h:77
cs_glob_domain
cs_domain_t * cs_glob_domain
Definition: cs_domain.c:85
cs_mesh.h
cs_xdef.h
cs_domain_define_current_time_step
void cs_domain_define_current_time_step(cs_domain_t *domain)
Set the current time step for this new time iteration.
Definition: cs_domain.c:365
cs_domain_free
void cs_domain_free(cs_domain_t **p_domain)
Free a cs_domain_t structure.
Definition: cs_domain.c:214
cs_domain_t::mesh
cs_mesh_t * mesh
Definition: cs_domain.h:90
mode
void const cs_int_t * mode
Definition: cs_syr_coupling.h:132
cs_time_step_t
time step descriptor
Definition: cs_time_step.h:51
cs_domain_t::cdo_context
cs_domain_cdo_context_t * cdo_context
Definition: cs_domain.h:117
cs_time_step_options_t
time step options descriptor
Definition: cs_time_step.h:80
ts
void cs_int_t cs_int_t cs_int_t cs_real_t * ts
Definition: cs_at_plugin.h:63
cs_cdo_quantities_t
Definition: cs_cdo_quantities.h:94
cs_cdo_connect_t
Definition: cs_cdo_connect.h:74
cs_domain_t::is_last_iter
bool is_last_iter
Definition: cs_domain.h:106
cs_domain_t::verbosity
int verbosity
Definition: cs_domain.h:114
cs_domain_cdo_context_t::hho_scheme_flag
cs_flag_t hho_scheme_flag
Definition: cs_domain.h:79
cs_domain_t::mesh_quantities
cs_mesh_quantities_t * mesh_quantities
Definition: cs_domain.h:91
cs_cdo_connect.h
cs_time_step.h
cs_domain_t::time_step
cs_time_step_t * time_step
Definition: cs_domain.h:108
cs_domain_needs_log
bool cs_domain_needs_log(const cs_domain_t *domain)
Check if an ouput is requested according to the domain setting.
Definition: cs_domain.c:336
cs_domain_t::only_steady
bool only_steady
Definition: cs_domain.h:105
cs_domain_t::time_options
cs_time_step_options_t time_options
Definition: cs_domain.h:109
cs_domain_t::cdo_quantities
cs_cdo_quantities_t * cdo_quantities
Definition: cs_domain.h:98
cs_flag_t
unsigned short int cs_flag_t
Definition: cs_defs.h:304
cs_domain_cdo_context_t::mode
int mode
Definition: cs_domain.h:72
cs_domain_t::output_nt
int output_nt
Definition: cs_domain.h:112
cs_domain_cdo_context_t::vcb_scheme_flag
cs_flag_t vcb_scheme_flag
Definition: cs_domain.h:78
cs_domain_cdo_context_t::fb_scheme_flag
cs_flag_t fb_scheme_flag
Definition: cs_domain.h:76
cs_domain_t::restart_nt
int restart_nt
Definition: cs_domain.h:113
cs_domain_t::ale_boundaries
cs_boundary_t * ale_boundaries
Definition: cs_domain.h:102
cs_boundary.h
cs_mesh_t
Definition: cs_mesh.h:63
cs_timer.h
cs_domain_create
cs_domain_t * cs_domain_create(void)
Create and initialize by default a cs_domain_t structure.
Definition: cs_domain.c:151