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 #include "cs_flag.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53 /*============================================================================
54  * Public function prototypes
55  *============================================================================*/
56 
57 /*----------------------------------------------------------------------------*/
69 /*----------------------------------------------------------------------------*/
70 
71 void
73  const cs_cdo_quantities_t *quant,
74  const double *dof,
75  double *p_crec[],
76  double *p_frec[]);
77 
78 /*----------------------------------------------------------------------------*/
88 /*----------------------------------------------------------------------------*/
89 
90 void
92  const cs_cdo_quantities_t *quant,
93  const double *array,
94  cs_real_t *val_xc);
95 
96 /*----------------------------------------------------------------------------*/
107 /*----------------------------------------------------------------------------*/
108 
109 void
111  const cs_adjacency_t *c2v,
112  const cs_cdo_quantities_t *quant,
113  const double *array,
114  cs_real_t *val_xc);
115 
116 /*----------------------------------------------------------------------------*/
127 /*----------------------------------------------------------------------------*/
128 
129 void
131  const cs_cdo_connect_t *connect,
132  const cs_cdo_quantities_t *quant,
133  const double *pdi,
134  cs_real_t *pdi_f);
135 
136 /*----------------------------------------------------------------------------*/
148 /*----------------------------------------------------------------------------*/
149 
150 void
152  const cs_adjacency_t *c2e,
153  const cs_cdo_quantities_t *quant,
154  const double *array,
155  cs_real_3_t val_xc);
156 
157 /*----------------------------------------------------------------------------*/
169 /*----------------------------------------------------------------------------*/
170 
171 void
173  const cs_real_t *array,
174  cs_real_3_t val_c);
175 
176 /*----------------------------------------------------------------------------*/
190 /*----------------------------------------------------------------------------*/
191 
192 void
194  short int e,
195  const cs_real_t *array,
196  cs_real_3_t val_pec);
197 
198 /*----------------------------------------------------------------------------*/
209 /*----------------------------------------------------------------------------*/
210 
211 void
213  const cs_cdo_connect_t *connect,
214  const cs_cdo_quantities_t *quant,
215  const cs_real_t *pdi,
216  cs_real_t val_xc[]);
217 
218 /*----------------------------------------------------------------------------*/
229 /*----------------------------------------------------------------------------*/
230 
231 void
233  const cs_real_t pdi[],
234  cs_real_t *cell_gradient);
235 
236 
237 /*----------------------------------------------------------------------------*/
247 /*----------------------------------------------------------------------------*/
248 
249 void
251  const cs_adjacency_t *c2e,
252  const cs_cdo_quantities_t *quant,
253  const double *dof,
254  double reco[]);
255 
256 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 
267 void
269  const cs_cdo_quantities_t *quant,
270  const double *dof,
271  double *p_ccrec[]);
272 
273 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
288 cs_real_t
290  const cs_real_t pdi[],
291  const cs_real_t length_xcxp,
292  const cs_real_t unitv_xcxp[],
293  cs_real_t wbuf[]);
294 
295 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 void
312  const cs_real_t *pot,
313  cs_cell_builder_t *cb,
314  cs_real_t *vgrd);
315 
316 /*----------------------------------------------------------------------------*/
328 /*----------------------------------------------------------------------------*/
329 
330 void
332  const cs_real_t *pot,
333  cs_cell_builder_t *cb,
334  cs_real_t *cgrd);
335 
336 /*----------------------------------------------------------------------------*/
346 /*----------------------------------------------------------------------------*/
347 
348 static inline cs_real_t
350  const cs_real_t *p_v)
351 {
352  cs_real_t p_f = 0.;
353 
354  if (p_v == NULL)
355  return p_f;
356 
357  const cs_quant_t pfq = fm->face;
358 
359  for (short int e = 0; e < fm->n_ef; e++)
360  p_f += (p_v[fm->e2v_ids[2*e]] + p_v[fm->e2v_ids[2*e+1]]) * fm->tef[e];
361  p_f *= 0.5 / pfq.meas;
362 
363  return p_f;
364 }
365 
366 /*----------------------------------------------------------------------------*/
377 /*----------------------------------------------------------------------------*/
378 
379 static inline cs_real_t
381  const cs_real_t *array)
382 {
383  /* Sanity checks */
384  assert(cm != NULL && array != NULL);
386 
387  /* Reconstruct the value at the cell center */
388  cs_real_t pc = 0.;
389  for (short int v = 0; v < cm->n_vc; v++)
390  pc += cm->wvc[v] * array[cm->v_ids[v]];
391 
392  return pc;
393 }
394 
395 /*----------------------------------------------------------------------------*/
396 
398 
399 #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
static bool cs_flag_test(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_flag.h:161
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:153
double * tef
Definition: cs_cdo_local.h:214
Definition: cs_mesh_adjacencies.h:89
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
#define CS_CDO_LOCAL_PVQ
Definition: cs_cdo_local.h:51
double meas
Definition: cs_cdo_quantities.h:88
Definition: cs_cdo_local.h:133
Definition: cs_cdo_connect.h:69
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
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:449
short int n_ef
Definition: cs_cdo_local.h:211
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:94
cs_lnum_t * v_ids
Definition: cs_cdo_local.h:151
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:217
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:135
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:201
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:349
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:380
Definition: cs_cdo_quantities.h:86
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
short int n_vc
Definition: cs_cdo_local.h:150
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:462
#define CS_CDO_LOCAL_PV
Definition: cs_cdo_local.h:50
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:191
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