7.1
general documentation
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-2021 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 
69 static inline cs_real_t
70 cs_reco_fw_scalar_pv_at_face_center(const cs_face_mesh_t *fm,
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 
100 static inline cs_real_t
101 cs_reco_cw_scalar_pv_at_face_center(const short int f,
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,
112  CS_FLAG_COMP_FE));
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 
136 static inline cs_real_t
137 cs_reco_cw_scalar_pv_at_cell_center(const cs_cell_mesh_t *cm,
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 /*----------------------------------------------------------------------------*/
170 /*----------------------------------------------------------------------------*/
171 
172 void
174  const cs_cdo_quantities_t *quant,
175  const double *dof,
176  double *p_crec[],
177  double *p_frec[]);
178 
179 /*----------------------------------------------------------------------------*/
189 /*----------------------------------------------------------------------------*/
190 
191 void
193  const cs_cdo_quantities_t *quant,
194  const double *array,
195  cs_real_t *val_xc);
196 
197 /*----------------------------------------------------------------------------*/
208 /*----------------------------------------------------------------------------*/
209 
210 void
212  const cs_cdo_quantities_t *quant,
213  const double *array,
214  cs_real_t *val_xc);
215 
216 /*----------------------------------------------------------------------------*/
228 /*----------------------------------------------------------------------------*/
229 
230 void
232  const cs_cdo_quantities_t *cdoq,
233  const cs_real_t i_face_vals[],
234  const cs_real_t b_face_vals[],
235  cs_real_t *cell_reco);
236 
237 /*----------------------------------------------------------------------------*/
252 /*----------------------------------------------------------------------------*/
253 
254 void
256  const cs_adjacency_t *c2f,
257  const cs_cdo_quantities_t *cdoq,
258  const cs_real_t face_dofs[],
259  bool local_input,
260  cs_real_t *cell_reco);
261 
262 /*----------------------------------------------------------------------------*/
275 /*----------------------------------------------------------------------------*/
276 
277 void
279  const cs_cdo_quantities_t *cdoq,
280  const cs_real_t face_dofs[],
281  cs_real_t *cell_reco);
282 
283 /*----------------------------------------------------------------------------*/
294 /*----------------------------------------------------------------------------*/
295 
296 void
298  const cs_adjacency_t *c2v,
299  const cs_cdo_quantities_t *quant,
300  const double *array,
301  cs_real_t *val_xc);
302 
303 /*----------------------------------------------------------------------------*/
313 /*----------------------------------------------------------------------------*/
314 
315 void
317  const cs_cdo_quantities_t *quant,
318  const double *val,
319  cs_real_t *reco_val);
320 
321 /*----------------------------------------------------------------------------*/
332 /*----------------------------------------------------------------------------*/
333 
334 void
336  const cs_cdo_connect_t *connect,
337  const cs_cdo_quantities_t *quant,
338  const double *pdi,
339  cs_real_t *pdi_f);
340 
341 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 void
357  const cs_adjacency_t *c2e,
358  const cs_cdo_quantities_t *quant,
359  const double *array,
360  cs_real_3_t val_xc);
361 
362 /*----------------------------------------------------------------------------*/
374 /*----------------------------------------------------------------------------*/
375 
376 void
378  const cs_real_t *array,
379  cs_real_3_t val_c);
380 
381 /*----------------------------------------------------------------------------*/
395 /*----------------------------------------------------------------------------*/
396 
397 void
399  short int e,
400  const cs_real_t *array,
401  cs_real_3_t val_pec);
402 
403 /*----------------------------------------------------------------------------*/
413 /*----------------------------------------------------------------------------*/
414 
415 void
417  const cs_adjacency_t *c2e,
418  const cs_cdo_quantities_t *quant,
419  const double *dof,
420  double reco[]);
421 
422 /*----------------------------------------------------------------------------*/
431 /*----------------------------------------------------------------------------*/
432 
433 void
435  const cs_cdo_quantities_t *quant,
436  const double *dof,
437  double *p_ccrec[]);
438 
439 /*----------------------------------------------------------------------------*/
450 /*----------------------------------------------------------------------------*/
451 
452 void
454  const cs_cdo_quantities_t *quant,
455  const cs_real_t *circ,
456  cs_real_t **p_curl);
457 
458 /*----------------------------------------------------------------------------*/
472 /*----------------------------------------------------------------------------*/
473 
474 void
476  const cs_cdo_connect_t *connect,
477  const cs_cdo_quantities_t *quant,
478  const cs_real_t *p_c,
479  const cs_real_t *p_f,
480  cs_real_t grd_c[]);
481 
482 /*----------------------------------------------------------------------------*/
496 /*----------------------------------------------------------------------------*/
497 
498 void
500  const cs_cdo_connect_t *connect,
501  const cs_cdo_quantities_t *quant,
502  const cs_real_t *u_c,
503  const cs_real_t *u_f,
504  cs_real_t grd_c[]);
505 
506 /*----------------------------------------------------------------------------*/
517 /*----------------------------------------------------------------------------*/
518 
519 void
521  const cs_cdo_connect_t *connect,
522  const cs_cdo_quantities_t *quant,
523  const cs_real_t *pdi,
524  cs_real_t val_xc[]);
525 
526 /*----------------------------------------------------------------------------*/
537 /*----------------------------------------------------------------------------*/
538 
539 void
541  const cs_real_t *fluxes,
542  cs_real_t *cell_reco);
543 
544 /*----------------------------------------------------------------------------*/
555 /*----------------------------------------------------------------------------*/
556 
557 void
559  const cs_real_t i_face_vals[],
560  const cs_real_t b_face_vals[],
561  cs_real_t *cell_reco);
562 
563 /*----------------------------------------------------------------------------*/
572 /*----------------------------------------------------------------------------*/
573 
574 void
576  const cs_real_t pdi[],
577  cs_real_t *cell_gradient);
578 
579 /*----------------------------------------------------------------------------*/
592 /*----------------------------------------------------------------------------*/
593 
594 cs_real_t
596  const cs_real_t pdi[],
597  const cs_real_t length_xcxp,
598  const cs_real_t unitv_xcxp[],
599  cs_real_t wbuf[]);
600 
601 /*----------------------------------------------------------------------------*/
614 /*----------------------------------------------------------------------------*/
615 
616 void
618  const cs_real_t *pot,
619  cs_cell_builder_t *cb,
620  cs_real_t *vgrd);
621 
622 /*----------------------------------------------------------------------------*/
634 /*----------------------------------------------------------------------------*/
635 
636 void
638  const cs_real_t *pot,
639  cs_cell_builder_t *cb,
640  cs_real_t *cgrd);
641 
642 /*----------------------------------------------------------------------------*/
643 
645 
646 #endif /* __CS_RECO_H__ */
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. for approximating the gradient. The computation takes into account a subdivision into tetrahedra of the current cell based on p_{ef,c}.
Definition: cs_reco.c:1299
double * tef
Definition: cs_cdo_local.h:254
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:1061
Definition: cs_flag.h:205
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:726
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. If p_crec and/or p_frec are not allocated, this done in this subroutine.
Definition: cs_reco.c:81
double * wvc
Definition: cs_cdo_local.h:222
double * tef
Definition: cs_cdo_local.h:295
Definition: cs_mesh_adjacencies.h:68
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:910
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
double meas
Definition: cs_cdo_quantities.h:123
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:202
Definition: cs_flag.h:211
Definition: cs_cdo_connect.h:79
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:437
short int * f2e_ids
Definition: cs_cdo_local.h:252
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:965
short int n_ef
Definition: cs_cdo_local.h:292
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
Definition: cs_cdo_quantities.h:129
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
Definition: cs_field_pointer.h:128
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. This array is stored in the same order as cm->f_ids Scalar-valued face DoFs are related to the normal flux across primal faces.
Definition: cs_reco.c:1016
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:1146
cs_eflag_t flag
Definition: cs_cdo_local.h:204
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:771
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:213
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:328
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:859
short int * e2v_ids
Definition: cs_cdo_local.h:298
Set of local and temporary buffers.
Definition: cs_cdo_local.h:60
cs_quant_t * face
Definition: cs_cdo_local.h:238
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:335
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:622
cs_quant_t face
Definition: cs_cdo_local.h:280
Definition: cs_cdo_quantities.h:121
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
short int n_vc
Definition: cs_cdo_local.h:219
Definition: cs_flag.h:214
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:581
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:264
#define END_C_DECLS
Definition: cs_defs.h:511
short int * e2v_ids
Definition: cs_cdo_local.h:243
void cs_reco_vect_pv_from_pc(const cs_adjacency_t *c2v, const cs_cdo_quantities_t *quant, const double *val, cs_real_t *reco_val)
Reconstruct a vector-valued array at vertices from a vector-valued array at cells.
Definition: cs_reco.c:479
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:530
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:1202
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:270
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:815
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:1105
Definition: cs_flag.h:190
short int * f2e_idx
Definition: cs_cdo_local.h:251
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:167
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:668
Definition: cs_flag.h:217
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:391