8.0
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-2023 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 {
74 
75  const cs_real_t ohf = -cm->f_sgn[f]/cm->hfc[f];
76 
77  grd_c[0] = ohf * cm->face[f].unitv[0];
78  grd_c[1] = ohf * cm->face[f].unitv[1];
79  grd_c[2] = ohf * cm->face[f].unitv[2];
80 }
81 
82 /*----------------------------------------------------------------------------*/
91 /*----------------------------------------------------------------------------*/
92 
93 inline static void
95  cs_real_t *grd_c)
96 {
97  const cs_real_t ohf = -fm->f_sgn/fm->hfc;
98 
99  grd_c[0] = ohf * fm->face.unitv[0];
100  grd_c[1] = ohf * fm->face.unitv[1];
101  grd_c[2] = ohf * fm->face.unitv[2];
102 }
103 
104 /*----------------------------------------------------------------------------*/
112 /*----------------------------------------------------------------------------*/
113 
114 inline static void
115 cs_compute_wef(short int f,
116  const cs_cell_mesh_t *cm,
117  cs_real_t *wef)
118 {
120 
121  const short int *f2e_idx = cm->f2e_idx + f;
122  const double *tef_vals = cm->tef + f2e_idx[0];
123  const double inv_f = 1./cm->face[f].meas;
124 
125  /* Compute a weight for each edge of the current face */
126 
127  for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++)
128  wef[e] = tef_vals[e] * inv_f;
129 }
130 
131 /*----------------------------------------------------------------------------*/
140 /*----------------------------------------------------------------------------*/
141 
142 inline static void
143 cs_compute_pefc(short int f,
144  const cs_cell_mesh_t *cm,
145  cs_real_t *pefc)
146 {
147  assert(cs_eflag_test(cm->flag,
149 
150  const short int *f2e_idx = cm->f2e_idx + f;
151  const double *tef_vals = cm->tef + f2e_idx[0];
152  const double f_coef = cm->pvol_f[f]/cm->face[f].meas;
153 
154  /* Compute a weight for each edge of the current face */
155 
156  for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++)
157  pefc[e] = tef_vals[e] * f_coef;
158 }
159 
160 /*----------------------------------------------------------------------------*/
171 /*----------------------------------------------------------------------------*/
172 
173 inline static void
174 cs_compute_wvf(short int f,
175  const cs_cell_mesh_t *cm,
176  cs_real_t *wvf)
177 {
178  assert(cs_eflag_test(cm->flag,
180 
181  /* Reset weights */
182 
183  memset(wvf, 0, cm->n_vc*sizeof(cs_real_t));
184 
185  const short int *f2e_idx = cm->f2e_idx + f;
186  const short int *f2e_ids = cm->f2e_ids + f2e_idx[0];
187  const double *tef_vals = cm->tef + f2e_idx[0];
188  const double inv_f = 1./cm->face[f].meas;
189 
190  /* Compute a weight for each vertex of the current face */
191 
192  for (short int e = 0; e < f2e_idx[1] - f2e_idx[0]; e++) {
193 
194  const short int *v = cm->e2v_ids + 2*f2e_ids[e];
195  const double w = 0.5*tef_vals[e] * inv_f;
196  wvf[v[0]] += w;
197  wvf[v[1]] += w;
198 
199  }
200 }
201 
202 /*============================================================================
203  * Public function prototypes
204  *============================================================================*/
205 
206 /*----------------------------------------------------------------------------*/
219 /*----------------------------------------------------------------------------*/
220 
221 void
223  short int f,
224  const cs_nvec3_t ax,
225  const cs_nvec3_t ay,
226  const cs_real_t center[3],
227  cs_real_t cov[3]);
228 
229 /*----------------------------------------------------------------------------*/
239 /*----------------------------------------------------------------------------*/
240 
241 void
243  const cs_real_t center[3],
244  cs_real_t inertia[3][3]);
245 
246 /*----------------------------------------------------------------------------*/
260 /*----------------------------------------------------------------------------*/
261 
262 void
263 cs_compute_grd_ve(const short int v1,
264  const short int v2,
265  const cs_nvec3_t deq,
266  const cs_real_3_t uvc[],
267  const cs_real_t lvc[],
268  cs_real_t *grd_v1,
269  cs_real_t *grd_v2);
270 
271 /*----------------------------------------------------------------------------*/
284 /*----------------------------------------------------------------------------*/
285 
286 void
287 cs_compute_wef_wvf(short int f,
288  const cs_cell_mesh_t *cm,
289  cs_real_t *wvf,
290  cs_real_t *wef);
291 
292 /*----------------------------------------------------------------------------*/
293 
295 
296 #endif /* __CS_CDO_SCHEME_GEOMETRY_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:509
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:332
#define END_C_DECLS
Definition: cs_defs.h:510
@ fm
Definition: cs_field_pointer.h:128
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:366
@ CS_FLAG_COMP_FEQ
Definition: cs_flag.h:246
@ CS_FLAG_COMP_HFQ
Definition: cs_flag.h:264
@ CS_FLAG_COMP_PFQ
Definition: cs_flag.h:230
@ CS_FLAG_COMP_EV
Definition: cs_flag.h:238
@ CS_FLAG_COMP_PFC
Definition: cs_flag.h:273
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:351
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.c:455
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:143
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:174
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:503
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:69
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:279
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:115
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:94
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:203
short int * e2v_ids
Definition: cs_cdo_local.h:250
cs_real_t * pvol_f
Definition: cs_cdo_local.h:246
short int n_vc
Definition: cs_cdo_local.h:223
double * hfc
Definition: cs_cdo_local.h:243
short int * f2e_idx
Definition: cs_cdo_local.h:259
cs_eflag_t flag
Definition: cs_cdo_local.h:205
short int * f2e_ids
Definition: cs_cdo_local.h:260
double * tef
Definition: cs_cdo_local.h:262
short int * f_sgn
Definition: cs_cdo_local.h:241
cs_quant_t * face
Definition: cs_cdo_local.h:244
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:279
Definition: cs_defs.h:367
double meas
Definition: cs_cdo_quantities.h:131
double unitv[3]
Definition: cs_cdo_quantities.h:132