programmer's documentation
cs_equation.h
Go to the documentation of this file.
1 #ifndef __CS_EQUATION_H__
2 #define __CS_EQUATION_H__
3 
4 /*============================================================================
5  * Routines to handle cs_equation_t structure and its related structures
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------
29  * Local headers
30  *----------------------------------------------------------------------------*/
31 
32 #include "cs_cdo_connect.h"
33 #include "cs_cdo_quantities.h"
34 #include "cs_equation_param.h"
35 #include "cs_equation_common.h"
36 #include "cs_field.h"
37 #include "cs_param.h"
38 #include "cs_mesh.h"
39 #include "cs_time_step.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53 typedef struct _cs_equation_t cs_equation_t;
54 
55 /*============================================================================
56  * Public function prototypes
57  *============================================================================*/
58 
59 /*----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------*/
66 
67 int
69 
70 /*----------------------------------------------------------------------------*/
79 /*----------------------------------------------------------------------------*/
80 
82 cs_equation_by_name(const char *eqname);
83 
84 /*----------------------------------------------------------------------------*/
93 /*----------------------------------------------------------------------------*/
94 
96 cs_equation_param_by_name(const char *eqname);
97 
98 /*----------------------------------------------------------------------------*/
107 /*----------------------------------------------------------------------------*/
108 
111 
112 /*----------------------------------------------------------------------------*/
121 /*----------------------------------------------------------------------------*/
122 
124 cs_equation_by_id(int eq_id);
125 
126 /*----------------------------------------------------------------------------*/
134 /*----------------------------------------------------------------------------*/
135 
136 bool
138 
139 /*----------------------------------------------------------------------------*/
147 /*----------------------------------------------------------------------------*/
148 
149 const char *
151 
152 /*----------------------------------------------------------------------------*/
160 /*----------------------------------------------------------------------------*/
161 
162 int
164 
165 /*----------------------------------------------------------------------------*/
173 /*----------------------------------------------------------------------------*/
174 
175 cs_field_t *
177 
178 /*----------------------------------------------------------------------------*/
186 /*----------------------------------------------------------------------------*/
187 
188 cs_flag_t
190 
191 /*----------------------------------------------------------------------------*/
200 /*----------------------------------------------------------------------------*/
201 
204 
205 /*----------------------------------------------------------------------------*/
214 /*----------------------------------------------------------------------------*/
215 
216 void *
218 
219 /*----------------------------------------------------------------------------*/
231 /*----------------------------------------------------------------------------*/
232 
234 cs_equation_add(const char *eqname,
235  const char *varname,
236  cs_equation_type_t eqtype,
237  int dim,
238  cs_param_bc_type_t default_bc);
239 
240 /*----------------------------------------------------------------------------*/
251 /*----------------------------------------------------------------------------*/
252 
254 cs_equation_add_user(const char *eqname,
255  const char *varname,
256  int dim,
257  cs_param_bc_type_t default_bc);
258 
259 /*----------------------------------------------------------------------------*/
263 /*----------------------------------------------------------------------------*/
264 
265 void
267 
268 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 void
277 
278 /*----------------------------------------------------------------------------*/
282 /*----------------------------------------------------------------------------*/
283 
284 void
286 
287 /*----------------------------------------------------------------------------*/
293 /*----------------------------------------------------------------------------*/
294 
295 void
297 
298 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 bool
312  bool do_profiling);
313 
314 /*----------------------------------------------------------------------------*/
318 /*----------------------------------------------------------------------------*/
319 
320 void
322 
323 /*----------------------------------------------------------------------------*/
335 /*----------------------------------------------------------------------------*/
336 
337 void
339  const cs_cdo_connect_t *connect,
340  const cs_cdo_quantities_t *quant,
341  const cs_time_step_t *ts);
342 
343 /*----------------------------------------------------------------------------*/
351 /*----------------------------------------------------------------------------*/
352 
353 bool
355 
356 /*----------------------------------------------------------------------------*/
365 /*----------------------------------------------------------------------------*/
366 
367 void
369  const cs_time_step_t *time_step,
370  double dt_cur,
371  cs_equation_t *eq);
372 
373 /*----------------------------------------------------------------------------*/
379 /*----------------------------------------------------------------------------*/
380 
381 void
383 
384 /*----------------------------------------------------------------------------*/
393 /*----------------------------------------------------------------------------*/
394 
397 
398 /*----------------------------------------------------------------------------*/
407 /*----------------------------------------------------------------------------*/
408 
411 
412 /*----------------------------------------------------------------------------*/
423 /*----------------------------------------------------------------------------*/
424 
427  const int reaction_id);
428 
429 /*----------------------------------------------------------------------------*/
438 /*----------------------------------------------------------------------------*/
439 
442 
443 /*----------------------------------------------------------------------------*/
452 /*----------------------------------------------------------------------------*/
453 
454 int
456 
457 /*----------------------------------------------------------------------------*/
465 /*----------------------------------------------------------------------------*/
466 
467 int
469 
470 /*----------------------------------------------------------------------------*/
478 /*----------------------------------------------------------------------------*/
479 
482 
483 /*----------------------------------------------------------------------------*/
492 /*----------------------------------------------------------------------------*/
493 
494 const cs_real_t *
496 
497 /*----------------------------------------------------------------------------*/
506 /*----------------------------------------------------------------------------*/
507 
508 const cs_real_t *
510 
511 /*----------------------------------------------------------------------------*/
522 /*----------------------------------------------------------------------------*/
523 
524 void
526  const char *ml_name,
527  const cs_real_3_t direction,
528  cs_real_t *diff_flux,
529  cs_real_t *conv_flux);
530 
531 /*----------------------------------------------------------------------------*/
540 /*----------------------------------------------------------------------------*/
541 
542 void
544  cs_flag_t location,
545  cs_real_t *diff_flux);
546 
547 /*----------------------------------------------------------------------------*/
554 /*----------------------------------------------------------------------------*/
555 
556 void
558  cs_real_t *v_gradient);
559 
560 /*----------------------------------------------------------------------------*/
567 /*----------------------------------------------------------------------------*/
568 
569 void
571  double dt);
572 
573 /*----------------------------------------------------------------------------*/
574 
576 
577 #endif /* __CS_EQUATION_H__ */
Store common elements used when building an algebraic system related to an equation.
Definition: cs_equation_common.h:62
time step descriptor
Definition: cs_time_step.h:51
cs_property_t * cs_equation_get_time_property(const cs_equation_t *eq)
Return a pointer to the cs_property_t structure associated to the unsteady term for this equation (NU...
Definition: cs_equation.c:699
Field descriptor.
Definition: cs_field.h:124
void cs_equation_initialize(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *ts)
Allocate and initialize the builder of the algebraic system. Set the initialize condition to all vari...
Definition: cs_equation.c:1503
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:150
void cs_equation_solve(cs_equation_t *eq)
Solve the linear system for this equation.
Definition: cs_equation.c:1618
void cs_equation_compute_flux_across_plane(const cs_equation_t *eq, const char *ml_name, const cs_real_3_t direction, cs_real_t *diff_flux, cs_real_t *conv_flux)
Compute the diffusive and convective flux accross a plane defined by a mesh location structure attach...
Definition: cs_equation.c:1854
cs_equation_builder_t * cs_equation_get_builder(const cs_equation_t *eq)
Return the cs_equation_builder_t structure associated to a cs_equation_t structure. Only for an advanced usage.
Definition: cs_equation.c:637
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
Definition: cs_cdo_connect.h:69
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:94
void cs_equation_build_system(const cs_mesh_t *mesh, const cs_time_step_t *time_step, double dt_cur, cs_equation_t *eq)
Build the linear system for this equation.
Definition: cs_equation.c:1572
bool cs_equation_needs_build(const cs_equation_t *eq)
Check if one has to build the linear system.
Definition: cs_equation.c:1552
cs_property_t * cs_equation_get_reaction_property(const cs_equation_t *eq, const int reaction_id)
Return a pointer to the cs_property_t structure associated to the reaction term called r_name and rel...
Definition: cs_equation.c:723
Definition: cs_mesh.h:63
cs_equation_t * cs_equation_by_id(int eq_id)
Find the cs_equation_t structure with name eqname Return NULL if not find.
Definition: cs_equation.c:535
void cs_equation_log_setup(void)
Summarize all cs_equation_t structures.
Definition: cs_equation.c:1074
cs_equation_param_t * cs_equation_get_param(const cs_equation_t *eq)
Return the cs_equation_param_t structure associated to a cs_equation_t structure. ...
Definition: cs_equation.c:515
cs_param_space_scheme_t cs_equation_get_space_scheme(const cs_equation_t *eq)
Return the type of numerical scheme used for the discretization in space.
Definition: cs_equation.c:772
bool cs_equation_finalize_setup(const cs_cdo_connect_t *connect, bool do_profiling)
Assign a set of pointer functions for managing the cs_equation_t structure during the computation...
Definition: cs_equation.c:1163
Definition: cs_field_pointer.h:65
void * cs_equation_get_scheme_context(const cs_equation_t *eq)
Return a pointer to a structure useful to handle low-level operations for the given equation...
Definition: cs_equation.c:657
void cs_equation_compute_vtx_field_gradient(const cs_equation_t *eq, cs_real_t *v_gradient)
Cellwise computation of the discrete gradient at vertices.
Definition: cs_equation.c:1943
cs_property_t * cs_equation_get_diffusion_property(const cs_equation_t *eq)
Return a pointer to the cs_property_t structure associated to the diffusion term for this equation (N...
Definition: cs_equation.c:677
int cs_equation_get_id(const cs_equation_t *eq)
Return the id number related to the given cs_equation_t structure.
Definition: cs_equation.c:574
cs_equation_t * cs_equation_add_user(const char *eqname, const char *varname, int dim, cs_param_bc_type_t default_bc)
Add a new user equation structure and set a first set of parameters.
Definition: cs_equation.c:968
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
cs_equation_type_t
Type of equations managed by the solver.
Definition: cs_equation_param.h:116
cs_param_bc_type_t
Definition: cs_param.h:273
char *restrict varname
Definition: cs_equation_priv.h:281
const cs_real_t * cs_equation_get_face_values(const cs_equation_t *eq)
Get the values at each face of the mesh for the field unknowns related to this equation.
Definition: cs_equation.c:1752
void cs_equation_create_fields(void)
Create a field structure related to all cs_equation_t structures.
Definition: cs_equation.c:1423
const cs_real_t * cs_equation_get_cell_values(const cs_equation_t *eq)
Get the values at each cell centers for the field unknowns related to this equation.
Definition: cs_equation.c:1797
cs_equation_type_t cs_equation_get_type(const cs_equation_t *eq)
Return the type of equation for the given equation structure.
Definition: cs_equation.c:836
void cs_equation_compute_diff_flux_cellwise(const cs_equation_t *eq, cs_flag_t location, cs_real_t *diff_flux)
Cellwise computation of the diffusive flux across all cell faces. Primal or dual faces are considered...
Definition: cs_equation.c:1903
#define END_C_DECLS
Definition: cs_defs.h:462
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_flag_t cs_equation_get_flag(const cs_equation_t *eq)
Return the flag associated to an equation.
Definition: cs_equation.c:613
cs_field_t * cs_equation_get_field(const cs_equation_t *eq)
Return the field structure associated to a cs_equation_t structure.
Definition: cs_equation.c:594
cs_equation_t * cs_equation_add(const char *eqname, const char *varname, cs_equation_type_t eqtype, int dim, cs_param_bc_type_t default_bc)
Add a new equation structure and set a first set of parameters.
Definition: cs_equation.c:861
cs_equation_param_t * cs_equation_param_by_name(const char *eqname)
Return the cs_equation_param_t structure associated to a cs_equation_t structure thanks to the equati...
Definition: cs_equation.c:486
int cs_equation_get_var_dim(const cs_equation_t *eq)
Return the dimension of the variable solved by this equation.
Definition: cs_equation.c:815
void cs_equation_destroy_all(void)
Destroy all cs_equation_t structures.
Definition: cs_equation.c:1003
Main structure to handle the discretization and the resolution of an equation.
cs_param_space_scheme_t
Type of numerical scheme for the discretization in space.
Definition: cs_param.h:122
void cs_equation_set_timer_stats(cs_equation_t *eq)
Create timer statistics structures to enable a "home-made" profiling.
Definition: cs_equation.c:1117
Structure and routines handling the specific settings related to a cs_equation_t structure.
const char * cs_equation_get_name(const cs_equation_t *eq)
Return the name related to the given cs_equation_t structure.
Definition: cs_equation.c:555
void cs_equation_extra_post_all(const cs_time_step_t *ts, double dt)
Predefined extra-operations related to all equations.
Definition: cs_equation.c:1981
cs_equation_t * cs_equation_by_name(const char *eqname)
Find the cs_equation_t structure with name eqname Return NULL if not find.
Definition: cs_equation.c:455
int cs_equation_get_space_poly_degree(const cs_equation_t *eq)
Return the max. degree used in the polynomial basis for the space discretization. ...
Definition: cs_equation.c:794
Definition: cs_property.h:63
Definition: cs_equation_priv.h:273
int cs_equation_get_n_equations(void)
Retrieve the number of equations.
Definition: cs_equation.c:438
Definition: mesh.f90:26
void cs_equation_log_monitoring(void)
Print a synthesis of the monitoring information in the performance file.
Definition: cs_equation.c:1049
bool cs_equation_is_steady(const cs_equation_t *eq)
Return true is the given equation is steady otherwise false.
Definition: cs_equation.c:747