programmer's documentation
cs_reco.h
Go to the documentation of this file.
1 #ifndef __CS_RECO_H__
2 #define __CS_RECO_H__
3 
4 /*============================================================================
5  * Routines 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-2018 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 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Macro definitions
46  *============================================================================*/
47 
48 /*============================================================================
49  * Type definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Public function prototypes
54  *============================================================================*/
55 
56 /*----------------------------------------------------------------------------*/
68 /*----------------------------------------------------------------------------*/
69 
70 void
72  const cs_cdo_quantities_t *quant,
73  const double *dof,
74  double *p_crec[],
75  double *p_frec[]);
76 
77 /*----------------------------------------------------------------------------*/
87 /*----------------------------------------------------------------------------*/
88 
89 void
91  const cs_cdo_quantities_t *quant,
92  const double *array,
93  cs_real_t *val_xc);
94 
95 /*----------------------------------------------------------------------------*/
106 /*----------------------------------------------------------------------------*/
107 
108 void
110  const cs_adjacency_t *c2v,
111  const cs_cdo_quantities_t *quant,
112  const double *array,
113  cs_real_t *val_xc);
114 
115 /*----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------*/
127 
128 void
130  const cs_cdo_connect_t *connect,
131  const cs_cdo_quantities_t *quant,
132  const double *pdi,
133  cs_real_t *pdi_f);
134 
135 /*----------------------------------------------------------------------------*/
147 /*----------------------------------------------------------------------------*/
148 
149 void
151  const cs_adjacency_t *c2e,
152  const cs_cdo_quantities_t *quant,
153  const double *array,
154  cs_real_3_t val_xc);
155 
156 /*----------------------------------------------------------------------------*/
168 /*----------------------------------------------------------------------------*/
169 
170 void
172  const cs_real_t *array,
173  cs_real_3_t val_c);
174 
175 /*----------------------------------------------------------------------------*/
189 /*----------------------------------------------------------------------------*/
190 
191 void
193  short int e,
194  const cs_real_t *array,
195  cs_real_3_t val_pec);
196 
197 /*----------------------------------------------------------------------------*/
208 /*----------------------------------------------------------------------------*/
209 
210 void
212  const cs_cdo_connect_t *connect,
213  const cs_cdo_quantities_t *quant,
214  const cs_real_t *pdi,
215  cs_real_t val_xc[]);
216 
217 /*----------------------------------------------------------------------------*/
228 /*----------------------------------------------------------------------------*/
229 
230 void
232  const cs_real_t pdi[],
233  cs_real_t *cell_gradient);
234 
235 
236 /*----------------------------------------------------------------------------*/
246 /*----------------------------------------------------------------------------*/
247 
248 void
250  const cs_adjacency_t *c2e,
251  const cs_cdo_quantities_t *quant,
252  const double *dof,
253  double reco[]);
254 
255 /*----------------------------------------------------------------------------*/
264 /*----------------------------------------------------------------------------*/
265 
266 void
268  const cs_cdo_quantities_t *quant,
269  const double *dof,
270  double *p_ccrec[]);
271 
272 /*----------------------------------------------------------------------------*/
285 /*----------------------------------------------------------------------------*/
286 
287 cs_real_t
289  const cs_real_t pdi[],
290  const cs_real_t length_xcxp,
291  const cs_real_t unitv_xcxp[],
292  cs_real_t wbuf[]);
293 
294 /*----------------------------------------------------------------------------*/
307 /*----------------------------------------------------------------------------*/
308 
309 void
311  const cs_real_t *pot,
312  cs_cell_builder_t *cb,
313  cs_real_t *vgrd);
314 
315 /*----------------------------------------------------------------------------*/
327 /*----------------------------------------------------------------------------*/
328 
329 void
331  const cs_real_t *pot,
332  cs_cell_builder_t *cb,
333  cs_real_t *cgrd);
334 
335 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
346 
347 static inline cs_real_t
349  const cs_real_t *p_v)
350 {
351  cs_real_t p_f = 0.;
352 
353  if (p_v == NULL)
354  return p_f;
355 
356  const cs_quant_t pfq = fm->face;
357 
358  for (short int e = 0; e < fm->n_ef; e++)
359  p_f += (p_v[fm->e2v_ids[2*e]] + p_v[fm->e2v_ids[2*e+1]]) * fm->tef[e];
360  p_f *= 0.5 / pfq.meas;
361 
362  return p_f;
363 }
364 
365 /*----------------------------------------------------------------------------*/
376 /*----------------------------------------------------------------------------*/
377 
378 static inline cs_real_t
380  const cs_real_t *array)
381 {
382  /* Sanity checks */
383  assert(cm != NULL && array != NULL);
385 
386  /* Reconstruct the value at the cell center */
387  cs_real_t pc = 0.;
388  for (short int v = 0; v < cm->n_vc; v++)
389  pc += cm->wvc[v] * array[cm->v_ids[v]];
390 
391  return pc;
392 }
393 
394 /*----------------------------------------------------------------------------*/
395 
397 
398 #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:779
void cs_reco_ccen_edge_dof(cs_lnum_t cid, 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:539
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:158
double * tef
Definition: cs_cdo_local.h:219
Definition: cs_mesh_adjacencies.h:89
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
#define CS_CDO_LOCAL_PVQ
Definition: cs_cdo_local.h:51
double meas
Definition: cs_cdo_quantities.h:83
Definition: cs_cdo_local.h:138
Definition: cs_cdo_connect.h:55
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:213
short int n_ef
Definition: cs_cdo_local.h:216
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:89
cs_lnum_t * v_ids
Definition: cs_cdo_local.h:156
static bool cs_test_flag(cs_flag_t flag_to_check, cs_flag_t reference)
Check if a two flag share the same pattern Return true if the flag to check has at least the pattern ...
Definition: cs_cdo.h:235
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
Definition: cs_field_pointer.h:123
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:625
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:581
short int * e2v_ids
Definition: cs_cdo_local.h:222
Definition: cs_cdo_local.h:71
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
cs_flag_t flag
Definition: cs_cdo_local.h:140
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:349
cs_quant_t face
Definition: cs_cdo_local.h:206
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:348
static cs_real_t cs_reco_cw_scalar_pv_at_cell_center(const cs_cell_mesh_t *cm, const cs_real_t *array)
Reconstruct the value of a scalar potential at the cell center from an array of values defined on pri...
Definition: cs_reco.h:379
Definition: cs_cdo_quantities.h:81
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
short int n_vc
Definition: cs_cdo_local.h:155
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:308
#define END_C_DECLS
Definition: cs_defs.h:454
#define CS_CDO_LOCAL_PV
Definition: cs_cdo_local.h:50
void cs_reco_grd_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:449
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:257
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:681
Definition: cs_cdo_local.h:196
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:501
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:395