programmer's documentation
cs_cdo_scheme_geometry.h
Go to the documentation of this file.
1 #ifndef __CS_CDO_SCHEME_GEOMETRY_H__
2 #define __CS_CDO_SCHEME_GEOMETRY_H__
3 
4 /*============================================================================
5  * Geometric computations for building discretization operators which is
6  * shared by several files
7  *============================================================================*/
8 
9 /*
10  This file is part of Code_Saturne, a general-purpose CFD tool.
11 
12  Copyright (C) 1998-2016 EDF S.A.
13 
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22  details.
23 
24  You should have received a copy of the GNU General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26  Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28 
29 /*----------------------------------------------------------------------------
30  * Standard C library headers
31  *----------------------------------------------------------------------------*/
32 
33 /*----------------------------------------------------------------------------
34  * Local headers
35  *----------------------------------------------------------------------------*/
36 
37 #include "cs_cdo_local.h"
38 #include "cs_math.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Public function prototypes
54  *============================================================================*/
55 
56 /*----------------------------------------------------------------------------*/
64 /*----------------------------------------------------------------------------*/
65 
66 inline static void
68  cs_real_t *grd_c)
69 {
70  const cs_quant_t pfq = fm->face;
71  const cs_nvec3_t deq = fm->dedge;
72  const double hf = cs_math_3_dot_product(pfq.unitv, deq.unitv) * deq.meas;
73  const cs_real_t ohf = -fm->f_sgn/hf;
74 
75  for (int k = 0; k < 3; k++)
76  grd_c[k] = ohf * pfq.unitv[k];
77 }
78 
79 /*----------------------------------------------------------------------------*/
88 /*----------------------------------------------------------------------------*/
89 
90 inline static double
91 cs_compute_tef(short int e,
92  const cs_face_mesh_t *fm)
93 {
94  double xef_len;
95  cs_real_3_t xef_un, un;
96 
97  const cs_quant_t pfq = fm->face;
98  const cs_quant_t peq = fm->edge[e];
99 
100  cs_math_3_length_unitv(peq.center, pfq.center, &xef_len, xef_un);
101  cs_math_3_cross_product(xef_un, peq.unitv, un);
102 
103  /* tef = ||(xe -xf) x e||/2 = s(v1,e,f) + s(v2, e, f) */
104  return 0.5 * xef_len * peq.meas * cs_math_3_norm(un);
105 
106 }
107 
108 /*----------------------------------------------------------------------------*/
117 /*----------------------------------------------------------------------------*/
118 
119 inline static double
120 cs_compute_tec(short int e,
121  const cs_cell_mesh_t *cm)
122 {
123  double xec_len;
124  cs_real_3_t xec_un, un;
125 
126  const cs_quant_t peq = cm->edge[e];
127 
128  cs_math_3_length_unitv(peq.center, cm->xc, &xec_len, xec_un);
129  cs_math_3_cross_product(xec_un, peq.unitv, un);
130 
131  /* tec = ||(xe -xc) x e||/2 */
132  return 0.5 * xec_len * peq.meas * cs_math_3_norm(un);
133 }
134 
135 /*----------------------------------------------------------------------------*/
149 /*----------------------------------------------------------------------------*/
150 
151 void
152 cs_compute_grd_ve(const short int v1,
153  const short int v2,
154  const cs_nvec3_t deq,
155  const cs_real_3_t uvc[],
156  const cs_real_t lvc[],
157  cs_real_t *grd_v1,
158  cs_real_t *grd_v2);
159 
160 /*----------------------------------------------------------------------------*/
171 /*----------------------------------------------------------------------------*/
172 
173 void
174 cs_compute_tef_grdc(short int f,
175  const cs_cell_mesh_t *cm,
176  cs_real_t *tef,
177  cs_real_t *grd_c);
178 
179 /*----------------------------------------------------------------------------*/
192 /*----------------------------------------------------------------------------*/
193 
194 void
195 cs_compute_fwbs_q0(short int f,
196  const cs_cell_mesh_t *cm,
197  cs_real_t *wvf,
198  cs_real_t *pefc_vol);
199 
200 /*----------------------------------------------------------------------------*/
215 /*----------------------------------------------------------------------------*/
216 
217 double
218 cs_compute_fwbs_q1(short int f,
219  const cs_cell_mesh_t *cm,
220  cs_real_t *wvf,
221  cs_real_t *pefc_vol);
222 
223 /*----------------------------------------------------------------------------*/
237 /*----------------------------------------------------------------------------*/
238 
239 void
240 cs_compute_fwbs_q2(short int f,
241  const cs_cell_mesh_t *cm,
242  cs_real_3_t grd_c,
243  cs_real_t *wvf,
244  cs_real_t *pefc_vol);
245 
246 /*----------------------------------------------------------------------------*/
262 /*----------------------------------------------------------------------------*/
263 
264 double
265 cs_compute_fwbs_q3(short int f,
266  const cs_cell_mesh_t *cm,
267  cs_real_3_t grd_c,
268  cs_real_t *wvf,
269  cs_real_t *pefc_vol);
270 
271 /*----------------------------------------------------------------------------*/
272 
274 
275 #endif /* __CS_CDO_SCHEME_GEOMETRY_H__ */
Definition: cs_field_pointer.h:69
static cs_real_t cs_math_3_dot_product(const cs_real_t u[3], const cs_real_t v[3])
Compute the dot product of two vectors of 3 real values.
Definition: cs_math.h:151
double center[3]
Definition: cs_cdo_quantities.h:83
void cs_compute_grd_ve(const short int v1, const short int v2, const cs_nvec3_t deq, const cs_real_3_t uvc[], const cs_real_t lvc[], cs_real_t *grd_v1, cs_real_t *grd_v2)
Compute the gradient of a Lagrange hat function related to primal vertices in a p_{ef,c} subvolume of a cell c where e is an edge belonging to the face f with vertices v1 and v2.
Definition: cs_cdo_scheme_geometry.c:137
double cs_compute_fwbs_q3(short int f, const cs_cell_mesh_t *cm, cs_real_3_t grd_c, cs_real_t *wvf, cs_real_t *pefc_vol)
Compute for a face the weight related to each vertex w_{v,f} This weight is equal to |dc(v) cap f|/|f...
Definition: cs_cdo_scheme_geometry.c:343
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
static void cs_compute_grdc(const cs_face_mesh_t *fm, cs_real_t *grd_c)
Compute the value of the constant gradient of the Lagrange function attached to xc in p_{f...
Definition: cs_cdo_scheme_geometry.h:67
double meas
Definition: cs_cdo_quantities.h:81
Definition: cs_cdo_local.h:73
void cs_math_3_length_unitv(const cs_real_t xa[3], const cs_real_t xb[3], cs_real_t *len, cs_real_3_t unitv)
Compute the length (euclidien norm) between two points xa and xb in a cartesian coordinate system of ...
Definition: cs_math.c:275
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
cs_nvec3_t dedge
Definition: cs_cdo_local.h:136
Definition: cs_cdo.h:121
double cs_compute_fwbs_q1(short int f, const cs_cell_mesh_t *cm, cs_real_t *wvf, cs_real_t *pefc_vol)
Compute for a face the weight related to each vertex w_{v,f} This weight is equal to |dc(v) cap f|/|f...
Definition: cs_cdo_scheme_geometry.c:268
Definition: cs_field_pointer.h:118
short int f_sgn
Definition: cs_cdo_local.h:134
static double cs_compute_tec(short int e, const cs_cell_mesh_t *cm)
Compute tec (the area of the triangle of base e and apex c)
Definition: cs_cdo_scheme_geometry.h:120
double meas
Definition: cs_cdo.h:123
cs_quant_t * edge
Definition: cs_cdo_local.h:147
static cs_real_t cs_math_3_norm(const cs_real_t v[3])
Compute the euclidean norm of a vector of dimension 3.
Definition: cs_math.h:170
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:308
static void cs_math_3_cross_product(const cs_real_t u[3], const cs_real_t v[3], cs_real_t uv[restrict 3])
Compute the cross product of two vectors of 3 real values.
Definition: cs_math.h:292
cs_quant_t face
Definition: cs_cdo_local.h:135
double unitv[3]
Definition: cs_cdo.h:124
Definition: cs_cdo_quantities.h:79
double unitv[3]
Definition: cs_cdo_quantities.h:82
void cs_compute_fwbs_q2(short int f, const cs_cell_mesh_t *cm, cs_real_3_t grd_c, cs_real_t *wvf, cs_real_t *pefc_vol)
Compute for a face the weight related to each vertex w_{v,f} This weight is equal to |dc(v) cap f|/|f...
Definition: cs_cdo_scheme_geometry.c:301
#define END_C_DECLS
Definition: cs_defs.h:449
void cs_compute_fwbs_q0(short int f, const cs_cell_mesh_t *cm, cs_real_t *wvf, cs_real_t *pefc_vol)
Compute for a face the weight related to each vertex w_{v,f} This weight is equal to |dc(v) cap f|/|f...
Definition: cs_cdo_scheme_geometry.c:234
void cs_compute_tef_grdc(short int f, const cs_cell_mesh_t *cm, cs_real_t *tef, cs_real_t *grd_c)
Compute tef (the are of the triangle of base e and apex f Compute also the value of the constant grad...
Definition: cs_cdo_scheme_geometry.c:185
static double cs_compute_tef(short int e, const cs_face_mesh_t *fm)
Compute tef (the area of the triangle of base e and apex f)
Definition: cs_cdo_scheme_geometry.h:91
Definition: cs_cdo_local.h:125
cs_real_t * xc
Definition: cs_cdo_local.h:81
cs_quant_t * edge
Definition: cs_cdo_local.h:95