programmer's documentation
cs_equation_param.h
Go to the documentation of this file.
1 #ifndef __CS_EQUATION_PARAM_H__
2 #define __CS_EQUATION_PARAM_H__
3 
4 /*============================================================================
5  * Header to handle specific settings related to a cs_equation_t structure
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_param.h"
33 #include "cs_param_cdo.h"
34 #include "cs_property.h"
35 #include "cs_advection_field.h"
36 #include "cs_xdef.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
50 /*============================================================================
51  * Macro definitions
52  *============================================================================*/
53 
74 #define CS_EQUATION_LOCKED (1 << 0) // 1
75 #define CS_EQUATION_UNSTEADY (1 << 1) // 2
76 #define CS_EQUATION_CONVECTION (1 << 2) // 4
77 #define CS_EQUATION_DIFFUSION (1 << 3) // 8
78 #define CS_EQUATION_REACTION (1 << 4) // 16
79 
93 #define CS_EQUATION_POST_PECLET (1 << 0) // 1
94 #define CS_EQUATION_POST_UPWIND_COEF (1 << 1) // 2
95 
98 /*============================================================================
99  * Type definitions
100  *============================================================================*/
101 
116 typedef enum {
117 
122 
124 
137 typedef enum {
138 
142 
144 
150 typedef struct {
151 
158  int dim;
159  int verbosity;
167 
173 
174  /* Numerical settings */
182 
208 
226 
255 
270 
285 
305 
328 
345 
349 
540 typedef enum {
541 
566 
568 
569 /*============================================================================
570  * Static inline public function prototypes
571  *============================================================================*/
572 
573 /*----------------------------------------------------------------------------*/
581 /*----------------------------------------------------------------------------*/
582 
583 static inline bool
585 {
586  if (eqp == NULL)
587  return false;
588  if (eqp->flag & CS_EQUATION_DIFFUSION)
589  return true;
590  else
591  return false;
592 }
593 
594 /*----------------------------------------------------------------------------*/
602 /*----------------------------------------------------------------------------*/
603 
604 static inline bool
606 {
607  if (eqp == NULL)
608  return false;
609  if (eqp->flag & CS_EQUATION_CONVECTION)
610  return true;
611  else
612  return false;
613 }
614 
615 /*----------------------------------------------------------------------------*/
623 /*----------------------------------------------------------------------------*/
624 
625 static inline bool
627 {
628  if (eqp == NULL)
629  return false;
630  if (eqp->flag & CS_EQUATION_REACTION)
631  return true;
632  else
633  return false;
634 }
635 
636 /*----------------------------------------------------------------------------*/
644 /*----------------------------------------------------------------------------*/
645 
646 static inline bool
648 {
649  if (eqp == NULL)
650  return false;
651  if (eqp->flag & CS_EQUATION_UNSTEADY)
652  return true;
653  else
654  return false;
655 }
656 
657 /*----------------------------------------------------------------------------*/
665 /*----------------------------------------------------------------------------*/
666 
667 static inline bool
669 {
670  if (eqp == NULL)
671  return false;
672  if (eqp->n_source_terms > 0)
673  return true;
674  else
675  return false;
676 }
677 
678 /*============================================================================
679  * Public function prototypes
680  *============================================================================*/
681 
682 /*----------------------------------------------------------------------------*/
692 /*----------------------------------------------------------------------------*/
693 
696  int dim,
697  cs_param_bc_type_t default_bc);
698 
699 /*----------------------------------------------------------------------------*/
707 /*----------------------------------------------------------------------------*/
708 
711 
712 /*----------------------------------------------------------------------------*/
721 /*----------------------------------------------------------------------------*/
722 
723 void
725  cs_equation_key_t key,
726  const char *keyval);
727 
728 /*----------------------------------------------------------------------------*/
738 /*----------------------------------------------------------------------------*/
739 
740 void
741 cs_equation_param_set_sles(const char *eqname,
742  cs_equation_param_t *eqp,
743  int field_id);
744 
745 /*----------------------------------------------------------------------------*/
752 /*----------------------------------------------------------------------------*/
753 
754 void
755 cs_equation_summary_param(const char *eqname,
756  const cs_equation_param_t *eqp);
757 
758 /*----------------------------------------------------------------------------*/
771 /*----------------------------------------------------------------------------*/
772 
773 void
775  const char *z_name,
776  cs_real_t *val);
777 
778 /*----------------------------------------------------------------------------*/
792 /*----------------------------------------------------------------------------*/
793 
794 void
796  const char *z_name,
797  double quantity);
798 
799 /*----------------------------------------------------------------------------*/
812 /*----------------------------------------------------------------------------*/
813 
814 void
816  const char *z_name,
817  cs_analytic_func_t *analytic,
818  void *input);
819 
820 /*----------------------------------------------------------------------------*/
831 /*----------------------------------------------------------------------------*/
832 
833 void
835  const cs_param_bc_type_t bc_type,
836  const char *z_name,
837  cs_real_t *values);
838 
839 /*----------------------------------------------------------------------------*/
852 /*----------------------------------------------------------------------------*/
853 
854 void
856  const cs_param_bc_type_t bc_type,
857  const char *z_name,
858  cs_flag_t loc,
859  cs_real_t *array,
860  cs_lnum_t *index);
861 
862 /*----------------------------------------------------------------------------*/
875 /*----------------------------------------------------------------------------*/
876 
877 void
879  const cs_param_bc_type_t bc_type,
880  const char *z_name,
881  cs_analytic_func_t *analytic,
882  void *input);
883 
884 /*----------------------------------------------------------------------------*/
892 /*----------------------------------------------------------------------------*/
893 
894 void
896  cs_property_t *property);
897 
898 /*----------------------------------------------------------------------------*/
906 /*----------------------------------------------------------------------------*/
907 
908 void
910  cs_property_t *property);
911 
912 /*----------------------------------------------------------------------------*/
920 /*----------------------------------------------------------------------------*/
921 
922 void
924  cs_adv_field_t *adv_field);
925 
926 /*----------------------------------------------------------------------------*/
936 /*----------------------------------------------------------------------------*/
937 
938 int
940  cs_property_t *property);
941 
942 /*----------------------------------------------------------------------------*/
953 /*----------------------------------------------------------------------------*/
954 
955 cs_xdef_t *
957  const char *z_name,
958  cs_real_t *val);
959 
960 /*----------------------------------------------------------------------------*/
973 /*----------------------------------------------------------------------------*/
974 
975 cs_xdef_t *
977  const char *z_name,
978  cs_analytic_func_t *ana,
979  void *input);
980 
981 /*----------------------------------------------------------------------------*/
994 /*----------------------------------------------------------------------------*/
995 
996 cs_xdef_t *
998  const char *z_name,
999  cs_flag_t loc,
1000  cs_real_t *array,
1001  cs_lnum_t *index);
1002 
1003 /*----------------------------------------------------------------------------*/
1004 
1006 
1007 #endif /* __CS_EQUATION_PARAM_H__ */
cs_xdef_t * cs_equation_add_source_term_by_analytic(cs_equation_param_t *eqp, const char *z_name, cs_analytic_func_t *ana, void *input)
Define a new source term structure and initialize it by an analytical function.
Definition: cs_equation_param.c:1751
Definition: cs_equation_param.h:549
cs_adv_field_t * adv_field
Definition: cs_equation_param.h:304
Definition: cs_equation_param.h:543
Definition: cs_equation_param.h:557
void() cs_analytic_func_t(cs_real_t time, cs_lnum_t n_elts, const cs_lnum_t *elt_ids, const cs_real_t *coords, bool compact, void *input, cs_real_t *retval)
Generic function pointer for an analytic function elt_ids is optional. If not NULL, it enables to access in coords at the right location and the same thing to fill retval if compact is set to false.
Definition: cs_param.h:66
Definition: cs_equation_param.h:141
cs_real_t theta
Definition: cs_equation_param.h:253
Definition: cs_equation_param.h:556
Definition: cs_advection_field.h:59
cs_flag_t flag
Definition: cs_equation_param.h:166
cs_equation_solver_class_t solver_class
Definition: cs_equation_param.h:224
cs_flag_t process_flag
Definition: cs_equation_param.h:172
cs_xdef_t ** ic_defs
Definition: cs_equation_param.h:269
cs_param_advection_form_t adv_formulation
Definition: cs_equation_param.h:302
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:150
Definition: cs_equation_param.h:551
cs_param_hodge_t time_hodge
Definition: cs_equation_param.h:250
cs_equation_type_t type
Definition: cs_equation_param.h:157
void cs_equation_add_bc_by_array(cs_equation_param_t *eqp, const cs_param_bc_type_t bc_type, const char *z_name, cs_flag_t loc, cs_real_t *array, cs_lnum_t *index)
Define and initialize a new structure to set a boundary condition related to the given equation struc...
Definition: cs_equation_param.c:1494
Definition: cs_equation_param.h:565
cs_param_advection_scheme_t
Definition: cs_param.h:236
static bool cs_equation_param_has_time(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs an unsteady term.
Definition: cs_equation_param.h:647
cs_param_dof_reduction_t dof_reduction
Definition: cs_equation_param.h:176
cs_param_hodge_t diffusion_hodge
Definition: cs_equation_param.h:283
cs_param_space_scheme_t space_scheme
Definition: cs_equation_param.h:175
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
static bool cs_equation_param_has_diffusion(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a diffusion term.
Definition: cs_equation_param.h:584
int space_poly_degree
Definition: cs_equation_param.h:181
cs_property_t ** reaction_properties
Definition: cs_equation_param.h:327
void cs_equation_add_bc_by_analytic(cs_equation_param_t *eqp, const cs_param_bc_type_t bc_type, const char *z_name, cs_analytic_func_t *analytic, void *input)
Define and initialize a new structure to set a boundary condition related to the given equation param...
Definition: cs_equation_param.c:1553
Definition: cs_equation_param.h:546
Definition: cs_equation_param.h:545
cs_xdef_t * cs_equation_add_source_term_by_val(cs_equation_param_t *eqp, const char *z_name, cs_real_t *val)
Define a new source term structure and initialize it by value.
Definition: cs_equation_param.c:1703
cs_param_time_scheme_t time_scheme
Definition: cs_equation_param.h:252
cs_param_advection_form_t
Definition: cs_param.h:205
Definition: cs_equation_param.h:550
cs_equation_param_t * cs_equation_create_param(cs_equation_type_t type, int dim, cs_param_bc_type_t default_bc)
Create a cs_equation_param_t.
Definition: cs_equation_param.c:370
void cs_equation_param_set_sles(const char *eqname, cs_equation_param_t *eqp, int field_id)
Set parameters for initializing SLES structures used for the resolution of the linear system...
Definition: cs_equation_param.c:886
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
#define CS_EQUATION_UNSTEADY
Unsteady term is needed.
Definition: cs_equation_param.h:75
Definition: cs_equation_param.h:561
cs_property_t * time_property
Definition: cs_equation_param.h:251
Definition: cs_equation_param.h:140
Definition: cs_equation_param.h:563
void cs_equation_add_bc_by_value(cs_equation_param_t *eqp, const cs_param_bc_type_t bc_type, const char *z_name, cs_real_t *values)
Define and initialize a new structure to set a boundary condition related to the given equation struc...
Definition: cs_equation_param.c:1449
Definition: cs_equation_param.h:564
cs_xdef_t ** source_terms
Definition: cs_equation_param.h:344
#define CS_EQUATION_CONVECTION
Convection term is needed.
Definition: cs_equation_param.h:76
Definition: cs_equation_param.h:562
cs_param_itsol_t itsol_info
Definition: cs_equation_param.h:225
void cs_equation_add_ic_by_analytic(cs_equation_param_t *eqp, const char *z_name, cs_analytic_func_t *analytic, void *input)
Define the initial condition for the unknown related to this equation. This definition can be done on...
Definition: cs_equation_param.c:1405
Definition: cs_equation_param.h:544
Definition: cs_equation_param.h:553
int cs_equation_add_reaction(cs_equation_param_t *eqp, cs_property_t *property)
Define and initialize a new structure to store parameters related to a reaction term.
Definition: cs_equation_param.c:1670
Definition: cs_equation_param.h:547
Definition: cs_equation_param.h:554
int dim
Definition: cs_equation_param.h:158
Definition: cs_equation_param.h:559
Definition: cs_equation_param.h:542
cs_property_t * diffusion_property
Definition: cs_equation_param.h:284
Definition: cs_equation_param.h:555
cs_param_time_scheme_t
Definition: cs_param.h:177
static int input(void)
cs_param_dof_reduction_t
Definition: cs_param.h:148
Definition: cs_equation_param.h:548
int n_ic_defs
Definition: cs_equation_param.h:268
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:122
int n_source_terms
Definition: cs_equation_param.h:343
cs_equation_key_t
List of available keys for setting the parameters of an equation.
Definition: cs_equation_param.h:540
Definition: cs_equation_param.h:119
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
void cs_equation_add_ic_by_value(cs_equation_param_t *eqp, const char *z_name, cs_real_t *val)
Define the initial condition for the unknown related to this equation This definition can be done on ...
Definition: cs_equation_param.c:1318
void cs_equation_add_time(cs_equation_param_t *eqp, cs_property_t *property)
Define and initialize a new structure to store parameters related to an unsteady term.
Definition: cs_equation_param.c:1624
Definition: cs_equation_param.h:139
void cs_equation_add_advection(cs_equation_param_t *eqp, cs_adv_field_t *adv_field)
Define and initialize a new structure to store parameters related to an advection term...
Definition: cs_equation_param.c:1646
int verbosity
Definition: cs_equation_param.h:159
Definition: cs_equation_param.h:118
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
int sles_verbosity
Definition: cs_equation_param.h:160
int n_reaction_terms
Definition: cs_equation_param.h:326
cs_param_advection_scheme_t adv_scheme
Definition: cs_equation_param.h:303
int n_bc_defs
Definition: cs_equation_param.h:206
Definition: cs_equation_param.h:121
#define END_C_DECLS
Definition: cs_defs.h:462
cs_xdef_t * cs_equation_add_source_term_by_array(cs_equation_param_t *eqp, const char *z_name, cs_flag_t loc, cs_real_t *array, cs_lnum_t *index)
Define a new source term defined by an array.
Definition: cs_equation_param.c:1806
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_param_bc_enforce_t enforcement
Definition: cs_equation_param.h:205
void cs_equation_set_param(cs_equation_param_t *eqp, cs_equation_key_t key, const char *keyval)
Set a parameter attached to a keyname in a cs_equation_param_t structure.
Definition: cs_equation_param.c:519
cs_equation_solver_class_t
Class of iterative solvers to consider for solver the linear system.
Definition: cs_equation_param.h:137
bool do_lumping
Definition: cs_equation_param.h:254
cs_param_bc_type_t default_bc
Definition: cs_equation_param.h:204
cs_xdef_t ** bc_defs
Definition: cs_equation_param.h:207
Definition: cs_equation_param.h:552
cs_equation_param_t * cs_equation_free_param(cs_equation_param_t *eqp)
Free a cs_equation_param_t.
Definition: cs_equation_param.c:461
cs_param_hodge_t reaction_hodge
Definition: cs_equation_param.h:325
#define CS_EQUATION_REACTION
Reaction term is needed.
Definition: cs_equation_param.h:78
#define CS_EQUATION_DIFFUSION
Diffusion term is needed.
Definition: cs_equation_param.h:77
Definition: cs_equation_param.h:560
cs_param_space_scheme_t
Type of numerical scheme for the discretization in space.
Definition: cs_param.h:122
Definition: cs_param_cdo.h:97
static bool cs_equation_param_has_reaction(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a reaction term.
Definition: cs_equation_param.h:626
Definition: cs_equation_param.h:558
static bool cs_equation_param_has_sourceterm(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a source term.
Definition: cs_equation_param.h:668
void cs_equation_summary_param(const char *eqname, const cs_equation_param_t *eqp)
Summary of a cs_equation_param_t structure.
Definition: cs_equation_param.c:1075
Definition: cs_property.h:63
cs_param_bc_enforce_t
Definition: cs_param.h:310
void cs_equation_add_ic_by_qov(cs_equation_param_t *eqp, const char *z_name, double quantity)
Define the initial condition for the unknown related to this equation This definition can be done on ...
Definition: cs_equation_param.c:1362
void cs_equation_add_diffusion(cs_equation_param_t *eqp, cs_property_t *property)
Define and initialize a new structure to store parameters related to a diffusion term.
Definition: cs_equation_param.c:1597
Structure storing all metadata related to the resolution of a linear system with an iterative solver...
Definition: cs_param.h:372
Definition: cs_equation_param.h:120
static bool cs_equation_param_has_convection(const cs_equation_param_t *eqp)
Ask if the parameters of the equation needs a convection term.
Definition: cs_equation_param.h:605