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_restart.h"
40 #include "cs_time_step.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*============================================================================
47  * Macro definitions
48  *============================================================================*/
49 
50 /*============================================================================
51  * Type definitions
52  *============================================================================*/
53 
54 typedef struct _cs_equation_t cs_equation_t;
55 
56 /*============================================================================
57  * Public function prototypes
58  *============================================================================*/
59 
60 /*----------------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------------*/
67 
68 int
70 
71 /*----------------------------------------------------------------------------*/
80 /*----------------------------------------------------------------------------*/
81 
83 cs_equation_by_name(const char *eqname);
84 
85 /*----------------------------------------------------------------------------*/
96 /*----------------------------------------------------------------------------*/
97 
98 bool
100  const char *fld_name);
101 
102 /*----------------------------------------------------------------------------*/
111 /*----------------------------------------------------------------------------*/
112 
114 cs_equation_param_by_name(const char *eqname);
115 
116 /*----------------------------------------------------------------------------*/
125 /*----------------------------------------------------------------------------*/
126 
129 
130 /*----------------------------------------------------------------------------*/
139 /*----------------------------------------------------------------------------*/
140 
142 cs_equation_by_id(int eq_id);
143 
144 /*----------------------------------------------------------------------------*/
152 /*----------------------------------------------------------------------------*/
153 
154 const char *
156 
157 /*----------------------------------------------------------------------------*/
165 /*----------------------------------------------------------------------------*/
166 
167 int
169 
170 /*----------------------------------------------------------------------------*/
178 /*----------------------------------------------------------------------------*/
179 
180 cs_field_t *
182 
183 /*----------------------------------------------------------------------------*/
192 /*----------------------------------------------------------------------------*/
193 
194 int
196 
197 /*----------------------------------------------------------------------------*/
206 /*----------------------------------------------------------------------------*/
207 
208 cs_field_t *
210 
211 /*----------------------------------------------------------------------------*/
219 /*----------------------------------------------------------------------------*/
220 
221 cs_flag_t
223 
224 /*----------------------------------------------------------------------------*/
231 /*----------------------------------------------------------------------------*/
232 
233 void
235  cs_flag_t flag);
236 
237 /*----------------------------------------------------------------------------*/
246 /*----------------------------------------------------------------------------*/
247 
250 
251 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
262 void *
264 
265 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 bool
277 
278 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
288 bool
290 
291 /*----------------------------------------------------------------------------*/
303 /*----------------------------------------------------------------------------*/
304 
306 cs_equation_add(const char *eqname,
307  const char *varname,
308  cs_equation_type_t eqtype,
309  int dim,
310  cs_param_bc_type_t default_bc);
311 
312 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
326 cs_equation_add_user(const char *eqname,
327  const char *varname,
328  int dim,
329  cs_param_bc_type_t default_bc);
330 
331 /*----------------------------------------------------------------------------*/
335 /*----------------------------------------------------------------------------*/
336 
337 void
339 
340 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
346 
347 void
349 
350 /*----------------------------------------------------------------------------*/
354 /*----------------------------------------------------------------------------*/
355 
356 void
358 
359 /*----------------------------------------------------------------------------*/
363 /*----------------------------------------------------------------------------*/
364 
365 void
367 
368 /*----------------------------------------------------------------------------*/
377 /*----------------------------------------------------------------------------*/
378 
379 void
381 
382 /*----------------------------------------------------------------------------*/
389 /*----------------------------------------------------------------------------*/
390 
391 bool
393 
394 /*----------------------------------------------------------------------------*/
398 /*----------------------------------------------------------------------------*/
399 
400 void
402 
403 /*----------------------------------------------------------------------------*/
414 /*----------------------------------------------------------------------------*/
415 
416 void
418  const cs_cdo_connect_t *connect,
419  const cs_cdo_quantities_t *quant,
420  const cs_time_step_t *ts);
421 
422 /*----------------------------------------------------------------------------*/
430 /*----------------------------------------------------------------------------*/
431 
432 void
434  cs_equation_t *eq);
435 
436 /*----------------------------------------------------------------------------*/
445 /*----------------------------------------------------------------------------*/
446 
447 void
449  double dt_cur,
450  cs_equation_t *eq);
451 
452 /*----------------------------------------------------------------------------*/
461 /*----------------------------------------------------------------------------*/
462 
463 void
465  const cs_time_step_t *time_step,
466  double dt_cur,
467  cs_equation_t *eq);
468 
469 /*----------------------------------------------------------------------------*/
475 /*----------------------------------------------------------------------------*/
476 
477 void
479 
480 /*----------------------------------------------------------------------------*/
489 /*----------------------------------------------------------------------------*/
490 
493 
494 /*----------------------------------------------------------------------------*/
503 /*----------------------------------------------------------------------------*/
504 
507 
508 /*----------------------------------------------------------------------------*/
520 /*----------------------------------------------------------------------------*/
521 
524  const int reaction_id);
525 
526 /*----------------------------------------------------------------------------*/
535 /*----------------------------------------------------------------------------*/
536 
539 
540 /*----------------------------------------------------------------------------*/
549 /*----------------------------------------------------------------------------*/
550 
551 int
553 
554 /*----------------------------------------------------------------------------*/
562 /*----------------------------------------------------------------------------*/
563 
564 int
566 
567 /*----------------------------------------------------------------------------*/
575 /*----------------------------------------------------------------------------*/
576 
579 
580 /*----------------------------------------------------------------------------*/
589 /*----------------------------------------------------------------------------*/
590 
591 cs_real_t *
593 
594 /*----------------------------------------------------------------------------*/
603 /*----------------------------------------------------------------------------*/
604 
605 cs_real_t *
607 
608 /*----------------------------------------------------------------------------*/
617 /*----------------------------------------------------------------------------*/
618 
619 cs_real_t *
621 
622 /*----------------------------------------------------------------------------*/
633 /*----------------------------------------------------------------------------*/
634 
635 void
637  const char *ml_name,
638  const cs_real_3_t direction,
639  cs_real_t *diff_flux,
640  cs_real_t *conv_flux);
641 
642 /*----------------------------------------------------------------------------*/
652 /*----------------------------------------------------------------------------*/
653 
654 void
656  cs_flag_t location,
657  cs_real_t t_eval,
658  cs_real_t *diff_flux);
659 
660 /*----------------------------------------------------------------------------*/
667 /*----------------------------------------------------------------------------*/
668 
669 void
671  cs_real_t *v_gradient);
672 
673 /*----------------------------------------------------------------------------*/
682 /*----------------------------------------------------------------------------*/
683 
684 void
686  const cs_time_step_t *ts,
687  cs_real_t peclet[]);
688 
689 /*----------------------------------------------------------------------------*/
696 /*----------------------------------------------------------------------------*/
697 
698 void
700 
701 /*----------------------------------------------------------------------------*/
708 /*----------------------------------------------------------------------------*/
709 
710 void
712 
713 /*----------------------------------------------------------------------------*/
723 /*----------------------------------------------------------------------------*/
724 
725 void
727  const cs_cdo_connect_t *connect,
728  const cs_cdo_quantities_t *cdoq,
729  const cs_time_step_t *ts,
730  double dt_cur);
731 
732 /*----------------------------------------------------------------------------*/
737 /*----------------------------------------------------------------------------*/
738 
739 void
741 
742 /*----------------------------------------------------------------------------*/
743 
745 
746 #endif /* __CS_EQUATION_H__ */
Store common elements used when building an algebraic system related to an equation.
Definition: cs_equation_common.h:63
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:928
void cs_equation_read_extra_restart(cs_restart_t *restart)
Write into the restart file additionnal arrays (not defined as fields) but useful for the checkpoint/...
Definition: cs_equation.c:2555
void cs_equation_set_flag(cs_equation_t *eq, cs_flag_t flag)
Redefine the flag associated to an equation.
Definition: cs_equation.c:844
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:1985
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:159
cs_real_t * cs_equation_get_face_values(const cs_equation_t *eq)
For a given equation, retrieve an array of values related to each face of the mesh for the unknowns...
Definition: cs_equation.c:2296
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 across a plane defined by a mesh location structure attache...
Definition: cs_equation.c:2370
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:866
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:2320
#define BEGIN_C_DECLS
Definition: cs_defs.h:462
bool cs_equation_uses_new_mechanism(const cs_equation_t *eq)
Return true is the given equation is steady otherwise false.
Definition: cs_equation.c:1087
void cs_equation_assign_range_set(const cs_cdo_connect_t *connect)
Assign cs_range_set_t structures for synchronization when computing in parallel mode After this call...
Definition: cs_equation.c:1407
Definition: cs_cdo_connect.h:74
void cs_equation_compute_diff_flux_cellwise(const cs_equation_t *eq, cs_flag_t location, cs_real_t t_eval, 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:2423
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:2071
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 with id equal to reac...
Definition: cs_equation.c:953
Definition: cs_mesh.h:63
cs_equation_t * cs_equation_by_id(int eq_id)
Find the cs_equation_t structure with id eq_id Return NULL if not find.
Definition: cs_equation.c:701
void cs_equation_log_setup(void)
Summarize all cs_equation_t structures.
Definition: cs_equation.c:1333
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:681
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:978
void cs_equation_post_balance(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_time_step_t *ts, double dt_cur)
Predefined extra-operations related to all equations.
Definition: cs_equation.c:2604
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:886
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:86
void cs_equation_extra_post(void)
Predefined extra-operations related to equations according to the type of numerical scheme (for the s...
Definition: cs_equation.c:2719
cs_field_t * cs_equation_get_boundary_flux(const cs_equation_t *eq)
Return the field structure for the (normal) boundary flux associated to a cs_equation_t structure...
Definition: cs_equation.c:801
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:2466
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:906
void cs_equation_solve_deprecated(cs_equation_t *eq)
Solve the linear system for this equation.
Definition: cs_equation.c:2115
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:741
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:1228
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:310
bool cs_equation_assign_functions(void)
Assign a set of pointer functions for managing the cs_equation_t structure during the computation...
Definition: cs_equation.c:1597
cs_equation_type_t
Type of equations managed by the solver.
Definition: cs_equation_param.h:125
cs_param_bc_type_t
Definition: cs_param.h:285
char *restrict varname
Definition: cs_equation_priv.h:349
int cs_equation_get_field_id(const cs_equation_t *eq)
Return the id related to the variable field structure associated to the cs_equation_t structure...
Definition: cs_equation.c:781
void cs_equation_create_fields(void)
Create a field structure related to all cs_equation_t structures.
Definition: cs_equation.c:1884
bool cs_equation_has_field_name(const cs_equation_t *eq, const char *fld_name)
Check if the asociated field to a cs_equation_t structure has name equal to fld_name.
Definition: cs_equation.c:624
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:1042
#define END_C_DECLS
Definition: cs_defs.h:463
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:822
void cs_equation_set_linear_solvers(void)
Setup the linear algebra requirements.
Definition: cs_equation.c:1375
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:761
void cs_equation_solve(const cs_mesh_t *mesh, double dt_cur, cs_equation_t *eq)
Build and then solve the linear system for an equation with an unsteady term.
Definition: cs_equation.c:2227
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:1118
void cs_equation_compute_peclet(const cs_equation_t *eq, const cs_time_step_t *ts, cs_real_t peclet[])
Compute and post-process Peclet number if requested.
Definition: cs_equation.c:2507
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:652
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:1021
void cs_equation_destroy_all(void)
Destroy all cs_equation_t structures.
Definition: cs_equation.c:1263
Main structure to handle the discretization and the resolution of an equation.
void cs_equation_solve_steady_state(const cs_mesh_t *mesh, cs_equation_t *eq)
Build and then solve the linear system for this equation when the goal is to find the steady state...
Definition: cs_equation.c:2262
cs_param_space_scheme_t
Type of numerical scheme for the discretization in space.
Definition: cs_param.h:122
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:721
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:588
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:1000
Definition: cs_property.h:104
void cs_equation_write_extra_restart(cs_restart_t *restart)
Write into the restart file additionnal arrays (not defined as fields) but useful for the checkpoint/...
Definition: cs_equation.c:2578
Definition: cs_equation_priv.h:342
cs_real_t * cs_equation_get_vertex_values(const cs_equation_t *eq)
For a given equation, retrieve an array of values related to each vertex of the mesh for the unknowns...
Definition: cs_equation.c:2344
int cs_equation_get_n_equations(void)
Retrieve the number of equations.
Definition: cs_equation.c:571
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:1308
bool cs_equation_is_steady(const cs_equation_t *eq)
Return true is the given equation is steady otherwise false.
Definition: cs_equation.c:1063