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 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
45 /*============================================================================
46  * Type definitions
47  *============================================================================*/
48 
49 /*----------------------------------------------------------------------------
50  * Function pointer types
51  *----------------------------------------------------------------------------*/
52 
53 /*----------------------------------------------------------------------------*/
63 /*----------------------------------------------------------------------------*/
64 
65 typedef void *
68 
69 /*----------------------------------------------------------------------------*/
77 /*----------------------------------------------------------------------------*/
78 
79 typedef void *
80 (cs_equation_free_context_t)(void *scheme_context);
81 
82 /*----------------------------------------------------------------------------*/
94 /*----------------------------------------------------------------------------*/
95 
96 typedef void
99  void *data,
100  cs_matrix_t **system_matrix,
101  cs_real_t **system_rhs);
102 
103 /*----------------------------------------------------------------------------*/
116 /*----------------------------------------------------------------------------*/
117 
118 typedef void
120  const cs_real_t *field_val,
121  double dt_cur,
122  const cs_equation_param_t *eqp,
124  void *data,
125  cs_real_t *rhs,
127 
128 /*----------------------------------------------------------------------------*/
138 /*----------------------------------------------------------------------------*/
139 
140 typedef void
141 (cs_equation_prepare_solve_t)(void *eq_to_cast,
142  cs_real_t *p_x[],
143  cs_real_t *p_rhs[]);
144 
145 /*----------------------------------------------------------------------------*/
157 /*----------------------------------------------------------------------------*/
158 
159 typedef void
161  const cs_real_t *rhs,
162  const cs_equation_param_t *eqp,
164  void *data,
165  cs_real_t *field_val);
166 
167 /*----------------------------------------------------------------------------*/
176 /*----------------------------------------------------------------------------*/
177 
178 typedef void
181  void *builder);
182 
183 /*----------------------------------------------------------------------------*/
196 /*----------------------------------------------------------------------------*/
197 
198 typedef void
200  const cs_real_t *pdi,
201  int ml_id,
202  const cs_equation_param_t *eqp,
204  void *data,
205  double *d_flux,
206  double *c_flux);
207 
208 /*----------------------------------------------------------------------------*/
220 /*----------------------------------------------------------------------------*/
221 
222 typedef void
224  const cs_equation_param_t *eqp,
226  void *data,
227  cs_flag_t location,
228  cs_real_t *d_flux);
229 
230 /*----------------------------------------------------------------------------*/
240 /*----------------------------------------------------------------------------*/
241 
242 typedef void
243 (cs_equation_extra_op_t)(const char *eqname,
244  const cs_field_t *field,
245  const cs_equation_param_t *eqp,
247  void *data);
248 
249 /*----------------------------------------------------------------------------*/
258 /*----------------------------------------------------------------------------*/
259 
260 typedef double *
261 (cs_equation_get_extra_values_t)(const void *scheme_context);
262 
263 /*----------------------------------------------------------------------------
264  * Structure type
265  *----------------------------------------------------------------------------*/
266 
274 
275  char *restrict name; /* Short description */
276  int id;
277 
278  cs_equation_param_t *param; /* Set of parameters related to an equation */
279 
280  /* Variable attached to this equation is defined as a cs_field_t structure */
282  int field_id;
283 
284  /* Algebraic system */
285  /* ---------------- */
286 
287  /* There are possibly two different sizes for the linear system to handle
288  - One for "scatter"-type operations based on the number of geometrical
289  entities owned by the local instance of the mesh
290  - One for "gather"-type operations based on a balance of the number of
291  DoFs from a algebraic point of view. In parallel runs, these two sizes
292  can be different.
293  n_sles_gather_elts <= n_sles_scatter_elts
294  */
295 
298 
299  /* Right-hand side defined by a local cellwise building. This may be
300  different from the rhs given to cs_sles_solve() in parallel mode. */
302 
303  /* Matrix to inverse with cs_sles_solve() The matrix size can be different
304  from the rhs size in parallel mode since the decomposition is different */
306 
307  /* Range set to handle parallelism. Shared with cs_cdo_connect_t struct.*/
309 
310  /* \var builder
311  * Common members for building the algebraic system between the numerical
312  * schemes
313  */
315 
316  /* Data depending on the numerical scheme (cast on-the-fly) */
318 
319  /* Pointer to functions (see prototypes just above) */
331 
332  /* Timer statistic for a "light" profiling */
333  int main_ts_id; /* Id of the main timer states structure related
334  to this equation */
335  int solve_ts_id; /* Id of the timer stats structure related to the
336  inversion of the linear system */
337 
338  bool do_build; /* false => keep the system as it is */
339 
340 };
341 
342 /*============================================================================
343  * Public function prototypes
344  *============================================================================*/
345 
346 
347 /*----------------------------------------------------------------------------*/
348 
350 
351 #endif /* __CS_EQUATION_PRIV_H__ */
cs_equation_flux_plane_t * compute_flux_across_plane
Definition: cs_equation_priv.h:327
cs_equation_param_t * param
Definition: cs_equation_priv.h:278
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:97
Store common elements used when building an algebraic system related to an equation.
Definition: cs_equation_common.h:62
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:141
#define restrict
Definition: cs_defs.h:122
double *() cs_equation_get_extra_values_t(const void *scheme_context)
Get the computed values at a different location than that of the field associated to this equation...
Definition: cs_equation_priv.h:261
cs_equation_cell_difflux_t * compute_cellwise_diff_flux
Definition: cs_equation_priv.h:328
cs_equation_update_field_t * update_field
Definition: cs_equation_priv.h:325
const cs_range_set_t * rset
Definition: cs_equation_priv.h:308
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:150
void *() cs_equation_init_context_t(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb)
Initialize a scheme data structure used during the building of the algebraic system.
Definition: cs_equation_priv.h:66
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:199
cs_lnum_t n_sles_scatter_elts
Definition: cs_equation_priv.h:296
#define BEGIN_C_DECLS
Definition: cs_defs.h:461
int field_id
Definition: cs_equation_priv.h:282
cs_equation_builder_t * builder
Definition: cs_equation_priv.h:314
Definition: field.f90:27
cs_lnum_t n_sles_gather_elts
Definition: cs_equation_priv.h:297
cs_equation_initialize_system_t * initialize_system
Definition: cs_equation_priv.h:322
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
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:90
Definition: cs_mesh.h:63
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:119
void * scheme_context
Definition: cs_equation_priv.h:317
void *() cs_equation_free_context_t(void *scheme_context)
Destroy a scheme data structure.
Definition: cs_equation_priv.h:80
char *restrict name
Definition: cs_equation_priv.h:275
Definition: cs_range_set.h:57
cs_equation_get_extra_values_t * get_extra_values
Definition: cs_equation_priv.h:330
void() cs_equation_cell_difflux_t(const cs_real_t *fvals, const cs_equation_param_t *eqp, 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:223
cs_equation_compute_source_t * compute_source
Definition: cs_equation_priv.h:326
char *restrict varname
Definition: cs_equation_priv.h:281
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:160
cs_real_t * rhs
Definition: cs_equation_priv.h:301
cs_equation_free_context_t * free_context
Definition: cs_equation_priv.h:321
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void() cs_equation_compute_source_t(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *builder)
Compute the contribution of source terms for the current time.
Definition: cs_equation_priv.h:179
cs_equation_extra_op_t * postprocess
Definition: cs_equation_priv.h:329
#define END_C_DECLS
Definition: cs_defs.h:462
unsigned short int cs_flag_t
Definition: cs_defs.h:299
bool do_build
Definition: cs_equation_priv.h:338
int solve_ts_id
Definition: cs_equation_priv.h:335
cs_equation_init_context_t * init_context
Definition: cs_equation_priv.h:320
Structure and routines handling the specific settings related to a cs_equation_t structure.
int main_ts_id
Definition: cs_equation_priv.h:333
cs_equation_build_system_t * build_system
Definition: cs_equation_priv.h:323
int id
Definition: cs_equation_priv.h:276
Definition: cs_equation_priv.h:273
cs_equation_prepare_solve_t * prepare_solving
Definition: cs_equation_priv.h:324
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:243
cs_matrix_t * matrix
Definition: cs_equation_priv.h:305