programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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-2017 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_advection_field.h"
35 #include "cs_cdo_connect.h"
36 #include "cs_cdo_quantities.h"
37 #include "cs_equation.h"
38 #include "cs_gwf.h"
39 #include "cs_mesh.h"
40 #include "cs_mesh_quantities.h"
41 #include "cs_param.h"
42 #include "cs_property.h"
43 #include "cs_time_step.h"
44 #include "cs_timer.h"
45 #include "cs_xdef.h"
46 
47 /*----------------------------------------------------------------------------*/
48 
50 
51 /*============================================================================
52  * Macro definitions
53  *============================================================================*/
54 
55 /*============================================================================
56  * Type definitions
57  *============================================================================*/
58 
59 typedef struct {
60 
61  cs_param_boundary_type_t default_type; // boundary set by default
62  int n_zones;
63  int *zone_ids;
65 
67 
68 typedef struct {
69 
70  /* Code_Saturne mesh and mesh quantities structures already computed */
71  const cs_mesh_t *mesh;
73 
74  /* CDO structures:
75  - cs_cdo_connect_t contains additional information about connectivity
76  - cs_cdo_quantities_t contains additional information on mesh quantities
77  */
80 
81  /* Physical boundary conditions on the computational domain:
82  inlet, outmet, wall, symmetry...
83  Store the type of boundary set on each boundary face */
85 
86  /* Time step management */
87  bool is_last_iter; // true or false
88  double dt_cur; // current time step
89  cs_xdef_t *time_step_def; // Definition of the time_step
90  cs_time_step_t *time_step; // time step descriptor
91  cs_time_step_options_t time_options; // time step options
92 
95 
96  /* Flag to know if scalar or vector equations are requested and which kind
97  of numerical schemes is requested to solve these equations */
99 
100  /* Output options */
101  int output_nt; /* Log information every nt iteration(s) */
102  int verbosity; /* Level of details given in log */
103  bool profiling; /* Activate a set of timer statistics (details differ
104  according to the verbosity level) */
105 
106  /* Monitoring */
107  cs_timer_counter_t tcp; /* Cumulated elapsed time for extra-operations
108  and post-processing */
109  cs_timer_counter_t tcs; /* Cumulated elapsed time for setup operations */
110 
111 } cs_domain_t;
112 
113 /* List of available keys for setting a property */
114 typedef enum {
115 
116  CS_DOMAIN_PROFILING, // activate the profiling
118 
120 
121 /*============================================================================
122  * Static global variables
123  *============================================================================*/
124 
125 extern cs_domain_t *cs_glob_domain; /* Pointer to main computational domain
126  used in CDO/HHO schmes */
127 
128 /*============================================================================
129  * Public function prototypes
130  *============================================================================*/
131 
132 /*----------------------------------------------------------------------------*/
138 /*----------------------------------------------------------------------------*/
139 
140 cs_domain_t *
141 cs_domain_create(void);
142 
143 /*----------------------------------------------------------------------------*/
151 /*----------------------------------------------------------------------------*/
152 
153 cs_domain_t *
154 cs_domain_free(cs_domain_t *domain);
155 
156 /*----------------------------------------------------------------------------*/
163 /*----------------------------------------------------------------------------*/
164 
165 void
168 
169 /*----------------------------------------------------------------------------*/
177 /*----------------------------------------------------------------------------*/
178 
179 void
182  const char *zone_name);
183 
184 /*----------------------------------------------------------------------------*/
193 /*----------------------------------------------------------------------------*/
194 
195 void
197  int nt_max,
198  double t_max);
199 
200 /*----------------------------------------------------------------------------*/
208 /*----------------------------------------------------------------------------*/
209 
210 void
212  int nt_list,
213  int verbosity);
214 
215 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
222 
223 void
225 
226 /*----------------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------------*/
235 
236 void
238  cs_domain_key_t key,
239  const char *keyval);
240 
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 /*----------------------------------------------------------------------------*/
276 /*----------------------------------------------------------------------------*/
277 
278 void
280 
281 /*----------------------------------------------------------------------------*/
287 /*----------------------------------------------------------------------------*/
288 
289 void
291 
292 /*----------------------------------------------------------------------------*/
298 /*----------------------------------------------------------------------------*/
299 
300 void
302 
303 /*----------------------------------------------------------------------------*/
311 /*----------------------------------------------------------------------------*/
312 
313 void
315  cs_mesh_t *mesh,
316  const cs_mesh_quantities_t *mesh_quantities);
317 
318 /*----------------------------------------------------------------------------*/
325 /*----------------------------------------------------------------------------*/
326 
327 void
329 
330 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
340 bool
342 
343 /*----------------------------------------------------------------------------*/
351 /*----------------------------------------------------------------------------*/
352 
353 bool
354 cs_domain_needs_log(const cs_domain_t *domain);
355 
356 /*----------------------------------------------------------------------------*/
362 /*----------------------------------------------------------------------------*/
363 
364 void
366 
367 /*----------------------------------------------------------------------------*/
373 /*----------------------------------------------------------------------------*/
374 
375 void
377 
378 /*----------------------------------------------------------------------------*/
384 /*----------------------------------------------------------------------------*/
385 
386 void
388 
389 /*----------------------------------------------------------------------------*/
395 /*----------------------------------------------------------------------------*/
396 
397 void
399 
400 /*----------------------------------------------------------------------------*/
406 /*----------------------------------------------------------------------------*/
407 
408 void
409 cs_domain_read_restart(const cs_domain_t *domain);
410 
411 /*----------------------------------------------------------------------------*/
417 /*----------------------------------------------------------------------------*/
418 
419 void
420 cs_domain_write_restart(const cs_domain_t *domain);
421 
422 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
431 cs_domain_summary(const cs_domain_t *domain);
432 
433 /*----------------------------------------------------------------------------*/
434 
436 
437 #endif /* __CS_DOMAIN_H__ */
Definition: cs_domain.h:116
time step descriptor
Definition: cs_time_step.h:51
cs_time_step_options_t time_options
Definition: cs_domain.h:91
void cs_domain_read_restart(const cs_domain_t *domain)
Read a restart file for the CDO module.
Definition: cs_domain.c:1185
cs_param_boundary_type_t
Definition: cs_param.h:150
cs_time_step_t * time_step
Definition: cs_domain.h:90
bool cs_domain_needs_iteration(cs_domain_t *domain)
Check if one needs to continue iterations in time.
Definition: cs_domain.c:918
cs_domain_t * cs_domain_create(void)
Create and initialize by default a cs_domain_t structure.
Definition: cs_domain.c:311
Definition: cs_domain.h:59
cs_domain_boundary_t * boundary_def
Definition: cs_domain.h:84
int * zone_ids
Definition: cs_domain.h:63
cs_cdo_connect_t * connect
Definition: cs_domain.h:78
void cs_domain_increment_time(cs_domain_t *domain)
Update time step after one temporal iteration.
Definition: cs_domain.c:1041
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
cs_param_boundary_type_t * type_by_zone
Definition: cs_domain.h:64
Definition: cs_cdo_connect.h:55
void cs_domain_set_default_boundary(cs_domain_t *domain, cs_param_boundary_type_t type)
Set the default boundary related to this domain.
Definition: cs_domain.c:446
int verbosity
Definition: cs_domain.h:102
cs_param_boundary_type_t default_type
Definition: cs_domain.h:61
void cs_domain_set_advanced_param(cs_domain_t *domain, cs_domain_key_t key, const char *keyval)
Set auxiliary parameters related to a cs_domain_t structure.
Definition: cs_domain.c:570
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:530
void cs_domain_process_after_solve(cs_domain_t *domain)
Process the computational domain after the resolution.
Definition: cs_domain.c:1146
void cs_domain_set_scheme_flag(cs_domain_t *domain)
Define the scheme flag for the current computational domain.
Definition: cs_domain.c:718
Definition: cs_cdo_quantities.h:89
int output_nt
Definition: cs_domain.h:101
const cs_mesh_t * mesh
Definition: cs_domain.h:71
cs_timer_counter_t tcs
Definition: cs_domain.h:109
Definition: cs_mesh.h:63
void cs_domain_finalize_setup(cs_domain_t *domain, cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
Build a cs_domain_t structure.
Definition: cs_domain.c:780
void cs_domain_update_mesh_locations(cs_domain_t *domain)
Add new mesh locations related to domain boundaries from existing mesh locations. ...
Definition: cs_domain.c:669
const cs_mesh_quantities_t * mesh_quantities
Definition: cs_domain.h:72
cs_domain_t * cs_glob_domain
Definition: cs_domain.c:85
int n_zones
Definition: cs_domain.h:62
Definition: cs_field_pointer.h:65
bool is_last_iter
Definition: cs_domain.h:87
double dt_cur
Definition: cs_domain.h:88
Definition: cs_mesh_quantities.h:82
cs_cdo_quantities_t * cdo_quantities
Definition: cs_domain.h:79
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:640
void cs_domain_update_advfield(cs_domain_t *domain)
Set to true the automatic update of all advection fields.
Definition: cs_domain.c:552
bool force_advfield_update
Definition: cs_domain.h:94
Definition: cs_domain.h:68
Definition: cs_xdef.h:72
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:981
bool only_steady
Definition: cs_domain.h:93
Definition: cs_domain.h:117
void cs_domain_setup_predefined_equations(cs_domain_t *domain)
Setup predefined equations which are activated.
Definition: cs_domain.c:695
cs_timer_counter_t tcp
Definition: cs_domain.h:107
void cs_domain_write_restart(const cs_domain_t *domain)
Write a restart file for the CDO module.
Definition: cs_domain.c:1330
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:952
cs_flag_t scheme_flag
Definition: cs_domain.h:98
time step options descriptor
Definition: cs_time_step.h:76
#define END_C_DECLS
Definition: cs_defs.h:454
cs_domain_t * cs_domain_free(cs_domain_t *domain)
Free a cs_domain_t structure.
Definition: cs_domain.c:390
unsigned short int cs_flag_t
Definition: cs_defs.h:299
void cs_domain_solve(cs_domain_t *domain)
Solve all the equations of a computational domain for one time step.
Definition: cs_domain.c:1066
void cs_domain_initialize_systems(cs_domain_t *domain)
Initialize systems of equations and their related field values according to the user settings...
Definition: cs_domain.c:883
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_cdo.h:192
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:603
cs_domain_key_t
Definition: cs_domain.h:114
bool profiling
Definition: cs_domain.h:103
void cs_domain_add_boundary(cs_domain_t *domain, cs_param_boundary_type_t type, const char *zone_name)
Add a boundary type defined on a mesh location.
Definition: cs_domain.c:471
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:509
cs_xdef_t * time_step_def
Definition: cs_domain.h:89
void cs_domain_summary(const cs_domain_t *domain)
Summary of a cs_domain_t structure.
Definition: cs_domain.c:1432
Definition: cs_timer.h:57