7.1
general 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  * Functions 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-2021 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_restart.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 /*----------------------------------------------------------------------------*/
65 /*----------------------------------------------------------------------------*/
66 
67 typedef void *
69  int var_id,
70  int bflux_id,
72 
73 /*----------------------------------------------------------------------------*/
81 /*----------------------------------------------------------------------------*/
82 
83 typedef void *
84 (cs_equation_free_context_t)(void *scheme_context);
85 
86 /*----------------------------------------------------------------------------*/
97 /*----------------------------------------------------------------------------*/
98 
99 typedef void
101  const int field_id,
102  const cs_mesh_t *mesh,
103  const cs_equation_param_t *eqp,
105  void *context);
106 
107 /*----------------------------------------------------------------------------*/
118 /*----------------------------------------------------------------------------*/
119 
120 typedef void
121 (cs_equation_solve_t)(bool cur2prev,
122  const cs_mesh_t *mesh,
123  const int field_id,
124  const cs_equation_param_t *eqp,
126  void *eqc);
127 
128 /*----------------------------------------------------------------------------*/
139 /*----------------------------------------------------------------------------*/
140 
141 typedef void
143  const cs_mesh_t *mesh,
144  const cs_equation_param_t *eqp,
146  void *context,
147  cs_real_t field_val[]);
148 
149 /*----------------------------------------------------------------------------*/
161 /*----------------------------------------------------------------------------*/
162 
163 typedef void
166  void *data,
167  cs_matrix_t **system_matrix,
168  cs_real_t **system_rhs);
169 
170 /*----------------------------------------------------------------------------*/
182 /*----------------------------------------------------------------------------*/
183 
184 typedef void
186  const cs_real_t *field_val,
187  const cs_equation_param_t *eqp,
189  void *data,
190  cs_real_t *rhs,
192 
193 /*----------------------------------------------------------------------------*/
203 /*----------------------------------------------------------------------------*/
204 
205 typedef void
206 (cs_equation_prepare_solve_t)(void *eq_to_cast,
207  cs_real_t *p_x[],
208  cs_real_t *p_rhs[]);
209 
210 /*----------------------------------------------------------------------------*/
222 /*----------------------------------------------------------------------------*/
223 
224 typedef void
226  const cs_real_t *rhs,
227  const cs_equation_param_t *eqp,
229  void *data,
230  cs_real_t *field_val);
231 
232 /*----------------------------------------------------------------------------*/
243 /*----------------------------------------------------------------------------*/
244 
245 typedef cs_equation_balance_t *
248  void *context);
249 
250 /*----------------------------------------------------------------------------*/
258 /*----------------------------------------------------------------------------*/
259 
260 typedef void
263  void *context);
264 
265 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 typedef void
277  cs_cell_builder_t **cb);
278 
279 /*----------------------------------------------------------------------------*/
291 /*----------------------------------------------------------------------------*/
292 
293 typedef cs_real_t *
294 (cs_equation_get_values_t)(void *scheme_context,
295  bool previous);
296 
297 /*----------------------------------------------------------------------------*/
306 /*----------------------------------------------------------------------------*/
307 
308 typedef void
310  const char *eqname,
311  void *scheme_context);
312 
313 /*----------------------------------------------------------------------------
314  * Structure type
315  *----------------------------------------------------------------------------*/
316 
324 
325  int id;
326 
327  cs_equation_param_t *param; /* Set of parameters related to an equation */
328 
329  /* Variable attached to this equation is defined as a cs_field_t structure */
331  int field_id;
333 
334  /* Algebraic system */
335  /* ---------------- */
336 
337  /* There can be two different sizes for the linear system to handle
338  - One for "scatter"-type operations based on the number of geometrical
339  entities owned by the local instance of the mesh
340  - One for "gather"-type operations based on a balance of the number of
341  DoFs from a algebraic point of view. In parallel runs, these two sizes
342  can be different.
343  n_sles_gather_elts <= n_sles_scatter_elts
344  */
345 
348 
349  /* Right-hand side defined by a local cellwise building. This may be
350  different from the rhs given to cs_sles_solve() in parallel mode. */
352 
353  /* Matrix to inverse with cs_sles_solve() The matrix size can be different
354  from the rhs size in parallel mode since the decomposition is different */
356 
357  /* Range set to handle parallelism. Shared with cs_cdo_connect_t struct.*/
359 
360  /* \var builder
361  * Common members for building the algebraic system between the numerical
362  * schemes
363  */
365 
366  /* Data depending on the numerical scheme (cast on-the-fly) */
368 
369  /* Pointer to functions (see prototypes just above) */
372 
376 
380 
383 
388 
390 
391  /* Deprecated functions --> use rather solve() and solve_steady_state() */
392  /* -------------------- */
398 
399  /* Timer statistic for a coarse profiling */
400  int main_ts_id; /* Id of the main timer stats for this equation */
401 
402 };
403 
404 /*============================================================================
405  * Public function prototypes
406  *============================================================================*/
407 
408 
409 /*----------------------------------------------------------------------------*/
410 
412 
413 #endif /* __CS_EQUATION_PRIV_H__ */
cs_equation_param_t * param
Definition: cs_equation_priv.h:327
cs_equation_set_dir_bc_t * set_dir_bc
Definition: cs_equation_priv.h:394
cs_equation_solve_t * solve
Definition: cs_equation_priv.h:375
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:164
Store common elements used when building an algebraic system related to an equation.
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:206
#define restrict
Definition: cs_defs.h:142
cs_equation_update_field_t * update_field
Definition: cs_equation_priv.h:397
void() cs_equation_build_system_t(const cs_mesh_t *mesh, const cs_real_t *field_val, 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:185
const cs_range_set_t * rset
Definition: cs_equation_priv.h:358
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:177
cs_equation_get_builders_t * get_cw_build_structures
Definition: cs_equation_priv.h:389
void() cs_equation_get_builders_t(cs_cell_sys_t **csys, cs_cell_builder_t **cb)
Retrieve cellwise structure including work buffers used to build a CDO system cellwise. Generic prototype for all CDO schemes.
Definition: cs_equation_priv.h:276
cs_equation_solve_t * solve_steady_state
Definition: cs_equation_priv.h:374
cs_lnum_t n_sles_scatter_elts
Definition: cs_equation_priv.h:346
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
cs_equation_get_values_t * get_face_values
Definition: cs_equation_priv.h:385
int field_id
Definition: cs_equation_priv.h:331
cs_equation_builder_t * builder
Definition: cs_equation_priv.h:364
cs_lnum_t n_sles_gather_elts
Definition: cs_equation_priv.h:347
cs_equation_initialize_system_t * initialize_system
Definition: cs_equation_priv.h:393
void() cs_equation_init_values_t(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)
Initialize the variable field values related to an equation.
Definition: cs_equation_priv.h:100
cs_equation_init_values_t * init_field_values
Definition: cs_equation_priv.h:373
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
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:146
int boundary_flux_id
Definition: cs_equation_priv.h:332
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:309
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:93
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:68
Definition: cs_mesh.h:84
cs_equation_get_values_t * get_cell_values
Definition: cs_equation_priv.h:384
Definition: cs_equation_common.h:233
cs_equation_get_values_t * get_edge_values
Definition: cs_equation_priv.h:386
void * scheme_context
Definition: cs_equation_priv.h:367
void *() cs_equation_free_context_t(void *scheme_context)
Destroy a scheme data structure.
Definition: cs_equation_priv.h:84
cs_equation_get_values_t * get_vertex_values
Definition: cs_equation_priv.h:387
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:93
Definition: cs_range_set.h:57
Set of local and temporary buffers.
Definition: cs_cdo_local.h:60
char *restrict varname
Definition: cs_equation_priv.h:330
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:225
cs_real_t * rhs
Definition: cs_equation_priv.h:351
void() cs_equation_set_dir_bc_t(cs_real_t t_eval, const cs_mesh_t *mesh, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context, cs_real_t field_val[])
Set the Dirichlet boundary stemming from the settings.
Definition: cs_equation_priv.h:142
cs_real_t *() cs_equation_get_values_t(void *scheme_context, bool previous)
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:294
cs_equation_get_balance_t * compute_balance
Definition: cs_equation_priv.h:377
cs_equation_free_context_t * free_context
Definition: cs_equation_priv.h:371
double precision, dimension(:,:), allocatable solu
Definition: atincl.f90:321
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
cs_equation_extra_op_t * postprocess
Definition: cs_equation_priv.h:378
#define END_C_DECLS
Definition: cs_defs.h:511
cs_equation_restart_t * write_restart
Definition: cs_equation_priv.h:382
cs_equation_balance_t *() cs_equation_get_balance_t(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_equation_priv.h:246
cs_equation_restart_t * read_restart
Definition: cs_equation_priv.h:381
void() cs_equation_extra_op_t(const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
Generic prototype for extra-operations related to an equation.
Definition: cs_equation_priv.h:261
cs_equation_init_context_t * init_context
Definition: cs_equation_priv.h:370
int main_ts_id
Definition: cs_equation_priv.h:400
cs_equation_build_system_t * build_system
Definition: cs_equation_priv.h:395
void() cs_equation_solve_t(bool cur2prev, 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:121
cs_equation_extra_op_t * current_to_previous
Definition: cs_equation_priv.h:379
int id
Definition: cs_equation_priv.h:325
Definition: cs_equation_priv.h:323
cs_equation_prepare_solve_t * prepare_solving
Definition: cs_equation_priv.h:396
Definition: mesh.f90:26
cs_matrix_t * matrix
Definition: cs_equation_priv.h:355