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-2016 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 /*----------------------------------------------------------------------------*/
194 /*----------------------------------------------------------------------------*/
195 
196 void
197 cs_equation_summary(const cs_equation_t *eq);
198 
199 /*----------------------------------------------------------------------------*/
205 /*----------------------------------------------------------------------------*/
206 
207 void
208 cs_equation_set_timer_stats(cs_equation_t *eq);
209 
210 /*----------------------------------------------------------------------------*/
217 /*----------------------------------------------------------------------------*/
218 
219 void
220 cs_equation_last_setup(cs_equation_t *eq);
221 
222 /*----------------------------------------------------------------------------*/
230 /*----------------------------------------------------------------------------*/
231 
232 void
233 cs_equation_set_param(cs_equation_t *eq,
234  cs_equation_key_t key,
235  const char *keyval);
236 
237 /*----------------------------------------------------------------------------*/
246 /*----------------------------------------------------------------------------*/
247 
248 void
249 cs_equation_link(cs_equation_t *eq,
250  const char *keyword,
251  void *pointer);
252 
253 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 
267 void
268 cs_equation_set_ic(cs_equation_t *eq,
269  const char *ml_name,
270  const char *def_key,
271  void *val);
272 
273 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
288 void
289 cs_equation_add_bc(cs_equation_t *eq,
290  const char *ml_name,
291  const char *bc_key,
292  const char *def_key,
293  const void *val);
294 
295 /*----------------------------------------------------------------------------*/
304 /*----------------------------------------------------------------------------*/
305 
306 void
307 cs_equation_add_linear_reaction(cs_equation_t *eq,
308  cs_property_t *property,
309  const char *r_name);
310 
311 /*----------------------------------------------------------------------------*/
322 /*----------------------------------------------------------------------------*/
323 
324 void
325 cs_equation_add_gravity_source_term(cs_equation_t *eq,
326  int ml_id,
327  cs_desc_t array_desc,
328  cs_real_t *array_values);
329 
330 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 void
343 cs_equation_add_source_term_by_val(cs_equation_t *eq,
344  const char *st_name,
345  const char *ml_name,
346  const void *val);
347 
348 /*----------------------------------------------------------------------------*/
358 /*----------------------------------------------------------------------------*/
359 
360 void
362  const char *st_name,
363  const char *ml_name,
364  cs_analytic_func_t *ana);
365 
366 
367 /*----------------------------------------------------------------------------*/
376 /*----------------------------------------------------------------------------*/
377 
378 void
380  const char *st_name,
381  cs_quadra_type_t quad_type);
382 
383 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 void
395 cs_equation_set_source_term_reduction(cs_equation_t *eq,
396  const char *st_name,
398 
399 /*----------------------------------------------------------------------------*/
406 /*----------------------------------------------------------------------------*/
407 
408 void
409 cs_equation_create_field(cs_equation_t *eq);
410 
411 /*----------------------------------------------------------------------------*/
419 /*----------------------------------------------------------------------------*/
420 
421 void
423  cs_equation_t *eq);
424 
425 /*----------------------------------------------------------------------------*/
433 /*----------------------------------------------------------------------------*/
434 
435 bool
436 cs_equation_needs_build(const cs_equation_t *eq);
437 
438 /*----------------------------------------------------------------------------*/
447 /*----------------------------------------------------------------------------*/
448 
449 void
451  const cs_time_step_t *time_step,
452  double dt_cur,
453  cs_equation_t *eq);
454 
455 /*----------------------------------------------------------------------------*/
462 /*----------------------------------------------------------------------------*/
463 
464 void
465 cs_equation_solve(cs_equation_t *eq,
466  bool do_logcvg);
467 
468 /*----------------------------------------------------------------------------*/
476 /*----------------------------------------------------------------------------*/
477 
478 void
479 cs_equation_extra_op(const cs_equation_t *eq,
480  const cs_time_step_t *ts,
481  double dt);
482 
483 /*----------------------------------------------------------------------------*/
491 /*----------------------------------------------------------------------------*/
492 
493 bool
494 cs_equation_is_steady(const cs_equation_t *eq);
495 
496 /*----------------------------------------------------------------------------*/
505 /*----------------------------------------------------------------------------*/
506 
507 const cs_real_t *
508 cs_equation_get_face_values(const cs_equation_t *eq);
509 
510 /*----------------------------------------------------------------------------*/
519 /*----------------------------------------------------------------------------*/
520 
521 const cs_real_t *
522 cs_equation_get_cell_values(const cs_equation_t *eq);
523 
524 /*----------------------------------------------------------------------------*/
533 /*----------------------------------------------------------------------------*/
534 
535 const char *
536 cs_equation_get_name(const cs_equation_t *eq);
537 
538 /*----------------------------------------------------------------------------*/
546 /*----------------------------------------------------------------------------*/
547 
548 cs_field_t *
549 cs_equation_get_field(const cs_equation_t *eq);
550 
551 /*----------------------------------------------------------------------------*/
559 /*----------------------------------------------------------------------------*/
560 
561 cs_flag_t
562 cs_equation_get_flag(const cs_equation_t *eq);
563 
564 /*----------------------------------------------------------------------------*/
573 /*----------------------------------------------------------------------------*/
574 
575 const cs_equation_param_t *
576 cs_equation_get_param(const cs_equation_t *eq);
577 
578 /*----------------------------------------------------------------------------*/
587 /*----------------------------------------------------------------------------*/
588 
589 cs_property_t *
590 cs_equation_get_diffusion_property(const cs_equation_t *eq);
591 
592 /*----------------------------------------------------------------------------*/
601 /*----------------------------------------------------------------------------*/
602 
603 cs_property_t *
604 cs_equation_get_time_property(const cs_equation_t *eq);
605 
606 /*----------------------------------------------------------------------------*/
616 /*----------------------------------------------------------------------------*/
617 
618 cs_property_t *
619 cs_equation_get_reaction_property(const cs_equation_t *eq,
620  const char *r_name);
621 
622 /*----------------------------------------------------------------------------*/
631 /*----------------------------------------------------------------------------*/
632 
634 cs_equation_get_space_scheme(const cs_equation_t *eq);
635 
636 /*----------------------------------------------------------------------------*/
644 /*----------------------------------------------------------------------------*/
645 
647 cs_equation_get_var_type(const cs_equation_t *eq);
648 
649 /*----------------------------------------------------------------------------*/
657 /*----------------------------------------------------------------------------*/
658 
660 cs_equation_get_type(const cs_equation_t *eq);
661 
662 /*----------------------------------------------------------------------------*/
673 /*----------------------------------------------------------------------------*/
674 
675 void
676 cs_equation_compute_flux_across_plane(const cs_equation_t *eq,
677  const char *ml_name,
678  const cs_real_3_t direction,
679  cs_real_t *diff_flux,
680  cs_real_t *conv_flux);
681 
682 /*----------------------------------------------------------------------------*/
690 /*----------------------------------------------------------------------------*/
691 
692 void
693 cs_equation_compute_diff_flux(const cs_equation_t *eq,
694  cs_real_t *diff_flux);
695 
696 /*----------------------------------------------------------------------------*/
697 
699 
700 #endif /* __CS_EQUATION_H__ */
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:476
Definition: cs_equation.h:57
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:2246
void 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:1398
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:1728
Definition: cs_cdo.h:112
Definition: cs_equation.h:74
Definition: cs_equation.h:58
void cs_equation_set_ic(cs_equation_t *eq, const char *ml_name, const char *def_key, void *val)
Define the initial condition of the unknown related to this equation This definition can be done by m...
Definition: cs_equation.c:1127
Field descriptor.
Definition: cs_field.h:121
void cs_equation_summary(const cs_equation_t *eq)
Summary of a cs_equation_t structure.
Definition: cs_equation.c:583
Definition: cs_equation_param.h:102
size_t cs_equation_get_tmpbuf_size(void)
Get the allocation size of the temporary buffer.
Definition: cs_equation_common.c:208
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:2432
Definition: cs_equation.h:64
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
cs_equation_key_t
Definition: cs_equation.h:55
void cs_equation_add_gravity_source_term(cs_equation_t *eq, int ml_id, cs_desc_t array_desc, cs_real_t *array_values)
Define and initialize a new structure to store parameters related to a source term def_key among "val...
Definition: cs_equation.c:1337
cs_source_term_reduction_t
Definition: cs_source_term.h:65
Definition: cs_equation.h:68
void cs_equation_set_source_term_reduction(cs_equation_t *eq, const char *st_name, cs_source_term_reduction_t type)
Set the type of quadrature to use for computing a source term If st_name is NULL, all source terms of...
Definition: cs_equation.c:1592
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:95
Definition: cs_cdo_connect.h:67
void() cs_analytic_func_t(cs_real_t time, const cs_real_3_t xyz, cs_get_t *retval)
Generic analytic function.
Definition: cs_cdo.h:154
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...
Definition: cs_equation.c:2471
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:2267
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
Definition: cs_cdo_quantities.h:100
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:1789
Definition: cs_equation.h:62
Definition: cs_equation.h:76
Definition: cs_mesh.h:62
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:1076
void cs_equation_set_source_term_quadrature(cs_equation_t *eq, const char *st_name, cs_quadra_type_t quad_type)
Set the type of quadrature to use for computing a source term If st_name is NULL, all source terms of...
Definition: cs_equation.c:1539
Definition: cs_equation.h:80
Definition: cs_equation.h:77
cs_space_scheme_t
Definition: cs_cdo.h:99
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:2206
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:194
void cs_equation_last_setup(cs_equation_t *eq)
Assign a set of pointer functions for managing the cs_equation_t structure during the computation...
Definition: cs_equation.c:654
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:1279
Definition: cs_equation.h:63
Definition: cs_field_pointer.h:64
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:162
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:2226
void cs_equation_extra_op(const cs_equation_t *eq, const cs_time_step_t *ts, double dt)
Predefined extra-operations related to this equation.
Definition: cs_equation.c:1991
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:735
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:308
cs_equation_type_t
Definition: cs_equation_param.h:63
cs_param_bc_type_t
Definition: cs_param.h:259
void cs_equation_solve(cs_equation_t *eq, bool do_logcvg)
Solve the linear system for this equation.
Definition: cs_equation.c:1902
cs_quadra_type_t
Definition: cs_quadrature.h:40
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:2365
void cs_equation_add_bc(cs_equation_t *eq, const char *ml_name, const char *bc_key, const char *def_key, const void *val)
Define and initialize a new structure to store parameters related to an equation bc_key among "dirich...
Definition: cs_equation.c:1191
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:2392
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:2307
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:2326
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:2345
Definition: cs_equation.h:75
Definition: cs_equation.h:70
#define END_C_DECLS
Definition: cs_defs.h:449
unsigned short int cs_flag_t
Definition: cs_defs.h:298
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:2182
Definition: cs_equation.h:79
cs_param_var_type_t
Definition: cs_param.h:109
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:1643
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:2163
Definition: cs_equation.h:73
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:605
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:2144
Definition: mesh.f90:26
Definition: cs_equation.h:78
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:1806
void 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:1476
cs_equation_t * cs_equation_free(cs_equation_t *eq)
Destroy a cs_equation_t structure.
Definition: cs_equation.c:547
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:2122