programmer's documentation
cs_cdo.h
Go to the documentation of this file.
1 #ifndef __CS_CDO_H__
2 #define __CS_CDO_H__
3 
4 /*============================================================================
5  * General functions or variables for the INNOV module
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 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 #include "cs_defs.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
45 /* Macros used for building a CDO system */
46 #define CDO_DIFFUSION 0
47 #define CDO_ADVECTION 1
48 #define CDO_REACTION 2
49 #define CDO_TIME 3
50 #define CDO_SOURCETERM 4
51 #define N_CDO_TERMS 5
52 
53 /* Flag related to CDO system building */
54 #define CS_CDO_BUILD_HCONF (1 << 0) // 1: build conforming Hodge op.
55 #define CS_CDO_BUILD_LOC_HCONF (1 << 1) // 2: build the local conf. Hodge
56 #define CS_CDO_PRIMAL_SOURCE (1 << 2) // 4: primal source term requested
57 #define CS_CDO_DUAL_SOURCE (1 << 3) // 8: dual source term requested
58 
59 /* Flags use to identify the nature/status of an object (variable, property) */
60 #define CS_FLAG_STATE_UNIFORM (1 << 0) // 1: uniform (in space)
61 #define CS_FLAG_STATE_CELLWISE (1 << 1) // 2: cellwise uniform
62 #define CS_FLAG_STATE_UNSTEADY (1 << 2) // 4: unsteady
63 #define CS_FLAG_STATE_POTENTIAL (1 << 3) // 8: potential
64 #define CS_FLAG_STATE_CIRCULATION (1 << 4) // 16: circulation
65 #define CS_FLAG_STATE_FLUX (1 << 5) // 32: flux
66 #define CS_FLAG_STATE_DENSITY (1 << 6) // 64: density
67 #define CS_FLAG_STATE_OWNER (1 << 7) // 128: owner
68 
69 /* Flags use to identify where is located a variable and how to access to
70  its values */
71 #define CS_FLAG_PRIMAL (1 << 0) // 1: on primal mesh
72 #define CS_FLAG_DUAL (1 << 1) // 2: on dual mesh
73 #define CS_FLAG_VERTEX (1 << 2) // 4: on vertices
74 #define CS_FLAG_EDGE (1 << 3) // 8: on edges
75 #define CS_FLAG_FACE (1 << 4) // 16: on faces
76 #define CS_FLAG_CELL (1 << 5) // 32: on cells
77 #define CS_FLAG_BORDER (1 << 6) // 64: located on the boundary
78 #define CS_FLAG_SCAL (1 << 7) // 128: scalar-valued (stride = 1)
79 #define CS_FLAG_VECT (1 << 8) // 256: vector-valued (stride = 3)
80 #define CS_FLAG_TENS (1 << 9) // 512: tensor-valued (stride = 9)
81 #define CS_FLAG_SCAN_BY_CELL (1 << 10) // 1024: by cell (c2e, c2f, c2v)
82 
83 /* Flags use to identify the type of numerical schemes requested for computing
84  the different equations attached to the computational domain. If flag is
85  activated, then at least one equation solved is discretized using thiq kind
86  of numerical scheme. */
87 #define CS_SCHEME_FLAG_CDOVB (1 << 0) // 1: CDO vertex-based scheme
88 #define CS_SCHEME_FLAG_CDOVCB (1 << 1) // 2: CDO vertex+cell-based scheme
89 #define CS_SCHEME_FLAG_CDOFB (1 << 2) // 4: CDO face-based scheme
90 #define CS_SCHEME_FLAG_HHO (1 << 3) // 8: Hybrid-High Order scheme
91 #define CS_SCHEME_FLAG_SCALAR (1 << 4) // 16: scheme for scalar eq.
92 #define CS_SCHEME_FLAG_VECTOR (1 << 5) // 32: scheme for a vector eq.
93 
94 /*============================================================================
95  * Type definitions
96  *============================================================================*/
97 
98 /* Type of numerical scheme for the discretization in space */
99 typedef enum {
100 
101  CS_SPACE_SCHEME_CDOVB, /* CDO scheme with vertex-based positionning */
102  CS_SPACE_SCHEME_CDOVCB, /* CDO scheme with vertex+cell-based positionning */
103  CS_SPACE_SCHEME_CDOFB, /* CDO cell-based scheme with hybridization */
104  CS_SPACE_SCHEME_HHO, /* Hybrid High Order scheme (CDO-FB + high-order) */
106 
108 
109 /* Description of an object (property, advection field, array..) using
110  mask of bits (i.e flag) */
111 
112 typedef struct {
113 
114  cs_flag_t location; /* where is defined this object */
115  cs_flag_t state; /* nature and additional information on this object */
116 
117 } cs_desc_t;
118 
119 /* Vector-valued quantity stored using its measure (i.e. length) and
120  its direction given by a unitary vector */
121 typedef struct {
122 
123  double meas;
124  double unitv[3];
125 
126 } cs_nvec3_t;
127 
128 /* Values associated to the different ways to retrieve data */
129 typedef union {
130 
131  cs_flag_t flag; // flag
132  int id; // identification number
133  cs_lnum_t num; // local number
134  cs_real_t val; // value
135  cs_real_2_t couple; // two values
136  cs_real_3_t vect; // vector: 3 values
137  cs_nvec3_t nvec3; // meas + unit vector
138  cs_real_6_t twovects; // two vectors
139  cs_real_33_t tens; // tensor: 9 values
140 
141 } cs_get_t;
142 
143 /*----------------------------------------------------------------------------*/
151 /*----------------------------------------------------------------------------*/
152 
153 typedef void
155  const cs_real_3_t xyz,
156  cs_get_t *retval);
157 
158 /*----------------------------------------------------------------------------*/
168 /*----------------------------------------------------------------------------*/
169 
170 typedef cs_real_t
171 (cs_timestep_func_t) (int time_iter,
172  double time);
173 
174 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 typedef void
188 (cs_onevar_law_func_t) (double var_value,
189  const void *law_param,
190  cs_get_t *retval);
191 
192 /*----------------------------------------------------------------------------*/
204 /*----------------------------------------------------------------------------*/
205 
206 typedef void
207 (cs_twovar_law_func_t) (double var1_value,
208  double var2_value,
209  const void *law_param,
210  cs_get_t *retval);
211 
212 /*----------------------------------------------------------------------------*/
225 /*----------------------------------------------------------------------------*/
226 
227 typedef void
228 (cs_scavec_law_func_t) (double var1_value,
229  const double var2_vect[],
230  const void *law_param,
231  cs_get_t *retval);
232 
233 /*============================================================================
234  * Global variables
235  *============================================================================*/
236 
237 /* Separation lines: long, medium, short */
238 extern const char lsepline[];
239 extern const char msepline[];
240 extern const char ssepline[];
241 
242 /* Default locations */
243 extern const cs_flag_t cs_cdo_primal_vtx;
244 extern const cs_flag_t cs_cdo_primal_face;
245 extern const cs_flag_t cs_cdo_primal_cell;
246 extern const cs_flag_t cs_cdo_dual_vtx;
247 extern const cs_flag_t cs_cdo_dual_face;
248 extern const cs_flag_t cs_cdo_dual_cell;
249 extern const cs_flag_t cs_cdo_dual_face_byc;
250 
251 /*============================================================================
252  * Static inline function prototypes
253  *============================================================================*/
254 
255 /*----------------------------------------------------------------------------*/
264 /*----------------------------------------------------------------------------*/
265 
266 static inline bool
268  cs_flag_t reference)
269 {
270  if ((location & reference) == reference)
271  return true;
272  else
273  return false;
274 }
275 
276 /*============================================================================
277  * Public function prototypes
278  *============================================================================*/
279 
280 /*----------------------------------------------------------------------------*/
288 /*----------------------------------------------------------------------------*/
289 
290 const char *
291 cs_base_strtf(bool boolean);
292 
293 /*----------------------------------------------------------------------------*/
300 /*----------------------------------------------------------------------------*/
301 
302 void
303 cs_nvec3(const cs_real_3_t v,
304  cs_nvec3_t *qv);
305 
306 /*----------------------------------------------------------------------------*/
307 
309 
310 #endif /* __CS_CDO_H__ */
const char ssepline[]
Definition: cs_cdo.c:68
cs_nvec3_t nvec3
Definition: cs_cdo.h:137
const cs_flag_t cs_cdo_dual_face_byc
Definition: cs_cdo.c:78
cs_real_t cs_real_2_t[2]
vector of 2 floating-point values
Definition: cs_defs.h:307
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:310
void( cs_scavec_law_func_t)(double var1_value, const double var2_vect[], const void *law_param, cs_get_t *retval)
Compute the value of a quantity according to a law depending only on two variables (the first one is ...
Definition: cs_cdo.h:228
Definition: cs_cdo.h:112
Definition: cs_cdo.h:105
void( cs_twovar_law_func_t)(double var1_value, double var2_value, const void *law_param, cs_get_t *retval)
Compute the value of a quantity according to a law depending only on two variables. This law is described by a set of parameters stored in a structure. result = law(var1_value, var2_value)
Definition: cs_cdo.h:207
cs_real_33_t tens
Definition: cs_cdo.h:139
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
const cs_flag_t cs_cdo_primal_face
Definition: cs_cdo.c:73
int id
Definition: cs_cdo.h:132
Definition: cs_cdo.h:129
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
Definition: cs_cdo.h:121
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
cs_space_scheme_t
Definition: cs_cdo.h:99
cs_flag_t location
Definition: cs_cdo.h:114
cs_real_2_t couple
Definition: cs_cdo.h:135
const char * cs_base_strtf(bool boolean)
Return a string "true" or "false" according to the boolean.
Definition: cs_cdo.c:104
void( cs_onevar_law_func_t)(double var_value, const void *law_param, cs_get_t *retval)
Compute the value of a quantity according to a law depending only on one variable. This law is described by a set of parameters stored in a structure. result = law(var_value)
Definition: cs_cdo.h:188
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
cs_real_t( cs_timestep_func_t)(int time_iter, double time)
Simple function to define the time step according to the number of iteration already done...
Definition: cs_cdo.h:171
Definition: cs_cdo.h:102
double meas
Definition: cs_cdo.h:123
Definition: cs_cdo.h:104
cs_real_t val
Definition: cs_cdo.h:134
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:308
cs_real_6_t twovects
Definition: cs_cdo.h:138
void cs_nvec3(const cs_real_3_t v, cs_nvec3_t *qv)
Define a cs_nvec3_t structure from a cs_real_3_t.
Definition: cs_cdo.c:122
const cs_flag_t cs_cdo_primal_cell
Definition: cs_cdo.c:74
cs_flag_t state
Definition: cs_cdo.h:115
const cs_flag_t cs_cdo_dual_cell
Definition: cs_cdo.c:77
cs_lnum_t num
Definition: cs_cdo.h:133
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
const char lsepline[]
Definition: cs_cdo.c:64
static bool cs_cdo_same_support(cs_flag_t location, cs_flag_t reference)
Check if a location matches a referenced support.
Definition: cs_cdo.h:267
const cs_flag_t cs_cdo_primal_vtx
Definition: cs_cdo.c:72
#define END_C_DECLS
Definition: cs_defs.h:449
const cs_flag_t cs_cdo_dual_face
Definition: cs_cdo.c:76
unsigned short int cs_flag_t
Definition: cs_defs.h:298
const char msepline[]
Definition: cs_cdo.c:66
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:314
Definition: cs_cdo.h:103
cs_flag_t flag
Definition: cs_cdo.h:131
Definition: cs_cdo.h:101
cs_real_3_t vect
Definition: cs_cdo.h:136
const cs_flag_t cs_cdo_dual_vtx
Definition: cs_cdo.c:75