programmer's documentation
cs_cdovcb_scaleq.h
Go to the documentation of this file.
1 #ifndef __CS_CDOVCB_SCALEQ_H__
2 #define __CS_CDOVCB_SCALEQ_H__
3 
4 /*============================================================================
5  * Build an algebraic CDO vertex+cell-based system for unsteady convection
6  * diffusion 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-2018 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_time_step.h"
35 #include "cs_mesh.h"
36 #include "cs_equation_common.h"
37 #include "cs_equation_param.h"
38 #include "cs_field.h"
39 #include "cs_cdo_connect.h"
40 #include "cs_cdo_quantities.h"
41 #include "cs_equation_param.h"
42 #include "cs_restart.h"
43 #include "cs_source_term.h"
44 
45 /*----------------------------------------------------------------------------*/
46 
48 
49 /*============================================================================
50  * Macro definitions
51  *============================================================================*/
52 
53 /*============================================================================
54  * Type definitions
55  *============================================================================*/
56 
57 /* Algebraic system for CDO vertex-based discretization */
58 typedef struct _cs_cdovcb_scaleq_t cs_cdovcb_scaleq_t;
59 
60 /*============================================================================
61  * Public function prototypes
62  *============================================================================*/
63 
64 /*----------------------------------------------------------------------------*/
71 /*----------------------------------------------------------------------------*/
72 
73 bool
75 
76 /*----------------------------------------------------------------------------*/
87 /*----------------------------------------------------------------------------*/
88 
89 void
91  const cs_cdo_connect_t *connect,
92  const cs_time_step_t *time_step,
93  const cs_matrix_structure_t *ms);
94 
95 /*----------------------------------------------------------------------------*/
102 /*----------------------------------------------------------------------------*/
103 
104 void
106  cs_cell_builder_t **cb);
107 
108 /*----------------------------------------------------------------------------*/
113 /*----------------------------------------------------------------------------*/
114 
115 void
117 
118 /*----------------------------------------------------------------------------*/
130 /*----------------------------------------------------------------------------*/
131 
132 void *
134  int var_id,
135  int bflux_id,
136  cs_equation_builder_t *eqb);
137 
138 /*----------------------------------------------------------------------------*/
146 /*----------------------------------------------------------------------------*/
147 
148 void *
150 
151 /*----------------------------------------------------------------------------*/
163 /*----------------------------------------------------------------------------*/
164 
165 void
168  void *context,
169  cs_matrix_t **system_matrix,
170  cs_real_t **system_rhs);
171 
172 /*----------------------------------------------------------------------------*/
183 /*----------------------------------------------------------------------------*/
184 
185 void
187  const cs_equation_param_t *eqp,
189  cs_real_t t_eval,
190  cs_real_t field_val[]);
191 
192 /*----------------------------------------------------------------------------*/
205 /*----------------------------------------------------------------------------*/
206 
207 void
209  const cs_mesh_t *mesh,
210  const int field_id,
211  const cs_equation_param_t *eqp,
213  void *context);
214 
215 /*----------------------------------------------------------------------------*/
229 /*----------------------------------------------------------------------------*/
230 
231 void
232 cs_cdovcb_scaleq_solve_implicit(double dt_cur,
233  const cs_mesh_t *mesh,
234  const int field_id,
235  const cs_equation_param_t *eqp,
237  void *context);
238 
239 /*----------------------------------------------------------------------------*/
253 /*----------------------------------------------------------------------------*/
254 
255 void
256 cs_cdovcb_scaleq_solve_theta(double dt_cur,
257  const cs_mesh_t *mesh,
258  const int field_id,
259  const cs_equation_param_t *eqp,
261  void *context);
262 
263 /*----------------------------------------------------------------------------*/
278 /*----------------------------------------------------------------------------*/
279 
280 void
282  const cs_real_t *field_val,
283  double dt_cur,
284  const cs_equation_param_t *eqp,
286  void *data,
287  cs_real_t *rhs,
289 
290 /*----------------------------------------------------------------------------*/
302 /*----------------------------------------------------------------------------*/
303 
304 void
306  const cs_real_t *rhs,
307  const cs_equation_param_t *eqp,
309  void *data,
310  cs_real_t *field_val);
311 
312 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
325 cs_real_t *
327 
328 /*----------------------------------------------------------------------------*/
341 /*----------------------------------------------------------------------------*/
342 
343 cs_real_t *
344 cs_cdovcb_scaleq_get_cell_values(void *context);
345 
346 /*----------------------------------------------------------------------------*/
359 /*----------------------------------------------------------------------------*/
360 
361 void
363  const cs_real_t *pdi,
364  int ml_id,
365  const cs_equation_param_t *eqp,
367  void *data,
368  double *d_flux,
369  double *c_flux);
370 
371 /*----------------------------------------------------------------------------*/
383 /*----------------------------------------------------------------------------*/
384 
385 void
387  const cs_equation_param_t *eqp,
388  cs_real_t t_eval,
390  void *context,
391  cs_flag_t location,
392  cs_real_t *diff_flux);
393 
394 /*----------------------------------------------------------------------------*/
403 /*----------------------------------------------------------------------------*/
404 
405 void
408  void *context,
409  cs_real_t *v_gradient);
410 
411 /*----------------------------------------------------------------------------*/
420 /*----------------------------------------------------------------------------*/
421 
422 void
424  const char *eqname,
425  void *scheme_context);
426 
427 /*----------------------------------------------------------------------------*/
436 /*----------------------------------------------------------------------------*/
437 
438 void
440  const char *eqname,
441  void *scheme_context);
442 
443 /*----------------------------------------------------------------------------*/
453 /*----------------------------------------------------------------------------*/
454 
455 void
456 cs_cdovcb_scaleq_extra_op(const char *eqname,
457  const cs_field_t *field,
458  const cs_equation_param_t *eqp,
460  void *context);
461 
462 /*----------------------------------------------------------------------------*/
463 
465 
466 #endif /* __CS_CDOVCB_SCALEQ_H__ */
Store common elements used when building an algebraic system related to an equation.
Definition: cs_equation_common.h:63
time step descriptor
Definition: cs_time_step.h:51
void cs_cdovcb_scaleq_build_system(const cs_mesh_t *mesh, const cs_real_t *field_val, double dt_cur, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *data, cs_real_t *rhs, cs_matrix_t *matrix)
Build the linear system arising from a scalar convection/diffusion equation with a CDO vertex+cell-ba...
Definition: cs_cdovcb_scaleq.c:1892
void cs_cdovcb_scaleq_get(cs_cell_sys_t **csys, cs_cell_builder_t **cb)
Retrieve work buffers used for building a CDO system cellwise.
Definition: cs_cdovcb_scaleq.c:768
Field descriptor.
Definition: cs_field.h:124
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:159
cs_real_t * cs_cdovcb_scaleq_get_vertex_values(void *context)
Retrieve an array of values at mesh vertices for the variable field associated to the given context T...
Definition: cs_cdovcb_scaleq.c:2275
void cs_cdovcb_scaleq_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_cdovcb_scaleq.c:2741
void cs_cdovcb_scaleq_initialize_system(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context, cs_matrix_t **system_matrix, cs_real_t **system_rhs)
Create the matrix of the current algebraic system. Allocate and initialize the right-hand side associ...
Definition: cs_cdovcb_scaleq.c:1053
void cs_cdovcb_scaleq_solve_theta(double dt_cur, 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_cdovcb_scaleq.c:1565
void * cs_cdovcb_scaleq_init_context(const cs_equation_param_t *eqp, int var_id, int bflux_id, cs_equation_builder_t *eqb)
Initialize a cs_cdovcb_scaleq_t structure storing data useful for building and managing such a scheme...
Definition: cs_cdovcb_scaleq.c:826
#define BEGIN_C_DECLS
Definition: cs_defs.h:462
void cs_cdovcb_scaleq_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_cdovcb_scaleq.c:2791
void cs_cdovcb_scaleq_extra_op(const char *eqname, const cs_field_t *field, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Predefined extra-operations related to this equation.
Definition: cs_cdovcb_scaleq.c:2832
cs_real_t * cs_cdovcb_scaleq_get_cell_values(void *context)
Get the computed values at mesh cells from the inverse operation w.r.t. the static condensation (DoF ...
Definition: cs_cdovcb_scaleq.c:2299
void cs_cdovcb_scaleq_update_field(const cs_real_t *solu, const cs_real_t *rhs, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *data, cs_real_t *field_val)
Store solution(s) of the linear system into a field structure Update extra-field values if required (...
Definition: cs_cdovcb_scaleq.c:2234
Definition: cs_cdo_connect.h:74
Definition: field.f90:27
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
void cs_cdovcb_scaleq_compute_flux_across_plane(const cs_real_t normal[], const cs_real_t *pdi, int ml_id, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *data, double *d_flux, double *c_flux)
Compute the diffusive and convective flux across a list of faces.
Definition: cs_cdovcb_scaleq.c:2325
Definition: cs_cdo_quantities.h:94
void matrix(const int *iconvp, const int *idiffp, const int *ndircp, const int *isym, const cs_real_t *thetap, const int *imucpp, const cs_real_t coefbp[], const cs_real_t cofbfp[], 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.c:111
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:112
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:90
Definition: cs_mesh.h:63
struct _cs_cdovcb_scaleq_t cs_cdovcb_scaleq_t
Definition: cs_cdovcb_scaleq.h:58
void * cs_cdovcb_scaleq_free_context(void *data)
Destroy a cs_cdovcb_scaleq_t structure.
Definition: cs_cdovcb_scaleq.c:1018
void cs_cdovcb_scaleq_init_common(const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect, const cs_time_step_t *time_step, const cs_matrix_structure_t *ms)
Allocate work buffer and general structures related to CDO vertex+cell-based schemes Set shared point...
Definition: cs_cdovcb_scaleq.c:718
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:86
Set of local and temporary buffers useful for building the algebraic system with a cellwise process...
Definition: cs_cdo_local.h:75
void cs_cdovcb_scaleq_set_dir_bc(const cs_mesh_t *mesh, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, cs_real_t t_eval, cs_real_t field_val[])
Set the boundary conditions known from the settings when the fields stem from a scalar CDO vertex+cel...
Definition: cs_cdovcb_scaleq.c:1094
void cs_cdovcb_scaleq_finalize_common(void)
Free buffers and generic structures related to CDO vertex+cell-based schemes.
Definition: cs_cdovcb_scaleq.c:790
void cs_cdovcb_scaleq_solve_steady_state(double dt_cur, 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_cdovcb_scaleq.c:1130
void cs_cdovcb_scaleq_solve_implicit(double dt_cur, 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_cdovcb_scaleq.c:1319
void cs_cdovcb_scaleq_vtx_gradient(const cs_real_t *v_values, cs_equation_builder_t *eqb, void *context, cs_real_t *v_gradient)
Cellwise computation of the discrete gradient at vertices.
Definition: cs_cdovcb_scaleq.c:2621
#define END_C_DECLS
Definition: cs_defs.h:463
unsigned short int cs_flag_t
Definition: cs_defs.h:299
void cs_cdovcb_scaleq_cellwise_diff_flux(const cs_real_t *values, const cs_equation_param_t *eqp, cs_real_t t_eval, cs_equation_builder_t *eqb, void *context, cs_flag_t location, cs_real_t *diff_flux)
Cellwise computation of the diffusive flux.
Definition: cs_cdovcb_scaleq.c:2505
Structure and routines handling the specific settings related to a cs_equation_t structure.
struct _cs_matrix_structure_t cs_matrix_structure_t
Definition: cs_matrix.h:86
Definition: mesh.f90:26
bool cs_cdovcb_scaleq_is_initialized(void)
Check if the generic structures for building a CDO-vertex+cell based scheme are allocated.
Definition: cs_cdovcb_scaleq.c:696