8.1
general documentation
cs_cdovb_scaleq.h
Go to the documentation of this file.
1 #ifndef __CS_CDOVB_SCALEQ_H__
2 #define __CS_CDOVB_SCALEQ_H__
3 
4 /*============================================================================
5  * Build an algebraic CDO vertex-based system for unsteady convection diffusion
6  * reaction of scalar-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-2023 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  * Local headers
31  *----------------------------------------------------------------------------*/
32 
33 #include "cs_base.h"
34 #include "cs_cdo_connect.h"
35 #include "cs_cdo_local.h"
36 #include "cs_cdo_quantities.h"
37 #include "cs_cdo_toolbox.h"
38 #include "cs_equation_builder.h"
39 #include "cs_equation_param.h"
40 #include "cs_field.h"
41 #include "cs_matrix.h"
42 #include "cs_mesh.h"
43 #include "cs_source_term.h"
44 #include "cs_time_step.h"
45 
46 /*----------------------------------------------------------------------------*/
47 
49 
50 /*============================================================================
51  * Macro definitions
52  *============================================================================*/
53 
54 /*============================================================================
55  * Public function prototypes
56  *============================================================================*/
57 
58 /*----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------*/
66 
67 bool
69 
70 /*----------------------------------------------------------------------------*/
79 /*----------------------------------------------------------------------------*/
80 
81 void
83  const cs_cdo_connect_t *connect,
84  const cs_time_step_t *time_step);
85 
86 /*----------------------------------------------------------------------------*/
93 /*----------------------------------------------------------------------------*/
94 
95 void
97  cs_cell_builder_t **cb);
98 
99 /*----------------------------------------------------------------------------*/
104 /*----------------------------------------------------------------------------*/
105 
106 void
108 
109 /*----------------------------------------------------------------------------*/
121 /*----------------------------------------------------------------------------*/
122 
123 void *
125  int var_id,
126  int bflux_id,
127  cs_equation_builder_t *eqb);
128 
129 /*----------------------------------------------------------------------------*/
137 /*----------------------------------------------------------------------------*/
138 
139 void *
140 cs_cdovb_scaleq_free_context(void *scheme_context);
141 
142 /*----------------------------------------------------------------------------*/
155 /*----------------------------------------------------------------------------*/
156 
157 void
159  const cs_mesh_t *mesh,
160  const cs_equation_param_t *eqp,
162  cs_flag_t vtx_bc_flag[]);
163 
164 /*----------------------------------------------------------------------------*/
175 /*----------------------------------------------------------------------------*/
176 
177 void
179  cs_real_t t_eval,
180  const cs_equation_param_t *eqp,
182  void *context);
183 
184 /*----------------------------------------------------------------------------*/
208 /*----------------------------------------------------------------------------*/
209 
210 double
212  cs_lnum_t c_id,
213  bool diag_block,
214  const cs_real_t f_val[],
215  const cs_equation_param_t *eqp,
217  void *context,
218  cs_cell_builder_t *cb,
219  cs_cell_sys_t *csys);
220 
221 /*----------------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------------*/
235 
236 void
238  const int field_id,
239  const cs_mesh_t *mesh,
240  const cs_equation_param_t *eqp,
242  void *context);
243 
244 /*----------------------------------------------------------------------------*/
257 /*----------------------------------------------------------------------------*/
258 
259 void
261  const cs_mesh_t *mesh,
262  const int field_id,
263  const cs_equation_param_t *eqp,
265  void *context);
266 
267 /*----------------------------------------------------------------------------*/
285 /*----------------------------------------------------------------------------*/
286 
287 void
289  const cs_mesh_t *mesh,
290  const int field_id,
291  const cs_equation_param_t *eqp,
293  void *context);
294 
295 /*----------------------------------------------------------------------------*/
309 /*----------------------------------------------------------------------------*/
310 
311 void
312 cs_cdovb_scaleq_solve_implicit(bool cur2prev,
313  const cs_mesh_t *mesh,
314  const int field_id,
315  const cs_equation_param_t *eqp,
317  void *context);
318 
319 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
340 void
342  const cs_mesh_t *mesh,
343  const int field_id,
344  const cs_equation_param_t *eqp,
346  void *context);
347 
348 /*----------------------------------------------------------------------------*/
362 /*----------------------------------------------------------------------------*/
363 
364 void
365 cs_cdovb_scaleq_solve_theta(bool cur2prev,
366  const cs_mesh_t *mesh,
367  const int field_id,
368  const cs_equation_param_t *eqp,
370  void *context);
371 
372 /*----------------------------------------------------------------------------*/
384 /*----------------------------------------------------------------------------*/
385 
386 cs_real_t *
388  bool previous);
389 
390 /*----------------------------------------------------------------------------*/
403 /*----------------------------------------------------------------------------*/
404 
405 cs_real_t *
406 cs_cdovb_scaleq_get_cell_values(void *context,
407  bool previous);
408 
409 /*----------------------------------------------------------------------------*/
419 /*----------------------------------------------------------------------------*/
420 
421 cs_real_t *
423 
424 /*----------------------------------------------------------------------------*/
436 /*----------------------------------------------------------------------------*/
437 
441  void *context);
442 
443 /*----------------------------------------------------------------------------*/
458 /*----------------------------------------------------------------------------*/
459 
460 void
463  void *context,
464  const cs_property_t *pty,
465  const cs_real_t *pot,
466  cs_flag_t res_loc,
467  cs_real_t *res);
468 
469 /*----------------------------------------------------------------------------*/
484 /*----------------------------------------------------------------------------*/
485 
486 void
488  const cs_equation_param_t *eqp,
489  const cs_real_t *pdi,
491  void *context,
492  cs_real_t *vf_flux);
493 
494 /*----------------------------------------------------------------------------*/
508 /*----------------------------------------------------------------------------*/
509 
510 void
512  const cs_real_t *pdi,
513  const cs_equation_param_t *eqp,
514  int ml_id,
516  void *context,
517  double *d_flux,
518  double *c_flux);
519 
520 /*----------------------------------------------------------------------------*/
534 /*----------------------------------------------------------------------------*/
535 
536 void
538  const cs_equation_param_t *eqp,
539  const cs_property_t *diff_pty,
540  cs_real_t t_eval,
542  void *eq_context,
543  cs_real_t *diff_flux);
544 
545 /*----------------------------------------------------------------------------*/
559 /*----------------------------------------------------------------------------*/
560 
561 void
563  const cs_equation_param_t *eqp,
564  const cs_property_t *diff_pty,
565  cs_real_t t_eval,
567  void *eq_context,
568  cs_real_t *diff_flux);
569 
570 /*----------------------------------------------------------------------------*/
579 /*----------------------------------------------------------------------------*/
580 
581 void
584  void *context);
585 
586 /*----------------------------------------------------------------------------*/
594 /*----------------------------------------------------------------------------*/
595 
596 void
599  void *context);
600 
601 /*----------------------------------------------------------------------------*/
602 
604 
605 #endif /* __CS_CDOVB_SCALEQ_H__ */
cs_real_t * cs_cdovb_scaleq_get_vertex_values(void *context, bool previous)
Retrieve an array of values at mesh vertices for the variable field associated to the given context T...
Definition: cs_cdovb_scaleq.c:3742
void cs_cdovb_scaleq_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 scalar steady-state convection/diffusion/reaction eq...
Definition: cs_cdovb_scaleq.c:2462
cs_real_t * cs_cdovb_scaleq_get_source_term_values(void *context)
Retrieve the array storing the source term values at dual mesh cells. The lifecycle of this array is ...
Definition: cs_cdovb_scaleq.c:3822
void cs_cdovb_scaleq_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 vertex-based schemes. Set shared pointers.
Definition: cs_cdovb_scaleq.c:1254
void cs_cdovb_scaleq_diff_flux_in_cells(const cs_real_t *values, const cs_equation_param_t *eqp, const cs_property_t *diff_pty, cs_real_t t_eval, cs_equation_builder_t *eqb, void *eq_context, cs_real_t *diff_flux)
Cellwise and threaded computation of an approximation of a constant diffusive flux (a vector) in each...
Definition: cs_cdovb_scaleq.c:4770
void cs_cdovb_scaleq_finalize_sharing(void)
Free work buffer and general structure related to CDO vertex-based schemes.
Definition: cs_cdovb_scaleq.c:1323
void cs_cdovb_scaleq_get(cs_cell_sys_t **csys, cs_cell_builder_t **cb)
Retrieve work buffers used for building a CDO system cellwise.
Definition: cs_cdovb_scaleq.c:1306
void cs_cdovb_scaleq_apply_stiffness(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context, const cs_property_t *pty, const cs_real_t *pot, cs_flag_t res_loc, cs_real_t *res)
Compute the cellwise stiffness matrix associated to the property given as a parameter and multiply it...
Definition: cs_cdovb_scaleq.c:4191
void cs_cdovb_scaleq_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_cdovb_scaleq.c:5074
void cs_cdovb_scaleq_init_properties(int t_id, cs_real_t t_eval, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Set the main properties before the main loop on cells. Case of scalar-valued CDO-Vb schemes.
Definition: cs_cdovb_scaleq.c:2085
void cs_cdovb_scaleq_boundary_diff_flux(const cs_real_t t_eval, const cs_equation_param_t *eqp, const cs_real_t *pdi, cs_equation_builder_t *eqb, void *context, cs_real_t *vf_flux)
Compute for each vertex of a boundary face, the portion of diffusive flux across the boundary face....
Definition: cs_cdovb_scaleq.c:4349
void cs_cdovb_scaleq_solve_steady_state_incr(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 scalar steady-state convection/diffusion/reaction eq...
Definition: cs_cdovb_scaleq.c:2684
void cs_cdovb_scaleq_diff_flux_dfaces(const cs_real_t *values, const cs_equation_param_t *eqp, const cs_property_t *diff_pty, cs_real_t t_eval, cs_equation_builder_t *eqb, void *eq_context, cs_real_t *diff_flux)
Cellwise and threaded computation of the diffusive flux accross dual faces (a scalar) in each cell....
Definition: cs_cdovb_scaleq.c:4914
void cs_cdovb_scaleq_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 scalar unsteady convection/diffusion/reaction equati...
Definition: cs_cdovb_scaleq.c:3455
cs_cdo_balance_t * cs_cdovb_scaleq_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_cdovb_scaleq.c:3847
void cs_cdovb_scaleq_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 scalar unsteady convection/diffusion/reaction equati...
Definition: cs_cdovb_scaleq.c:2941
void cs_cdovb_scaleq_setup(cs_real_t t_eval, const cs_mesh_t *mesh, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, cs_flag_t vtx_bc_flag[])
Set the boundary conditions known from the settings Define an indirection array for the enforcement o...
Definition: cs_cdovb_scaleq.c:2041
void cs_cdovb_scaleq_extra_post(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Predefined extra-operations related to this equation.
Definition: cs_cdovb_scaleq.c:5098
void * cs_cdovb_scaleq_free_context(void *scheme_context)
Destroy a cs_cdovb_scaleq_t structure.
Definition: cs_cdovb_scaleq.c:2002
void * cs_cdovb_scaleq_init_context(const cs_equation_param_t *eqp, int var_id, int bflux_id, cs_equation_builder_t *eqb)
Initialize a cs_cdovb_scaleq_t structure storing data useful for building and managing such a scheme.
Definition: cs_cdovb_scaleq.c:1359
cs_real_t * cs_cdovb_scaleq_get_cell_values(void *context, bool previous)
Compute an array of values at mesh cells by interpolating the variable field associated to the given ...
Definition: cs_cdovb_scaleq.c:3774
bool cs_cdovb_scaleq_is_initialized(void)
Check if the generic structures for building a CDO-Vb scheme are allocated.
Definition: cs_cdovb_scaleq.c:1234
void cs_cdovb_scaleq_solve_implicit_incr(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 scalar unsteady convection/diffusion/reaction equati...
Definition: cs_cdovb_scaleq.c:3175
void cs_cdovb_scaleq_flux_across_plane(const cs_real_t normal[], const cs_real_t *pdi, const cs_equation_param_t *eqp, int ml_id, cs_equation_builder_t *eqb, void *context, double *d_flux, double *c_flux)
Compute the diffusive and convective flux across a list of faces Case of scalar-valued CDO-Vb schemes...
Definition: cs_cdovb_scaleq.c:4588
void cs_cdovb_scaleq_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_cdovb_scaleq.c:2349
double cs_cdovb_scaleq_build_block_implicit(int t_id, cs_lnum_t c_id, bool diag_block, const cs_real_t f_val[], const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Build the cell system for the given cell id when the build occurs in a coupled system....
Definition: cs_cdovb_scaleq.c:2136
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
unsigned short int cs_flag_t
Definition: cs_defs.h:321
Definition: mesh.f90:26
Definition: cs_cdo_toolbox.h:68
Definition: cs_cdo_connect.h:61
Definition: cs_cdo_quantities.h:137
Set of local and temporary buffers.
Definition: cs_cdo_local.h:60
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
Definition: cs_mesh.h:85
Structure associated to the definition of a property relying on the cs_xdef_t structure.
time step descriptor
Definition: cs_time_step.h:64