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-2015 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  /* Overview of pre-defined equations to solve
108  - Navier-Stokes equations (named NavierStokes)
109  - Groundwater module (named Richards)
110  - Wall distance (named WallDistance)
111 
112  Predefined equations
113  If xxxxx_eq_id = -1, then this equation is not activated */
114 
115  int richards_eq_id; // Main equation of the groundwater module
116  int wall_distance_eq_id; // Wall distance computation
117 
118  /* Groundwater flow module (NULL if not used) */
119  cs_groundwater_t *gw;
120 
121  /* Output options */
123 
124 } cs_domain_t;
125 
126 /*============================================================================
127  * Static global variables
128  *============================================================================*/
129 
130 /*============================================================================
131  * Public function prototypes
132  *============================================================================*/
133 
134 /*----------------------------------------------------------------------------*/
143 /*----------------------------------------------------------------------------*/
144 
145 cs_domain_t *
147  const cs_mesh_quantities_t *mesh_quantities);
148 
149 /*----------------------------------------------------------------------------*/
155 /*----------------------------------------------------------------------------*/
156 
157 void
159 
160 /*----------------------------------------------------------------------------*/
168 /*----------------------------------------------------------------------------*/
169 
170 cs_domain_t *
171 cs_domain_free(cs_domain_t *domain);
172 
173 /*----------------------------------------------------------------------------*/
179 /*----------------------------------------------------------------------------*/
180 
181 void
182 cs_domain_summary(const cs_domain_t *domain);
183 
184 /*----------------------------------------------------------------------------*/
191 /*----------------------------------------------------------------------------*/
192 
193 void
195  const char *bdy_name);
196 
197 /*----------------------------------------------------------------------------*/
205 /*----------------------------------------------------------------------------*/
206 
207 void
209  const char *ml_name,
210  const char *bdy_name);
211 
212 /*----------------------------------------------------------------------------*/
219 /*----------------------------------------------------------------------------*/
220 
221 void
223  int freq);
224 
225 /*----------------------------------------------------------------------------*/
235 /*----------------------------------------------------------------------------*/
236 
237 void
239  double t_end,
240  int nt_max,
241  const char *defkey,
242  void *defval);
243 
244 /*----------------------------------------------------------------------------*/
250 /*----------------------------------------------------------------------------*/
251 
252 void
254 
255 /*----------------------------------------------------------------------------*/
263 /*----------------------------------------------------------------------------*/
264 
265 void
267  const char *pty_name,
268  const char *type_name);
269 
270 /*----------------------------------------------------------------------------*/
279 /*----------------------------------------------------------------------------*/
280 
281 cs_property_t *
282 cs_domain_get_property(const cs_domain_t *domain,
283  const char *ref_name);
284 
285 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 
294 void
296  const char *adv_name);
297 
298 /*----------------------------------------------------------------------------*/
307 /*----------------------------------------------------------------------------*/
308 
309 cs_adv_field_t *
311  const char *ref_name);
312 
313 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
325 cs_equation_t *
326 cs_domain_get_equation(const cs_domain_t *domain,
327  const char *eqname);
328 
329 /*----------------------------------------------------------------------------*/
335 /*----------------------------------------------------------------------------*/
336 
337 void
339 
340 /*----------------------------------------------------------------------------*/
347 /*----------------------------------------------------------------------------*/
348 
349 void
351  const char *model);
352 
353 /*----------------------------------------------------------------------------*/
368 /*----------------------------------------------------------------------------*/
369 
370 void
372  const char *eq_name,
373  const char *var_name,
374  cs_real_3_t dispersivity,
375  double bulk_density,
376  double distribution_coef,
377  double reaction_rate);
378 
379 /*----------------------------------------------------------------------------*/
388 /*----------------------------------------------------------------------------*/
389 
390 cs_groundwater_t *
392 
393 /*----------------------------------------------------------------------------*/
399 /*----------------------------------------------------------------------------*/
400 
401 void
403 
404 /*----------------------------------------------------------------------------*/
415 /*----------------------------------------------------------------------------*/
416 
417 void
419  const char *eqname,
420  const char *varname,
421  const char *key_type,
422  const char *key_bc);
423 
424 /*----------------------------------------------------------------------------*/
431 /*----------------------------------------------------------------------------*/
432 
433 void
435 
436 /*----------------------------------------------------------------------------*/
444 /*----------------------------------------------------------------------------*/
445 
446 bool
448 
449 /*----------------------------------------------------------------------------*/
455 /*----------------------------------------------------------------------------*/
456 
457 void
459 
460 /*----------------------------------------------------------------------------*/
466 /*----------------------------------------------------------------------------*/
467 
468 void
470 
471 /*----------------------------------------------------------------------------*/
472 
474 
475 #endif /* __CS_DOMAIN_H__ */
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:116
cs_time_step_t * time_step
Definition: cs_domain.h:83
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:1172
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:1199
void cs_domain_increment_time(cs_domain_t *domain)
Update time step after one temporal iteration.
Definition: cs_domain.c:1531
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:481
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
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:834
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:1107
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:1083
bool cs_domain_needs_iterate(cs_domain_t *domain)
Check if one needs to continue iterations in time.
Definition: cs_domain.c:1498
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:1476
void cs_domain_activate_groundwater(cs_domain_t *domain, const char *model)
Activate the computation of the Richards' equation.
Definition: cs_domain.c:1230
Definition: cs_cdo_quantities.h:86
const cs_mesh_t * mesh
Definition: cs_domain.h:65
cs_equation_t ** equations
Definition: cs_domain.h:103
Definition: cs_mesh.h:62
void cs_domain_set_default_boundary(cs_domain_t *domain, const char *bdy_name)
Set the boundary type by default.
Definition: cs_domain.c:794
void cs_domain_last_setup(cs_domain_t *domain)
Proceed to the last settings of a cs_domain_t structure.
Definition: cs_domain.c:582
const cs_mesh_quantities_t * mesh_quantities
Definition: cs_domain.h:66
int n_predef_equations
Definition: cs_domain.h:101
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:1145
cs_adv_field_t ** adv_fields
Definition: cs_domain.h:94
int output_freq
Definition: cs_domain.h:122
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_set_time_step(cs_domain_t *domain, double t_end, int nt_max, const char *defkey, void *defval)
Setup the time step structure related to a domain.
Definition: cs_domain.c:925
int richards_eq_id
Definition: cs_domain.h:115
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:998
bool only_steady
Definition: cs_domain.h:105
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:307
void cs_domain_setup_predefined_equations(cs_domain_t *domain)
Setup predefined equations which are activated.
Definition: cs_domain.c:1380
Definition: cs_param.h:73
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:1294
void cs_domain_add_property(cs_domain_t *domain, const char *pty_name, const char *type_name)
Add a new property to the current computational domain.
Definition: cs_domain.c:1043
time step options descriptor
Definition: cs_time_step.h:76
void cs_domain_add_groundwater_tracer(cs_domain_t *domain, const char *eq_name, const char *var_name, cs_real_3_t dispersivity, double bulk_density, double distribution_coef, double reaction_rate)
Add a new equation related to the groundwater flow module This equation is a specific unsteady advect...
Definition: cs_domain.c:1321
#define END_C_DECLS
Definition: cs_defs.h:430
cs_domain_t * cs_domain_free(cs_domain_t *domain)
Free a cs_domain_t structure.
Definition: cs_domain.c:637
cs_param_def_type_t time_step_def_type
Definition: cs_domain.h:81
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:1418
void cs_domain_solve(cs_domain_t *domain)
Solve all the equations of a computational domain for one time step.
Definition: cs_domain.c:1550
void cs_domain_set_output_freq(cs_domain_t *domain, int freq)
Set the frequency at which output is done in listing.
Definition: cs_domain.c:901
cs_groundwater_t * gw
Definition: cs_domain.h:119
cs_property_t ** properties
Definition: cs_domain.h:90
cs_param_def_type_t
Definition: cs_param.h:83
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:688