9.2
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-2026 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#include <cstring>
34
35/*----------------------------------------------------------------------------
36 * Local headers
37 *----------------------------------------------------------------------------*/
38
39#include "base/cs_math.h"
40#include "cdo/cs_cdo_local.h"
41
42/*============================================================================
43 * Macro definitions
44 *============================================================================*/
45
46/*============================================================================
47 * Type definitions
48 *============================================================================*/
49
50/*=============================================================================
51 * Inline static function prototypes
52 *============================================================================*/
53
54/*----------------------------------------------------------------------------*/
64/*----------------------------------------------------------------------------*/
65
66inline static void
68 const cs_cell_mesh_t *cm,
69 cs_real_t *grd_c)
70{
72
73 const cs_real_t ohf = -cm->f_sgn[f]/cm->hfc[f];
74
75 grd_c[0] = ohf * cm->face[f].unitv[0];
76 grd_c[1] = ohf * cm->face[f].unitv[1];
77 grd_c[2] = ohf * cm->face[f].unitv[2];
78}
79
80/*----------------------------------------------------------------------------*/
89/*----------------------------------------------------------------------------*/
90
91inline static void
93 cs_real_t *grd_c)
94{
95 const cs_real_t ohf = -fm->f_sgn/fm->hfc;
96
97 grd_c[0] = ohf * fm->face.unitv[0];
98 grd_c[1] = ohf * fm->face.unitv[1];
99 grd_c[2] = ohf * fm->face.unitv[2];
100}
101
102/*----------------------------------------------------------------------------*/
110/*----------------------------------------------------------------------------*/
111
112inline static void
113cs_compute_wef(short int f,
114 const cs_cell_mesh_t *cm,
115 cs_real_t *wef)
116{
118
119 const short int *f2e_idx = cm->f2e_idx + f;
120 const double *tef_vals = cm->tef + f2e_idx[0];
121 const double inv_f = 1./cm->face[f].meas;
122
123 /* Compute a weight for each edge of the current face */
124
125 for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++)
126 wef[e] = tef_vals[e] * inv_f;
127}
128
129/*----------------------------------------------------------------------------*/
138/*----------------------------------------------------------------------------*/
139
140inline static void
141cs_compute_pefc(short int f,
142 const cs_cell_mesh_t *cm,
143 cs_real_t *pefc)
144{
145 assert(cs_eflag_test(cm->flag,
147
148 const short int *f2e_idx = cm->f2e_idx + f;
149 const double *tef_vals = cm->tef + f2e_idx[0];
150 const double f_coef = cm->pvol_f[f]/cm->face[f].meas;
151
152 /* Compute a weight for each edge of the current face */
153
154 for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++)
155 pefc[e] = tef_vals[e] * f_coef;
156}
157
158/*----------------------------------------------------------------------------*/
169/*----------------------------------------------------------------------------*/
170
171inline static void
172cs_compute_wvf(short int f,
173 const cs_cell_mesh_t *cm,
174 cs_real_t *wvf)
175{
176 assert(cs_eflag_test(cm->flag,
178
179 /* Reset weights */
180
181 std::memset(wvf, 0, cm->n_vc * sizeof(cs_real_t));
182
183 const short int *f2e_idx = cm->f2e_idx + f;
184 const short int *f2e_ids = cm->f2e_ids + f2e_idx[0];
185 const double *tef_vals = cm->tef + f2e_idx[0];
186 const double inv_f = 1./cm->face[f].meas;
187
188 /* Compute a weight for each vertex of the current face */
189
190 for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++) {
191
192 const short int *v = cm->e2v_ids + 2*f2e_ids[e];
193 const double w = 0.5*tef_vals[e] * inv_f;
194 wvf[v[0]] += w;
195 wvf[v[1]] += w;
196
197 }
198}
199
200/*============================================================================
201 * Public function prototypes
202 *============================================================================*/
203
204/*----------------------------------------------------------------------------*/
217/*----------------------------------------------------------------------------*/
218
219void
221 short int f,
222 const cs_nvec3_t ax,
223 const cs_nvec3_t ay,
224 const cs_real_t center[3],
225 cs_real_t cov[3]);
226
227/*----------------------------------------------------------------------------*/
237/*----------------------------------------------------------------------------*/
238
239void
241 const cs_real_t center[3],
242 cs_real_t inertia[3][3]);
243
244/*----------------------------------------------------------------------------*/
258/*----------------------------------------------------------------------------*/
259
260void
261cs_compute_grd_ve(const short int v1,
262 const short int v2,
263 const cs_nvec3_t deq,
264 const cs_real_3_t uvc[],
265 const cs_real_t lvc[],
266 cs_real_t *grd_v1,
267 cs_real_t *grd_v2);
268
269/*----------------------------------------------------------------------------*/
282/*----------------------------------------------------------------------------*/
283
284void
285cs_compute_wef_wvf(short int f,
286 const cs_cell_mesh_t *cm,
287 cs_real_t *wvf,
288 cs_real_t *wef);
289
290#endif /* CS_CDO_SCHEME_GEOMETRY_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
@ fm
Definition: cs_field_pointer.h:126
static bool cs_eflag_test(cs_eflag_t flag_to_check, cs_eflag_t reference)
Check if a two compute flag share the same pattern Return true if the computed flag to check has at l...
Definition: cs_flag.h:381
@ CS_FLAG_COMP_FEQ
Definition: cs_flag.h:249
@ CS_FLAG_COMP_HFQ
Definition: cs_flag.h:267
@ CS_FLAG_COMP_PFQ
Definition: cs_flag.h:233
@ CS_FLAG_COMP_EV
Definition: cs_flag.h:241
@ CS_FLAG_COMP_PFC
Definition: cs_flag.h:276
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.cpp:303
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,...
Definition: cs_scheme_geometry.cpp:409
static void cs_compute_pefc(short int f, const cs_cell_mesh_t *cm, cs_real_t *pefc)
Compute the volume related to each tetrahedron of base tef and apex x_c (there are as many tetrahedra...
Definition: cs_scheme_geometry.h:141
static void cs_compute_wvf(short int f, const cs_cell_mesh_t *cm, cs_real_t *wvf)
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_scheme_geometry.h:172
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.cpp:457
static void cs_compute_grdfc_cw(short int f, const cs_cell_mesh_t *cm, cs_real_t *grd_c)
Compute the value of the constant gradient of the Lagrange function attached to xc in p_{f,...
Definition: cs_scheme_geometry.h:67
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.cpp:231
static void cs_compute_wef(short int f, const cs_cell_mesh_t *cm, cs_real_t *wef)
Compute the weight wef = |tef|/|f|.
Definition: cs_scheme_geometry.h:113
static void cs_compute_grdfc_fw(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_scheme_geometry.h:92
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:242
short int * e2v_ids
Definition: cs_cdo_local.h:290
cs_real_t * pvol_f
Definition: cs_cdo_local.h:286
short int n_vc
Definition: cs_cdo_local.h:262
double * hfc
Definition: cs_cdo_local.h:283
short int * f2e_idx
Definition: cs_cdo_local.h:299
cs_eflag_t flag
Definition: cs_cdo_local.h:244
short int * f2e_ids
Definition: cs_cdo_local.h:300
double * tef
Definition: cs_cdo_local.h:302
short int * f_sgn
Definition: cs_cdo_local.h:280
cs_quant_t * face
Definition: cs_cdo_local.h:284
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:432
Definition: cs_defs.h:390
double meas
Definition: cs_cdo_quantities.h:136
double unitv[3]
Definition: cs_cdo_quantities.h:137