9.2
general documentation
cs_basis_func.h
Go to the documentation of this file.
1#ifndef CS_BASIS_FUNC_H
2#define CS_BASIS_FUNC_H
3
4/*============================================================================
5 * Build a set of basis functions for cells and faces and cell gradients
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 "cdo/cs_cdo_local.h"
35#include "cdo/cs_quadrature.h"
36
37/*============================================================================
38 * Macro definitions
39 *============================================================================*/
40
41/* Default basis function are rescale and modified according to the
42 geometrical inertia tensor of the related entity unless a flag "monomial"
43 is set */
44
45#define CS_BASIS_FUNC_MONOMIAL (1 << 0) /* 1: Use mononial basis functions */
46#define CS_BASIS_FUNC_GRADIENT (1 << 1) /* 2: Basis functions for gradient */
47
48/*============================================================================
49 * Type definitions
50 *============================================================================*/
51
52/*----------------------------------------------------------------------------*/
61/*----------------------------------------------------------------------------*/
62
63typedef void
64(cs_basis_func_eval_all_at_point_t) (const void *bf,
65 const cs_real_t coords[3],
66 cs_real_t *eval);
67
68/*----------------------------------------------------------------------------*/
79/*----------------------------------------------------------------------------*/
80
81typedef void
82(cs_basis_func_eval_at_point_t) (const void *bf,
83 const cs_real_t coords[3],
84 short int start,
85 short int end,
86 cs_real_t *eval);
87
88/*----------------------------------------------------------------------------*/
98/*----------------------------------------------------------------------------*/
99
100typedef void
101(cs_basis_func_setup_t) (void *pbf,
102 const cs_cell_mesh_t *cm,
103 const short int id,
104 const cs_real_t center[3],
106
107/*----------------------------------------------------------------------------*/
116/*----------------------------------------------------------------------------*/
117
118typedef void
120 const cs_cell_mesh_t *cm,
121 const short int id);
122
123/*----------------------------------------------------------------------------*/
130/*----------------------------------------------------------------------------*/
131
132typedef void
134
135/*----------------------------------------------------------------------------*/
147/*----------------------------------------------------------------------------*/
148
149typedef void
150(cs_basis_func_project_t) (const void *pbf,
151 const cs_real_t *array,
152 cs_real_t *dof);
153
154/*----------------------------------------------------------------------------*/
161/*----------------------------------------------------------------------------*/
162
163typedef void
164(cs_basis_func_dump_proj_t) (const void *pbf);
165
166
167/* Structure storing information to build and use a set of basis functions
168 *
169 * - When dealing with volumetric basis fucntions (eg cell- or grad-basis),
170 * the functions are ordered as follows:
171 * 1, x, y, z, xx, xy, xz, yy, yz, zz
172 * - When dealing with face-basis fucntions the functions are ordered as
173 * follows:
174 * 1, x, y, xx, xy, yy
175 */
176
177typedef struct {
178
179 cs_flag_t flag; // metadata
180 short int poly_order; // max. polynomial order of the basis
181 short int dim; // 2D or 3D associated geometrical entities
182 int size; // number of elementary basis functions
183
184 cs_real_t phi0; // constant basis function
185 cs_nvec3_t *axis; // over_diam * main axis of the entity
186 cs_real_3_t center; // center used for rescaling
187
188 /* For poly_order > 1 we store the degree related to each monone for
189 each basis function */
191 short int *deg; /* size = n_deg_elts * dim */
192
193 /* Function used for setting up the quantities used for defining
194 the set of basis functions */
196
197 /* Function used for evaluating basis functions on a set of points */
200
201 /* Projector is a mass matrix related to the basis function */
202 cs_sdm_t *projector;
205
206 /* Modified Cholesky factorization. To perform the inversion agains a set
207 of right-hand sides */
212
213 /* Quadrature function to use for computing integral over o volume (tet) or
214 on a surface (tria) */
219
221
222/*============================================================================
223 * Static inline public function prototypes
224 *============================================================================*/
225
226/*----------------------------------------------------------------------------*/
234/*----------------------------------------------------------------------------*/
235
236static inline short int
238{
239 if (bf == NULL)
240 return -1;
241 else
242 return bf->poly_order;
243}
244
245/*============================================================================
246 * Public function prototypes
247 *============================================================================*/
248
249/*----------------------------------------------------------------------------*/
250/*
251 * \brief Allocate a cs_basis_func_t structure
252 *
253 * \param[in] flag metadata related to the way of building basis functions
254 * \param[in] k polynomial order
255 * \param[in] dim 2 or 3 w.r.t. the geometrical dimension
256 *
257 * \return a pointer to the new cs_basis_func_t
258 */
259/*----------------------------------------------------------------------------*/
260
263 short int k,
264 short int dim);
265
266/*----------------------------------------------------------------------------*/
267/*
268 * \brief Allocate a cs_basis_func_t structure which is associated to an
269 * existing set of basis functions.
270 * Up to now, only cell basis functions are handled.
271 * Building a projection matrix is not possible in this case.
272 *
273 * \param[in] ref set of basis function used as a reference
274 *
275 * \return a pointer to the new cs_basis_func_t for gradient of the current
276 * basis functions
277 */
278/*----------------------------------------------------------------------------*/
279
282
283/*----------------------------------------------------------------------------*/
284/*
285 * \brief Copy the center and the different axis from the reference basis
286 * Up to now, only cell basis functions are handled.
287 *
288 * \param[in] ref set of basis function used as a reference
289 * \param[in, out] rcv set of basis function where members are set
290 */
291/*----------------------------------------------------------------------------*/
292
293void
295 cs_basis_func_t *rcv);
296
297/*----------------------------------------------------------------------------*/
298/*
299 * \brief Free a cs_basis_func_t structure
300 *
301 * \param[in, out] pbf pointer to the cs_basis_func_t structure to free
302 *
303 * \return a null pointer
304 */
305/*----------------------------------------------------------------------------*/
306
309
310/*----------------------------------------------------------------------------*/
311/*
312 * \brief Set options for basis functions when using HHO schemes
313 *
314 * \param[in] face_flag options related to face basis functinos
315 * \param[in] cell_flag options related to cell basis functinos
316 */
317/*----------------------------------------------------------------------------*/
318
319void
321 cs_flag_t cell_flag);
322
323/*----------------------------------------------------------------------------*/
324/*
325 * \brief Get options for basis functions when using HHO schemes
326 *
327 * \param[out] face_flag pointer to options related to face basis functinos
328 * \param[out] cell_flag pointer to options related to cell basis functinos
329 */
330/*----------------------------------------------------------------------------*/
331
332void
334 cs_flag_t *cell_flag);
335
336/*----------------------------------------------------------------------------*/
337/*
338 * \brief Dump a cs_basis_func_t structure
339 *
340 * \param[in] pbf pointer to the cs_basis_func_t structure to dump
341 */
342/*----------------------------------------------------------------------------*/
343
344void
346
347/*----------------------------------------------------------------------------*/
348/*
349 * \brief Print a cs_basis_func_t structure
350 * Print into the file f if given otherwise open a new file named
351 * fname if given otherwise print into the standard output
352 *
353 * \param[in] fp pointer to a file structure or null
354 * \param[in] fname filename or null
355 * \param[in] pbf pointer to the cs_basis_func_t structure to dump
356 */
357/*----------------------------------------------------------------------------*/
358
359void
360cs_basis_func_fprintf(FILE *fp,
361 const char *fname,
362 const cs_basis_func_t *pbf);
363
364#endif /* CS_BASIS_FUNC_H */
void cs_basis_func_set_hho_flag(cs_flag_t face_flag, cs_flag_t cell_flag)
Set options for basis functions when using HHO schemes.
Definition: cs_basis_func.cpp:2696
void cs_basis_func_dump(const cs_basis_func_t *pbf)
Dump a cs_basis_func_t structure.
Definition: cs_basis_func.cpp:2729
static short int cs_basis_func_get_poly_order(const cs_basis_func_t *bf)
Get the polynomial order of the given basis.
Definition: cs_basis_func.h:237
void() cs_basis_func_project_t(const void *pbf, const cs_real_t *array, cs_real_t *dof)
Generic prototype for projecting an array on the polynomial basis function. This results from the app...
Definition: cs_basis_func.h:150
cs_basis_func_t * cs_basis_func_create(cs_flag_t flag, short int k, short int dim)
Allocate a cs_basis_func_t structure.
Definition: cs_basis_func.cpp:2360
cs_basis_func_t * cs_basis_func_grad_create(const cs_basis_func_t *ref)
Allocate a cs_basis_func_t structure which is associated to an existing set of basis functions....
Definition: cs_basis_func.cpp:2557
void() cs_basis_func_dump_proj_t(const void *pbf)
Generic prototype for printing the projector matrix related to the given basis function.
Definition: cs_basis_func.h:164
void cs_basis_func_copy_setup(const cs_basis_func_t *ref, cs_basis_func_t *rcv)
Copy the center and the different axis from the reference basis Up to now, only cell basis functions ...
Definition: cs_basis_func.cpp:2642
void cs_basis_func_get_hho_flag(cs_flag_t *face_flag, cs_flag_t *cell_flag)
Get options for basis functions when using HHO schemes.
Definition: cs_basis_func.cpp:2713
void() cs_basis_func_compute_proj_t(void *pbf, const cs_cell_mesh_t *cm, const short int id)
Generic prototype for computing the projector to the space spanned by the basis functions.
Definition: cs_basis_func.h:119
void() cs_basis_func_eval_all_at_point_t(const void *bf, const cs_real_t coords[3], cs_real_t *eval)
Generic prototype for evaluating all basis functions at a given point.
Definition: cs_basis_func.h:64
void() cs_basis_func_compute_facto_t(void *pbf)
Generic prototype for computing the Modified Choloesky factorization of the projection matrix (mass m...
Definition: cs_basis_func.h:133
cs_basis_func_t * cs_basis_func_free(cs_basis_func_t *pbf)
Free a cs_basis_func_t structure.
Definition: cs_basis_func.cpp:2668
void cs_basis_func_fprintf(FILE *fp, const char *fname, const cs_basis_func_t *pbf)
Print a cs_basis_func_t structure Print into the file f if given otherwise open a new file named fnam...
Definition: cs_basis_func.cpp:2770
void() cs_basis_func_eval_at_point_t(const void *bf, const cs_real_t coords[3], short int start, short int end, cs_real_t *eval)
Generic prototype for evaluating a set of basis functions at a given point.
Definition: cs_basis_func.h:82
void() cs_basis_func_setup_t(void *pbf, const cs_cell_mesh_t *cm, const short int id, const cs_real_t center[3], cs_cell_builder_t *cb)
Generic prototype for setting up a set of basis functions.
Definition: cs_basis_func.h:101
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
unsigned short int cs_flag_t
Definition: cs_defs.h:334
@ k
Definition: cs_field_pointer.h:68
void() cs_quadrature_tria_t(const cs_real_3_t v1, const cs_real_3_t v2, const cs_real_3_t v3, double area, cs_real_3_t gpts[], double *weights)
Generic functoin pointer to compute the quadrature points for a triangle.
Definition: cs_quadrature.h:125
void() cs_quadrature_tet_t(const cs_real_3_t v1, const cs_real_3_t v2, const cs_real_3_t v3, const cs_real_3_t v4, double vol, cs_real_3_t gpts[], double weights[])
Generic function to compute the quadrature points in a tetrehedra.
Definition: cs_quadrature.h:147
Definition: cs_basis_func.h:177
cs_nvec3_t * axis
Definition: cs_basis_func.h:185
cs_basis_func_compute_facto_t * compute_factorization
Definition: cs_basis_func.h:208
cs_basis_func_dump_proj_t * dump_projector
Definition: cs_basis_func.h:204
int size
Definition: cs_basis_func.h:182
short int * deg
Definition: cs_basis_func.h:191
int n_deg_elts
Definition: cs_basis_func.h:190
cs_basis_func_setup_t * setup
Definition: cs_basis_func.h:195
cs_basis_func_eval_all_at_point_t * eval_all_at_point
Definition: cs_basis_func.h:198
cs_basis_func_compute_proj_t * compute_projector
Definition: cs_basis_func.h:203
cs_basis_func_project_t * project
Definition: cs_basis_func.h:209
cs_real_t * facto
Definition: cs_basis_func.h:210
int n_gpts_tria
Definition: cs_basis_func.h:215
cs_flag_t flag
Definition: cs_basis_func.h:179
short int poly_order
Definition: cs_basis_func.h:180
cs_real_t phi0
Definition: cs_basis_func.h:184
short int dim
Definition: cs_basis_func.h:181
cs_basis_func_eval_at_point_t * eval_at_point
Definition: cs_basis_func.h:199
int n_gpts_tetra
Definition: cs_basis_func.h:217
cs_sdm_t * projector
Definition: cs_basis_func.h:202
cs_real_3_t center
Definition: cs_basis_func.h:186
cs_quadrature_tria_t * quadrature_tria
Definition: cs_basis_func.h:216
int facto_max_size
Definition: cs_basis_func.h:211
cs_quadrature_tet_t * quadrature_tetra
Definition: cs_basis_func.h:218
Set of local and temporary buffers.
Definition: cs_cdo_local.h:56
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:242
Definition: cs_defs.h:390