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  * - Physical boundary conditions attached to a domain
7  * - Equations
8  *============================================================================*/
9 
10 /*
11  This file is part of Code_Saturne, a general-purpose CFD tool.
12 
13  Copyright (C) 1998-2018 EDF S.A.
14 
15  This program is free software; you can redistribute it and/or modify it under
16  the terms of the GNU General Public License as published by the Free Software
17  Foundation; either version 2 of the License, or (at your option) any later
18  version.
19 
20  This program is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23  details.
24 
25  You should have received a copy of the GNU General Public License along with
26  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27  Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_cdo_connect.h"
35 #include "cs_cdo_quantities.h"
36 #include "cs_mesh.h"
37 #include "cs_mesh_quantities.h"
38 #include "cs_time_step.h"
39 #include "cs_timer.h"
40 #include "cs_xdef.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*============================================================================
47  * Macro definitions
48  *============================================================================*/
49 
50 /* Flag related to the activation (or not) of the CDO schemes */
51 #define CS_DOMAIN_CDO_MODE_OFF -1 // CDO schemes are not used
52 #define CS_DOMAIN_CDO_MODE_WITH_FV 1 // CDO and legacy FV schemes are used
53 #define CS_DOMAIN_CDO_MODE_ONLY 2 // CDO schemes are exclusively used
54 
55 /*============================================================================
56  * Type definitions
57  *============================================================================*/
58 
59 /* Physic-driven boundary */
60 typedef enum {
61 
67 
69 
70 typedef struct {
71 
72  cs_domain_boundary_type_t default_type; /* boundary set by default */
73  int n_zones;
74  int *zone_ids; /* List of boundary zone ids */
75  cs_domain_boundary_type_t *zone_type; /* Type of boundary by zone */
76 
78 
79 typedef struct {
80 
81  /* Mode for CDO: activated, switched off... */
82  int mode;
83 
84  /* Metadata for CDO */
86 
87  /* Flag to know if scalar or vector equations are requested and which kind
88  of numerical schemes is requested to solve these equations */
93 
95 
96 /* Structure storing the main feature */
97 typedef struct {
98 
99  /* Code_Saturne mesh and mesh quantities structures already computed */
100  const cs_mesh_t *mesh;
102 
103  /* CDO structures:
104  - cs_cdo_connect_t contains additional information about connectivity
105  - cs_cdo_quantities_t contains additional information on mesh quantities
106  */
109 
110  /* Physical boundary conditions on the computational domain:
111  inlet, outmet, wall, symmetry...
112  Store the type of boundary set on each boundary face */
114 
115  /* Time step management */
117  bool is_last_iter; // true or false
118  double dt_cur; // current time step
119  cs_xdef_t *time_step_def; // Definition of the time_step
120  cs_time_step_t *time_step; // time step descriptor
121  cs_time_step_options_t time_options; // time step options
122 
123  /* Output options */
124  int output_nt; /* Log information every nt iteration(s) */
125  int verbosity; /* Level of details given in log */
126  bool profiling; /* Activate a set of timer statistics (details differ
127  according to the verbosity level) */
128 
129  /* Specific context structure related to the numerical schemes */
131 
132  /* Monitoring */
133  cs_timer_counter_t tcp; /* Cumulated elapsed time for extra-operations
134  and post-processing */
135  cs_timer_counter_t tcs; /* Cumulated elapsed time for setup operations */
136 
137 } cs_domain_t;
138 
139 /*============================================================================
140  * Static global variables
141  *============================================================================*/
142 
143 extern cs_domain_t *cs_glob_domain; /* Pointer to main computational domain
144  used in CDO/HHO schmes */
145 
146 /*============================================================================
147  * Public function prototypes
148  *============================================================================*/
149 
150 /*----------------------------------------------------------------------------*/
156 /*----------------------------------------------------------------------------*/
157 
158 cs_domain_t *
159 cs_domain_create(void);
160 
161 /*----------------------------------------------------------------------------*/
167 /*----------------------------------------------------------------------------*/
168 
169 void
170 cs_domain_free(cs_domain_t **p_domain);
171 
172 /*----------------------------------------------------------------------------*/
180 /*----------------------------------------------------------------------------*/
181 
182 void
184  int mode);
185 
186 /*----------------------------------------------------------------------------*/
194 /*----------------------------------------------------------------------------*/
195 
196 int
197 cs_domain_get_cdo_mode(const cs_domain_t *domain);
198 
199 /*----------------------------------------------------------------------------*/
207 /*----------------------------------------------------------------------------*/
208 
209 void
211  int nt_list,
212  int verbosity);
213 
214 
215 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
222 
223 void
225 
226 /*----------------------------------------------------------------------------*/
235 /*----------------------------------------------------------------------------*/
236 
237 void
239  int nt_max,
240  double t_max);
241 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 void
253  cs_timestep_func_t *func,
254  void *func_input);
255 
256 /*----------------------------------------------------------------------------*/
263 /*----------------------------------------------------------------------------*/
264 
265 void
267  double dt);
268 
269 /*----------------------------------------------------------------------------*/
277 /*----------------------------------------------------------------------------*/
278 
279 const char *
281 
282 /*----------------------------------------------------------------------------*/
289 /*----------------------------------------------------------------------------*/
290 
291 void
294 
295 /*----------------------------------------------------------------------------*/
303 /*----------------------------------------------------------------------------*/
304 
305 void
308  const char *zone_name);
309 
310 /*----------------------------------------------------------------------------*/
318 /*----------------------------------------------------------------------------*/
319 
320 bool
322 
323 /*----------------------------------------------------------------------------*/
331 /*----------------------------------------------------------------------------*/
332 
333 bool
334 cs_domain_needs_log(const cs_domain_t *domain);
335 
336 /*----------------------------------------------------------------------------*/
342 /*----------------------------------------------------------------------------*/
343 
344 void
346 
347 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 void
357 
358 /*----------------------------------------------------------------------------*/
364 /*----------------------------------------------------------------------------*/
365 
366 void
367 cs_domain_cdo_log(const cs_domain_t *domain);
368 
369 /*----------------------------------------------------------------------------*/
375 /*----------------------------------------------------------------------------*/
376 
377 void
378 cs_domain_summary(const cs_domain_t *domain);
379 
380 /*----------------------------------------------------------------------------*/
381 
383 
384 #endif /* __CS_DOMAIN_H__ */
void cs_domain_set_default_boundary(cs_domain_t *domain, cs_domain_boundary_type_t type)
Set the default boundary related to this domain.
Definition: cs_domain.c:340
time step descriptor
Definition: cs_time_step.h:51
cs_time_step_options_t time_options
Definition: cs_domain.h:121
cs_time_step_t * time_step
Definition: cs_domain.h:120
bool cs_domain_needs_iteration(cs_domain_t *domain)
Check if one needs to continue iterations in time.
Definition: cs_domain.c:516
cs_domain_t * cs_domain_create(void)
Create and initialize by default a cs_domain_t structure.
Definition: cs_domain.c:161
void cs_domain_add_boundary(cs_domain_t *domain, cs_domain_boundary_type_t type, const char *zone_name)
Add a boundary type defined on a mesh location.
Definition: cs_domain.c:366
Definition: cs_domain.h:70
Definition: cs_domain.h:65
int * zone_ids
Definition: cs_domain.h:74
cs_cdo_connect_t * connect
Definition: cs_domain.h:107
void cs_domain_increment_time(cs_domain_t *domain)
Update time step after one temporal iteration.
Definition: cs_domain.c:643
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
Definition: cs_domain.h:62
Definition: cs_cdo_connect.h:69
int verbosity
Definition: cs_domain.h:125
Definition: cs_domain.h:63
Definition: cs_domain.h:79
void cs_domain_set_output_param(cs_domain_t *domain, int nt_list, int verbosity)
Set auxiliary parameters related to the way output is done.
Definition: cs_domain.c:425
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:300
cs_domain_cdo_context_t * cdo_context
Definition: cs_domain.h:130
cs_domain_boundary_type_t
Definition: cs_domain.h:60
Definition: cs_cdo_quantities.h:94
cs_real_t() cs_timestep_func_t(int time_iter, double time, void *input)
Function which defines the time step according to the number of iteration already done...
Definition: cs_param.h:89
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:668
void cs_domain_free(cs_domain_t **p_domain)
Free a cs_domain_t structure.
Definition: cs_domain.c:233
int output_nt
Definition: cs_domain.h:124
const cs_mesh_t * mesh
Definition: cs_domain.h:100
cs_timer_counter_t tcs
Definition: cs_domain.h:135
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:274
Definition: cs_mesh.h:63
const cs_mesh_quantities_t * mesh_quantities
Definition: cs_domain.h:101
cs_flag_t vb_scheme_flag
Definition: cs_domain.h:90
cs_domain_t * cs_glob_domain
Definition: cs_domain.c:85
int n_zones
Definition: cs_domain.h:73
const char * cs_domain_get_boundary_name(cs_domain_boundary_type_t type)
Get the name of the domain boundary condition.
Definition: cs_domain.c:322
Definition: cs_field_pointer.h:65
bool is_last_iter
Definition: cs_domain.h:117
double dt_cur
Definition: cs_domain.h:118
Definition: cs_mesh_quantities.h:85
cs_cdo_quantities_t * cdo_quantities
Definition: cs_domain.h:108
void cs_domain_def_time_step_by_value(cs_domain_t *domain, double dt)
Define the value of the time step.
Definition: cs_domain.c:486
bool force_advfield_update
Definition: cs_domain.h:85
cs_domain_boundary_t * boundary
Definition: cs_domain.h:113
Definition: cs_domain.h:97
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:122
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:579
bool only_steady
Definition: cs_domain.h:116
cs_flag_t fb_scheme_flag
Definition: cs_domain.h:89
cs_timer_counter_t tcp
Definition: cs_domain.h:133
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:550
time step options descriptor
Definition: cs_time_step.h:76
void cs_domain_activate_profiling(cs_domain_t *domain)
Activate profiling output.
#define END_C_DECLS
Definition: cs_defs.h:462
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_flag_t hho_scheme_flag
Definition: cs_domain.h:92
int mode
Definition: cs_domain.h:82
void cs_domain_def_time_step_by_function(cs_domain_t *domain, cs_timestep_func_t *func, void *func_input)
Define the value of the time step thanks to a predefined function.
Definition: cs_domain.c:449
cs_domain_boundary_type_t default_type
Definition: cs_domain.h:72
bool profiling
Definition: cs_domain.h:126
void cs_domain_set_time_param(cs_domain_t *domain, int nt_max, double t_max)
Set parameters for unsteady computations: the max number of time steps or the final physical time of ...
Definition: cs_domain.c:404
cs_xdef_t * time_step_def
Definition: cs_domain.h:119
Definition: cs_domain.h:64
Definition: cs_domain.h:66
cs_domain_boundary_type_t * zone_type
Definition: cs_domain.h:75
cs_flag_t vcb_scheme_flag
Definition: cs_domain.h:91
void cs_domain_summary(const cs_domain_t *domain)
Summary of a cs_domain_t structure.
Definition: cs_timer.h:57