8.3
general documentation
cs_macfb_vecteq.h
Go to the documentation of this file.
1#ifndef __CS_MACFB_VECTEQ_H__
2#define __CS_MACFB_VECTEQ_H__
3
4/*============================================================================
5 * Build an algebraic MAC 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-2024 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 "cs_defs.h"
32
33/*----------------------------------------------------------------------------
34 * Standard C library headers
35 *----------------------------------------------------------------------------*/
36
37/*----------------------------------------------------------------------------
38 * Local headers
39 *----------------------------------------------------------------------------*/
40
41#include "cs_base.h"
42#include "cs_cdo_assembly.h"
43#include "cs_cdo_connect.h"
44#include "cs_cdo_quantities.h"
45#include "cs_equation_builder.h"
46#include "cs_equation_param.h"
47#include "cs_field.h"
48#include "cs_macfb_priv.h"
49#include "cs_matrix.h"
50#include "cs_mesh.h"
51#include "cs_restart.h"
52#include "cs_sles.h"
53#include "cs_source_term.h"
54#include "cs_time_step.h"
55
56/*----------------------------------------------------------------------------*/
57
59
60/*============================================================================
61 * Macro definitions
62 *============================================================================*/
63
64/*============================================================================
65 * Type definitions
66 *============================================================================*/
67
68/* Algebraic system for MAC face-based discretization */
69
70typedef struct _cs_macfb_t cs_macfb_vecteq_t;
71
72/*============================================================================
73 * Static inline public function prototypes
74 *============================================================================*/
75
76/*============================================================================
77 * Public function prototypes
78 *============================================================================*/
79
80/*----------------------------------------------------------------------------*/
87/*----------------------------------------------------------------------------*/
88
90
91/*----------------------------------------------------------------------------*/
101/*----------------------------------------------------------------------------*/
102
104 const cs_cdo_connect_t *connect,
105 const cs_time_step_t *time_step);
106
107/*----------------------------------------------------------------------------*/
114/*----------------------------------------------------------------------------*/
115
117
118/*----------------------------------------------------------------------------*/
123/*----------------------------------------------------------------------------*/
124
126
127/*----------------------------------------------------------------------------*/
139/*----------------------------------------------------------------------------*/
140
142 int var_id,
143 int bflux_id,
145
146/*----------------------------------------------------------------------------*/
154/*----------------------------------------------------------------------------*/
155
156void *cs_macfb_vecteq_free_context(void *data);
157
158/*----------------------------------------------------------------------------*/
171/*----------------------------------------------------------------------------*/
172
174 const int field_id,
175 const cs_mesh_t *mesh,
176 const cs_equation_param_t *eqp,
178 void *context);
179
180/*----------------------------------------------------------------------------*/
197/*----------------------------------------------------------------------------*/
198
200 const cs_equation_param_t *eqp,
201 const cs_equation_builder_t *eqb,
202 const cs_real_t val_f_n[],
203 const cs_real_t val_f_nm1[],
204 cs_macfb_builder_t *macb,
205 cs_cell_sys_t *csys,
207
208/*----------------------------------------------------------------------------*/
219/*----------------------------------------------------------------------------*/
220
222 const cs_mesh_t *mesh,
223 const cs_equation_param_t *eqp,
225
226/*----------------------------------------------------------------------------*/
241/*----------------------------------------------------------------------------*/
242
244 const cs_cdo_quantities_t *quant,
245 const cs_equation_param_t *eqp,
246 const cs_equation_builder_t *eqb,
247 const cs_lnum_t c_id,
248 const cs_real_t vel_f_n[],
249 cs_cell_mesh_t *cm,
250 cs_macfb_builder_t *macb,
251 cs_cell_sys_t *csys,
253
254/*----------------------------------------------------------------------------*/
268/*----------------------------------------------------------------------------*/
269
271 const cs_equation_param_t *eqp,
272 cs_macfb_builder_t *macb,
273 const cs_real_t t_eval,
274 const cs_real_t coef,
277 cs_cell_sys_t *csys);
278
279/*----------------------------------------------------------------------------*/
291/*----------------------------------------------------------------------------*/
292
294 const cs_cell_mesh_t *cm,
295 const cs_macfb_builder_t *macb,
296 const cs_cell_builder_t *cb,
297 const cs_real_t dt,
298 cs_cell_sys_t *csys);
299
300/*----------------------------------------------------------------------------*/
313/*----------------------------------------------------------------------------*/
314
316 const cs_cell_mesh_t *cm,
317 const cs_macfb_builder_t *macb,
318 const cs_property_t *diff_pty,
319 cs_cell_sys_t *csys,
321
322/*----------------------------------------------------------------------------*/
334/*----------------------------------------------------------------------------*/
335
337 const cs_macfb_vecteq_t *eqc,
338 const cs_cell_mesh_t *cm,
339 const cs_macfb_builder_t *macb,
340 cs_cell_sys_t *csys,
342
343/*----------------------------------------------------------------------------*/
360/*----------------------------------------------------------------------------*/
361
363 const cs_equation_builder_t *eqb,
364 const cs_macfb_vecteq_t *eqc,
365 const cs_cell_mesh_t *cm,
366 const cs_macfb_builder_t *macb,
367 const cs_property_data_t *diff_pty,
368 cs_cell_sys_t *csys,
370
371/*----------------------------------------------------------------------------*/
381/*----------------------------------------------------------------------------*/
382
385 cs_real_t *rhs,
386 cs_cdo_assembly_t *asb);
387
388/*----------------------------------------------------------------------------*/
397/*----------------------------------------------------------------------------*/
398
400 cs_field_t *fld,
401 bool cur2prev);
402
403/*----------------------------------------------------------------------------*/
418/*----------------------------------------------------------------------------*/
419
421 const cs_mesh_t *mesh,
422 const int field_id,
423 const cs_equation_param_t *eqp,
425 void *context);
426
427/*----------------------------------------------------------------------------*/
440/*----------------------------------------------------------------------------*/
441
442void cs_macfb_vecteq_solve_theta(bool cur2prev,
443 const cs_mesh_t *mesh,
444 const int field_id,
445 const cs_equation_param_t *eqp,
447 void *context);
448
449/*----------------------------------------------------------------------------*/
458/*----------------------------------------------------------------------------*/
459
462 void *context);
463
464/*----------------------------------------------------------------------------*/
472/*----------------------------------------------------------------------------*/
473
476 void *context);
477
478/*----------------------------------------------------------------------------*/
491/*----------------------------------------------------------------------------*/
492
493cs_real_t *cs_macfb_vecteq_get_cell_values(void *context, bool previous);
494
495/*----------------------------------------------------------------------------*/
506/*----------------------------------------------------------------------------*/
507
508cs_real_t *cs_macfb_vecteq_get_face_values(void *context, bool previous);
509
510/*----------------------------------------------------------------------------*/
519/*----------------------------------------------------------------------------*/
520
522 const char *eqname,
523 void *scheme_context);
524
525/*----------------------------------------------------------------------------*/
534/*----------------------------------------------------------------------------*/
535
537 const char *eqname,
538 void *scheme_context);
539
540/*----------------------------------------------------------------------------*/
541
543
544#endif /* __CS_MACFB_VECTEQ_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
@ dt
Definition: cs_field_pointer.h:65
void cs_macfb_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_macfb_vecteq.cpp:1392
void cs_macfb_vecteq_setup(cs_real_t t_eval, const cs_mesh_t *mesh, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb)
Set the boundary conditions known from the settings Define an indirection array for the enforcement o...
Definition: cs_macfb_vecteq.cpp:305
void cs_macfb_vecteq_solve_steady_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 MAC-Fb scheme:
Definition: cs_macfb_vecteq.cpp:817
void cs_macfb_vecteq_update_fields(cs_timer_counter_t *tce, cs_field_t *fld, bool cur2prev)
Update the variables associated to cells in case of a MAC-fb scheme. This has to be done after a reso...
Definition: cs_macfb_vecteq.cpp:784
cs_real_t * cs_macfb_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_macfb_vecteq.cpp:1649
void cs_macfb_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_macfb_vecteq.cpp:1676
void cs_macfb_vecteq_sourceterm(const cs_cell_mesh_t *cm, const cs_equation_param_t *eqp, cs_macfb_builder_t *macb, const cs_real_t t_eval, const cs_real_t coef, cs_equation_builder_t *eqb, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Compute the source term for a vector-valued MAC scheme and add it to the local rhs.
Definition: cs_macfb_vecteq.cpp:511
void cs_macfb_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_f_nm1[], cs_macfb_builder_t *macb, 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_macfb_vecteq.cpp:348
void cs_macfb_vecteq_diffusion(const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, const cs_property_t *diff_pty, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
Build the local matrices arising from the diffusion term in the vector-valued MAC schemes.
Definition: cs_macfb_vecteq.cpp:556
void cs_macfb_vecteq_finalize_sharing(void)
Free work buffer and general structure related to CDO face-based schemes.
Definition: cs_macfb_vecteq.cpp:1074
void cs_macfb_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_macfb_vecteq.cpp:1559
cs_real_t * cs_macfb_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_macfb_vecteq.cpp:1620
void cs_macfb_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_macfb_vecteq.cpp:1764
void cs_macfb_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 MAC scheme and an i...
Definition: cs_macfb_vecteq.cpp:953
bool cs_macfb_vecteq_is_initialized(void)
Check if the generic structures for building a MAC scheme are allocated.
Definition: cs_macfb_vecteq.cpp:979
void cs_macfb_vecteq_advection(const cs_equation_param_t *eqp, const cs_macfb_vecteq_t *eqc, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
Build the local matrices arising from the convection term in the vector-valued MAC-Fb schemes.
Definition: cs_macfb_vecteq.cpp:595
void cs_macfb_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_macfb_vecteq.cpp:1528
void * cs_macfb_vecteq_init_context(cs_equation_param_t *eqp, int var_id, int bflux_id, cs_equation_builder_t *eqb)
Initialize a cs_macfb_vecteq_t structure storing data useful for building and managing such a scheme.
Definition: cs_macfb_vecteq.cpp:1110
void cs_macfb_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_macfb_vecteq.cpp:1000
void * cs_macfb_vecteq_free_context(void *data)
Destroy a cs_macfb_vecteq_t structure.
Definition: cs_macfb_vecteq.cpp:1355
void cs_macfb_vecteq_conv_diff_reac(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_macfb_vecteq_t *eqc, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, const cs_property_data_t *diff_pty, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
Build the local matrices arising from the convection, diffusion, reaction terms in vector-valued MAC-...
Definition: cs_macfb_vecteq.cpp:647
void cs_macfb_vecteq_get(cs_cell_sys_t **csys, cs_cell_builder_t **cb)
Retrieve work buffers used for building a CDO system cellwise.
Definition: cs_macfb_vecteq.cpp:1058
void cs_macfb_vecteq_init_build(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_lnum_t c_id, const cs_real_t vel_f_n[], cs_cell_mesh_t *cm, cs_macfb_builder_t *macb, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
Initialize stuctures for a gven cell.
Definition: cs_macfb_vecteq.cpp:443
void cs_macfb_vecteq_assembly(const cs_cell_sys_t *csys, cs_cdo_system_block_t *block, cs_real_t *rhs, cs_cdo_assembly_t *asb)
Perform the assembly stage for a vector-valued system obtained with MAC scheme.
Definition: cs_macfb_vecteq.cpp:749
void cs_macfb_vecteq_euler_implicit_term(const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, const cs_cell_builder_t *cb, const cs_real_t dt, cs_cell_sys_t *csys)
Compute the matrix and rhs for a vector-valued MAC scheme and Euler implicit. Values are added in pla...
Definition: cs_macfb_vecteq.cpp:696
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:95
Definition: mesh.f90:26
Definition: cs_macfb_priv.h:51
Definition: cs_cdo_connect.h:61
Definition: cs_cdo_quantities.h:139
Definition: cs_cdo_system.h:335
Set of local and temporary buffers.
Definition: cs_cdo_local.h:60
Set of local quantities and connectivities related to a mesh cell.
Definition: cs_cdo_local.h:203
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:147
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:192
Field descriptor.
Definition: cs_field.h:131
Definition: cs_macfb_builder.h:54
Definition: cs_mesh.h:85
Structure storing the evaluation of a property and its related data.
Definition: cs_property.h:223
Structure associated to the definition of a property relying on the cs_xdef_t structure.
time step descriptor
Definition: cs_time_step.h:64
Definition: cs_timer.h:55