9.2
general documentation
cs_reco_cw.h
Go to the documentation of this file.
1#ifndef CS_RECO_CW_H
2#define CS_RECO_CW_H
3
4/*============================================================================
5 * Functions to handle the cell-wise reconstruction of fields relying on the
6 * cell mesh structure
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
31/*----------------------------------------------------------------------------
32 * Local headers
33 *----------------------------------------------------------------------------*/
34
35#include "cdo/cs_cdo_local.h"
36
37/*============================================================================
38 * Macro definitions
39 *============================================================================*/
40
41/*============================================================================
42 * Type definitions
43 *============================================================================*/
44
45/*============================================================================
46 * Public function prototypes
47 *============================================================================*/
48
49/*----------------------------------------------------------------------------*/
59/*----------------------------------------------------------------------------*/
60
61void
62cs_reco_cw_stride_v2c(int stride,
63 const cs_cell_mesh_t *cm,
64 const cs_real_t *array,
65 cs_real_t *reco);
66
67/*----------------------------------------------------------------------------*/
80/*----------------------------------------------------------------------------*/
81
82void
84 const cs_cell_mesh_t *cm,
85 const cs_real_t *array,
86 cs_real_t *reco);
87
88/*============================================================================
89 * Inline public function prototypes
90 *============================================================================*/
91
92/*----------------------------------------------------------------------------*/
102/*----------------------------------------------------------------------------*/
103
104static inline cs_real_t
106 const cs_real_t *p_v)
107{
108 cs_real_t p_f = 0.;
109
110 if (p_v == NULL)
111 return p_f;
112
113 const cs_quant_t pfq = fm->face;
114
115 for (short int e = 0; e < fm->n_ef; e++)
116 p_f += (p_v[fm->e2v_ids[2*e]] + p_v[fm->e2v_ids[2*e+1]]) * fm->tef[e];
117 p_f *= 0.5 / pfq.meas;
118
119 return p_f;
120}
121
122/*----------------------------------------------------------------------------*/
133/*----------------------------------------------------------------------------*/
134
135static inline cs_real_t
137 const cs_cell_mesh_t *cm,
138 const cs_real_t *p_v)
139{
140 cs_real_t p_f = 0.;
141
142 if (p_v == NULL)
143 return p_f;
144
145 assert(cs_eflag_test(cm->flag,
148
149 for (int ie = cm->f2e_idx[f]; ie < cm->f2e_idx[f+1]; ie++) {
150 const short int *v = cm->e2v_ids + 2*cm->f2e_ids[ie];
151 p_f += (p_v[v[0]] + p_v[v[1]]) * cm->tef[ie];
152 }
153 p_f *= 0.5 / cm->face[f].meas;
154
155 return p_f;
156}
157
158/*----------------------------------------------------------------------------*/
169/*----------------------------------------------------------------------------*/
170
171static inline cs_real_t
173 const cs_real_t *p_v)
174{
175 cs_real_t p_c = 0.;
176
177 if (p_v == NULL || cm == NULL)
178 return p_c;
179
180 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PVQ)); /* Sanity check */
181
182 /* Reconstruct the value at the cell center */
183
184 for (short int v = 0; v < cm->n_vc; v++)
185 p_c += cm->wvc[v] * p_v[v];
186
187 return p_c;
188}
189
190/*----------------------------------------------------------------------------*/
200/*----------------------------------------------------------------------------*/
201
202static inline cs_real_t
204 const cs_real_t *array)
205{
206 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PVQ));
207
208 cs_real_t val_c = 0;
209
210 if (array == NULL)
211 return val_c;
212
213 for (short int v = 0; v < cm->n_vc; v++)
214 val_c += cm->wvc[v] * array[cm->v_ids[v]];
215
216 return val_c;
217}
218
219/*----------------------------------------------------------------------------*/
231/*----------------------------------------------------------------------------*/
232
233static inline cs_real_t
235 const cs_real_t *array)
236{
237 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PVQ));
238
239 cs_real_t val_c = 0;
240
241 if (array == NULL)
242 return val_c;
243
244 for (short int v = 0; v < cm->n_vc; v++)
245 val_c += cm->wvc[v] * array[v];
246
247 return val_c;
248}
249
250/*----------------------------------------------------------------------------*/
262/*----------------------------------------------------------------------------*/
263
264static inline cs_real_t
266 const cs_real_t *array)
267{
268 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PEC));
269
270 cs_real_t val_c = 0;
271
272 if (array == NULL)
273 return val_c;
274
275 for (short int e = 0; e < cm->n_ec; e++)
276 val_c += cm->pvol_e[e] * array[e];
277 val_c /= cm->vol_c;
278
279 return val_c;
280}
281
282#endif /* CS_RECO_CW_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
@ 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_PVQ
Definition: cs_flag.h:213
@ CS_FLAG_COMP_FEQ
Definition: cs_flag.h:249
@ CS_FLAG_COMP_PEC
Definition: cs_flag.h:280
@ CS_FLAG_COMP_PFQ
Definition: cs_flag.h:233
@ CS_FLAG_COMP_EV
Definition: cs_flag.h:241
@ CS_FLAG_COMP_FE
Definition: cs_flag.h:245
static cs_real_t cs_reco_cw_scalar_ebyc2c(const cs_cell_mesh_t *cm, const cs_real_t *array)
Reconstruct a scalar value at the cell center. array is scanned thanks to the c2e connectivity....
Definition: cs_reco_cw.h:265
static cs_real_t cs_reco_cw_scalar_v2c(const cs_cell_mesh_t *cm, const cs_real_t *array)
Reconstruct a scalar value at the cell center from an array of values located at vertices (for the fu...
Definition: cs_reco_cw.h:203
static cs_real_t cs_reco_cw_scalar_v2f_loc(const short int f, const cs_cell_mesh_t *cm, const cs_real_t *p_v)
Reconstruct the value at the face center from an array of values defined on primal vertices.
Definition: cs_reco_cw.h:136
static cs_real_t cs_reco_cw_scalar_v2f_fw(const cs_face_mesh_t *fm, const cs_real_t *p_v)
Reconstruct the value at the face center from an array of values defined on primal vertices attached ...
Definition: cs_reco_cw.h:105
void cs_reco_cw_stride_v2c(int stride, const cs_cell_mesh_t *cm, const cs_real_t *array, cs_real_t *reco)
Reconstruct a scalar value at the cell center. array is assumed to be interlaced and of size stride*n...
Definition: cs_reco_cw.cpp:74
static cs_real_t cs_reco_cw_scalar_vbyc2c(const cs_cell_mesh_t *cm, const cs_real_t *array)
Reconstruct a scalar value at the cell center. array is scanned thanks to the c2v connectivity....
Definition: cs_reco_cw.h:234
void cs_reco_cw_stride_vbyc2c(int stride, const cs_cell_mesh_t *cm, const cs_real_t *array, cs_real_t *reco)
Reconstruct a scalar value at the cell center. array is scanned thanks to the c2v connectivity....
Definition: cs_reco_cw.cpp:115
static cs_real_t cs_reco_cw_scalar_v2c_loc(const cs_cell_mesh_t *cm, const cs_real_t *p_v)
Reconstruct the value of a scalar potential at the cell center from an array of values defined on pri...
Definition: cs_reco_cw.h:172
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
short int n_vc
Definition: cs_cdo_local.h:262
double * wvc
Definition: cs_cdo_local.h:265
short int n_ec
Definition: cs_cdo_local.h:269
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
double vol_c
Definition: cs_cdo_local.h:257
cs_lnum_t * v_ids
Definition: cs_cdo_local.h:263
cs_real_t * pvol_e
Definition: cs_cdo_local.h:273
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_cdo_quantities.h:134
double meas
Definition: cs_cdo_quantities.h:136