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