7.1
general documentation
cs_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-2021 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  * Inline static function prototypes
54  *============================================================================*/
55 
56 /*----------------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------------*/
67 
68 inline static void
69 cs_compute_grdfc_cw(short int f,
70  const cs_cell_mesh_t *cm,
71  cs_real_t *grd_c)
72 {
73  /* Sanity checks */
74  assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PFQ | CS_FLAG_COMP_HFQ));
75 
76  const cs_real_t ohf = -cm->f_sgn[f]/cm->hfc[f];
77 
78  grd_c[0] = ohf * cm->face[f].unitv[0];
79  grd_c[1] = ohf * cm->face[f].unitv[1];
80  grd_c[2] = ohf * cm->face[f].unitv[2];
81 }
82 
83 /*----------------------------------------------------------------------------*/
93 /*----------------------------------------------------------------------------*/
94 
95 inline static void
96 cs_compute_grdfc_fw(const cs_face_mesh_t *fm,
97  cs_real_t *grd_c)
98 {
99  const cs_real_t ohf = -fm->f_sgn/fm->hfc;
100 
101  grd_c[0] = ohf * fm->face.unitv[0];
102  grd_c[1] = ohf * fm->face.unitv[1];
103  grd_c[2] = ohf * fm->face.unitv[2];
104 }
105 
106 /*----------------------------------------------------------------------------*/
114 /*----------------------------------------------------------------------------*/
115 
116 inline static void
117 cs_compute_wef(short int f,
118  const cs_cell_mesh_t *cm,
119  cs_real_t *wef)
120 {
121  /* Sanity checks */
122  assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PFQ | CS_FLAG_COMP_FEQ));
123 
124  const short int *f2e_idx = cm->f2e_idx + f;
125  const double *tef_vals = cm->tef + f2e_idx[0];
126  const double inv_f = 1./cm->face[f].meas;
127 
128  /* Compute a weight for each edge of the current face */
129  for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++)
130  wef[e] = tef_vals[e] * inv_f;
131 }
132 
133 /*----------------------------------------------------------------------------*/
142 /*----------------------------------------------------------------------------*/
143 
144 inline static void
145 cs_compute_pefc(short int f,
146  const cs_cell_mesh_t *cm,
147  cs_real_t *pefc)
148 {
149  /* Sanity checks */
150  assert(cs_eflag_test(cm->flag,
152 
153  const short int *f2e_idx = cm->f2e_idx + f;
154  const double *tef_vals = cm->tef + f2e_idx[0];
155  const double f_coef = cm->pvol_f[f]/cm->face[f].meas;
156 
157  /* Compute a weight for each edge of the current face */
158  for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++)
159  pefc[e] = tef_vals[e] * f_coef;
160 }
161 
162 /*----------------------------------------------------------------------------*/
173 /*----------------------------------------------------------------------------*/
174 
175 inline static void
176 cs_compute_wvf(short int f,
177  const cs_cell_mesh_t *cm,
178  cs_real_t *wvf)
179 {
180  /* Sanity checks */
181  assert(cs_eflag_test(cm->flag,
183 
184  /* Reset weights */
185  memset(wvf, 0, cm->n_vc*sizeof(cs_real_t));
186 
187  const short int *f2e_idx = cm->f2e_idx + f;
188  const short int *f2e_ids = cm->f2e_ids + f2e_idx[0];
189  const double *tef_vals = cm->tef + f2e_idx[0];
190  const double inv_f = 1./cm->face[f].meas;
191 
192  /* Compute a weight for each vertex of the current face */
193  for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++) {
194 
195  const short int *v = cm->e2v_ids + 2*f2e_ids[e];
196  const double w = 0.5*tef_vals[e] * inv_f;
197  wvf[v[0]] += w;
198  wvf[v[1]] += w;
199 
200  }
201 }
202 
203 /*============================================================================
204  * Public function prototypes
205  *============================================================================*/
206 
207 /*----------------------------------------------------------------------------*/
220 /*----------------------------------------------------------------------------*/
221 
222 void
224  short int f,
225  const cs_nvec3_t ax,
226  const cs_nvec3_t ay,
227  const cs_real_t center[3],
228  cs_real_t cov[3]);
229 
230 /*----------------------------------------------------------------------------*/
240 /*----------------------------------------------------------------------------*/
241 
242 void
244  const cs_real_t center[3],
245  cs_real_t inertia[3][3]);
246 
247 /*----------------------------------------------------------------------------*/
261 /*----------------------------------------------------------------------------*/
262 
263 void
264 cs_compute_grd_ve(const short int v1,
265  const short int v2,
266  const cs_nvec3_t deq,
267  const cs_real_3_t uvc[],
268  const cs_real_t lvc[],
269  cs_real_t *grd_v1,
270  cs_real_t *grd_v2);
271 
272 /*----------------------------------------------------------------------------*/
285 /*----------------------------------------------------------------------------*/
286 
287 void
288 cs_compute_wef_wvf(short int f,
289  const cs_cell_mesh_t *cm,
290  cs_real_t *wvf,
291  cs_real_t *wef);
292 
293 /*----------------------------------------------------------------------------*/
294 
296 
297 #endif /* __CS_CDO_SCHEME_GEOMETRY_H__ */
double * tef
Definition: cs_cdo_local.h:254
Definition: cs_flag.h:205
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
double meas
Definition: cs_cdo_quantities.h:123
double * hfc
Definition: cs_cdo_local.h:237
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:202
Definition: cs_flag.h:238
Definition: cs_flag.h:211
short int * f2e_ids
Definition: cs_cdo_local.h:252
void cs_compute_wef_wvf(short int f, const cs_cell_mesh_t *cm, cs_real_t *wvf, cs_real_t *wef)
Compute for a face the weight related to each vertex w_{v,f} and the weight related to each edge w_{v...
Definition: cs_scheme_geometry.c:502
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
Definition: cs_defs.h:368
short int * f_sgn
Definition: cs_cdo_local.h:235
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
Definition: cs_field_pointer.h:128
void cs_compute_face_covariance_tensor(const cs_cell_mesh_t *cm, short int f, const cs_nvec3_t ax, const cs_nvec3_t ay, const cs_real_t center[3], cs_real_t cov[3])
Compute the inertial matrix of a cell with respect to the point called "center". This computation is ...
Definition: cs_scheme_geometry.c:278
cs_eflag_t flag
Definition: cs_cdo_local.h:204
short int f_sgn
Definition: cs_cdo_local.h:279
double hfc
Definition: cs_cdo_local.h:283
Definition: cs_flag.h:231
void cs_compute_inertia_tensor(const cs_cell_mesh_t *cm, const cs_real_t center[3], cs_real_t inertia[3][3])
Compute the inertial matrix of a cell with respect to the point called "center". This computation is ...
Definition: cs_scheme_geometry.c:350
cs_quant_t * face
Definition: cs_cdo_local.h:238
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:335
cs_quant_t face
Definition: cs_cdo_local.h:280
short int n_vc
Definition: cs_cdo_local.h:219
double unitv[3]
Definition: cs_cdo_quantities.h:124
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 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_scheme_geometry.c:454
#define END_C_DECLS
Definition: cs_defs.h:511
short int * e2v_ids
Definition: cs_cdo_local.h:243
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:270
short int * f2e_idx
Definition: cs_cdo_local.h:251
Definition: cs_flag.h:217
cs_real_t * pvol_f
Definition: cs_cdo_local.h:240