8.1
general documentation
cs_field_operator.h
Go to the documentation of this file.
1 #ifndef __CS_FIELD_OPERATOR_H__
2 #define __CS_FIELD_OPERATOR_H__
3 
4 /*============================================================================
5  * Field based algebraic operators.
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 "cs_defs.h"
35 #include "cs_field.h"
36 #include "cs_gradient.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*=============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
46 /*============================================================================
47  * Type definitions
48  *============================================================================*/
49 
50 /*----------------------------------------------------------------------------
51  * Field values interpolation type
52  *----------------------------------------------------------------------------*/
53 
54 typedef enum {
55 
56  CS_FIELD_INTERPOLATE_MEAN, /* mean element value (P0 interpolation) */
57  CS_FIELD_INTERPOLATE_GRADIENT /* mean + gradient correction (pseudo-P1) */
58 
60 
61 /*=============================================================================
62  * Public function prototypes
63  *============================================================================*/
64 
65 /*----------------------------------------------------------------------------
66  * Compute cell gradient of scalar field or component of vector or
67  * tensor field.
68  *
69  * parameters:
70  * f <-- pointer to field
71  * use_previous_t <-- should we use values from the previous time step ?
72  * inc <-- if 0, solve on increment; 1 otherwise
73  * grad --> gradient
74  *----------------------------------------------------------------------------*/
75 
76 void
78  bool use_previous_t,
79  int inc,
80  cs_real_3_t *restrict grad);
81 
82 /*----------------------------------------------------------------------------*/
94 /*----------------------------------------------------------------------------*/
95 
96 void
98  int inc,
99  const cs_real_t bc_coeff_a[],
100  const cs_real_t bc_coeff_b[],
101  cs_real_t var[],
102  cs_real_3_t grad[]);
103 
104 /*----------------------------------------------------------------------------
105  * Compute cell gradient of scalar field or component of vector or
106  * tensor field.
107  *
108  * parameters:
109  * f <-- pointer to field
110  * use_previous_t <-- should we use values from the previous time step ?
111  * inc <-- if 0, solve on increment; 1 otherwise
112  * hyd_p_flag <-- flag for hydrostatic pressure
113  * f_ext <-- exterior force generating the hydrostatic pressure
114  * grad --> gradient
115  *----------------------------------------------------------------------------*/
116 
117 void
119  bool use_previous_t,
120  int inc,
121  int hyd_p_flag,
122  cs_real_3_t f_ext[],
123  cs_real_3_t *restrict grad);
124 
125 /*----------------------------------------------------------------------------
126  * Compute cell gradient of scalar field or component of vector or
127  * tensor field.
128  *
129  * parameters:
130  * f <-- pointer to field
131  * use_previous_t <-- should we use values from the previous time step ?
132  * inc <-- if 0, solve on increment; 1 otherwise
133  * grad --> gradient
134  *----------------------------------------------------------------------------*/
135 
136 void
138  bool use_previous_t,
139  int inc,
140  cs_real_33_t *restrict grad);
141 
142 /*----------------------------------------------------------------------------
143  * Compute cell gradient of tensor field.
144  *
145  * parameters:
146  * f <-- pointer to field
147  * use_previous_t <-- should we use values from the previous time step ?
148  * inc <-- if 0, solve on increment; 1 otherwise
149  * grad --> gradient
150  *----------------------------------------------------------------------------*/
151 
152 void
154  bool use_previous_t,
155  int inc,
156  cs_real_63_t *restrict grad);
157 
158 /*----------------------------------------------------------------------------*/
168 /*----------------------------------------------------------------------------*/
169 
170 void
172  bool use_previous_t,
173  cs_lnum_t n_faces,
174  const cs_lnum_t *face_ids,
175  cs_real_t var_iprime[]);
176 
177 /*----------------------------------------------------------------------------*/
187 /*----------------------------------------------------------------------------*/
188 
189 void
191  bool use_previous_t,
192  cs_lnum_t n_faces,
193  const cs_lnum_t *face_ids,
194  cs_real_3_t var_iprime[]);
195 
196 /*----------------------------------------------------------------------------*/
207 /*----------------------------------------------------------------------------*/
208 
209 void
211  bool use_previous_t,
212  cs_lnum_t n_faces,
213  const cs_lnum_t *face_ids,
214  cs_real_6_t var_iprime[]);
215 
216 /*----------------------------------------------------------------------------
217  * Interpolate field values at a given set of points.
218  *
219  * parameters:
220  * f <-- pointer to field
221  * interpolation_type <-- interpolation type
222  * n_points <-- number of points at which interpolation
223  * is required
224  * point_location <-- location of points in mesh elements
225  * (based on the field location)
226  * point_coords <-- point coordinates
227  * val --> interpolated values
228  *----------------------------------------------------------------------------*/
229 
230 void
232  cs_field_interpolate_t interpolation_type,
233  cs_lnum_t n_points,
234  const cs_lnum_t point_location[],
235  const cs_real_3_t point_coords[],
236  cs_real_t *val);
237 
238 /*----------------------------------------------------------------------------*/
249 /*----------------------------------------------------------------------------*/
250 
251 void
253  cs_halo_type_t halo_type,
254  cs_real_t *local_max,
255  cs_real_t *local_min);
256 
257 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 
267 void
269  const cs_real_t mean);
270 
271 /*----------------------------------------------------------------------------*/
280 /*----------------------------------------------------------------------------*/
281 
282 void
284  cs_halo_type_t halo_type);
285 
286 /*----------------------------------------------------------------------------*/
287 
289 
290 #endif /* __CS_FIELD_OPERATOR_H__ */
#define restrict
Definition: cs_defs.h:139
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:334
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:336
#define END_C_DECLS
Definition: cs_defs.h:515
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:343
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:351
void cs_field_local_extrema_scalar(int f_id, cs_halo_type_t halo_type, cs_real_t *local_max, cs_real_t *local_min)
Find local extrema of a given scalar field at each cell.
Definition: cs_field_operator.c:1456
cs_field_interpolate_t
Definition: cs_field_operator.h:54
@ CS_FIELD_INTERPOLATE_MEAN
Definition: cs_field_operator.h:56
@ CS_FIELD_INTERPOLATE_GRADIENT
Definition: cs_field_operator.h:57
void cs_field_gradient_scalar_array(int f_id, int inc, const cs_real_t bc_coeff_a[], const cs_real_t bc_coeff_b[], cs_real_t var[], cs_real_3_t grad[])
Compute cell gradient of scalar array using parameters associated with a given field.
Definition: cs_field_operator.c:580
void cs_field_gradient_vector(const cs_field_t *f, bool use_previous_t, int inc, cs_real_33_t *restrict grad)
Compute cell gradient of vector field.
Definition: cs_field_operator.c:761
void cs_field_gradient_boundary_iprime_scalar(const cs_field_t *f, bool use_previous_t, cs_lnum_t n_faces, const cs_lnum_t *face_ids, cs_real_t var_iprime[])
Compute the values of a scalar field at boundary face I' positions.
Definition: cs_field_operator.c:933
void cs_field_gradient_boundary_iprime_vector(const cs_field_t *f, bool use_previous_t, cs_lnum_t n_faces, const cs_lnum_t *face_ids, cs_real_3_t var_iprime[])
Compute the values of a vector field at boundary face I' positions.
Definition: cs_field_operator.c:1103
void cs_field_gradient_scalar(const cs_field_t *f, bool use_previous_t, int inc, cs_real_3_t *restrict grad)
Compute cell gradient of scalar field or component of vector or tensor field.
Definition: cs_field_operator.c:470
void cs_field_synchronize(cs_field_t *f, cs_halo_type_t halo_type)
Synchronize current parallel and periodic field values.
Definition: cs_field_operator.c:1539
void cs_field_set_volume_average(cs_field_t *f, const cs_real_t mean)
Shift field values in order to set its spatial average to a given value.
Definition: cs_field_operator.c:1499
void cs_field_gradient_potential(const cs_field_t *f, bool use_previous_t, int inc, int hyd_p_flag, cs_real_3_t f_ext[], cs_real_3_t *restrict grad)
Compute cell gradient of scalar field or component of vector or tensor field.
Definition: cs_field_operator.c:649
void cs_field_gradient_boundary_iprime_tensor(const cs_field_t *f, bool use_previous_t, cs_lnum_t n_faces, const cs_lnum_t *face_ids, cs_real_6_t var_iprime[])
Compute the values of a symmetric tensor field at boundary face I' positions.
Definition: cs_field_operator.c:1265
void cs_field_interpolate(cs_field_t *f, cs_field_interpolate_t interpolation_type, cs_lnum_t n_points, const cs_lnum_t point_location[], const cs_real_3_t point_coords[], cs_real_t *val)
Interpolate field values at a given set of points.
Definition: cs_field_operator.c:1412
void cs_field_gradient_tensor(const cs_field_t *f, bool use_previous_t, int inc, cs_real_63_t *restrict grad)
Compute cell gradient of tensor field.
Definition: cs_field_operator.c:861
cs_halo_type_t
Definition: cs_halo.h:56
Field descriptor.
Definition: cs_field.h:131