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-2016 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_time_step.h"
35 #include "cs_mesh.h"
36 #include "cs_mesh_quantities.h"
37 #include "cs_cdo_connect.h"
38 #include "cs_cdo_quantities.h"
39 #include "cs_param.h"
40 #include "cs_equation.h"
41 #include "cs_property.h"
42 #include "cs_advection_field.h"
43 #include "cs_groundwater.h"
44 
45 /*----------------------------------------------------------------------------*/
46 
48 
49 /*============================================================================
50  * Macro definitions
51  *============================================================================*/
52 
53 /*============================================================================
54  * Type definitions
55  *============================================================================*/
56 
57 /* Store information about the kind of boundary attached to the computational
58  domain: inlet, outlet, wall, symmetry... */
59 
60 typedef struct _cs_domain_boundary_t cs_domain_boundary_t;
61 
62 typedef struct {
63 
64  /* Code_Saturne mesh and mesh quantities structures already computed */
65  const cs_mesh_t *mesh;
67 
68  /* CDO structures:
69  - cs_cdo_connect_t contains additional information about connectivity
70  - cs_cdo_quantities_t contains additional information on mesh quantities
71  */
72 
75 
76  /* Physical boundary conditions on the computational domain */
77  cs_domain_boundary_t *boundaries;
78 
79  /* Time step management */
80  double dt_cur; // current time step
81  cs_param_def_type_t time_step_def_type; // Way of defining the time step
82  cs_def_t time_step_def; // Definition of the time_step
83  cs_time_step_t *time_step; // time step descriptor
84  cs_time_step_options_t time_options; // time step options
85 
86  /* Properties attached to the computational domain.
87  "unity" is created by default
88  */
90  cs_property_t **properties;
91 
92  /* Advection fields attached to the computational domain */
94  cs_adv_field_t **adv_fields;
95 
96  /* Number of equations defined on this domain splitted into
97  predefined equations and user equations.
98  Predefined equations are stored first.
99  */
103  cs_equation_t **equations;
104 
106 
107  /* Flag to know if scalar or vector equations are requested and which kind
108  of numerical schemes is requested to solve these equations */
110 
111 
112  /* Pre-defined equations to solve
113  If xxxxx_eq_id = -1, then this equation is not activated */
114 
115  /* GROUNDWATER FLOW MODULE */
116 
117  int richards_eq_id; // Main equation of the groundwater module
118  cs_groundwater_t *gw; // 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  cs_real_t output_dt; /* Log information every dt elapsed simulated time */
128  int verbosity; /* Level of details given in log */
129  bool profiling; /* Activate a set of timer statistics (details differ
130  according to the verbosity level) */
131 
132 } cs_domain_t;
133 
134 /* List of available keys for setting a property */
135 typedef enum {
136 
137  CS_DOMAIN_DEFAULT_BOUNDARY, // set the default boundary
138  CS_DOMAIN_OUTPUT_NT, // set the output frequency (number of iterations)
139  CS_DOMAIN_OUTPUT_DT, // set the output frequency (simulation time)
140  CS_DOMAIN_PROFILING, // activate the profiling
141  CS_DOMAIN_NTMAX, // set the max number of iterations to perform
142  CS_DOMAIN_TMAX, // set the maximum simulated time
143  CS_DOMAIN_VERBOSITY, // set the verbosity
145 
147 
148 /*============================================================================
149  * Static global variables
150  *============================================================================*/
151 
152 /*============================================================================
153  * Public function prototypes
154  *============================================================================*/
155 
156 /*----------------------------------------------------------------------------*/
165 /*----------------------------------------------------------------------------*/
166 
167 cs_domain_t *
169  const cs_mesh_quantities_t *mesh_quantities);
170 
171 /*----------------------------------------------------------------------------*/
179 /*----------------------------------------------------------------------------*/
180 
181 cs_domain_t *
182 cs_domain_free(cs_domain_t *domain);
183 
184 /*----------------------------------------------------------------------------*/
192 /*----------------------------------------------------------------------------*/
193 
194 void
196  cs_domain_key_t key,
197  const char *keyval);
198 
199 /*----------------------------------------------------------------------------*/
207 /*----------------------------------------------------------------------------*/
208 
209 bool
210 cs_domain_needs_log(const cs_domain_t *domain);
211 
212 /*----------------------------------------------------------------------------*/
218 /*----------------------------------------------------------------------------*/
219 
220 void
221 cs_domain_summary(const cs_domain_t *domain);
222 
223 /*----------------------------------------------------------------------------*/
229 /*----------------------------------------------------------------------------*/
230 
231 void
233 
234 /*----------------------------------------------------------------------------*/
242 /*----------------------------------------------------------------------------*/
243 
244 void
246  const char *ml_name,
247  const char *bdy_name);
248 
249 /*----------------------------------------------------------------------------*/
256 /*----------------------------------------------------------------------------*/
257 
258 void
260  cs_timestep_func_t *func);
261 
262 /*----------------------------------------------------------------------------*/
269 /*----------------------------------------------------------------------------*/
270 
271 void
273  double dt);
274 
275 /*----------------------------------------------------------------------------*/
283 /*----------------------------------------------------------------------------*/
284 
285 bool
287 
288 /*----------------------------------------------------------------------------*/
294 /*----------------------------------------------------------------------------*/
295 
296 void
298 
299 /*----------------------------------------------------------------------------*/
305 /*----------------------------------------------------------------------------*/
306 
307 void
309 
310 /*----------------------------------------------------------------------------*/
319 /*----------------------------------------------------------------------------*/
320 
321 void
323  const char *pty_name,
324  const char *type_name,
325  int n_subdomains);
326 
327 /*----------------------------------------------------------------------------*/
336 /*----------------------------------------------------------------------------*/
337 
338 cs_property_t *
339 cs_domain_get_property(const cs_domain_t *domain,
340  const char *ref_name);
341 
342 /*----------------------------------------------------------------------------*/
349 /*----------------------------------------------------------------------------*/
350 
351 void
353  const char *adv_name);
354 
355 /*----------------------------------------------------------------------------*/
364 /*----------------------------------------------------------------------------*/
365 
366 cs_adv_field_t *
368  const char *ref_name);
369 
370 /*----------------------------------------------------------------------------*/
380 /*----------------------------------------------------------------------------*/
381 
382 cs_equation_t *
383 cs_domain_get_equation(const cs_domain_t *domain,
384  const char *eqname);
385 
386 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 void
396 
397 /*----------------------------------------------------------------------------*/
407 /*----------------------------------------------------------------------------*/
408 
409 void
411  const char *kw_type,
412  const char *kw_time,
413  int n_soils,
414  int n_tracers);
415 
416 /*----------------------------------------------------------------------------*/
425 /*----------------------------------------------------------------------------*/
426 
427 cs_groundwater_t *
429 
430 /*----------------------------------------------------------------------------*/
442 /*----------------------------------------------------------------------------*/
443 
444 void
446  const char *eq_name,
447  const char *var_name);
448 
449 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
466 void
468  const char *eq_name,
469  const char *ml_name,
470  double wmd,
471  double alpha_l,
472  double alpha_t,
473  double bulk_density,
474  double distrib_coef,
475  double reaction_rate);
476 
477 /*----------------------------------------------------------------------------*/
483 /*----------------------------------------------------------------------------*/
484 
485 void
487 
488 /*----------------------------------------------------------------------------*/
499 /*----------------------------------------------------------------------------*/
500 
501 void
503  const char *eqname,
504  const char *varname,
505  const char *key_type,
506  const char *key_bc);
507 
508 /*----------------------------------------------------------------------------*/
515 /*----------------------------------------------------------------------------*/
516 
517 void
519 
520 /*----------------------------------------------------------------------------*/
526 /*----------------------------------------------------------------------------*/
527 
528 void
530 
531 /*----------------------------------------------------------------------------*/
537 /*----------------------------------------------------------------------------*/
538 
539 void
541 
542 /*----------------------------------------------------------------------------*/
548 /*----------------------------------------------------------------------------*/
549 
550 void
551 cs_domain_write_restart(const cs_domain_t *domain);
552 
553 /*----------------------------------------------------------------------------*/
554 
556 
557 #endif /* __CS_DOMAIN_H__ */
Definition: cs_domain.h:140
int n_properties
Definition: cs_domain.h:89
time step descriptor
Definition: cs_time_step.h:51
cs_time_step_options_t time_options
Definition: cs_domain.h:84
int wall_distance_eq_id
Definition: cs_domain.h:121
cs_time_step_t * time_step
Definition: cs_domain.h:83
void cs_domain_set_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:659
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:1319
cs_cdo_connect_t * connect
Definition: cs_domain.h:73
void cs_domain_activate_wall_distance(cs_domain_t *domain)
Activate the computation of the wall distance.
Definition: cs_domain.c:1346
void cs_domain_increment_time(cs_domain_t *domain)
Update time step after one temporal iteration.
Definition: cs_domain.c:1165
cs_domain_t * cs_domain_init(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
Create and initialize of cs_domain_t structure.
Definition: cs_domain.c:483
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
void cs_domain_add_boundary(cs_domain_t *domain, const char *ml_name, const char *bdy_name)
Add a boundary type defined on a mesh location.
Definition: cs_domain.c:961
cs_domain_boundary_t * boundaries
Definition: cs_domain.h:77
void 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:1256
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:171
Definition: cs_cdo_connect.h:67
int n_equations
Definition: cs_domain.h:100
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:1232
int verbosity
Definition: cs_domain.h:128
bool cs_domain_needs_iterate(cs_domain_t *domain)
Check if one needs to continue iterations in time.
Definition: cs_domain.c:1087
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:1770
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
Definition: cs_cdo_quantities.h:100
int output_nt
Definition: cs_domain.h:126
const cs_mesh_t * mesh
Definition: cs_domain.h:65
Definition: cs_domain.h:143
cs_equation_t ** equations
Definition: cs_domain.h:103
void cs_domain_postprocess(cs_domain_t *domain)
Process the computed solution.
Definition: cs_domain.c:1885
Definition: cs_mesh.h:62
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:1027
void cs_domain_add_groundwater_tracer(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:1482
void cs_domain_last_setup(cs_domain_t *domain)
Proceed to the last settings of a cs_domain_t structure.
Definition: cs_domain.c:871
const cs_mesh_quantities_t * mesh_quantities
Definition: cs_domain.h:66
int n_predef_equations
Definition: cs_domain.h:101
void cs_domain_set_groundwater_tracer(cs_domain_t *domain, const char *eq_name, const char *ml_name, double wmd, double alpha_l, double alpha_t, double bulk_density, double distrib_coef, double reaction_rate)
Set the parameters related to a tracer equation used in the groundwater flow module.
Definition: cs_domain.c:1551
int n_adv_fields
Definition: cs_domain.h:93
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:1292
cs_adv_field_t ** adv_fields
Definition: cs_domain.h:94
Definition: cs_field_pointer.h:64
double dt_cur
Definition: cs_domain.h:80
int n_user_equations
Definition: cs_domain.h:102
Definition: cs_mesh_quantities.h:51
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:1059
Definition: cs_domain.h:141
Definition: cs_domain.h:137
int richards_eq_id
Definition: cs_domain.h:117
Definition: cs_domain.h:62
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:1119
bool only_steady
Definition: cs_domain.h:105
Definition: cs_domain.h:144
void cs_domain_setup_predefined_equations(cs_domain_t *domain)
Setup predefined equations which are activated.
Definition: cs_domain.c:1602
Definition: cs_param.h:57
cs_groundwater_t * cs_domain_get_groundwater(const cs_domain_t *domain)
Retrieve the pointer to a cs_groundwater_t structure related to this domain.
Definition: cs_domain.c:1459
void cs_domain_write_restart(const cs_domain_t *domain)
Write a restart file for the CDO module.
Definition: cs_domain.c:1930
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:726
cs_flag_t scheme_flag
Definition: cs_domain.h:109
void cs_domain_activate_groundwater(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.
Definition: cs_domain.c:1380
time step options descriptor
Definition: cs_time_step.h:76
#define END_C_DECLS
Definition: cs_defs.h:449
cs_domain_t * cs_domain_free(cs_domain_t *domain)
Free a cs_domain_t structure.
Definition: cs_domain.c:601
cs_param_def_type_t time_step_def_type
Definition: cs_domain.h:81
unsigned short int cs_flag_t
Definition: cs_defs.h:298
Definition: cs_domain.h:138
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:1712
void cs_domain_solve(cs_domain_t *domain)
Solve all the equations of a computational domain for one time step.
Definition: cs_domain.c:1790
void 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:1193
Definition: cs_domain.h:142
cs_real_t output_dt
Definition: cs_domain.h:127
Definition: cs_domain.h:139
cs_domain_key_t
Definition: cs_domain.h:135
bool profiling
Definition: cs_domain.h:129
cs_groundwater_t * gw
Definition: cs_domain.h:118
cs_property_t ** properties
Definition: cs_domain.h:90
cs_param_def_type_t
Definition: cs_param.h:82
Definition: mesh.f90:26
cs_def_t time_step_def
Definition: cs_domain.h:82
void cs_domain_summary(const cs_domain_t *domain)
Summary of a cs_domain_t structure.
Definition: cs_domain.c:759