6.3
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  * 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-2020 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 
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_restart_t
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
_cs_equation_t::get_cell_values
cs_equation_get_values_t * get_cell_values
Definition: cs_equation_priv.h:384
cs_equation_balance_t
Definition: cs_equation_common.h:220
_cs_equation_t::field_id
int field_id
Definition: cs_equation_priv.h:331
_cs_equation_t::rhs
cs_real_t * rhs
Definition: cs_equation_priv.h:351
_cs_equation_t::prepare_solving
cs_equation_prepare_solve_t * prepare_solving
Definition: cs_equation_priv.h:396
cs_equation_common.h
restrict
#define restrict
Definition: cs_defs.h:124
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:493
_cs_equation_t::write_restart
cs_equation_restart_t * write_restart
Definition: cs_equation_priv.h:382
cs_equation_solve_t
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_get_values_t
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,...
Definition: cs_equation_priv.h:294
_cs_equation_t::get_face_values
cs_equation_get_values_t * get_face_values
Definition: cs_equation_priv.h:385
cs_equation_set_dir_bc_t
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
double cs_real_t
Floating-point value.
Definition: cs_defs.h:304
cs_equation_update_field_t
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_equation_get_balance_t
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_t
Definition: cs_equation_priv.h:323
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:492
cs_matrix_t
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:94
cs_equation_extra_op_t
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_t::solve_steady_state
cs_equation_solve_t * solve_steady_state
Definition: cs_equation_priv.h:374
_cs_equation_t::initialize_system
cs_equation_initialize_system_t * initialize_system
Definition: cs_equation_priv.h:393
_cs_equation_t::compute_balance
cs_equation_get_balance_t * compute_balance
Definition: cs_equation_priv.h:377
_cs_equation_t::get_vertex_values
cs_equation_get_values_t * get_vertex_values
Definition: cs_equation_priv.h:387
cs_equation_initialize_system_t
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
_cs_equation_t::builder
cs_equation_builder_t * builder
Definition: cs_equation_priv.h:364
mesh
Definition: mesh.f90:26
_cs_equation_t::n_sles_scatter_elts
cs_lnum_t n_sles_scatter_elts
Definition: cs_equation_priv.h:346
cs_equation_prepare_solve_t
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
_cs_equation_t::read_restart
cs_equation_restart_t * read_restart
Definition: cs_equation_priv.h:381
cs_equation_build_system_t
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
_cs_equation_t::varname
char *restrict varname
Definition: cs_equation_priv.h:330
cs_equation_param_t
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:201
_cs_equation_t::current_to_previous
cs_equation_extra_op_t * current_to_previous
Definition: cs_equation_priv.h:379
_cs_equation_t::solve
cs_equation_solve_t * solve
Definition: cs_equation_priv.h:375
_cs_equation_t::get_cw_build_structures
cs_equation_get_builders_t * get_cw_build_structures
Definition: cs_equation_priv.h:389
_cs_equation_t::update_field
cs_equation_update_field_t * update_field
Definition: cs_equation_priv.h:397
_cs_equation_t::param
cs_equation_param_t * param
Definition: cs_equation_priv.h:327
cs_field.h
_cs_equation_t::postprocess
cs_equation_extra_op_t * postprocess
Definition: cs_equation_priv.h:378
_cs_equation_t::init_context
cs_equation_init_context_t * init_context
Definition: cs_equation_priv.h:370
cs_equation_get_builders_t
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....
Definition: cs_equation_priv.h:276
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_restart_t
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:93
cs_range_set_t
Definition: cs_range_set.h:57
cs_equation_init_values_t
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_cell_builder_t
Set of local and temporary buffers useful for building the algebraic system with a cellwise process....
Definition: cs_cdo_local.h:69
_cs_equation_t::id
int id
Definition: cs_equation_priv.h:325
_cs_equation_t::main_ts_id
int main_ts_id
Definition: cs_equation_priv.h:400
_cs_equation_t::n_sles_gather_elts
cs_lnum_t n_sles_gather_elts
Definition: cs_equation_priv.h:347
_cs_equation_t::matrix
cs_matrix_t * matrix
Definition: cs_equation_priv.h:355
cs_equation_builder_t
Store common elements used when building an algebraic system related to an equation.
_cs_equation_t::scheme_context
void * scheme_context
Definition: cs_equation_priv.h:367
cs_equation_init_context_t
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
cs_equation_free_context_t
void *() cs_equation_free_context_t(void *scheme_context)
Destroy a scheme data structure.
Definition: cs_equation_priv.h:84
matrix
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:112
atincl::solu
double precision, dimension(:,:), allocatable solu
Definition: atincl.f90:312
_cs_equation_t::free_context
cs_equation_free_context_t * free_context
Definition: cs_equation_priv.h:371
_cs_equation_t::build_system
cs_equation_build_system_t * build_system
Definition: cs_equation_priv.h:395
_cs_equation_t::boundary_flux_id
int boundary_flux_id
Definition: cs_equation_priv.h:332
cs_equation_param.h
Structure and routines handling the specific settings related to a cs_equation_t structure.
_cs_equation_t::init_field_values
cs_equation_init_values_t * init_field_values
Definition: cs_equation_priv.h:373
cs_cell_sys_t
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:107
_cs_equation_t::rset
const cs_range_set_t * rset
Definition: cs_equation_priv.h:358
cs_restart.h
_cs_equation_t::get_edge_values
cs_equation_get_values_t * get_edge_values
Definition: cs_equation_priv.h:386
_cs_equation_t::set_dir_bc
cs_equation_set_dir_bc_t * set_dir_bc
Definition: cs_equation_priv.h:394
cs_mesh_t
Definition: cs_mesh.h:84