9.2
general documentation
cs_cdofb_vecteq.h
Go to the documentation of this file.
1#ifndef CS_CDOFB_VECTEQ_H
2#define CS_CDOFB_VECTEQ_H
3
4/*============================================================================
5 * Build an algebraic CDO face-based system for unsteady convection/diffusion
6 * reaction of vector-valued equations with source terms
7 *============================================================================*/
8
9/*
10 This file is part of code_saturne, a general-purpose CFD tool.
11
12 Copyright (C) 1998-2026 EDF S.A.
13
14 This program is free software; you can redistribute it and/or modify it under
15 the terms of the GNU General Public License as published by the Free Software
16 Foundation; either version 2 of the License, or (at your option) any later
17 version.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 details.
23
24 You should have received a copy of the GNU General Public License along with
25 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26 Street, Fifth Floor, Boston, MA 02110-1301, USA.
27*/
28
29/*----------------------------------------------------------------------------*/
30
31#include "base/cs_defs.h"
32
33/*----------------------------------------------------------------------------
34 * Standard C library headers
35 *----------------------------------------------------------------------------*/
36
37/*----------------------------------------------------------------------------
38 * Local headers
39 *----------------------------------------------------------------------------*/
40
41#include "alge/cs_matrix.h"
42#include "alge/cs_sles.h"
43#include "base/cs_base.h"
44#include "base/cs_field.h"
45#include "base/cs_restart.h"
46#include "base/cs_time_step.h"
47#include "cdo/cs_cdo_assembly.h"
48#include "cdo/cs_cdo_connect.h"
50#include "cdo/cs_cdofb_priv.h"
53#include "cdo/cs_source_term.h"
54#include "mesh/cs_mesh.h"
55
56/*============================================================================
57 * Macro definitions
58 *============================================================================*/
59
60/*============================================================================
61 * Type definitions
62 *============================================================================*/
63
64/* Algebraic system for CDO face-based discretization */
65
66typedef struct _cs_cdofb_t cs_cdofb_vecteq_t;
67
68/*============================================================================
69 * Static inline public function prototypes
70 *============================================================================*/
71
72/*----------------------------------------------------------------------------*/
87/*----------------------------------------------------------------------------*/
88
89static inline void
91 const cs_equation_param_t *eqp,
92 const cs_real_t t_eval,
93 const cs_real_t coef,
97 cs_cell_sys_t *csys)
98{
99 /* Reset the local contribution */
100
101 std::memset(csys->source, 0, csys->n_dofs * sizeof(cs_real_t));
102
104 (cs_xdef_t *const *)eqp->source_terms,
105 cm,
106 eqb->source_mask,
107 eqb->compute_source,
108 t_eval,
109 mass_hodge, /* Mass matrix context */
110 cb,
111 csys->source);
112
113 /* Only cell-DoFs are involved */
114
115 const short int _off = 3*cm->n_fc;
116 csys->rhs[_off ] += coef * csys->source[_off ];
117 csys->rhs[_off + 1] += coef * csys->source[_off + 1];
118 csys->rhs[_off + 2] += coef * csys->source[_off + 2];
119}
120
121/*============================================================================
122 * Public function prototypes
123 *============================================================================*/
124
125/*----------------------------------------------------------------------------*/
132/*----------------------------------------------------------------------------*/
133
134bool
136
137/*----------------------------------------------------------------------------*/
147/*----------------------------------------------------------------------------*/
148
149void
151 const cs_cdo_connect_t *connect,
152 const cs_time_step_t *time_step);
153
154/*----------------------------------------------------------------------------*/
161/*----------------------------------------------------------------------------*/
162
163void
165 cs_cell_builder_t **cb);
166
167/*----------------------------------------------------------------------------*/
172/*----------------------------------------------------------------------------*/
173
174void
176
177/*----------------------------------------------------------------------------*/
189/*----------------------------------------------------------------------------*/
190
191void *
193 int var_id,
194 int bflux_id,
196
197/*----------------------------------------------------------------------------*/
205/*----------------------------------------------------------------------------*/
206
207void *
209
210/*----------------------------------------------------------------------------*/
223/*----------------------------------------------------------------------------*/
224
225void
227 const int field_id,
228 const cs_mesh_t *mesh,
229 const cs_equation_param_t *eqp,
231 void *context);
232
233/*----------------------------------------------------------------------------*/
251/*----------------------------------------------------------------------------*/
252
253void
255 const cs_equation_param_t *eqp,
256 const cs_equation_builder_t *eqb,
257 const cs_real_t val_f_n[],
258 const cs_real_t val_c_n[],
259 const cs_real_t val_f_nm1[],
260 const cs_real_t val_c_nm1[],
261 cs_cell_sys_t *csys,
263
264/*----------------------------------------------------------------------------*/
279/*----------------------------------------------------------------------------*/
280
281void
283 const cs_equation_param_t *eqp,
284 const cs_equation_builder_t *eqb,
285 const cs_real_t nu,
286 const cs_real_t k,
287 const cs_real_t *uc,
288 cs_cell_sys_t *csys,
290 cs_lnum_t *icodcl_vel,
291 cs_real_t *rcodcl1_vel);
292
293/*----------------------------------------------------------------------------*/
304/*----------------------------------------------------------------------------*/
305
306void
308 const cs_mesh_t *mesh,
309 const cs_equation_param_t *eqp,
311 const cs_cdofb_vecteq_t *eqc);
312
313/*----------------------------------------------------------------------------*/
326/*----------------------------------------------------------------------------*/
327
328void
330 const cs_equation_builder_t *eqb,
331 const cs_cdofb_vecteq_t *eqc,
332 const cs_cell_mesh_t *cm,
333 cs_hodge_t *diff_hodge,
334 cs_cell_sys_t *csys,
336
337/*----------------------------------------------------------------------------*/
353/*----------------------------------------------------------------------------*/
354
355void
357 const cs_equation_builder_t *eqb,
358 const cs_cdofb_vecteq_t *eqc,
359 const cs_cell_mesh_t *cm,
361 cs_hodge_t *diff_hodge,
362 cs_cell_sys_t *csys,
364
365/*----------------------------------------------------------------------------*/
376/*----------------------------------------------------------------------------*/
377
378void
381 cs_real_t *rhs,
382 cs_cdofb_vecteq_t *eqc,
383 cs_cdo_assembly_t *asb);
384
385/*----------------------------------------------------------------------------*/
395/*----------------------------------------------------------------------------*/
396
397void
399 cs_field_t *fld,
400 cs_cdofb_vecteq_t *eqc,
401 bool cur2prev);
402
403/*----------------------------------------------------------------------------*/
416/*----------------------------------------------------------------------------*/
417
418void
420 const cs_mesh_t *mesh,
421 const int field_id,
422 const cs_equation_param_t *eqp,
424 void *context);
425
426/*----------------------------------------------------------------------------*/
439/*----------------------------------------------------------------------------*/
440
441void
443 const cs_mesh_t *mesh,
444 const int field_id,
445 const cs_equation_param_t *eqp,
447 void *context);
448
449/*----------------------------------------------------------------------------*/
462/*----------------------------------------------------------------------------*/
463
464void
465cs_cdofb_vecteq_solve_theta(bool cur2prev,
466 const cs_mesh_t *mesh,
467 const int field_id,
468 const cs_equation_param_t *eqp,
470 void *context);
471
472/*----------------------------------------------------------------------------*/
484/*----------------------------------------------------------------------------*/
485
489 void *context);
490
491/*----------------------------------------------------------------------------*/
500/*----------------------------------------------------------------------------*/
501
502void
505 void *context);
506
507/*----------------------------------------------------------------------------*/
515/*----------------------------------------------------------------------------*/
516
517void
520 void *context);
521
522/*----------------------------------------------------------------------------*/
535/*----------------------------------------------------------------------------*/
536
537cs_real_t *
539 bool previous);
540
541/*----------------------------------------------------------------------------*/
552/*----------------------------------------------------------------------------*/
553
554cs_real_t *
556 bool previous);
557
558/*----------------------------------------------------------------------------*/
567/*----------------------------------------------------------------------------*/
568
569void
571 const char *eqname,
572 void *scheme_context);
573
574/*----------------------------------------------------------------------------*/
583/*----------------------------------------------------------------------------*/
584
585void
587 const char *eqname,
588 void *scheme_context);
589
590#endif /* CS_CDOFB_VECTEQ_H */
Field descriptor.
Definition: cs_field.h:275
time step descriptor
Definition: cs_time_step.h:60
void cs_cdofb_vecteq_init_sharing(const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect, const cs_time_step_t *time_step)
Allocate work buffer and general structures related to CDO vector-valued face-based schemes....
Definition: cs_cdofb_vecteq.cpp:1921
cs_real_t * cs_cdofb_vecteq_get_cell_values(void *context, bool previous)
Get the computed values at mesh cells from the inverse operation w.r.t. the static condensation (DoF ...
Definition: cs_cdofb_vecteq.cpp:2599
void cs_cdofb_vecteq_assembly(const cs_cell_sys_t *csys, cs_cdo_system_block_t *block, cs_real_t *rhs, cs_cdofb_vecteq_t *eqc, cs_cdo_assembly_t *asb)
Perform the assembly stage for a vector-valued system obtained with CDO-Fb scheme.
Definition: cs_cdofb_vecteq.cpp:737
cs_cdo_balance_t * cs_cdofb_vecteq_balance(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Compute the balance for an equation over the full computational domain between time t_cur and t_cur +...
Definition: cs_cdofb_vecteq.cpp:1557
void * cs_cdofb_vecteq_free_context(void *data)
Destroy a cs_cdofb_vecteq_t structure.
Definition: cs_cdofb_vecteq.cpp:2337
void cs_cdofb_vecteq_update_cell_fields(cs_timer_counter_t *tce, cs_field_t *fld, cs_cdofb_vecteq_t *eqc, bool cur2prev)
Update the variables associated to cells in case of a CDO-Fb scheme. This has to be done after a reso...
Definition: cs_cdofb_vecteq.cpp:785
static void cs_cdofb_vecteq_sourceterm(const cs_cell_mesh_t *cm, const cs_equation_param_t *eqp, const cs_real_t t_eval, const cs_real_t coef, cs_hodge_t *mass_hodge, cs_cell_builder_t *cb, cs_equation_builder_t *eqb, cs_cell_sys_t *csys)
Compute the source term for a vector-valued CDO-Fb scheme and add it to the local rhs Mass matrix is ...
Definition: cs_cdofb_vecteq.h:90
void cs_cdofb_vecteq_init_cell_system(const cs_cell_mesh_t *cm, const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_real_t val_f_n[], const cs_real_t val_c_n[], const cs_real_t val_f_nm1[], const cs_real_t val_c_nm1[], cs_cell_sys_t *csys, cs_cell_builder_t *cb)
Initialize the local structure for the current cell The algebraic system for time t^{n+1} is going to...
Definition: cs_cdofb_vecteq.cpp:336
void cs_cdofb_vecteq_conv_diff_reac(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_cdofb_vecteq_t *eqc, const cs_cell_mesh_t *cm, cs_hodge_t *mass_hodge, cs_hodge_t *diff_hodge, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
Build the local matrices arising from the convection, diffusion, reaction terms in vector-valued CDO-...
Definition: cs_cdofb_vecteq.cpp:580
void cs_cdofb_vecteq_finalize_sharing(void)
Free work buffer and general structure related to CDO face-based schemes.
Definition: cs_cdofb_vecteq.cpp:1999
void cs_cdofb_vecteq_read_restart(cs_restart_t *restart, const char *eqname, void *scheme_context)
Read additional arrays (not defined as fields) but useful for the checkpoint/restart process.
Definition: cs_cdofb_vecteq.cpp:2657
cs_real_t * cs_cdofb_vecteq_get_face_values(void *context, bool previous)
Retrieve an array of values at mesh faces for the current context. The lifecycle of this array is man...
Definition: cs_cdofb_vecteq.cpp:2629
bool cs_cdofb_vecteq_is_initialized(void)
Check if the generic structures for building a CDO-Fb scheme are allocated.
Definition: cs_cdofb_vecteq.cpp:1900
void cs_cdofb_vecteq_solve_steady_state(bool cur2prev, const cs_mesh_t *mesh, const int field_id, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Build and solve the linear system arising from a vector steady-state diffusion equation with a CDO-Fb...
Definition: cs_cdofb_vecteq.cpp:826
void * cs_cdofb_vecteq_init_context(cs_equation_param_t *eqp, int var_id, int bflux_id, cs_equation_builder_t *eqb)
Initialize a cs_cdofb_vecteq_t structure storing data useful for building and managing such a scheme.
Definition: cs_cdofb_vecteq.cpp:2035
void cs_cdofb_vecteq_write_restart(cs_restart_t *restart, const char *eqname, void *scheme_context)
Write additional arrays (not defined as fields) but useful for the checkpoint/restart process.
Definition: cs_cdofb_vecteq.cpp:2746
void cs_cdofb_vecteq_solve_implicit(bool cur2prev, const cs_mesh_t *mesh, const int field_id, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Build and solve the linear system arising from a vector diffusion equation with a CDO-Fb scheme and a...
Definition: cs_cdofb_vecteq.cpp:1031
void cs_cdofb_vecteq_extra_post(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Predefined extra-operations related to this equation.
Definition: cs_cdofb_vecteq.cpp:2538
void cs_cdofb_vecteq_init_values(cs_real_t t_eval, const int field_id, const cs_mesh_t *mesh, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Set the initial values of the variable field taking into account the boundary conditions....
Definition: cs_cdofb_vecteq.cpp:2376
void cs_cdofb_vecteq_diffusion(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_cdofb_vecteq_t *eqc, const cs_cell_mesh_t *cm, cs_hodge_t *diff_hodge, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
Build the local matrices arising from the diffusion term in the vector-valued CDO-Fb schemes.
Definition: cs_cdofb_vecteq.cpp:513
void cs_cdofb_vecteq_current_to_previous(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Operate a current to previous operation for the field associated to this equation and potentially for...
Definition: cs_cdofb_vecteq.cpp:2507
void cs_cdofb_vecteq_get(cs_cell_sys_t **csys, cs_cell_builder_t **cb)
Retrieve work buffers used for building a CDO system cellwise.
Definition: cs_cdofb_vecteq.cpp:1982
void cs_cdofb_vecteq_setup(cs_real_t t_eval, const cs_mesh_t *mesh, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, const cs_cdofb_vecteq_t *eqc)
Set the boundary conditions known from the settings Define an indirection array for the enforcement o...
Definition: cs_cdofb_vecteq.cpp:282
void cs_cdofb_vecteq_init_turb_bc(const cs_cell_mesh_t *cm, const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_real_t nu, const cs_real_t k, const cs_real_t *uc, cs_cell_sys_t *csys, cs_cell_builder_t *cb, cs_lnum_t *icodcl_vel, cs_real_t *rcodcl1_vel)
Initialize the modelled wall BC related coefficients.
Definition: cs_cdofb_vecteq.cpp:440
void cs_cdofb_vecteq_solve_theta(bool cur2prev, const cs_mesh_t *mesh, const int field_id, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Build and solve the linear system arising from a vector diffusion equation with a CDO-Fb scheme and a...
Definition: cs_cdofb_vecteq.cpp:1272
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
@ k
Definition: cs_field_pointer.h:68
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:91
void cs_source_term_compute_cellwise(const int n_source_terms, cs_xdef_t *const *source_terms, const cs_cell_mesh_t *cm, const cs_mask_t *source_mask, cs_source_term_cellwise_t *compute_source[], cs_real_t time_eval, void *input, cs_cell_builder_t *cb, cs_real_t *result)
Compute the local contributions of source terms in a cell.
Definition: cs_source_term.cpp:1001
Definition: mesh.f90:26
Definition: cs_cdofb_priv.h:47
cs_hodge_t ** mass_hodge
Definition: cs_cdofb_priv.h:100
Definition: cs_cdo_toolbox.h:64
Definition: cs_cdo_connect.h:57
Definition: cs_cdo_quantities.h:142
Definition: cs_cdo_system.h:331
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
short int n_fc
Definition: cs_cdo_local.h:277
Set of arrays and local (small) dense matrices related to a mesh cell This is a key structure for bui...
Definition: cs_cdo_local.h:163
double * source
Definition: cs_cdo_local.h:173
double * rhs
Definition: cs_cdo_local.h:172
int n_dofs
Definition: cs_cdo_local.h:167
Store common elements used when building an algebraic system related to an equation.
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:190
cs_xdef_t ** source_terms
Definition: cs_equation_param.h:765
int n_source_terms
Definition: cs_equation_param.h:764
Structure associated to a discrete Hodge operator *.
Definition: cs_hodge.h:179
Definition: cs_mesh.h:85
Definition: cs_timer.h:51
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:156