8.3
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-2024 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 "cs_cdo_local.h"
36
37/*----------------------------------------------------------------------------*/
38
40
41/*============================================================================
42 * Macro definitions
43 *============================================================================*/
44
45/*============================================================================
46 * Type definitions
47 *============================================================================*/
48
49/*============================================================================
50 * Public function prototypes
51 *============================================================================*/
52
53/*----------------------------------------------------------------------------*/
63/*----------------------------------------------------------------------------*/
64
65void
66cs_reco_cw_stride_v2c(int stride,
67 const cs_cell_mesh_t *cm,
68 const cs_real_t *array,
69 cs_real_t *reco);
70
71/*----------------------------------------------------------------------------*/
84/*----------------------------------------------------------------------------*/
85
86void
88 const cs_cell_mesh_t *cm,
89 const cs_real_t *array,
90 cs_real_t *reco);
91
92/*============================================================================
93 * Inline public function prototypes
94 *============================================================================*/
95
96/*----------------------------------------------------------------------------*/
106/*----------------------------------------------------------------------------*/
107
108static inline cs_real_t
110 const cs_real_t *p_v)
111{
112 cs_real_t p_f = 0.;
113
114 if (p_v == NULL)
115 return p_f;
116
117 const cs_quant_t pfq = fm->face;
118
119 for (short int e = 0; e < fm->n_ef; e++)
120 p_f += (p_v[fm->e2v_ids[2*e]] + p_v[fm->e2v_ids[2*e+1]]) * fm->tef[e];
121 p_f *= 0.5 / pfq.meas;
122
123 return p_f;
124}
125
126/*----------------------------------------------------------------------------*/
137/*----------------------------------------------------------------------------*/
138
139static inline cs_real_t
141 const cs_cell_mesh_t *cm,
142 const cs_real_t *p_v)
143{
144 cs_real_t p_f = 0.;
145
146 if (p_v == NULL)
147 return p_f;
148
149 assert(cs_eflag_test(cm->flag,
152
153 for (int ie = cm->f2e_idx[f]; ie < cm->f2e_idx[f+1]; ie++) {
154 const short int *v = cm->e2v_ids + 2*cm->f2e_ids[ie];
155 p_f += (p_v[v[0]] + p_v[v[1]]) * cm->tef[ie];
156 }
157 p_f *= 0.5 / cm->face[f].meas;
158
159 return p_f;
160}
161
162/*----------------------------------------------------------------------------*/
173/*----------------------------------------------------------------------------*/
174
175static inline cs_real_t
177 const cs_real_t *p_v)
178{
179 cs_real_t p_c = 0.;
180
181 if (p_v == NULL || cm == NULL)
182 return p_c;
183
184 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PVQ)); /* Sanity check */
185
186 /* Reconstruct the value at the cell center */
187
188 for (short int v = 0; v < cm->n_vc; v++)
189 p_c += cm->wvc[v] * p_v[v];
190
191 return p_c;
192}
193
194/*----------------------------------------------------------------------------*/
204/*----------------------------------------------------------------------------*/
205
206static inline cs_real_t
208 const cs_real_t *array)
209{
210 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PVQ));
211
212 cs_real_t val_c = 0;
213
214 if (array == NULL)
215 return val_c;
216
217 for (short int v = 0; v < cm->n_vc; v++)
218 val_c += cm->wvc[v] * array[cm->v_ids[v]];
219
220 return val_c;
221}
222
223/*----------------------------------------------------------------------------*/
235/*----------------------------------------------------------------------------*/
236
237static inline cs_real_t
239 const cs_real_t *array)
240{
241 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PVQ));
242
243 cs_real_t val_c = 0;
244
245 if (array == NULL)
246 return val_c;
247
248 for (short int v = 0; v < cm->n_vc; v++)
249 val_c += cm->wvc[v] * array[v];
250
251 return val_c;
252}
253
254/*----------------------------------------------------------------------------*/
266/*----------------------------------------------------------------------------*/
267
268static inline cs_real_t
270 const cs_real_t *array)
271{
272 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PEC));
273
274 cs_real_t val_c = 0;
275
276 if (array == NULL)
277 return val_c;
278
279 for (short int e = 0; e < cm->n_ec; e++)
280 val_c += cm->pvol_e[e] * array[e];
281 val_c /= cm->vol_c;
282
283 return val_c;
284}
285
286/*----------------------------------------------------------------------------*/
287
289
290#endif /* __CS_RECO_CW_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:543
@ fm
Definition: cs_field_pointer.h:129
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:383
@ CS_FLAG_COMP_PVQ
Definition: cs_flag.h:215
@ CS_FLAG_COMP_FEQ
Definition: cs_flag.h:251
@ CS_FLAG_COMP_PEC
Definition: cs_flag.h:282
@ CS_FLAG_COMP_PFQ
Definition: cs_flag.h:235
@ CS_FLAG_COMP_EV
Definition: cs_flag.h:243
@ CS_FLAG_COMP_FE
Definition: cs_flag.h:247
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:269
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:207
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:140
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:109
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:80
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:238
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:121
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:176
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:113
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:251
short int n_vc
Definition: cs_cdo_local.h:223
double * wvc
Definition: cs_cdo_local.h:226
short int n_ec
Definition: cs_cdo_local.h:230
short int * f2e_idx
Definition: cs_cdo_local.h:260
cs_eflag_t flag
Definition: cs_cdo_local.h:205
short int * f2e_ids
Definition: cs_cdo_local.h:261
double * tef
Definition: cs_cdo_local.h:263
double vol_c
Definition: cs_cdo_local.h:218
cs_lnum_t * v_ids
Definition: cs_cdo_local.h:224
cs_real_t * pvol_e
Definition: cs_cdo_local.h:234
cs_quant_t * face
Definition: cs_cdo_local.h:245
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:280
Definition: cs_cdo_quantities.h:131
double meas
Definition: cs_cdo_quantities.h:133