My Project
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-2019 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
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
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_flag_test(cm->flag,
112  CS_FLAG_COMP_FE));
113 
114  const cs_quant_t pfq = cm->face[f];
115  for (int ie = cm->f2e_idx[f]; ie < cm->f2e_idx[f+1]; ie++) {
116  const short int *v = cm->e2v_ids + 2*cm->f2e_ids[ie];
117  p_f += (p_v[v[0]] + p_v[v[1]]) * cm->tef[ie];
118  }
119  p_f *= 0.5 / pfq.meas;
120 
121  return p_f;
122 }
123 
124 /*----------------------------------------------------------------------------*/
135 /*----------------------------------------------------------------------------*/
136 
137 static inline cs_real_t
139  const cs_real_t *p_v)
140 {
141  cs_real_t p_c = 0.;
142 
143  if (p_v == NULL || cm == NULL)
144  return p_c;
145 
146  assert(cs_flag_test(cm->flag, CS_FLAG_COMP_PVQ)); /* Sanity check */
147 
148  /* Reconstruct the value at the cell center */
149  for (short int v = 0; v < cm->n_vc; v++)
150  p_c += cm->wvc[v] * p_v[v];
151 
152  return p_c;
153 }
154 
155 /*============================================================================
156  * Public function prototypes
157  *============================================================================*/
158 
159 /*----------------------------------------------------------------------------*/
171 /*----------------------------------------------------------------------------*/
172 
173 void
175  const cs_cdo_quantities_t *quant,
176  const double *dof,
177  double *p_crec[],
178  double *p_frec[]);
179 
180 /*----------------------------------------------------------------------------*/
190 /*----------------------------------------------------------------------------*/
191 
192 void
194  const cs_cdo_quantities_t *quant,
195  const double *array,
196  cs_real_t *val_xc);
197 
198 /*----------------------------------------------------------------------------*/
209 /*----------------------------------------------------------------------------*/
210 
211 void
213  const cs_cdo_quantities_t *quant,
214  const double *array,
215  cs_real_t *val_xc);
216 
217 /*----------------------------------------------------------------------------*/
229 /*----------------------------------------------------------------------------*/
230 
231 void
233  const cs_cdo_quantities_t *cdoq,
234  const cs_real_t i_face_vals[],
235  const cs_real_t b_face_vals[],
236  cs_real_t *cell_reco);
237 
238 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 void
253  const cs_adjacency_t *c2v,
254  const cs_cdo_quantities_t *quant,
255  const double *array,
256  cs_real_t *val_xc);
257 
258 /*----------------------------------------------------------------------------*/
268 /*----------------------------------------------------------------------------*/
269 
270 void
272  const cs_cdo_quantities_t *quant,
273  const double *val,
274  cs_real_t *reco_val);
275 
276 /*----------------------------------------------------------------------------*/
287 /*----------------------------------------------------------------------------*/
288 
289 void
291  const cs_cdo_connect_t *connect,
292  const cs_cdo_quantities_t *quant,
293  const double *pdi,
294  cs_real_t *pdi_f);
295 
296 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 void
312  const cs_adjacency_t *c2e,
313  const cs_cdo_quantities_t *quant,
314  const double *array,
315  cs_real_3_t val_xc);
316 
317 /*----------------------------------------------------------------------------*/
329 /*----------------------------------------------------------------------------*/
330 
331 void
333  const cs_real_t *array,
334  cs_real_3_t val_c);
335 
336 /*----------------------------------------------------------------------------*/
350 /*----------------------------------------------------------------------------*/
351 
352 void
354  short int e,
355  const cs_real_t *array,
356  cs_real_3_t val_pec);
357 
358 /*----------------------------------------------------------------------------*/
368 /*----------------------------------------------------------------------------*/
369 
370 void
372  const cs_adjacency_t *c2e,
373  const cs_cdo_quantities_t *quant,
374  const double *dof,
375  double reco[]);
376 
377 /*----------------------------------------------------------------------------*/
386 /*----------------------------------------------------------------------------*/
387 
388 void
390  const cs_cdo_quantities_t *quant,
391  const double *dof,
392  double *p_ccrec[]);
393 
394 /*----------------------------------------------------------------------------*/
405 /*----------------------------------------------------------------------------*/
406 
407 void
409  const cs_cdo_connect_t *connect,
410  const cs_cdo_quantities_t *quant,
411  const cs_real_t *pdi,
412  cs_real_t val_xc[]);
413 
414 /*----------------------------------------------------------------------------*/
425 /*----------------------------------------------------------------------------*/
426 
427 void
429  const cs_real_t i_face_vals[],
430  const cs_real_t b_face_vals[],
431  cs_real_t *cell_reco);
432 
433 /*----------------------------------------------------------------------------*/
442 /*----------------------------------------------------------------------------*/
443 
444 void
446  const cs_real_t pdi[],
447  cs_real_t *cell_gradient);
448 
449 /*----------------------------------------------------------------------------*/
462 /*----------------------------------------------------------------------------*/
463 
464 cs_real_t
466  const cs_real_t pdi[],
467  const cs_real_t length_xcxp,
468  const cs_real_t unitv_xcxp[],
469  cs_real_t wbuf[]);
470 
471 /*----------------------------------------------------------------------------*/
484 /*----------------------------------------------------------------------------*/
485 
486 void
488  const cs_real_t *pot,
489  cs_cell_builder_t *cb,
490  cs_real_t *vgrd);
491 
492 /*----------------------------------------------------------------------------*/
504 /*----------------------------------------------------------------------------*/
505 
506 void
508  const cs_real_t *pot,
509  cs_cell_builder_t *cb,
510  cs_real_t *cgrd);
511 
512 /*----------------------------------------------------------------------------*/
513 
515 
516 #endif /* __CS_RECO_H__ */
cs_cell_mesh_t::wvc
double * wvc
Definition: cs_cdo_local.h:166
f_id
void const int * f_id
Definition: cs_gui.h:292
cs_cell_mesh_t::flag
cs_flag_t flag
Definition: cs_cdo_local.h:148
cs_cell_mesh_t::e2v_ids
short int * e2v_ids
Definition: cs_cdo_local.h:186
cs_reco_cw_cell_grad_from_scalar_pv
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:800
cs_reco_cw_vgrd_wbs_from_pvc
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:897
cs_reco_pv_at_cell_centers
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
CS_FLAG_COMP_EV
#define CS_FLAG_COMP_EV
Definition: cs_flag.h:139
fm
Definition: cs_field_pointer.h:134
cs_reco_pv_at_cell_center
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:323
cs_reco_grad_cell_from_pv
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:692
cs_real_3_t
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:315
cs_reco_cw_cell_vect_from_face_dofs
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:744
cs_face_mesh_t
Set of local quantities and connectivities related to a mesh face Structure used to get a better memo...
Definition: cs_cdo_local.h:212
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
cs_reco_ccen_edge_dof
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:608
atimbr::v
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
cs_quant_t::meas
double meas
Definition: cs_cdo_quantities.h:88
cs_reco_vect_pv_at_cell_centers
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
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_cell_mesh_t::n_vc
short int n_vc
Definition: cs_cdo_local.h:163
cs_reco_cw_scalar_pv_inside_cell
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:841
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_cdo_quantities.h
cs_reco_fw_scalar_pv_at_face_center
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
cs_reco_cw_scalar_pv_at_cell_center
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:138
cs_reco_dfbyc_in_cell
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:509
cs_reco_dfbyc_at_cell_center
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:468
cs_cell_mesh_t::f2e_idx
short int * f2e_idx
Definition: cs_cdo_local.h:194
cs_reco_cw_scalar_pv_at_face_center
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
cs_reco_vect_pv_from_pc
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:366
cs_cdo_quantities_t
Definition: cs_cdo_quantities.h:94
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_cell_mesh_t::tef
double * tef
Definition: cs_cdo_local.h:196
cs_cdo_connect_t
Definition: cs_cdo_connect.h:74
cs_reco_pf_from_pv
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:417
cs_cell_builder_t
Set of local and temporary buffers useful for building the algebraic system with a cellwise process....
Definition: cs_cdo_local.h:56
cs_adjacency_t
Definition: cs_mesh_adjacencies.h:90
cs_flag.h
cs_reco_ccen_edge_dofs
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:650
cs_cdo_connect.h
CS_FLAG_COMP_FE
#define CS_FLAG_COMP_FE
Definition: cs_flag.h:140
cs_cell_mesh_t::face
cs_quant_t * face
Definition: cs_cdo_local.h:182
CS_FLAG_COMP_PVQ
#define CS_FLAG_COMP_PVQ
Definition: cs_flag.h:132
cs_reco_dfbyc_in_pec
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:555
cs_reco_cw_cgrd_wbs_from_pvc
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:995
cs_flag_test
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:188
cs_quant_t
Definition: cs_cdo_quantities.h:86
cs_cell_mesh_t::f2e_ids
short int * f2e_ids
Definition: cs_cdo_local.h:195
CS_FLAG_COMP_FEQ
#define CS_FLAG_COMP_FEQ
Definition: cs_flag.h:141
cs_reco_cell_vect_from_face_dofs
void cs_reco_cell_vect_from_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
cs_cell_mesh_t
Set of local quantities and connectivities related to a mesh cell This is a key structure for all cel...
Definition: cs_cdo_local.h:146
CS_FLAG_COMP_PFQ
#define CS_FLAG_COMP_PFQ
Definition: cs_flag.h:137
cs_reco_conf_vtx_dofs
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:81
cs_cdo_local.h