8.0
general documentation
Loading...
Searching...
No Matches
cs_reco.h
Go to the documentation of this file.
1#ifndef __CS_RECO_H__
2#define __CS_RECO_H__
3
4/*============================================================================
5 * Functions to handle the reconstruction of fields
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2023 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30/*----------------------------------------------------------------------------
31 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "assert.h"
35
36#include "cs_cdo_connect.h"
37#include "cs_cdo_local.h"
38#include "cs_cdo_quantities.h"
39#include "cs_flag.h"
40
41/*----------------------------------------------------------------------------*/
42
44
45/*============================================================================
46 * Macro definitions
47 *============================================================================*/
48
49/*============================================================================
50 * Type definitions
51 *============================================================================*/
52
53/*============================================================================
54 * Inline public function prototypes
55 *============================================================================*/
56
57/*----------------------------------------------------------------------------*/
67/*----------------------------------------------------------------------------*/
68
69static inline cs_real_t
71 const cs_real_t *p_v)
72{
73 cs_real_t p_f = 0.;
74
75 if (p_v == NULL)
76 return p_f;
77
78 const cs_quant_t pfq = fm->face;
79
80 for (short int e = 0; e < fm->n_ef; e++)
81 p_f += (p_v[fm->e2v_ids[2*e]] + p_v[fm->e2v_ids[2*e+1]]) * fm->tef[e];
82 p_f *= 0.5 / pfq.meas;
83
84 return p_f;
85}
86
87/*----------------------------------------------------------------------------*/
98/*----------------------------------------------------------------------------*/
99
100static inline cs_real_t
102 const cs_cell_mesh_t *cm,
103 const cs_real_t *p_v)
104{
105 cs_real_t p_f = 0.;
106
107 if (p_v == NULL)
108 return p_f;
109
110 assert(cs_eflag_test(cm->flag,
113
114 for (int ie = cm->f2e_idx[f]; ie < cm->f2e_idx[f+1]; ie++) {
115 const short int *v = cm->e2v_ids + 2*cm->f2e_ids[ie];
116 p_f += (p_v[v[0]] + p_v[v[1]]) * cm->tef[ie];
117 }
118 p_f *= 0.5 / cm->face[f].meas;
119
120 return p_f;
121}
122
123/*----------------------------------------------------------------------------*/
134/*----------------------------------------------------------------------------*/
135
136static inline cs_real_t
138 const cs_real_t *p_v)
139{
140 cs_real_t p_c = 0.;
141
142 if (p_v == NULL || cm == NULL)
143 return p_c;
144
145 assert(cs_eflag_test(cm->flag, CS_FLAG_COMP_PVQ)); /* Sanity check */
146
147 /* Reconstruct the value at the cell center */
148 for (short int v = 0; v < cm->n_vc; v++)
149 p_c += cm->wvc[v] * p_v[v];
150
151 return p_c;
152}
153
154/*============================================================================
155 * Public function prototypes
156 *============================================================================*/
157
158/*----------------------------------------------------------------------------*/
171/*----------------------------------------------------------------------------*/
172
173void
175 const cs_cdo_quantities_t *quant,
176 int stride,
177 bool interlace,
178 cs_real_t *array);
179
180/*----------------------------------------------------------------------------*/
192/*----------------------------------------------------------------------------*/
193
194void
196 const cs_cdo_quantities_t *quant,
197 const double *dof,
198 double *p_crec[],
199 double *p_frec[]);
200
201/*----------------------------------------------------------------------------*/
211/*----------------------------------------------------------------------------*/
212
213void
215 const cs_cdo_quantities_t *quant,
216 const double *array,
217 cs_real_t *val_xc);
218
219/*----------------------------------------------------------------------------*/
230/*----------------------------------------------------------------------------*/
231
232void
234 const cs_cdo_quantities_t *quant,
235 const double *array,
236 cs_real_t *val_xc);
237
238/*----------------------------------------------------------------------------*/
250/*----------------------------------------------------------------------------*/
251
252void
254 const cs_cdo_quantities_t *cdoq,
255 const cs_real_t i_face_vals[],
256 const cs_real_t b_face_vals[],
257 cs_real_t *cell_reco);
258
259/*----------------------------------------------------------------------------*/
274/*----------------------------------------------------------------------------*/
275
276void
278 const cs_adjacency_t *c2f,
279 const cs_cdo_quantities_t *cdoq,
280 const cs_real_t face_dofs[],
281 bool local_input,
282 cs_real_t *cell_reco);
283
284/*----------------------------------------------------------------------------*/
297/*----------------------------------------------------------------------------*/
298
299void
301 const cs_cdo_quantities_t *cdoq,
302 const cs_real_t face_dofs[],
303 cs_real_t *cell_reco);
304
305/*----------------------------------------------------------------------------*/
316/*----------------------------------------------------------------------------*/
317
318void
320 const cs_adjacency_t *c2v,
321 const cs_cdo_quantities_t *quant,
322 const double *array,
323 cs_real_t *val_xc);
324
325/*----------------------------------------------------------------------------*/
335/*----------------------------------------------------------------------------*/
336
337void
339 const cs_cdo_quantities_t *quant,
340 const cs_real_t *cell_val,
341 cs_real_t *vtx_val);
342
343/*----------------------------------------------------------------------------*/
353/*----------------------------------------------------------------------------*/
354
355void
357 const cs_cdo_quantities_t *quant,
358 const cs_real_t *cell_val,
359 cs_real_t *vtx_val);
360
361/*----------------------------------------------------------------------------*/
372/*----------------------------------------------------------------------------*/
373
374void
376 const cs_cdo_connect_t *connect,
377 const cs_cdo_quantities_t *quant,
378 const double *pdi,
379 cs_real_t *pdi_f);
380
381/*----------------------------------------------------------------------------*/
393/*----------------------------------------------------------------------------*/
394
395void
397 const cs_adjacency_t *c2e,
398 const cs_cdo_quantities_t *quant,
399 const double *array,
400 cs_real_3_t val_xc);
401
402/*----------------------------------------------------------------------------*/
414/*----------------------------------------------------------------------------*/
415
416void
418 const cs_real_t *array,
419 cs_real_3_t val_c);
420
421/*----------------------------------------------------------------------------*/
435/*----------------------------------------------------------------------------*/
436
437void
439 short int e,
440 const cs_real_t *array,
441 cs_real_3_t val_pec);
442
443/*----------------------------------------------------------------------------*/
453/*----------------------------------------------------------------------------*/
454
455void
457 const cs_adjacency_t *c2e,
458 const cs_cdo_quantities_t *quant,
459 const double *dof,
460 double reco[]);
461
462/*----------------------------------------------------------------------------*/
471/*----------------------------------------------------------------------------*/
472
473void
475 const cs_cdo_quantities_t *quant,
476 const double *dof,
477 double *p_ccrec[]);
478
479/*----------------------------------------------------------------------------*/
490/*----------------------------------------------------------------------------*/
491
492void
494 const cs_cdo_quantities_t *quant,
495 const cs_real_t *circ,
496 cs_real_t **p_curl);
497
498/*----------------------------------------------------------------------------*/
512/*----------------------------------------------------------------------------*/
513
514void
516 const cs_cdo_connect_t *connect,
517 const cs_cdo_quantities_t *quant,
518 const cs_real_t *p_c,
519 const cs_real_t *p_f,
520 cs_real_t grd_c[]);
521
522/*----------------------------------------------------------------------------*/
536/*----------------------------------------------------------------------------*/
537
538void
540 const cs_cdo_connect_t *connect,
541 const cs_cdo_quantities_t *quant,
542 const cs_real_t *u_c,
543 const cs_real_t *u_f,
544 cs_real_t grd_c[]);
545
546/*----------------------------------------------------------------------------*/
557/*----------------------------------------------------------------------------*/
558
559void
561 const cs_cdo_connect_t *connect,
562 const cs_cdo_quantities_t *quant,
563 const cs_real_t *pdi,
564 cs_real_t val_xc[]);
565
566/*----------------------------------------------------------------------------*/
577/*----------------------------------------------------------------------------*/
578
579void
581 const cs_real_t *fluxes,
582 cs_real_t *cell_reco);
583
584/*----------------------------------------------------------------------------*/
595/*----------------------------------------------------------------------------*/
596
597void
599 const cs_real_t i_face_vals[],
600 const cs_real_t b_face_vals[],
601 cs_real_t *cell_reco);
602
603/*----------------------------------------------------------------------------*/
612/*----------------------------------------------------------------------------*/
613
614void
616 const cs_real_t pdi[],
617 cs_real_t *cell_gradient);
618
619/*----------------------------------------------------------------------------*/
632/*----------------------------------------------------------------------------*/
633
636 const cs_real_t pdi[],
637 const cs_real_t length_xcxp,
638 const cs_real_t unitv_xcxp[],
639 cs_real_t wbuf[]);
640
641/*----------------------------------------------------------------------------*/
654/*----------------------------------------------------------------------------*/
655
656void
658 const cs_real_t *pot,
660 cs_real_t *vgrd);
661
662/*----------------------------------------------------------------------------*/
674/*----------------------------------------------------------------------------*/
675
676void
678 const cs_real_t *pot,
680 cs_real_t *cgrd);
681
682/*----------------------------------------------------------------------------*/
683
685
686#endif /* __CS_RECO_H__ */
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
#define END_C_DECLS
Definition cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition cs_defs.h:332
@ 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_PVQ
Definition cs_flag.h:210
@ CS_FLAG_COMP_FEQ
Definition cs_flag.h:246
@ CS_FLAG_COMP_PFQ
Definition cs_flag.h:230
@ CS_FLAG_COMP_EV
Definition cs_flag.h:238
@ CS_FLAG_COMP_FE
Definition cs_flag.h:242
static cs_real_t cs_reco_cw_scalar_pv_at_face_center(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.h:101
void cs_reco_dfbyc_in_pec(const cs_cell_mesh_t *cm, short int e, const cs_real_t *array, cs_real_3_t val_pec)
Reconstruct a constant vector inside pec which is a volume surrounding the edge e inside the cell c....
Definition cs_reco.c:787
void cs_reco_cw_cell_vect_from_flux(const cs_cell_mesh_t *cm, const cs_real_t *fluxes, cs_real_t *cell_reco)
Reconstruct the vector-valued quantity inside each cell from the given flux array....
Definition cs_reco.c:1135
void cs_reco_dual_vol_weight_reduction(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, int stride, bool interlace, cs_real_t *array)
Apply 1/|dual_vol| to a synchronized array of DoF vertices Parallel synchronization is done inside th...
Definition cs_reco.c:84
void cs_reco_dfbyc_in_cell(const cs_cell_mesh_t *cm, const cs_real_t *array, cs_real_3_t val_c)
Reconstruct a constant vector inside the cell c. array is scanned thanks to the c2e connectivity....
Definition cs_reco.c:741
void cs_reco_cw_vgrd_wbs_from_pvc(const cs_cell_mesh_t *cm, const cs_real_t *pot, cs_cell_builder_t *cb, cs_real_t *vgrd)
Compute the weighted (by volume) gradient inside a given primal cell for the related vertices....
Definition cs_reco.c:1327
static cs_real_t cs_reco_cw_scalar_pv_at_cell_center(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.h:137
void cs_reco_cell_vectors_by_ib_face_dofs(const cs_adjacency_t *c2f, const cs_cdo_quantities_t *cdoq, const cs_real_t i_face_vals[], const cs_real_t b_face_vals[], cs_real_t *cell_reco)
Reconstruct the vector-valued quantity inside each cell from the face DoFs (interior and boundary)....
Definition cs_reco.c:356
void cs_reco_grad_cell_from_fb_dofs(cs_lnum_t c_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_real_t *p_c, const cs_real_t *p_f, cs_real_t grd_c[])
Reconstruct the mean-value of the gradient field with DoFs arising from a face-based scheme (values a...
Definition cs_reco.c:978
void cs_reco_cw_cell_vect_from_face_dofs(const cs_cell_mesh_t *cm, const cs_real_t i_face_vals[], const cs_real_t b_face_vals[], cs_real_t *cell_reco)
Reconstruct the vector-valued quantity inside each cell from the face DoFs (interior and boundary)....
Definition cs_reco.c:1182
void cs_reco_cw_cgrd_wbs_from_pvc(const cs_cell_mesh_t *cm, const cs_real_t *pot, cs_cell_builder_t *cb, cs_real_t *cgrd)
Compute the mean value of a gradient inside a given primal cell. Use the WBS algo....
Definition cs_reco.c:1430
void cs_reco_grad_33_cell_from_fb_dofs(cs_lnum_t c_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_real_t *u_c, const cs_real_t *u_f, cs_real_t grd_c[])
Reconstruct the mean-value of the tensor gradient field with DoFs arising from a face-based scheme (v...
Definition cs_reco.c:1029
void cs_reco_cell_vectors_by_face_dofs(const cs_adjacency_t *c2f, const cs_cdo_quantities_t *cdoq, const cs_real_t face_dofs[], cs_real_t *cell_reco)
Reconstruct the vector-valued quantity inside each cell from the face DoFs (interior and boundary)....
Definition cs_reco.c:481
void cs_reco_ccen_edge_dofs(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const double *dof, double *p_ccrec[])
Reconstruct at each cell center a field of edge-based DoFs.
Definition cs_reco.c:890
void cs_reco_dfbyc_at_cell_center(cs_lnum_t c_id, const cs_adjacency_t *c2e, const cs_cdo_quantities_t *quant, const double *array, cs_real_3_t val_xc)
Reconstruct a constant vector at the cell center from an array of values defined on dual faces lying ...
Definition cs_reco.c:700
void cs_reco_cell_curl_by_edge_dofs(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_real_t *circ, cs_real_t **p_curl)
Reconstruct a cell-wise constant curl from the knowledge of the circulation at primal edges.
Definition cs_reco.c:934
static cs_real_t cs_reco_fw_scalar_pv_at_face_center(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.
Definition cs_reco.h:70
void cs_reco_cell_vector_by_face_dofs(cs_lnum_t c_id, const cs_adjacency_t *c2f, const cs_cdo_quantities_t *cdoq, const cs_real_t face_dofs[], bool local_input, cs_real_t *cell_reco)
Reconstruct the vector-valued quantity inside a cell from the face DoFs (interior and boundary)....
Definition cs_reco.c:418
cs_real_t cs_reco_cw_scalar_pv_inside_cell(const cs_cell_mesh_t *cm, const cs_real_t pdi[], const cs_real_t length_xcxp, const cs_real_t unitv_xcxp[], cs_real_t wbuf[])
Reconstruct the value of a scalar potential at a point inside a cell The scalar potential has DoFs lo...
Definition cs_reco.c:1269
void cs_reco_vect_pv_at_cell_centers(const cs_adjacency_t *c2v, const cs_cdo_quantities_t *quant, const double *array, cs_real_t *val_xc)
Reconstruct the value at all cell centers from an array of values defined on primal vertices....
Definition cs_reco.c:307
void cs_reco_ccen_edge_dof(cs_lnum_t c_id, const cs_adjacency_t *c2e, const cs_cdo_quantities_t *quant, const double *dof, double reco[])
Reconstruct at the cell center a field of edge-based DoFs.
Definition cs_reco.c:845
void cs_reco_pv_at_cell_centers(const cs_adjacency_t *c2v, const cs_cdo_quantities_t *quant, const double *array, cs_real_t *val_xc)
Reconstruct the value at all cell centers from an array of values defined on primal vertices.
Definition cs_reco.c:263
void cs_reco_pf_from_pv(cs_lnum_t f_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const double *pdi, cs_real_t *pdi_f)
Reconstruct the value at the face center from an array of values defined on primal vertices.
Definition cs_reco.c:649
void cs_reco_pv_at_cell_center(cs_lnum_t c_id, const cs_adjacency_t *c2v, const cs_cdo_quantities_t *quant, const double *array, cs_real_t *val_xc)
Reconstruct the value at the cell center from an array of values defined on primal vertices.
Definition cs_reco.c:525
void cs_reco_vect_pv_from_pc(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_real_t *cell_val, cs_real_t *vtx_val)
Reconstruct a vector-valued array at vertices from a vector-valued array at cells.
Definition cs_reco.c:604
void cs_reco_grad_cell_from_pv(cs_lnum_t c_id, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_real_t *pdi, cs_real_t val_xc[])
Reconstruct the value at the cell center of the gradient of a field defined on primal vertices.
Definition cs_reco.c:1084
void cs_reco_conf_vtx_dofs(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const double *dof, double *p_crec[], double *p_frec[])
Reconstruct at cell centers and face centers a vertex-based field Linear interpolation....
Definition cs_reco.c:174
void cs_reco_cw_cell_grad_from_scalar_pv(const cs_cell_mesh_t *cm, const cs_real_t pdi[], cs_real_t *cell_gradient)
Reconstruct the value of a scalar potential at a point inside a cell The scalar potential has DoFs lo...
Definition cs_reco.c:1228
void cs_reco_scal_pv_from_pc(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_real_t *cell_val, cs_real_t *vtx_val)
Reconstruct a scalar-valued array at vertices from a scalar-valued array at cells.
Definition cs_reco.c:567
Definition cs_mesh_adjacencies.h:68
Definition cs_cdo_connect.h:61
Definition cs_cdo_quantities.h:137
Set of local and temporary buffers.
Definition cs_cdo_local.h:60
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
short int n_vc
Definition cs_cdo_local.h:223
double * wvc
Definition cs_cdo_local.h:226
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
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_cdo_quantities.h:129
double meas
Definition cs_cdo_quantities.h:131