9.2
general documentation
cs_matrix_building.h
Go to the documentation of this file.
1#ifndef CS_MATRIX_BUILDING_H
2#define CS_MATRIX_BUILDING_H
3
4/*============================================================================
5 * Matrix building
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#include "base/cs_defs.h"
31#include "base/cs_math.h"
32#include "base/cs_parameters.h" // for BC types
33
34/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "base/cs_base.h"
39#include "base/cs_halo.h"
40
41/*----------------------------------------------------------------------------*/
42
43/*=============================================================================
44 * Local Macro definitions
45 *============================================================================*/
46
47/*============================================================================
48 * Type definition
49 *============================================================================*/
50
51/*============================================================================
52 * Global variables
53 *============================================================================*/
54
55/*=============================================================================
56 * Public function prototypes
57 *============================================================================*/
58
59/*----------------------------------------------------------------------------*/
60/*
61 * \brief Build the diagonal of the advection/diffusion matrix
62 * for determining the variable time step, flow, Fourier.
63 *
64 * \param[in, out] a pointer to matrix structure
65 * \param[in] f pointer to field, or null
66 * \param[in] iconvp indicator
67 * - 1 advection
68 * - 0 otherwise
69 * \param[in] idiffp indicator
70 * - 1 diffusion
71 * - 0 otherwise
72 * \param[in] ndircp number of Dirichlet BCs
73 * \param[in] thetap time scheme parameter
74 * \param[in] relaxp relaxation coefficient (if < 1)
75 * \param[in] imucp 1 for temperature (with Cp), 0 otherwise
76 * \param[in] bc_coeffs boundary condition structure
77 * \param[in] rovsdt implicit terms (rho / dt)
78 * \param[in] i_massflux mass flux at interior faces
79 * \param[in] b_massflux mass flux at border faces
80 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
81 * at interior faces for the matrix
82 * \param[in] b_visc \f$ S_\fib \f$
83 * at border faces for the matrix
84 * \param[in] xcpp Cp per cell, or null
85 */
86/*----------------------------------------------------------------------------*/
87
88void
90 const cs_field_t *f,
91 int iconvp,
92 int idiffp,
93 int ndircp,
94 double thetap,
95 double relaxp,
96 int imucpp,
97 const cs_field_bc_coeffs_t *bc_coeffs,
98 const cs_real_t rovsdt[],
99 const cs_real_t i_massflux[],
100 const cs_real_t b_massflux[],
101 const cs_real_t i_visc[],
102 const cs_real_t b_visc[],
103 const cs_real_t xcpp[]);
104
105/*----------------------------------------------------------------------------*/
135/*----------------------------------------------------------------------------*/
136
137template <cs_lnum_t stride>
138void
140(
141 cs_matrix_t *a,
142 const cs_field_t *f,
143 int iconvp,
144 int idiffp,
145 int tensorial_diffusion,
146 int ndircp,
147 cs_lnum_t eb_size,
148 double thetap,
149 double relaxp,
150 const cs_field_bc_coeffs_t *bc_coeffs,
151 const cs_real_t fimp[][stride][stride],
152 const cs_real_t i_massflux[],
153 const cs_real_t b_massflux[],
154 const cs_real_t i_visc[],
155 const cs_real_t b_visc[]
156);
157
158/*----------------------------------------------------------------------------
159 * Compute legacy matrix coefficients
160 *----------------------------------------------------------------------------*/
161
162void
163cs_matrix_wrapper(int iconvp,
164 int idiffp,
165 int ndircp,
166 int isym,
167 double thetap,
168 int imucpp,
169 const cs_field_bc_coeffs_t *bc_coeffs,
170 const cs_real_t rovsdt[],
171 const cs_real_t i_massflux[],
172 const cs_real_t b_massflux[],
173 const cs_real_t i_visc[],
174 const cs_real_t b_visc[],
175 const cs_real_t xcpp[],
176 cs_real_t da[],
177 cs_real_t xa[]);
178
179/*----------------------------------------------------------------------------
180 * Compute legacy matrix coefficients
181 *----------------------------------------------------------------------------*/
182
183template <cs_lnum_t stride>
184void
185cs_matrix_wrapper(int iconvp,
186 int idiffp,
187 int tensorial_diffusion,
188 int ndircp,
189 int isym,
190 cs_lnum_t eb_size,
191 double thetap,
192 const cs_field_bc_coeffs_t *bc_coeffs_v,
193 const cs_real_t fimp[][stride][stride],
194 const cs_real_t i_massflux[],
195 const cs_real_t b_massflux[],
196 const cs_real_t i_visc[],
197 const cs_real_t b_visc[],
198 cs_real_t da[][stride][stride],
199 cs_real_t xa[]);
200
201/*----------------------------------------------------------------------------*/
202/*
203 * \brief Build the diagonal of the advection/diffusion matrix
204 * for determining the variable time step, flow, Fourier.
205 *
206 * \param[in] m pointer to mesh structure
207 * \param[in] iconvp indicator
208 * - 1 advection
209 * - 0 otherwise
210 * \param[in] idiffp indicator
211 * - 1 diffusion
212 * - 0 otherwise
213 * \param[in] isym indicator
214 * - 1 symmetric matrix
215 * - 2 non symmmetric matrix
216 * \param[in] bc_coeffs boundary condition structure for the variable
217 * \param[in] i_massflux mass flux at interior faces
218 * \param[in] b_massflux mass flux at border faces
219 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$
220 * at interior faces for the matrix
221 * \param[in] b_visc \f$ S_\fib \f$
222 * at border faces for the matrix
223 * \param[out] da diagonal part of the matrix
224 */
225/*----------------------------------------------------------------------------*/
226
227void
229 int iconvp,
230 int idiffp,
231 int isym,
232 const cs_field_bc_coeffs_t *bc_coeffs,
233 const cs_real_t i_massflux[],
234 const cs_real_t b_massflux[],
235 const cs_real_t i_visc[],
236 const cs_real_t b_visc[],
237 cs_real_t *da);
238
239/*----------------------------------------------------------------------------*/
240
241#endif /* CS_MATRIX_BUILDING_H */
Field boundary condition descriptor (for variables)
Definition: cs_field.h:107
Field descriptor.
Definition: cs_field.h:275
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
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:108
void cs_matrix_time_step(const cs_mesh_t *m, int iconvp, int idiffp, int isym, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_t *da)
void cs_matrix_wrapper(int iconvp, int idiffp, int ndircp, int isym, double thetap, int imucpp, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t rovsdt[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t xcpp[], cs_real_t da[], cs_real_t xa[])
Definition: cs_matrix_building.cpp:2660
void cs_matrix_compute_coeffs(cs_matrix_t *a, const cs_field_t *f, int iconvp, int idiffp, int ndircp, double thetap, double relaxp, int imucpp, const cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t rovsdt[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t xcpp[])
Build the diagonal of the advection/diffusion matrix for determining the variable time step,...
Definition: cs_matrix_building.cpp:1949
Definition: cs_mesh.h:85