programmer's documentation
cs_equation_priv.h
Go to the documentation of this file.
1 #ifndef __CS_EQUATION_PRIV_H__
2 #define __CS_EQUATION_PRIV_H__
3 
4 /*============================================================================
5  * Routines to handle cs_equation_t structure and its related structures
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 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  * Local headers
30  *----------------------------------------------------------------------------*/
31 
32 #include "cs_equation_param.h"
33 #include "cs_equation_common.h"
34 #include "cs_field.h"
35 #include "cs_param.h"
36 #include "cs_restart.h"
37 
38 /*----------------------------------------------------------------------------*/
39 
41 
42 /*============================================================================
43  * Macro definitions
44  *============================================================================*/
45 
46 /*============================================================================
47  * Type definitions
48  *============================================================================*/
49 
50 /*----------------------------------------------------------------------------
51  * Function pointer types
52  *----------------------------------------------------------------------------*/
53 
54 /*----------------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------------*/
67 
68 typedef void *
70  int var_id,
71  int bflux_id,
73 
74 /*----------------------------------------------------------------------------*/
82 /*----------------------------------------------------------------------------*/
83 
84 typedef void *
85 (cs_equation_free_context_t)(void *scheme_context);
86 
87 /*----------------------------------------------------------------------------*/
99 /*----------------------------------------------------------------------------*/
100 
101 typedef void
104  void *data,
105  cs_matrix_t **system_matrix,
106  cs_real_t **system_rhs);
107 
108 /*----------------------------------------------------------------------------*/
118 /*----------------------------------------------------------------------------*/
119 
120 typedef void
122  const cs_equation_param_t *eqp,
124  cs_real_t t_eval,
125  cs_real_t field_val[]);
126 
127 /*----------------------------------------------------------------------------*/
140 /*----------------------------------------------------------------------------*/
141 
142 typedef void
144  const cs_real_t *field_val,
145  double dt_cur,
146  const cs_equation_param_t *eqp,
148  void *data,
149  cs_real_t *rhs,
151 
152 /*----------------------------------------------------------------------------*/
163 /*----------------------------------------------------------------------------*/
164 
165 typedef void
166 (cs_equation_solve_t)(double dt_cur,
167  const cs_mesh_t *mesh,
168  const int field_id,
169  const cs_equation_param_t *eqp,
171  void *eqc);
172 
173 /*----------------------------------------------------------------------------*/
183 /*----------------------------------------------------------------------------*/
184 
185 typedef void
186 (cs_equation_prepare_solve_t)(void *eq_to_cast,
187  cs_real_t *p_x[],
188  cs_real_t *p_rhs[]);
189 
190 /*----------------------------------------------------------------------------*/
202 /*----------------------------------------------------------------------------*/
203 
204 typedef void
206  const cs_real_t *rhs,
207  const cs_equation_param_t *eqp,
209  void *data,
210  cs_real_t *field_val);
211 
212 /*----------------------------------------------------------------------------*/
224 /*----------------------------------------------------------------------------*/
225 
226 typedef cs_equation_balance_t *
229  void *context,
230  cs_real_t dt_cur);
231 
232 /*----------------------------------------------------------------------------*/
245 /*----------------------------------------------------------------------------*/
246 
247 typedef void
249  const cs_real_t *pdi,
250  int ml_id,
251  const cs_equation_param_t *eqp,
253  void *data,
254  double *d_flux,
255  double *c_flux);
256 
257 /*----------------------------------------------------------------------------*/
270 /*----------------------------------------------------------------------------*/
271 
272 typedef void
274  const cs_equation_param_t *eqp,
275  cs_real_t t_eval,
277  void *data,
278  cs_flag_t location,
279  cs_real_t *d_flux);
280 
281 /*----------------------------------------------------------------------------*/
291 /*----------------------------------------------------------------------------*/
292 
293 typedef void
294 (cs_equation_extra_op_t)(const char *eqname,
295  const cs_field_t *field,
296  const cs_equation_param_t *eqp,
298  void *data);
299 
300 /*----------------------------------------------------------------------------*/
311 /*----------------------------------------------------------------------------*/
312 
313 typedef cs_real_t *
314 (cs_equation_get_values_t)(void *scheme_context);
315 
316 /*----------------------------------------------------------------------------*/
325 /*----------------------------------------------------------------------------*/
326 
327 typedef void
329  const char *eqname,
330  void *scheme_context);
331 
332 /*----------------------------------------------------------------------------
333  * Structure type
334  *----------------------------------------------------------------------------*/
335 
343 
344  int id;
345 
346  cs_equation_param_t *param; /* Set of parameters related to an equation */
347 
348  /* Variable attached to this equation is defined as a cs_field_t structure */
350  int field_id;
352 
353  /* Algebraic system */
354  /* ---------------- */
355 
356  /* There are possibly two different sizes for the linear system to handle
357  - One for "scatter"-type operations based on the number of geometrical
358  entities owned by the local instance of the mesh
359  - One for "gather"-type operations based on a balance of the number of
360  DoFs from a algebraic point of view. In parallel runs, these two sizes
361  can be different.
362  n_sles_gather_elts <= n_sles_scatter_elts
363  */
364 
367 
368  /* Right-hand side defined by a local cellwise building. This may be
369  different from the rhs given to cs_sles_solve() in parallel mode. */
371 
372  /* Matrix to inverse with cs_sles_solve() The matrix size can be different
373  from the rhs size in parallel mode since the decomposition is different */
375 
376  /* Range set to handle parallelism. Shared with cs_cdo_connect_t struct.*/
378 
379  /* \var builder
380  * Common members for building the algebraic system between the numerical
381  * schemes
382  */
384 
385  /* Data depending on the numerical scheme (cast on-the-fly) */
387 
388  /* Pointer to functions (see prototypes just above) */
398 
405 
409 
410  /* Timer statistic for a "light" profiling */
411  int main_ts_id; /* Id of the main timer states structure related
412  to this equation */
413 };
414 
415 /*============================================================================
416  * Public function prototypes
417  *============================================================================*/
418 
419 
420 /*----------------------------------------------------------------------------*/
421 
423 
424 #endif /* __CS_EQUATION_PRIV_H__ */
cs_equation_flux_plane_t * compute_flux_across_plane
Definition: cs_equation_priv.h:400
cs_equation_param_t * param
Definition: cs_equation_priv.h:346
cs_equation_set_dir_bc_t * set_dir_bc
Definition: cs_equation_priv.h:392
cs_equation_solve_t * solve
Definition: cs_equation_priv.h:397
void() cs_equation_initialize_system_t(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *data, 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_equation_priv.h:102
Store common elements used when building an algebraic system related to an equation.
Definition: cs_equation_common.h:63
void() cs_equation_prepare_solve_t(void *eq_to_cast, cs_real_t *p_x[], cs_real_t *p_rhs[])
Carry out operations for allocating and/or initializing the solution array and the right hand side of...
Definition: cs_equation_priv.h:186
#define restrict
Definition: cs_defs.h:122
cs_equation_cell_difflux_t * compute_cellwise_diff_flux
Definition: cs_equation_priv.h:401
void() cs_equation_set_dir_bc_t(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 Dirichlet boundary stemming from the settings.
Definition: cs_equation_priv.h:121
cs_equation_update_field_t * update_field
Definition: cs_equation_priv.h:395
const cs_range_set_t * rset
Definition: cs_equation_priv.h:377
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
void() cs_equation_flux_plane_t(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_equation_priv.h:248
cs_equation_solve_t * solve_steady_state
Definition: cs_equation_priv.h:396
cs_lnum_t n_sles_scatter_elts
Definition: cs_equation_priv.h:365
#define BEGIN_C_DECLS
Definition: cs_defs.h:462
cs_equation_get_values_t * get_face_values
Definition: cs_equation_priv.h:406
int field_id
Definition: cs_equation_priv.h:350
cs_equation_builder_t * builder
Definition: cs_equation_priv.h:383
Definition: field.f90:27
cs_lnum_t n_sles_gather_elts
Definition: cs_equation_priv.h:366
cs_equation_initialize_system_t * initialize_system
Definition: cs_equation_priv.h:391
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
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
int boundary_flux_id
Definition: cs_equation_priv.h:351
void() cs_equation_restart_t(cs_restart_t *restart, const char *eqname, void *scheme_context)
Generic prototype dedicated to read or write additional arrays (not defined as fields) useful for the...
Definition: cs_equation_priv.h:328
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:90
void *() cs_equation_init_context_t(const cs_equation_param_t *eqp, int var_id, int bflux_id, cs_equation_builder_t *eqb)
Initialize a scheme data structure used during the building of the algebraic system.
Definition: cs_equation_priv.h:69
Definition: cs_mesh.h:63
cs_equation_get_values_t * get_cell_values
Definition: cs_equation_priv.h:407
Definition: cs_equation_common.h:155
void() cs_equation_build_system_t(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 a linear system within the CDO framework.
Definition: cs_equation_priv.h:143
void * scheme_context
Definition: cs_equation_priv.h:386
void *() cs_equation_free_context_t(void *scheme_context)
Destroy a scheme data structure.
Definition: cs_equation_priv.h:85
cs_real_t *() cs_equation_get_values_t(void *scheme_context)
Compute or retrieve an array of values at a given mesh location Currently, vertices, cells or faces are possible locations The lifecycle of this array is managed by the code. So one does not have to free the return pointer.
Definition: cs_equation_priv.h:314
cs_equation_get_values_t * get_vertex_values
Definition: cs_equation_priv.h:408
cs_equation_balance_t *() cs_equation_get_balance_t(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context, cs_real_t dt_cur)
Compute the balance for an equation over the full computational domain between time t_cur and t_cur +...
Definition: cs_equation_priv.h:227
void() cs_equation_solve_t(double dt_cur, const cs_mesh_t *mesh, const int field_id, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *eqc)
Build and solve a linear system within the CDO framework.
Definition: cs_equation_priv.h:166
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:86
Definition: cs_range_set.h:57
void() cs_equation_cell_difflux_t(const cs_real_t *fvals, const cs_equation_param_t *eqp, cs_real_t t_eval, cs_equation_builder_t *eqb, void *data, cs_flag_t location, cs_real_t *d_flux)
Cellwise computation of the diffusive flux across all faces. Primal or dual faces are considered acco...
Definition: cs_equation_priv.h:273
char *restrict varname
Definition: cs_equation_priv.h:349
void() cs_equation_update_field_t(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_equation_priv.h:205
cs_real_t * rhs
Definition: cs_equation_priv.h:370
cs_equation_get_balance_t * compute_balance
Definition: cs_equation_priv.h:399
cs_equation_free_context_t * free_context
Definition: cs_equation_priv.h:390
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
cs_equation_extra_op_t * postprocess
Definition: cs_equation_priv.h:402
#define END_C_DECLS
Definition: cs_defs.h:463
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_equation_restart_t * write_restart
Definition: cs_equation_priv.h:404
cs_equation_restart_t * read_restart
Definition: cs_equation_priv.h:403
cs_equation_init_context_t * init_context
Definition: cs_equation_priv.h:389
Structure and routines handling the specific settings related to a cs_equation_t structure.
int main_ts_id
Definition: cs_equation_priv.h:411
cs_equation_build_system_t * build_system
Definition: cs_equation_priv.h:393
int id
Definition: cs_equation_priv.h:344
Definition: cs_equation_priv.h:342
cs_equation_prepare_solve_t * prepare_solving
Definition: cs_equation_priv.h:394
Definition: mesh.f90:26
void() cs_equation_extra_op_t(const char *eqname, const cs_field_t *field, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *data)
Extra-operation related to this equation.
Definition: cs_equation_priv.h:294
cs_matrix_t * matrix
Definition: cs_equation_priv.h:374