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_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 
46 /*----------------------------------------------------------------------------*/
47 
49 
50 /*============================================================================
51  * Macro definitions
52  *============================================================================*/
53 
54 /*============================================================================
55  * Type definitions
56  *============================================================================*/
57 
58 /* Store information about the kind of boundary attached to the computational
59  domain: inlet, outlet, wall, symmetry... */
60 
61 typedef struct _cs_domain_boundary_t cs_domain_boundary_t;
62 
63 typedef struct {
64 
65  /* Code_Saturne mesh and mesh quantities structures already computed */
66  const cs_mesh_t *mesh;
68 
69  /* CDO structures:
70  - cs_cdo_connect_t contains additional information about connectivity
71  - cs_cdo_quantities_t contains additional information on mesh quantities
72  */
75 
76  /* Physical boundary conditions on the computational domain */
77  cs_domain_boundary_t *boundaries;
78 
79  /* Time step management */
80  bool is_last_iter; // true or false
81  double dt_cur; // current time step
82  cs_param_def_type_t time_step_def_type; // Way of defining the time step
83  cs_def_t time_step_def; // Definition of the time_step
84  cs_time_step_t *time_step; // time step descriptor
85  cs_time_step_options_t time_options; // time step options
86 
87  /* Properties attached to the computational domain.
88  "unity" is created by default
89  */
92 
93  /* Advection fields attached to the computational domain */
96 
97  /* Number of equations defined on this domain splitted into
98  predefined equations and user equations.
99  Predefined equations are stored first.
100  */
104  cs_equation_t **equations;
105 
108 
109  /* Flag to know if scalar or vector equations are requested and which kind
110  of numerical schemes is requested to solve these equations */
112 
113  /* Pre-defined equations to solve
114  If xxxxx_eq_id = -1, then this equation is not activated */
115 
116  /* GROUNDWATER FLOW MODULE */
117  int richards_eq_id; // Main equation of the groundwater flow module
118  cs_gwf_t *gwf; // NULL is not activated
119 
120  /* WALL DISTANCE */
121  int wall_distance_eq_id; // Wall distance computation
122 
123  /* TODO: NAVIER-STOKES */
124 
125  /* Output options */
126  int output_nt; /* Log information every nt iteration(s) */
127  int verbosity; /* Level of details given in log */
128  bool profiling; /* Activate a set of timer statistics (details differ
129  according to the verbosity level) */
130 
131  /* Monitoring */
132  cs_timer_counter_t tcp; /* Cumulated elapsed time for extra-operations
133  and post-processing */
134  cs_timer_counter_t tcs; /* Cumulated elapsed time for setup operations */
135 
136 } cs_domain_t;
137 
138 /* List of available keys for setting a property */
139 typedef enum {
140 
141  CS_DOMAIN_PROFILING, // activate the profiling
143 
145 
146 /*============================================================================
147  * Static global variables
148  *============================================================================*/
149 
150 extern cs_domain_t *cs_glob_domain; /* Pointer to main computational domain
151  used in CDO/HHO schmes */
152 
153 /*============================================================================
154  * Public function prototypes
155  *============================================================================*/
156 
157 /*----------------------------------------------------------------------------*/
163 /*----------------------------------------------------------------------------*/
164 
165 cs_domain_t *
166 cs_domain_create(void);
167 
168 /*----------------------------------------------------------------------------*/
176 /*----------------------------------------------------------------------------*/
177 
178 cs_domain_t *
179 cs_domain_free(cs_domain_t *domain);
180 
181 /*----------------------------------------------------------------------------*/
189 /*----------------------------------------------------------------------------*/
190 
191 void
194 
195 /*----------------------------------------------------------------------------*/
203 /*----------------------------------------------------------------------------*/
204 
205 void
208  const char *ml_name);
209 
210 /*----------------------------------------------------------------------------*/
219 /*----------------------------------------------------------------------------*/
220 
221 void
223  int nt_max,
224  double t_max);
225 
226 /*----------------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------------*/
235 
236 void
238  int nt_list,
239  int verbosity);
240 
241 /*----------------------------------------------------------------------------*/
247 /*----------------------------------------------------------------------------*/
248 
249 void
251 
252 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
262 void
264  cs_domain_key_t key,
265  const char *keyval);
266 
267 /*----------------------------------------------------------------------------*/
274 /*----------------------------------------------------------------------------*/
275 
276 void
278  cs_timestep_func_t *func);
279 
280 /*----------------------------------------------------------------------------*/
287 /*----------------------------------------------------------------------------*/
288 
289 void
291  double dt);
292 
293 /*----------------------------------------------------------------------------*/
304 /*----------------------------------------------------------------------------*/
305 
308  const char *pty_name,
309  const char *type_name,
310  int n_subdomains);
311 
312 /*----------------------------------------------------------------------------*/
321 /*----------------------------------------------------------------------------*/
322 
325  const char *adv_name);
326 
327 /*----------------------------------------------------------------------------*/
337 /*----------------------------------------------------------------------------*/
338 
339 cs_equation_t *
341 
342 /*----------------------------------------------------------------------------*/
362 /*----------------------------------------------------------------------------*/
363 
364 cs_gwf_t *
366  const char *kw_type,
367  const char *kw_time,
368  int n_soils,
369  int n_tracers);
370 
371 /*----------------------------------------------------------------------------*/
383 /*----------------------------------------------------------------------------*/
384 
385 void
387  const char *eq_name,
388  const char *var_name);
389 
390 /*----------------------------------------------------------------------------*/
404 /*----------------------------------------------------------------------------*/
405 
406 void
408  const char *eq_name,
409  const char *ml_name,
410  double wmd,
411  double alpha_l,
412  double alpha_t,
413  double distrib_coef,
414  double reaction_rate);
415 
416 /*----------------------------------------------------------------------------*/
427 /*----------------------------------------------------------------------------*/
428 
429 void
431  const char *eqname,
432  const char *varname,
433  const char *key_type,
434  const char *key_bc);
435 
436 /*----------------------------------------------------------------------------*/
443 /*----------------------------------------------------------------------------*/
444 
445 void
447 
448 /*----------------------------------------------------------------------------*/
454 /*----------------------------------------------------------------------------*/
455 
456 void
458 
459 /*----------------------------------------------------------------------------*/
468 /*----------------------------------------------------------------------------*/
469 
471 cs_domain_get_property(const cs_domain_t *domain,
472  const char *ref_name);
473 
474 /*----------------------------------------------------------------------------*/
483 /*----------------------------------------------------------------------------*/
484 
487  const char *ref_name);
488 
489 /*----------------------------------------------------------------------------*/
499 /*----------------------------------------------------------------------------*/
500 
501 cs_equation_t *
502 cs_domain_get_equation(const cs_domain_t *domain,
503  const char *eqname);
504 
505 /*----------------------------------------------------------------------------*/
514 /*----------------------------------------------------------------------------*/
515 
516 cs_gwf_t *
518 
519 /*----------------------------------------------------------------------------*/
526 /*----------------------------------------------------------------------------*/
527 
528 void
530 
531 /*----------------------------------------------------------------------------*/
537 /*----------------------------------------------------------------------------*/
538 
539 void
541 
542 /*----------------------------------------------------------------------------*/
550 /*----------------------------------------------------------------------------*/
551 
552 void
554  cs_mesh_t *mesh,
555  const cs_mesh_quantities_t *mesh_quantities);
556 
557 /*----------------------------------------------------------------------------*/
565 /*----------------------------------------------------------------------------*/
566 
567 bool
569 
570 /*----------------------------------------------------------------------------*/
578 /*----------------------------------------------------------------------------*/
579 
580 bool
581 cs_domain_needs_log(const cs_domain_t *domain);
582 
583 /*----------------------------------------------------------------------------*/
589 /*----------------------------------------------------------------------------*/
590 
591 void
593 
594 /*----------------------------------------------------------------------------*/
600 /*----------------------------------------------------------------------------*/
601 
602 void
604 
605 /*----------------------------------------------------------------------------*/
611 /*----------------------------------------------------------------------------*/
612 
613 void
615 
616 /*----------------------------------------------------------------------------*/
622 /*----------------------------------------------------------------------------*/
623 
624 void
626 
627 /*----------------------------------------------------------------------------*/
633 /*----------------------------------------------------------------------------*/
634 
635 void
636 cs_domain_write_restart(const cs_domain_t *domain);
637 
638 /*----------------------------------------------------------------------------*/
644 /*----------------------------------------------------------------------------*/
645 
646 void
647 cs_domain_summary(const cs_domain_t *domain);
648 
649 /*----------------------------------------------------------------------------*/
650 
652 
653 #endif /* __CS_DOMAIN_H__ */
Definition: cs_domain.h:141
int n_properties
Definition: cs_domain.h:90
time step descriptor
Definition: cs_time_step.h:51
cs_time_step_options_t time_options
Definition: cs_domain.h:85
int wall_distance_eq_id
Definition: cs_domain.h:121
Definition: cs_advection_field.h:59
cs_param_boundary_type_t
Definition: cs_param.h:262
cs_time_step_t * time_step
Definition: cs_domain.h:84
cs_domain_t * cs_domain_create(void)
Create and initialize by default a cs_domain_t structure.
Definition: cs_domain.c:381
cs_equation_t * cs_domain_get_equation(const cs_domain_t *domain, const char *eqname)
Find the cs_equation_t structure whith name eqname Return NULL if not find.
Definition: cs_domain.c:1352
cs_cdo_connect_t * connect
Definition: cs_domain.h:73
void cs_domain_add_boundary(cs_domain_t *domain, cs_param_boundary_type_t type, const char *ml_name)
Add a boundary type defined on a mesh location.
Definition: cs_domain.c:569
void cs_domain_increment_time(cs_domain_t *domain)
Update time step after one temporal iteration.
Definition: cs_domain.c:1706
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
cs_domain_boundary_t * boundaries
Definition: cs_domain.h:77
cs_real_t() cs_timestep_func_t(int time_iter, double time)
Simple function to define the time step according to the number of iteration already done...
Definition: cs_cdo.h:177
Definition: cs_cdo_connect.h:56
cs_equation_t * cs_domain_activate_wall_distance(cs_domain_t *domain)
Activate the computation of the wall distance Define a new equation called "WallDistance" and its rel...
Definition: cs_domain.c:845
void cs_domain_set_default_boundary(cs_domain_t *domain, cs_param_boundary_type_t type)
Add a boundary type defined on a mesh location.
Definition: cs_domain.c:544
int n_equations
Definition: cs_domain.h:101
cs_property_t * cs_domain_get_property(const cs_domain_t *domain, const char *ref_name)
Find the related property definition from its name.
Definition: cs_domain.c:1299
int verbosity
Definition: cs_domain.h:127
bool cs_domain_needs_iterate(cs_domain_t *domain)
Check if one needs to continue iterations in time.
Definition: cs_domain.c:1586
void cs_domain_create_fields(cs_domain_t *domain)
Create a cs_field_t structure for each equation defined in the domain.
Definition: cs_domain.c:1400
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:671
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:631
void cs_domain_process_after_solve(cs_domain_t *domain)
Process the computational domain after the resolution.
Definition: cs_domain.c:1821
void cs_domain_set_scheme_flag(cs_domain_t *domain)
Define the scheme flag for the current computational domain.
Definition: cs_domain.c:1420
Definition: cs_cdo_quantities.h:102
int output_nt
Definition: cs_domain.h:126
const cs_mesh_t * mesh
Definition: cs_domain.h:66
cs_equation_t ** equations
Definition: cs_domain.h:104
cs_timer_counter_t tcs
Definition: cs_domain.h:134
Definition: cs_mesh.h:63
void cs_domain_def_time_step_by_function(cs_domain_t *domain, cs_timestep_func_t *func)
Define the value of the time step thanks to a predefined function.
Definition: cs_domain.c:703
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:1074
const cs_mesh_quantities_t * mesh_quantities
Definition: cs_domain.h:67
int n_predef_equations
Definition: cs_domain.h:102
cs_domain_t * cs_glob_domain
Definition: cs_domain.c:83
int n_adv_fields
Definition: cs_domain.h:94
cs_adv_field_t * cs_domain_get_advection_field(const cs_domain_t *domain, const char *ref_name)
Find the related advection field definition from its name.
Definition: cs_domain.c:1325
cs_adv_field_t ** adv_fields
Definition: cs_domain.h:95
Definition: cs_field_pointer.h:65
bool is_last_iter
Definition: cs_domain.h:80
double dt_cur
Definition: cs_domain.h:81
int n_user_equations
Definition: cs_domain.h:103
Definition: cs_mesh_quantities.h:52
cs_cdo_quantities_t * cdo_quantities
Definition: cs_domain.h:74
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:734
void cs_domain_update_advfield(cs_domain_t *domain)
Set to true the automatic update of all advection fields.
Definition: cs_domain.c:653
bool force_advfield_update
Definition: cs_domain.h:107
int richards_eq_id
Definition: cs_domain.h:117
Definition: cs_domain.h:63
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:1649
cs_adv_field_t * cs_domain_add_advection_field(cs_domain_t *domain, const char *adv_name)
Add a new advection field to the current computational domain.
Definition: cs_domain.c:805
bool only_steady
Definition: cs_domain.h:106
cs_gwf_t * gwf
Definition: cs_domain.h:118
Definition: cs_domain.h:142
void cs_domain_add_gwf_tracer_eq(cs_domain_t *domain, const char *eq_name, const char *var_name)
Add a new equation related to the groundwater flow module This equation is a particular type of unste...
Definition: cs_domain.c:965
cs_gwf_t * cs_domain_activate_gwf(cs_domain_t *domain, const char *kw_type, const char *kw_time, int n_soils, int n_tracers)
Activate the computation of the Richards' equation This activation yields severals consequences: ...
Definition: cs_domain.c:889
void cs_domain_setup_predefined_equations(cs_domain_t *domain)
Setup predefined equations which are activated.
Definition: cs_domain.c:1130
cs_timer_counter_t tcp
Definition: cs_domain.h:132
Definition: cs_param.h:72
void cs_domain_set_gwf_tracer_eq(cs_domain_t *domain, const char *eq_name, const char *ml_name, double wmd, double alpha_l, double alpha_t, double distrib_coef, double reaction_rate)
Set the parameters related to a tracer equation used in the groundwater flow module.
Definition: cs_domain.c:1027
void cs_domain_write_restart(const cs_domain_t *domain)
Write a restart file for the CDO module.
Definition: cs_domain.c:1862
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:1620
cs_flag_t scheme_flag
Definition: cs_domain.h:111
time step options descriptor
Definition: cs_time_step.h:76
#define END_C_DECLS
Definition: cs_defs.h:452
cs_domain_t * cs_domain_free(cs_domain_t *domain)
Free a cs_domain_t structure.
Definition: cs_domain.c:476
cs_param_def_type_t time_step_def_type
Definition: cs_domain.h:82
unsigned short int cs_flag_t
Definition: cs_defs.h:299
void cs_domain_add_user_equation(cs_domain_t *domain, const char *eqname, const char *varname, const char *key_type, const char *key_bc)
Add a new user equation to a domain.
Definition: cs_domain.c:1240
cs_property_t * cs_domain_add_property(cs_domain_t *domain, const char *pty_name, const char *type_name, int n_subdomains)
Add a new property to the current computational domain.
Definition: cs_domain.c:764
void cs_domain_solve(cs_domain_t *domain)
Solve all the equations of a computational domain for one time step.
Definition: cs_domain.c:1731
void cs_domain_initialize(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:1478
cs_gwf_t * cs_domain_get_gwf_struct(const cs_domain_t *domain)
Retrieve the pointer to a cs_gwf_t structure related to this domain.
Definition: cs_domain.c:1382
cs_domain_key_t
Definition: cs_domain.h:139
bool profiling
Definition: cs_domain.h:128
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:610
cs_property_t ** properties
Definition: cs_domain.h:91
Definition: cs_property.h:66
cs_param_def_type_t
Definition: cs_param.h:94
Definition: mesh.f90:26
cs_def_t time_step_def
Definition: cs_domain.h:83
void cs_domain_summary(const cs_domain_t *domain)
Summary of a cs_domain_t structure.
Definition: cs_domain.c:1950
Definition: cs_timer.h:57