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_quantities.h"
33 #include "cs_equation_param.h"
34 #include "cs_field.h"
35 #include "cs_param.h"
36 #include "cs_mesh.h"
37 #include "cs_source_term.h"
38 #include "cs_time_step.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 typedef struct _cs_equation_t cs_equation_t;
53 
54 /* List of available keys for setting an equation */
55 typedef enum {
56 
81 
83 
84 /*============================================================================
85  * Public function prototypes
86  *============================================================================*/
87 
88 /*----------------------------------------------------------------------------*/
104 /*----------------------------------------------------------------------------*/
105 
106 void
108  const cs_cdo_quantities_t *quant,
109  const cs_time_step_t *time_step,
110  cs_flag_t scheme_flag);
111 
112 /*----------------------------------------------------------------------------*/
124 /*----------------------------------------------------------------------------*/
125 
126 void
128 
129 /*----------------------------------------------------------------------------*/
137 /*----------------------------------------------------------------------------*/
138 
139 cs_real_t *
141 
142 /*----------------------------------------------------------------------------*/
148 /*----------------------------------------------------------------------------*/
149 
150 size_t
152 
153 /*----------------------------------------------------------------------------*/
166 /*----------------------------------------------------------------------------*/
167 
168 cs_equation_t *
169 cs_equation_create(const char *eqname,
170  const char *varname,
171  cs_equation_type_t eqtype,
172  cs_param_var_type_t vartype,
173  cs_param_bc_type_t default_bc);
174 
175 /*----------------------------------------------------------------------------*/
183 /*----------------------------------------------------------------------------*/
184 
185 cs_equation_t *
186 cs_equation_free(cs_equation_t *eq);
187 
188 /*----------------------------------------------------------------------------*/
195 /*----------------------------------------------------------------------------*/
196 
197 void
198 cs_equation_print_monitoring(const cs_equation_t *eq);
199 
200 /*----------------------------------------------------------------------------*/
206 /*----------------------------------------------------------------------------*/
207 
208 void
209 cs_equation_summary(const cs_equation_t *eq);
210 
211 /*----------------------------------------------------------------------------*/
217 /*----------------------------------------------------------------------------*/
218 
219 void
220 cs_equation_set_timer_stats(cs_equation_t *eq);
221 
222 /*----------------------------------------------------------------------------*/
230 /*----------------------------------------------------------------------------*/
231 
232 void
234  cs_equation_t *eq);
235 
236 /*----------------------------------------------------------------------------*/
244 /*----------------------------------------------------------------------------*/
245 
246 void
247 cs_equation_set_param(cs_equation_t *eq,
248  cs_equation_key_t key,
249  const char *keyval);
250 
251 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
262 void
263 cs_equation_link(cs_equation_t *eq,
264  const char *keyword,
265  void *pointer);
266 
267 /*----------------------------------------------------------------------------*/
280 /*----------------------------------------------------------------------------*/
281 
282 void
283 cs_equation_set_ic_by_value(cs_equation_t *eq,
284  const char *ml_name,
285  cs_get_t get);
286 
287 /*----------------------------------------------------------------------------*/
301 /*----------------------------------------------------------------------------*/
302 
303 void
304 cs_equation_set_ic_by_qov(cs_equation_t *eq,
305  const char *ml_name,
306  double quantity);
307 
308 /*----------------------------------------------------------------------------*/
320 /*----------------------------------------------------------------------------*/
321 
322 void
323 cs_equation_set_ic_by_analytic(cs_equation_t *eq,
324  const char *ml_name,
325  cs_analytic_func_t *analytic);
326 
327 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
340 void
341 cs_equation_add_bc_by_value(cs_equation_t *eq,
342  const cs_param_bc_type_t bc_type,
343  const char *ml_name,
344  const cs_get_t get);
345 
346 /*----------------------------------------------------------------------------*/
357 /*----------------------------------------------------------------------------*/
358 
359 void
360 cs_equation_add_bc_by_analytic(cs_equation_t *eq,
361  const cs_param_bc_type_t bc_type,
362  const char *ml_name,
363  cs_analytic_func_t *analytic);
364 
365 /*----------------------------------------------------------------------------*/
374 /*----------------------------------------------------------------------------*/
375 
376 void
377 cs_equation_add_linear_reaction(cs_equation_t *eq,
378  cs_property_t *property,
379  const char *r_name);
380 
381 /*----------------------------------------------------------------------------*/
393 /*----------------------------------------------------------------------------*/
394 
396 cs_equation_add_source_term_by_val(cs_equation_t *eq,
397  const char *st_name,
398  const char *ml_name,
399  const void *val);
400 
401 /*----------------------------------------------------------------------------*/
413 /*----------------------------------------------------------------------------*/
414 
417  const char *st_name,
418  const char *ml_name,
419  cs_analytic_func_t *ana);
420 
421 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
431 cs_equation_create_field(cs_equation_t *eq);
432 
433 /*----------------------------------------------------------------------------*/
441 /*----------------------------------------------------------------------------*/
442 
443 void
445  cs_equation_t *eq);
446 
447 /*----------------------------------------------------------------------------*/
455 /*----------------------------------------------------------------------------*/
456 
457 bool
458 cs_equation_needs_build(const cs_equation_t *eq);
459 
460 /*----------------------------------------------------------------------------*/
469 /*----------------------------------------------------------------------------*/
470 
471 void
473  const cs_time_step_t *time_step,
474  double dt_cur,
475  cs_equation_t *eq);
476 
477 /*----------------------------------------------------------------------------*/
483 /*----------------------------------------------------------------------------*/
484 
485 void
486 cs_equation_solve(cs_equation_t *eq);
487 
488 /*----------------------------------------------------------------------------*/
496 /*----------------------------------------------------------------------------*/
497 
498 bool
499 cs_equation_is_steady(const cs_equation_t *eq);
500 
501 /*----------------------------------------------------------------------------*/
510 /*----------------------------------------------------------------------------*/
511 
512 const cs_real_t *
513 cs_equation_get_face_values(const cs_equation_t *eq);
514 
515 /*----------------------------------------------------------------------------*/
524 /*----------------------------------------------------------------------------*/
525 
526 const cs_real_t *
527 cs_equation_get_cell_values(const cs_equation_t *eq);
528 
529 /*----------------------------------------------------------------------------*/
538 /*----------------------------------------------------------------------------*/
539 
540 const char *
541 cs_equation_get_name(const cs_equation_t *eq);
542 
543 /*----------------------------------------------------------------------------*/
551 /*----------------------------------------------------------------------------*/
552 
553 cs_field_t *
554 cs_equation_get_field(const cs_equation_t *eq);
555 
556 /*----------------------------------------------------------------------------*/
564 /*----------------------------------------------------------------------------*/
565 
566 cs_flag_t
567 cs_equation_get_flag(const cs_equation_t *eq);
568 
569 /*----------------------------------------------------------------------------*/
578 /*----------------------------------------------------------------------------*/
579 
580 const cs_equation_param_t *
581 cs_equation_get_param(const cs_equation_t *eq);
582 
583 /*----------------------------------------------------------------------------*/
592 /*----------------------------------------------------------------------------*/
593 
595 cs_equation_get_diffusion_property(const cs_equation_t *eq);
596 
597 /*----------------------------------------------------------------------------*/
606 /*----------------------------------------------------------------------------*/
607 
609 cs_equation_get_time_property(const cs_equation_t *eq);
610 
611 /*----------------------------------------------------------------------------*/
621 /*----------------------------------------------------------------------------*/
622 
624 cs_equation_get_reaction_property(const cs_equation_t *eq,
625  const char *r_name);
626 
627 /*----------------------------------------------------------------------------*/
636 /*----------------------------------------------------------------------------*/
637 
639 cs_equation_get_space_scheme(const cs_equation_t *eq);
640 
641 /*----------------------------------------------------------------------------*/
650 /*----------------------------------------------------------------------------*/
651 
652 int
653 cs_equation_get_space_poly_degree(const cs_equation_t *eq);
654 
655 /*----------------------------------------------------------------------------*/
663 /*----------------------------------------------------------------------------*/
664 
666 cs_equation_get_var_type(const cs_equation_t *eq);
667 
668 /*----------------------------------------------------------------------------*/
676 /*----------------------------------------------------------------------------*/
677 
679 cs_equation_get_type(const cs_equation_t *eq);
680 
681 /*----------------------------------------------------------------------------*/
692 /*----------------------------------------------------------------------------*/
693 
694 void
695 cs_equation_compute_flux_across_plane(const cs_equation_t *eq,
696  const char *ml_name,
697  const cs_real_3_t direction,
698  cs_real_t *diff_flux,
699  cs_real_t *conv_flux);
700 
701 /*----------------------------------------------------------------------------*/
710 /*----------------------------------------------------------------------------*/
711 
712 void
713 cs_equation_compute_diff_flux_cellwise(const cs_equation_t *eq,
714  cs_flag_t location,
715  cs_real_t *diff_flux);
716 
717 /*----------------------------------------------------------------------------*/
725 /*----------------------------------------------------------------------------*/
726 
727 void
728 cs_equation_compute_diff_flux(const cs_equation_t *eq,
729  cs_real_t *diff_flux);
730 
731 /*----------------------------------------------------------------------------*/
739 /*----------------------------------------------------------------------------*/
740 
741 void
742 cs_equation_extra_post(const cs_equation_t *eq,
743  const cs_time_step_t *ts,
744  double dt);
745 
746 /*----------------------------------------------------------------------------*/
747 
749 
750 #endif /* __CS_EQUATION_H__ */
void() cs_analytic_func_t(cs_real_t time, cs_lnum_t n_points, const cs_real_t *xyz, cs_real_t *retval)
Generic analytic function.
Definition: cs_cdo.h:170
cs_equation_t * cs_equation_create(const char *eqname, const char *varname, cs_equation_type_t eqtype, cs_param_var_type_t vartype, cs_param_bc_type_t default_bc)
Define and initialize a new structure to store parameters related to an equation. ...
Definition: cs_equation.c:606
Definition: cs_equation.h:57
void cs_equation_last_setup(const cs_cdo_connect_t *connect, cs_equation_t *eq)
Assign a set of pointer functions for managing the cs_equation_t structure during the computation...
Definition: cs_equation.c:802
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...
Definition: cs_equation.c:2176
void cs_equation_init_system(const cs_mesh_t *mesh, cs_equation_t *eq)
Initialize the values of a field according to the initial condition related to its equation...
Definition: cs_equation.c:1774
void cs_equation_add_bc_by_value(cs_equation_t *eq, const cs_param_bc_type_t bc_type, const char *ml_name, const cs_get_t get)
Define and initialize a new structure to set a boundary condition related to the givan equation struc...
Definition: cs_equation.c:1465
Definition: cs_equation.h:73
Definition: cs_equation.h:58
void cs_equation_set_ic_by_qov(cs_equation_t *eq, const char *ml_name, double quantity)
Define the initial condition for the unknown related to this equation This definition can be done on ...
Definition: cs_equation.c:1388
Field descriptor.
Definition: cs_field.h:124
void cs_equation_summary(const cs_equation_t *eq)
Summary of a cs_equation_t structure.
Definition: cs_equation.c:735
Definition: cs_equation_param.h:100
void cs_equation_solve(cs_equation_t *eq)
Solve the linear system for this equation.
Definition: cs_equation.c:1878
size_t cs_equation_get_tmpbuf_size(void)
Get the allocation size of the temporary buffer.
Definition: cs_equation_common.c:869
Definition: cs_equation.h:61
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:2388
Definition: cs_equation.h:64
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
cs_equation_key_t
Definition: cs_equation.h:55
cs_source_term_t * cs_equation_add_source_term_by_val(cs_equation_t *eq, const char *st_name, const char *ml_name, const void *val)
Define and initialize by value a new structure to store parameters related to a source term defined b...
Definition: cs_equation.c:1603
Definition: cs_equation.h:68
void cs_equation_allocate_common_structures(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, cs_flag_t scheme_flag)
Allocate a pointer to a buffer of size at least the 2*n_cells for managing temporary usage of memory ...
Definition: cs_equation_common.c:283
Definition: cs_cdo_connect.h:56
Definition: cs_equation.h:67
void cs_equation_compute_diff_flux(const cs_equation_t *eq, cs_real_t *diff_flux)
Cellwise computation of the diffusive flux across all cell faces. Primal or dual faces are considered...
cs_property_t * cs_equation_get_reaction_property(const cs_equation_t *eq, const char *r_name)
Return a pointer to the cs_property_t structure associated to the reaction term called r_name and rel...
Definition: cs_equation.c:2197
Definition: cs_param.h:51
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:102
Definition: cs_equation.h:71
bool cs_equation_needs_build(const cs_equation_t *eq)
Check if one has to build the linear system.
Definition: cs_equation.c:1820
Definition: cs_equation.h:62
Definition: cs_equation.h:76
Definition: cs_mesh.h:63
void cs_equation_link(cs_equation_t *eq, const char *keyword, void *pointer)
Associate a material property or an advection field with an equation for a given term (diffusion...
Definition: cs_equation.c:1290
Definition: cs_equation.h:80
void cs_equation_add_bc_by_analytic(cs_equation_t *eq, const cs_param_bc_type_t bc_type, const char *ml_name, cs_analytic_func_t *analytic)
Define and initialize a new structure to set a boundary condition related to the givan equation struc...
Definition: cs_equation.c:1506
Definition: cs_equation.h:77
cs_space_scheme_t
Definition: cs_cdo.h:148
const 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:2136
cs_real_t * cs_equation_get_tmpbuf(void)
Retrieve a pointer to a buffer of size at least the 2*n_cells The size of the temporary buffer can be...
Definition: cs_equation_common.c:855
void cs_equation_extra_post(const cs_equation_t *eq, const cs_time_step_t *ts, double dt)
Predefined extra-operations related to this equation.
Definition: cs_equation.c:2466
void cs_equation_add_linear_reaction(cs_equation_t *eq, cs_property_t *property, const char *r_name)
Define and initialize a new structure to store parameters related to a reaction term.
Definition: cs_equation.c:1545
Definition: cs_equation.h:63
Definition: cs_field_pointer.h:65
void cs_equation_free_common_structures(cs_flag_t scheme_flag)
Allocate a pointer to a buffer of size at least the 2*n_cells for managing temporary usage of memory ...
Definition: cs_equation_common.c:443
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...
Definition: cs_equation.c:2156
Definition: cs_equation.h:69
Definition: cs_equation.h:65
void cs_equation_set_param(cs_equation_t *eq, cs_equation_key_t key, const char *keyval)
Set a parameter in a cs_equation_t structure attached to keyname.
Definition: cs_equation.c:934
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
cs_equation_type_t
Definition: cs_equation_param.h:61
cs_param_bc_type_t
Definition: cs_param.h:273
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:2315
void cs_equation_set_ic_by_value(cs_equation_t *eq, const char *ml_name, cs_get_t get)
Define the initial condition for the unknown related to this equation This definition can be done on ...
Definition: cs_equation.c:1347
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:2345
Definition: cs_equation.h:72
cs_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:2237
cs_param_var_type_t cs_equation_get_var_type(const cs_equation_t *eq)
Return the type of variable solved by this equation.
Definition: cs_equation.c:2276
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:2295
Definition: cs_equation.h:75
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:2430
Definition: cs_equation.h:70
#define END_C_DECLS
Definition: cs_defs.h:452
unsigned short int cs_flag_t
Definition: cs_defs.h:299
Definition: cs_equation.h:59
cs_flag_t cs_equation_get_flag(const cs_equation_t *eq)
Return the flag associated to an equation.
Definition: cs_equation.c:2112
Definition: cs_equation.h:79
void cs_equation_set_ic_by_analytic(cs_equation_t *eq, const char *ml_name, cs_analytic_func_t *analytic)
Define the initial condition for the unknown related to this equation This definition can be done on ...
Definition: cs_equation.c:1427
cs_param_var_type_t
Definition: cs_param.h:120
void cs_equation_create_field(cs_equation_t *eq)
Create a field structure related to this cs_equation_t structure to an equation.
Definition: cs_equation.c:1690
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:2093
cs_source_term_t * cs_equation_add_source_term_by_analytic(cs_equation_t *eq, const char *st_name, const char *ml_name, cs_analytic_func_t *ana)
Define and initialize by an analytical function a new structure related to a source term defined by a...
Definition: cs_equation.c:1649
void cs_equation_print_monitoring(const cs_equation_t *eq)
Print a synthesis of the monitoring information in the performance file.
Definition: cs_equation.c:719
Definition: cs_equation.h:74
Definition: cs_equation.h:60
void cs_equation_set_timer_stats(cs_equation_t *eq)
Create timer statistics structures to enable a "home-made" profiling.
Definition: cs_equation.c:758
const char * cs_equation_get_name(const cs_equation_t *eq)
Return the name related to the given cs_equation_t structure to an equation.
Definition: cs_equation.c:2074
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:2257
Definition: cs_property.h:66
Definition: mesh.f90:26
Definition: cs_equation.h:78
Definition: cs_source_term.h:56
void cs_equation_build_system(const cs_mesh_t *m, 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:1837
cs_equation_t * cs_equation_free(cs_equation_t *eq)
Destroy a cs_equation_t structure.
Definition: cs_equation.c:682
Definition: cs_equation.h:66
bool cs_equation_is_steady(const cs_equation_t *eq)
Return true is the given equation is steady otherwise false.
Definition: cs_equation.c:2052