My Project
programmer's documentation
Loading...
Searching...
No Matches
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-2019 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_advection_field.h"
33#include "cs_param.h"
34#include "cs_param_cdo.h"
35#include "cs_property.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
104#define CS_EQUATION_POST_BALANCE (1 << 0) /* 1 */
105#define CS_EQUATION_POST_PECLET (1 << 1) /* 2 */
106#define CS_EQUATION_POST_UPWIND_COEF (1 << 2) /* 4 */
107#define CS_EQUATION_POST_NORMAL_FLUX (1 << 3) /* 8 */
108
111/*============================================================================
112 * Type definitions
113 *============================================================================*/
114
142
405
676
677/*============================================================================
678 * Static inline public function prototypes
679 *============================================================================*/
680
681/*----------------------------------------------------------------------------*/
688/*----------------------------------------------------------------------------*/
689
690static inline void
692 cs_flag_t flag)
693{
694 assert(eqp != NULL);
695 eqp->flag |= flag;
696}
697
698/*----------------------------------------------------------------------------*/
706/*----------------------------------------------------------------------------*/
707
708static inline bool
710{
711 assert(eqp != NULL);
712 if (eqp->flag & CS_EQUATION_DIFFUSION)
713 return true;
714 else
715 return false;
716}
717
718/*----------------------------------------------------------------------------*/
726/*----------------------------------------------------------------------------*/
727
728static inline bool
730{
731 assert(eqp != NULL);
732 if (eqp->flag & CS_EQUATION_CONVECTION)
733 return true;
734 else
735 return false;
736}
737
738/*----------------------------------------------------------------------------*/
746/*----------------------------------------------------------------------------*/
747
748static inline bool
750{
751 assert(eqp != NULL);
752 if (eqp->flag & CS_EQUATION_REACTION)
753 return true;
754 else
755 return false;
756}
757
758/*----------------------------------------------------------------------------*/
766/*----------------------------------------------------------------------------*/
767
768static inline bool
770{
771 assert(eqp != NULL);
772 if (eqp->flag & CS_EQUATION_UNSTEADY)
773 return true;
774 else
775 return false;
776}
777
778/*----------------------------------------------------------------------------*/
786/*----------------------------------------------------------------------------*/
787
788static inline bool
790{
791 assert(eqp != NULL);
792 if (eqp->n_source_terms > 0)
793 return true;
794 else
795 return false;
796}
797
798/*----------------------------------------------------------------------------*/
807/*----------------------------------------------------------------------------*/
808
809static inline bool
811{
812 assert(eqp != NULL);
814 return true;
815 else
816 return false;
817}
818
819/*----------------------------------------------------------------------------*/
830/*----------------------------------------------------------------------------*/
831
832static inline bool
834 const char *name)
835{
836 if (eqp == NULL)
837 return false;
838 if (eqp->name == NULL)
839 return false;
840 if (strcmp(eqp->name, name) == 0)
841 return true;
842 else
843 return false;
844}
845
846/*============================================================================
847 * Public function prototypes
848 *============================================================================*/
849
850/*----------------------------------------------------------------------------*/
861/*----------------------------------------------------------------------------*/
862
864cs_equation_create_param(const char *name,
866 int dim,
867 cs_param_bc_type_t default_bc);
868
869/*----------------------------------------------------------------------------*/
877/*----------------------------------------------------------------------------*/
878
879void
882
883/*----------------------------------------------------------------------------*/
891/*----------------------------------------------------------------------------*/
892
895
896/*----------------------------------------------------------------------------*/
905/*----------------------------------------------------------------------------*/
906
907void
910 const char *keyval);
911
912/*----------------------------------------------------------------------------*/
921/*----------------------------------------------------------------------------*/
922
923void
925 int field_id);
926
927/*----------------------------------------------------------------------------*/
934/*----------------------------------------------------------------------------*/
935
936void
938
939/*----------------------------------------------------------------------------*/
945/*----------------------------------------------------------------------------*/
946
947void
949
950/*----------------------------------------------------------------------------*/
965/*----------------------------------------------------------------------------*/
966
967cs_xdef_t *
969 const char *z_name,
970 cs_real_t *val);
971
972/*----------------------------------------------------------------------------*/
988/*----------------------------------------------------------------------------*/
989
990cs_xdef_t *
992 const char *z_name,
993 double quantity);
994
995/*----------------------------------------------------------------------------*/
1010/*----------------------------------------------------------------------------*/
1011
1012cs_xdef_t *
1014 const char *z_name,
1015 cs_analytic_func_t *analytic,
1016 void *input);
1017
1018/*----------------------------------------------------------------------------*/
1027/*----------------------------------------------------------------------------*/
1028
1029void
1031 cs_xdef_t *xdef);
1032
1033/*----------------------------------------------------------------------------*/
1046/*----------------------------------------------------------------------------*/
1047
1048cs_xdef_t *
1050 const cs_param_bc_type_t bc_type,
1051 const char *z_name,
1052 cs_real_t *values);
1053
1054/*----------------------------------------------------------------------------*/
1071/*----------------------------------------------------------------------------*/
1072
1073cs_xdef_t *
1075 const cs_param_bc_type_t bc_type,
1076 const char *z_name,
1077 cs_flag_t loc,
1078 cs_real_t *array,
1079 bool is_owner,
1080 cs_lnum_t *index);
1081
1082/*----------------------------------------------------------------------------*/
1097/*----------------------------------------------------------------------------*/
1098
1099cs_xdef_t *
1101 const cs_param_bc_type_t bc_type,
1102 const char *z_name,
1103 cs_analytic_func_t *analytic,
1104 void *input);
1105
1106/*----------------------------------------------------------------------------*/
1115/*----------------------------------------------------------------------------*/
1116
1117void
1119 const char *z_name);
1120
1121/*----------------------------------------------------------------------------*/
1129/*----------------------------------------------------------------------------*/
1130
1131void
1133 cs_property_t *property);
1134
1135/*----------------------------------------------------------------------------*/
1143/*----------------------------------------------------------------------------*/
1144
1145void
1147 cs_property_t *property);
1148
1149/*----------------------------------------------------------------------------*/
1157/*----------------------------------------------------------------------------*/
1158
1159void
1161 cs_adv_field_t *adv_field);
1162
1163/*----------------------------------------------------------------------------*/
1173/*----------------------------------------------------------------------------*/
1174
1175int
1177 cs_property_t *property);
1178
1179/*----------------------------------------------------------------------------*/
1190/*----------------------------------------------------------------------------*/
1191
1192cs_xdef_t *
1194 const char *z_name,
1195 cs_real_t *val);
1196
1197/*----------------------------------------------------------------------------*/
1210/*----------------------------------------------------------------------------*/
1211
1212cs_xdef_t *
1214 const char *z_name,
1215 cs_analytic_func_t *ana,
1216 void *input);
1217
1218/*----------------------------------------------------------------------------*/
1233/*----------------------------------------------------------------------------*/
1234
1235cs_xdef_t *
1237 const char *z_name,
1238 cs_flag_t loc,
1239 cs_real_t *array,
1240 bool is_owner,
1241 cs_lnum_t *index);
1242
1243/*----------------------------------------------------------------------------*/
1256/*----------------------------------------------------------------------------*/
1257
1258void
1260 cs_lnum_t n_elts,
1261 const cs_lnum_t elt_ids[],
1262 const cs_real_t elt_values[]);
1263
1264/*----------------------------------------------------------------------------*/
1265
1267
1268#endif /* __CS_EQUATION_PARAM_H__ */
#define restrict
Definition cs_defs.h:127
#define BEGIN_C_DECLS
Definition cs_defs.h:467
double cs_real_t
Floating-point value.
Definition cs_defs.h:302
#define END_C_DECLS
Definition cs_defs.h:468
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:298
unsigned short int cs_flag_t
Definition cs_defs.h:304
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:2615
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, bool is_owner, 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:2178
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:2417
void cs_equation_summary_param(const cs_equation_param_t *eqp)
Summary of a cs_equation_param_t structure.
Definition cs_equation_param.c:1651
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:1088
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:769
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:2251
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:1951
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:2046
void cs_equation_add_sliding_condition(cs_equation_param_t *eqp, const char *z_name)
Define and initialize a new structure to set a sliding boundary condition related to the given equati...
Definition cs_equation_param.c:2305
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, bool is_owner, cs_lnum_t *index)
Define a new source term defined by an array.
Definition cs_equation_param.c:2555
#define CS_EQUATION_UNSTEADY
Unsteady term is needed.
Definition cs_equation_param.h:79
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:1999
#define CS_EQUATION_DIFFUSION
Diffusion term is needed.
Definition cs_equation_param.h:81
cs_equation_param_t * cs_equation_free_param(cs_equation_param_t *eqp)
Free a cs_equation_param_t.
Definition cs_equation_param.c:1198
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:1266
#define CS_EQUATION_REACTION
Reaction term is needed.
Definition cs_equation_param.h:82
cs_equation_key_t
List of available keys for setting the parameters of an equation.
Definition cs_equation_param.h:643
@ CS_EQKEY_SOLVER_FAMILY
Definition cs_equation_param.h:667
@ CS_EQKEY_VERBOSITY
Definition cs_equation_param.h:671
@ CS_EQKEY_HODGE_TIME_ALGO
Definition cs_equation_param.h:658
@ CS_EQKEY_ITSOL_MAX_ITER
Definition cs_equation_param.h:662
@ CS_EQKEY_ITSOL
Definition cs_equation_param.h:660
@ CS_EQKEY_BC_WEAK_PENA_COEFF
Definition cs_equation_param.h:652
@ CS_EQKEY_BC_QUADRATURE
Definition cs_equation_param.h:650
@ CS_EQKEY_HODGE_DIFF_COEF
Definition cs_equation_param.h:657
@ CS_EQKEY_HODGE_DIFF_ALGO
Definition cs_equation_param.h:656
@ CS_EQKEY_AMG_TYPE
Definition cs_equation_param.h:648
@ CS_EQKEY_ITSOL_RESNORM_TYPE
Definition cs_equation_param.h:663
@ CS_EQKEY_ITSOL_EPS
Definition cs_equation_param.h:661
@ CS_EQKEY_ADV_UPWIND_PORTION
Definition cs_equation_param.h:647
@ CS_EQKEY_TIME_SCHEME
Definition cs_equation_param.h:669
@ CS_EQKEY_DO_LUMPING
Definition cs_equation_param.h:653
@ CS_EQKEY_PRECOND
Definition cs_equation_param.h:665
@ CS_EQKEY_ADV_SCHEME
Definition cs_equation_param.h:646
@ CS_EQKEY_BC_STRONG_PENA_COEFF
Definition cs_equation_param.h:651
@ CS_EQKEY_TIME_THETA
Definition cs_equation_param.h:670
@ CS_EQKEY_ADV_FORMULATION
Definition cs_equation_param.h:645
@ CS_EQKEY_EXTRA_OP
Definition cs_equation_param.h:655
@ CS_EQKEY_OMP_ASSEMBLY_STRATEGY
Definition cs_equation_param.h:664
@ CS_EQKEY_DOF_REDUCTION
Definition cs_equation_param.h:654
@ CS_EQKEY_SPACE_SCHEME
Definition cs_equation_param.h:668
@ CS_EQKEY_BC_ENFORCEMENT
Definition cs_equation_param.h:649
@ CS_EQKEY_HODGE_REAC_ALGO
Definition cs_equation_param.h:659
@ CS_EQKEY_SLES_VERBOSITY
Definition cs_equation_param.h:666
@ CS_EQKEY_N_KEYS
Definition cs_equation_param.h:673
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:810
#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_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:2450
void cs_equation_param_last_stage(cs_equation_param_t *eqp)
Last modification of the cs_equation_param_t structure before launching the computation.
Definition cs_equation_param.c:1619
void cs_equation_add_xdef_bc(cs_equation_param_t *eqp, cs_xdef_t *xdef)
Set a boundary condition from an existing cs_xdef_t structure The lifecycle of the cs_xdef_t structur...
Definition cs_equation_param.c:2090
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:2393
#define CS_EQUATION_CONVECTION
Convection term is needed.
Definition cs_equation_param.h:80
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:789
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:2498
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:1300
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:960
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:833
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:2118
static void cs_equation_param_set_flag(cs_equation_param_t *eqp, cs_flag_t flag)
Update the flag related to a cs_equation_param_t structure.
Definition cs_equation_param.h:691
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:709
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:2371
cs_equation_type_t
Type of equations managed by the solver.
Definition cs_equation_param.h:133
@ CS_EQUATION_TYPE_NAVSTO
Definition cs_equation_param.h:137
@ CS_EQUATION_TYPE_USER
Definition cs_equation_param.h:135
@ CS_EQUATION_TYPE_GROUNDWATER
Definition cs_equation_param.h:136
@ CS_EQUATION_TYPE_PREDEFINED
Definition cs_equation_param.h:138
@ CS_EQUATION_N_TYPES
Definition cs_equation_param.h:139
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:729
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:749
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:2344
cs_param_space_scheme_t
Type of numerical scheme for the discretization in space.
Definition cs_param.h:125
cs_param_advection_form_t
Definition cs_param.h:212
cs_param_bc_type_t
Definition cs_param.h:302
cs_param_bc_enforce_t
Definition cs_param.h:343
cs_param_time_scheme_t
Definition cs_param.h:183
cs_param_advection_scheme_t
Definition cs_param.h:255
cs_param_dof_reduction_t
Definition cs_param.h:151
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,...
Definition cs_param.h:66
cs_param_assemble_omp_strategy_t
Definition cs_param_cdo.h:90
static int input(void)
Definition cs_advection_field.h:149
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition cs_equation_param.h:148
cs_real_t strong_pena_bc_coeff
Definition cs_equation_param.h:220
cs_real_t upwind_portion
Definition cs_equation_param.h:312
cs_param_assemble_omp_strategy_t omp_assembly_choice
Definition cs_equation_param.h:400
int n_reaction_terms
Definition cs_equation_param.h:335
cs_real_t weak_pena_bc_coeff
Definition cs_equation_param.h:221
cs_param_bc_enforce_t default_enforcement
Definition cs_equation_param.h:219
cs_property_t * diffusion_property
Definition cs_equation_param.h:286
int verbosity
Definition cs_equation_param.h:157
cs_param_sles_t sles_param
Definition cs_equation_param.h:389
int space_poly_degree
Definition cs_equation_param.h:178
cs_param_advection_scheme_t adv_scheme
Definition cs_equation_param.h:311
cs_xdef_t ** ic_defs
Definition cs_equation_param.h:236
cs_param_time_scheme_t time_scheme
Definition cs_equation_param.h:270
cs_xdef_t ** source_terms
Definition cs_equation_param.h:353
cs_param_hodge_t reaction_hodge
Definition cs_equation_param.h:334
cs_lnum_t * enforced_dof_ids
Definition cs_equation_param.h:374
cs_adv_field_t * adv_field
Definition cs_equation_param.h:313
int n_ic_defs
Definition cs_equation_param.h:235
cs_real_t * enforced_dof_values
Definition cs_equation_param.h:375
cs_param_hodge_t time_hodge
Definition cs_equation_param.h:268
int dim
Definition cs_equation_param.h:156
bool do_lumping
Definition cs_equation_param.h:250
cs_flag_t flag
Definition cs_equation_param.h:163
cs_param_dof_reduction_t dof_reduction
Definition cs_equation_param.h:173
cs_equation_type_t type
Definition cs_equation_param.h:155
int n_source_terms
Definition cs_equation_param.h:352
cs_property_t ** reaction_properties
Definition cs_equation_param.h:336
cs_param_advection_form_t adv_formulation
Definition cs_equation_param.h:310
cs_xdef_t ** bc_defs
Definition cs_equation_param.h:217
cs_flag_t process_flag
Definition cs_equation_param.h:169
int n_bc_defs
Definition cs_equation_param.h:216
cs_property_t * time_property
Definition cs_equation_param.h:269
cs_param_hodge_t diffusion_hodge
Definition cs_equation_param.h:285
cs_param_bc_type_t default_bc
Definition cs_equation_param.h:215
char *restrict name
Definition cs_equation_param.h:154
cs_param_space_scheme_t space_scheme
Definition cs_equation_param.h:172
cs_real_t theta
Definition cs_equation_param.h:271
cs_lnum_t n_enforced_dofs
Definition cs_equation_param.h:373
Definition cs_param_cdo.h:128
Structure storing all metadata related to the resolution of a linear system with an iterative solver.
Definition cs_param.h:469
Definition cs_property.h:104
Structure storing medata for defining a quantity in a very flexible way.
Definition cs_xdef.h:126