9.1
general documentation
cs_gradient_boundary.h
Go to the documentation of this file.
1#ifndef CS_GRADIENT_BOUNDARY_H
2#define CS_GRADIENT_BOUNDARY_H
3
4/*============================================================================
5 * Gradient reconstruction at boundaries.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2025 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 "base/cs_base.h"
35#include "base/cs_dispatch.h"
36#include "base/cs_field.h"
37#include "base/cs_halo.h"
38#include "mesh/cs_mesh.h"
40
41/*----------------------------------------------------------------------------*/
42
43#ifdef __cplusplus
44
45/*=============================================================================
46 * Local Macro definitions
47 *============================================================================*/
48
49/*============================================================================
50 * Type definition
51 *============================================================================*/
52
53/*============================================================================
54 * Global variables
55 *============================================================================*/
56
57/*============================================================================
58 * Public function prototypes
59 *============================================================================*/
60
61/*----------------------------------------------------------------------------*/
62/*
63 * \brief Compute the values of a scalar at boundary face I' positions
64 * using least-squares interpolation.
65 *
66 * This assumes ghost cell values for the variable (var) are up-to-date.
67 *
68 * A simple limiter is applied to ensure the maximum principle is preserved
69 * (using non-reconstructed values in case of non-homogeneous Neumann
70 * conditions).
71 *
72 * \remark
73 *
74 * To compute the values at I', we only need the gradient along II', so
75 * in most cases, we could simply assume a Neumann BC for a given face.
76 *
77 * We still use the provided BC's when possible, for the following cases:
78 * - Given a non-uniform Dirichlet condition and a non-orthogonal mesh,
79 * the Dirichlet values at face centers (shifted by II' relative to I')
80 * can convey a portion of the information of the gradient along II'.
81 * - For cells with multiple boundary faces, information from faces whose
82 * normals are not orthogonal to II' can also provide a significant
83 * contribution to the normal.
84 *
85 * \param[in] ctx Reference to dispatch context
86 * \param[in] m pointer to associated mesh structure
87 * \param[in] fvq pointer to associated finite volume quantities
88 * \param[in] n_faces number of faces at which to compute values
89 * \param[in] face_ids ids of boundary faces at which to compute
90 * values, or null for all
91 * \param[in] halo_type halo (cell neighborhood) type
92 * \param[in] clip_coeff clipping (limiter) coefficient
93 * (no limiter if < 0)
94 * \param[in] hyd_p_flag flag for hydrostatic pressure
95 * \param[in] f_ext exterior force generating pressure
96 * \param[in] df_limiter diffusion clipping (limiter) field
97 * \param[in] bc_coeffs boundary condition structure, or null
98 * \param[in] c_weight cell variable weight, or null
99 * \param[in] var variable values et cell centers
100 * \param[out] var_iprime variable values et face iprime locations
101 * \param[out] var_iprime_lim limited variable values at face iprime locations
102 */
103/*----------------------------------------------------------------------------*/
104
105void
108 const cs_mesh_t *m,
109 const cs_mesh_quantities_t *fvq,
110 cs_lnum_t n_faces,
111 const cs_lnum_t *face_ids,
112 cs_halo_type_t halo_type,
113 double clip_coeff,
114 int hyd_p_flag,
115 cs_real_t f_ext[][3],
116 cs_real_t *df_limiter,
117 const cs_field_bc_coeffs_t *bc_coeffs,
118 const cs_real_t c_weight[],
119 const cs_real_t var[],
120 cs_real_t *var_iprime,
121 cs_real_t var_iprime_lim[]);
122
123/*----------------------------------------------------------------------------*/
124/*
125 * \brief Compute the values of a scalar at boundary face I' positions
126 * using least-squares interpolation with anisotropic weighting.
127 *
128 * This assumes ghost cell values for the variable (var) are up-to-date.
129 *
130 * A simple limiter is applied to ensure the maximum principle is preserved
131 * (using non-reconstructed values in case of non-homogeneous Neumann
132 * conditions).
133 *
134 * \remark The same remark applies as for \ref cs_gradient_boundary_iprime_lsq_s.
135 *
136 * \param[in] ctx Reference to dispatch context
137 * \param[in] m pointer to associated mesh structure
138 * \param[in] fvq pointer to associated finite volume quantities
139 * \param[in] n_faces number of faces at which to compute values
140 * \param[in] face_ids ids of boundary faces at which to compute
141 * values, or null for all
142 * \param[in] clip_coeff clipping (limiter) coefficient
143 * (no limiter if < 0)
144 * \param[in] hyd_p_flag flag for hydrostatic pressure
145 * \param[in] f_ext exterior force generating pressure
146 * \param[in] df_limiter diffusion clipping (limiter) field
147 * \param[in] bc_coeffs boundary condition structure
148 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$,
149 or nullptr
150 * \param[in] weighb boundary face weight for cells i in case
151 * of tensor diffusion, or nullptr
152 * \param[in] c_weight cell variable weight, or null
153 * \param[in] var variable values et cell centers
154 * \param[out] var_iprime variable values et face iprime locations
155 * \param[out] var_iprime_lim limited variable values at face iprime locations
156 */
157/*----------------------------------------------------------------------------*/
158
159void
162 const cs_mesh_t *m,
163 const cs_mesh_quantities_t *fvq,
164 cs_lnum_t n_faces,
165 const cs_lnum_t *face_ids,
166 double clip_coeff,
167 int hyd_p_flag,
168 cs_real_t f_ext[][3],
169 cs_real_t *df_limiter,
170 const cs_field_bc_coeffs_t *bc_coeffs,
171 cs_real_t viscel[][6],
172 const cs_real_t weighb[],
173 const cs_real_t c_weight[][6],
174 const cs_real_t var[],
175 cs_real_t *var_iprime,
176 cs_real_t var_iprime_lim[]);
177
178/*----------------------------------------------------------------------------*/
179/*
180 * \brief Compute the values of a vector at boundary face I' positions
181 * using least-squares interpolation.
182 *
183 * This assumes ghost cell values which might be used are already
184 * synchronized.
185 *
186 * A simple limiter is applied to ensure the maximum principle is preserved
187 * (using non-reconstructed values in case of non-homogeneous Neumann
188 * conditions).
189 *
190 * This function uses a local iterative approach to compute the cell gradient,
191 * as handling of the boundary condition terms b in higher dimensions
192 * would otherwise require solving higher-dimensional systems, often at
193 * a higher cost.
194 *
195 * \remark
196 *
197 * To compute the values at I', we only need the gradient along II', so
198 * in most cases, we could simply assume a Neuman BC.
199 *
200 * The same logic is applied as for \ref cs_gradient_boundary_iprime_lsq_s.
201 *
202 * \param[in] ctx Reference to dispatch context
203 * \param[in] m pointer to associated mesh structure
204 * \param[in] fvq pointer to associated finite volume quantities
205 * \param[in] n_faces number of faces at which to compute values
206 * \param[in] face_ids ids of boundary faces at which to compute
207 * values, or NULL for all
208 * \param[in] halo_type halo (cell neighborhood) type
209 * \param[in] b_clip_coeff boundary clipping (limiter) coefficient
210 * (no limiter if < 0)
211 * \param[in] df_limiter diffusion clipping (limiter) field
212 * (no limiter if nullptr)
213 * \param[in] bc_coeffs boundary condition structure, or NULL
214 * \param[in] c_weight cell variable weight, or NULL
215 * \param[in] var variable values at cell centers
216 * \param[out] var_iprime variable values at face iprime locations
217 * \param[out] var_iprime_lim limited variable values at face iprime locations
218 */
219/*----------------------------------------------------------------------------*/
220
221template <cs_lnum_t stride>
222void
225 const cs_mesh_t *m,
226 const cs_mesh_quantities_t *fvq,
227 cs_lnum_t n_faces,
228 const cs_lnum_t *face_ids,
229 cs_halo_type_t halo_type,
230 double b_clip_coeff,
231 cs_real_t *df_limiter,
232 const cs_field_bc_coeffs_t *bc_coeffs,
233 const cs_real_t c_weight[],
234 const cs_real_t var[][stride],
235 cs_real_t var_iprime[][stride],
236 cs_real_t var_iprime_lim[][stride]);
237
238/*----------------------------------------------------------------------------*/
239
240#endif /* cplusplus */
241
242#endif /* CS_GRADIENT_BOUNDARY */
Definition: cs_dispatch.h:1711
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:350
void cs_gradient_boundary_iprime_lsq_s_ani(cs_dispatch_context &ctx, const cs_mesh_t *m, const cs_mesh_quantities_t *fvq, cs_lnum_t n_faces, const cs_lnum_t *face_ids, double clip_coeff, int hyd_p_flag, cs_real_t f_ext[][3], cs_real_t *df_limiter, const cs_field_bc_coeffs_t *bc_coeffs, cs_real_t viscel[][6], const cs_real_t weighb[], const cs_real_t c_weight[][6], const cs_real_t var[], cs_real_t *var_iprime, cs_real_t var_iprime_lim[])
void cs_gradient_boundary_iprime_lsq_strided(cs_dispatch_context &ctx, const cs_mesh_t *m, const cs_mesh_quantities_t *fvq, cs_lnum_t n_faces, const cs_lnum_t *face_ids, cs_halo_type_t halo_type, double b_clip_coeff, cs_real_t *df_limiter, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t c_weight[], const cs_real_t var[][stride], cs_real_t var_iprime[][stride], cs_real_t var_iprime_lim[][stride])
Compute the values of a vector at boundary face I' positions using least-squares interpolation.
Definition: cs_gradient_boundary.cpp:1109
void cs_gradient_boundary_iprime_lsq_s(cs_dispatch_context &ctx, const cs_mesh_t *m, const cs_mesh_quantities_t *fvq, cs_lnum_t n_faces, const cs_lnum_t *face_ids, cs_halo_type_t halo_type, double clip_coeff, int hyd_p_flag, cs_real_t f_ext[][3], cs_real_t *df_limiter, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t c_weight[], const cs_real_t var[], cs_real_t *var_iprime, cs_real_t var_iprime_lim[])
cs_halo_type_t
Definition: cs_halo.h:57
Field boundary condition descriptor (for variables)
Definition: cs_field.h:120
Definition: cs_mesh_quantities.h:92
Definition: cs_mesh.h:85