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 
78 #define CS_EQUATION_LOCKED (1 << 0) /* 1 */
79 #define CS_EQUATION_UNSTEADY (1 << 1) /* 2 */
80 #define CS_EQUATION_CONVECTION (1 << 2) /* 4 */
81 #define CS_EQUATION_DIFFUSION (1 << 3) /* 8 */
82 #define CS_EQUATION_REACTION (1 << 4) /* 16 */
83 #define CS_EQUATION_FORCE_VALUES (1 << 5) /* 32 */
84 
101 #define CS_EQUATION_POST_BALANCE (1 << 0) /* 1 */
102 #define CS_EQUATION_POST_PECLET (1 << 1) /* 2 */
103 #define CS_EQUATION_POST_UPWIND_COEF (1 << 2) /* 4 */
104 
107 /*============================================================================
108  * Type definitions
109  *============================================================================*/
110 
125 typedef enum {
126 
131 
133 
146 typedef enum {
147 
151 
153 
159 typedef struct {
160 
165  char *restrict name;
167  int dim;
168  int verbosity;
176 
182 
183  /* Numerical settings */
191 
225 
243 
272 
287 
302 
329 
352 
369 
393 
397 
626 typedef enum {
627 
654 
656 
658 
659 /*============================================================================
660  * Static inline public function prototypes
661  *============================================================================*/
662 
663 /*----------------------------------------------------------------------------*/
671 /*----------------------------------------------------------------------------*/
672 
673 static inline bool
675 {
676  assert(eqp != NULL);
677  if (eqp->flag & CS_EQUATION_DIFFUSION)
678  return true;
679  else
680  return false;
681 }
682 
683 /*----------------------------------------------------------------------------*/
691 /*----------------------------------------------------------------------------*/
692 
693 static inline bool
695 {
696  assert(eqp != NULL);
697  if (eqp->flag & CS_EQUATION_CONVECTION)
698  return true;
699  else
700  return false;
701 }
702 
703 /*----------------------------------------------------------------------------*/
711 /*----------------------------------------------------------------------------*/
712 
713 static inline bool
715 {
716  assert(eqp != NULL);
717  if (eqp->flag & CS_EQUATION_REACTION)
718  return true;
719  else
720  return false;
721 }
722 
723 /*----------------------------------------------------------------------------*/
731 /*----------------------------------------------------------------------------*/
732 
733 static inline bool
735 {
736  assert(eqp != NULL);
737  if (eqp->flag & CS_EQUATION_UNSTEADY)
738  return true;
739  else
740  return false;
741 }
742 
743 /*----------------------------------------------------------------------------*/
751 /*----------------------------------------------------------------------------*/
752 
753 static inline bool
755 {
756  assert(eqp != NULL);
757  if (eqp->n_source_terms > 0)
758  return true;
759  else
760  return false;
761 }
762 
763 /*----------------------------------------------------------------------------*/
772 /*----------------------------------------------------------------------------*/
773 
774 static inline bool
776 {
777  assert(eqp != NULL);
778  if (eqp->flag & CS_EQUATION_FORCE_VALUES)
779  return true;
780  else
781  return false;
782 }
783 
784 /*----------------------------------------------------------------------------*/
795 /*----------------------------------------------------------------------------*/
796 
797 static inline bool
799  const char *name)
800 {
801  if (eqp == NULL)
802  return false;
803  if (eqp->name == NULL)
804  return false;
805  if (strcmp(eqp->name, name) == 0)
806  return true;
807  else
808  return false;
809 }
810 
811 /*============================================================================
812  * Public function prototypes
813  *============================================================================*/
814 
815 /*----------------------------------------------------------------------------*/
826 /*----------------------------------------------------------------------------*/
827 
829 cs_equation_create_param(const char *name,
830  cs_equation_type_t type,
831  int dim,
832  cs_param_bc_type_t default_bc);
833 
834 /*----------------------------------------------------------------------------*/
842 /*----------------------------------------------------------------------------*/
843 
844 void
846  cs_equation_param_t *dst);
847 
848 /*----------------------------------------------------------------------------*/
856 /*----------------------------------------------------------------------------*/
857 
860 
861 /*----------------------------------------------------------------------------*/
870 /*----------------------------------------------------------------------------*/
871 
872 void
874  cs_equation_key_t key,
875  const char *keyval);
876 
877 /*----------------------------------------------------------------------------*/
886 /*----------------------------------------------------------------------------*/
887 
888 void
890  int field_id);
891 
892 /*----------------------------------------------------------------------------*/
898 /*----------------------------------------------------------------------------*/
899 
900 void
902 
903 /*----------------------------------------------------------------------------*/
918 /*----------------------------------------------------------------------------*/
919 
920 cs_xdef_t *
922  const char *z_name,
923  cs_real_t *val);
924 
925 /*----------------------------------------------------------------------------*/
941 /*----------------------------------------------------------------------------*/
942 
943 cs_xdef_t *
945  const char *z_name,
946  double quantity);
947 
948 /*----------------------------------------------------------------------------*/
963 /*----------------------------------------------------------------------------*/
964 
965 cs_xdef_t *
967  const char *z_name,
968  cs_analytic_func_t *analytic,
969  void *input);
970 
971 /*----------------------------------------------------------------------------*/
984 /*----------------------------------------------------------------------------*/
985 
986 cs_xdef_t *
988  const cs_param_bc_type_t bc_type,
989  const char *z_name,
990  cs_real_t *values);
991 
992 /*----------------------------------------------------------------------------*/
1007 /*----------------------------------------------------------------------------*/
1008 
1009 cs_xdef_t *
1011  const cs_param_bc_type_t bc_type,
1012  const char *z_name,
1013  cs_flag_t loc,
1014  cs_real_t *array,
1015  cs_lnum_t *index);
1016 
1017 /*----------------------------------------------------------------------------*/
1032 /*----------------------------------------------------------------------------*/
1033 
1034 cs_xdef_t *
1036  const cs_param_bc_type_t bc_type,
1037  const char *z_name,
1038  cs_analytic_func_t *analytic,
1039  void *input);
1040 
1041 /*----------------------------------------------------------------------------*/
1049 /*----------------------------------------------------------------------------*/
1050 
1051 void
1053  cs_property_t *property);
1054 
1055 /*----------------------------------------------------------------------------*/
1063 /*----------------------------------------------------------------------------*/
1064 
1065 void
1067  cs_property_t *property);
1068 
1069 /*----------------------------------------------------------------------------*/
1077 /*----------------------------------------------------------------------------*/
1078 
1079 void
1081  cs_adv_field_t *adv_field);
1082 
1083 /*----------------------------------------------------------------------------*/
1093 /*----------------------------------------------------------------------------*/
1094 
1095 int
1097  cs_property_t *property);
1098 
1099 /*----------------------------------------------------------------------------*/
1110 /*----------------------------------------------------------------------------*/
1111 
1112 cs_xdef_t *
1114  const char *z_name,
1115  cs_real_t *val);
1116 
1117 /*----------------------------------------------------------------------------*/
1130 /*----------------------------------------------------------------------------*/
1131 
1132 cs_xdef_t *
1134  const char *z_name,
1135  cs_analytic_func_t *ana,
1136  void *input);
1137 
1138 /*----------------------------------------------------------------------------*/
1151 /*----------------------------------------------------------------------------*/
1152 
1153 cs_xdef_t *
1155  const char *z_name,
1156  cs_flag_t loc,
1157  cs_real_t *array,
1158  cs_lnum_t *index);
1159 
1160 /*----------------------------------------------------------------------------*/
1173 /*----------------------------------------------------------------------------*/
1174 
1175 void
1177  cs_lnum_t n_elts,
1178  const cs_lnum_t elt_ids[],
1179  const cs_real_t elt_values[]);
1180 
1181 /*----------------------------------------------------------------------------*/
1182 
1184 
1185 #endif /* __CS_EQUATION_PARAM_H__ */
cs_real_t * enforced_dof_values
Definition: cs_equation_param.h:392
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:2087
void cs_equation_summary_param(const cs_equation_param_t *eqp)
Summary of a cs_equation_param_t structure.
Definition: cs_equation_param.c:1368
Definition: cs_equation_param.h:638
cs_adv_field_t * adv_field
Definition: cs_equation_param.h:328
#define restrict
Definition: cs_defs.h:122
Definition: cs_equation_param.h:629
Definition: cs_equation_param.h:646
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:150
cs_real_t theta
Definition: cs_equation_param.h:270
Definition: cs_equation_param.h:645
Definition: cs_advection_field.h:118
cs_flag_t flag
Definition: cs_equation_param.h:175
cs_equation_solver_class_t solver_class
Definition: cs_equation_param.h:241
cs_flag_t process_flag
Definition: cs_equation_param.h:181
void cs_equation_enforce_vertex_dofs(cs_equation_param_t *eqp, cs_lnum_t n_elts, const cs_lnum_t elt_ids[], const cs_real_t elt_values[])
Add an enforcement of the value of degrees of freedom located at mesh vertices. The spatial discretiz...
Definition: cs_equation_param.c:2201
cs_xdef_t ** ic_defs
Definition: cs_equation_param.h:286
cs_param_advection_form_t adv_formulation
Definition: cs_equation_param.h:325
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:159
Definition: cs_equation_param.h:630
Definition: cs_equation_param.h:640
cs_param_hodge_t time_hodge
Definition: cs_equation_param.h:267
cs_equation_type_t type
Definition: cs_equation_param.h:166
Definition: cs_equation_param.h:655
cs_xdef_t * 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:1632
cs_param_advection_scheme_t
Definition: cs_param.h:247
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:734
cs_param_dof_reduction_t dof_reduction
Definition: cs_equation_param.h:185
cs_param_hodge_t diffusion_hodge
Definition: cs_equation_param.h:300
cs_param_space_scheme_t space_scheme
Definition: cs_equation_param.h:184
#define BEGIN_C_DECLS
Definition: cs_defs.h:462
cs_real_t upwind_portion
Definition: cs_equation_param.h:327
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:674
int space_poly_degree
Definition: cs_equation_param.h:190
cs_property_t ** reaction_properties
Definition: cs_equation_param.h:351
Definition: cs_equation_param.h:635
cs_xdef_t * 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:1775
Definition: cs_equation_param.h:634
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:2039
cs_param_time_scheme_t time_scheme
Definition: cs_equation_param.h:269
cs_param_advection_form_t
Definition: cs_param.h:209
Definition: cs_equation_param.h:639
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:79
Definition: cs_equation_param.h:650
Definition: cs_equation_param.h:633
cs_property_t * time_property
Definition: cs_equation_param.h:268
Definition: cs_equation_param.h:149
Definition: cs_equation_param.h:652
void cs_equation_param_update_from(const cs_equation_param_t *ref, cs_equation_param_t *dst)
Copy the settings from one cs_equation_param_t structure to another one.
Definition: cs_equation_param.c:472
Definition: cs_equation_param.h:653
cs_xdef_t * 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:1824
cs_xdef_t ** source_terms
Definition: cs_equation_param.h:368
#define CS_EQUATION_CONVECTION
Convection term is needed.
Definition: cs_equation_param.h:80
Definition: cs_equation_param.h:651
cs_param_itsol_t itsol_info
Definition: cs_equation_param.h:242
Definition: cs_equation_param.h:632
Definition: cs_equation_param.h:642
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:2006
cs_lnum_t * enforced_dof_ids
Definition: cs_equation_param.h:391
Definition: cs_equation_param.h:636
Definition: cs_equation_param.h:643
int dim
Definition: cs_equation_param.h:167
Definition: cs_equation_param.h:648
Definition: cs_equation_param.h:628
cs_xdef_t * 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:1887
cs_property_t * diffusion_property
Definition: cs_equation_param.h:301
Definition: cs_equation_param.h:644
cs_param_time_scheme_t
Definition: cs_param.h:180
static int input(void)
Definition: cs_equation_param.h:631
cs_param_dof_reduction_t
Definition: cs_param.h:148
char *restrict name
Definition: cs_equation_param.h:165
Definition: cs_equation_param.h:637
int n_ic_defs
Definition: cs_equation_param.h:285
static bool cs_equation_param_has_name(cs_equation_param_t *eqp, const char *name)
Check if a cs_equation_param_t structure has its name member equal to the given name.
Definition: cs_equation_param.h:798
cs_xdef_t * 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:1680
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:126
int n_source_terms
Definition: cs_equation_param.h:367
#define CS_EQUATION_FORCE_VALUES
Add an algebraic manipulation to set the value of a given set of interior degrees of freedom...
Definition: cs_equation_param.h:83
cs_equation_key_t
List of available keys for setting the parameters of an equation.
Definition: cs_equation_param.h:626
Definition: cs_equation_param.h:128
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
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:1960
Definition: cs_equation_param.h:148
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:1982
int verbosity
Definition: cs_equation_param.h:168
Definition: cs_equation_param.h:127
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
int sles_verbosity
Definition: cs_equation_param.h:169
int n_reaction_terms
Definition: cs_equation_param.h:350
cs_param_advection_scheme_t adv_scheme
Definition: cs_equation_param.h:326
cs_lnum_t n_enforced_dofs
Definition: cs_equation_param.h:390
int n_bc_defs
Definition: cs_equation_param.h:223
Definition: cs_equation_param.h:130
#define END_C_DECLS
Definition: cs_defs.h:463
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:2142
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_real_t bc_penalization_coeff
Definition: cs_equation_param.h:222
cs_xdef_t * 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:1727
cs_param_bc_enforce_t enforcement
Definition: cs_equation_param.h:221
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:647
cs_equation_solver_class_t
Class of iterative solvers to consider for solver the linear system.
Definition: cs_equation_param.h:146
bool do_lumping
Definition: cs_equation_param.h:271
void cs_equation_param_set_sles(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:1060
cs_param_bc_type_t default_bc
Definition: cs_equation_param.h:220
static bool cs_equation_param_has_internal_enforcement(const cs_equation_param_t *eqp)
Ask if the parameters of the equation has an internal enforcement of the degrees of freedom...
Definition: cs_equation_param.h:775
cs_xdef_t ** bc_defs
Definition: cs_equation_param.h:224
Definition: cs_equation_param.h:641
cs_equation_param_t * cs_equation_free_param(cs_equation_param_t *eqp)
Free a cs_equation_param_t.
Definition: cs_equation_param.c:579
cs_param_hodge_t reaction_hodge
Definition: cs_equation_param.h:349
#define CS_EQUATION_REACTION
Reaction term is needed.
Definition: cs_equation_param.h:82
#define CS_EQUATION_DIFFUSION
Diffusion term is needed.
Definition: cs_equation_param.h:81
Definition: cs_equation_param.h:649
cs_param_space_scheme_t
Type of numerical scheme for the discretization in space.
Definition: cs_param.h:122
Definition: cs_param_cdo.h:105
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:714
Definition: cs_equation_param.h:647
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:754
cs_equation_param_t * cs_equation_create_param(const char *name, cs_equation_type_t type, int dim, cs_param_bc_type_t default_bc)
Create a cs_equation_param_t structure.
Definition: cs_equation_param.c:364
Definition: cs_property.h:104
cs_param_bc_enforce_t
Definition: cs_param.h:325
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:1933
Structure storing all metadata related to the resolution of a linear system with an iterative solver...
Definition: cs_param.h:408
Definition: cs_equation_param.h:129
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:694