My Project
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-2019 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 /*----------------------------------------------------------------------------*/
98 /*----------------------------------------------------------------------------*/
99 
100 typedef void
102  const int field_id,
103  const cs_mesh_t *mesh,
104  const cs_equation_param_t *eqp,
106  void *context);
107 
108 /*----------------------------------------------------------------------------*/
118 /*----------------------------------------------------------------------------*/
119 
120 typedef void
122  const int field_id,
123  const cs_equation_param_t *eqp,
125  void *eqc);
126 
127 /*----------------------------------------------------------------------------*/
138 /*----------------------------------------------------------------------------*/
139 
140 typedef void
142  const cs_mesh_t *mesh,
143  const cs_equation_param_t *eqp,
145  void *context,
146  cs_real_t field_val[]);
147 
148 /*----------------------------------------------------------------------------*/
160 /*----------------------------------------------------------------------------*/
161 
162 typedef void
165  void *data,
166  cs_matrix_t **system_matrix,
167  cs_real_t **system_rhs);
168 
169 /*----------------------------------------------------------------------------*/
181 /*----------------------------------------------------------------------------*/
182 
183 typedef void
185  const cs_real_t *field_val,
186  const cs_equation_param_t *eqp,
188  void *data,
189  cs_real_t *rhs,
190  cs_matrix_t *matrix);
191 
192 /*----------------------------------------------------------------------------*/
202 /*----------------------------------------------------------------------------*/
203 
204 typedef void
205 (cs_equation_prepare_solve_t)(void *eq_to_cast,
206  cs_real_t *p_x[],
207  cs_real_t *p_rhs[]);
208 
209 /*----------------------------------------------------------------------------*/
221 /*----------------------------------------------------------------------------*/
222 
223 typedef void
225  const cs_real_t *rhs,
226  const cs_equation_param_t *eqp,
228  void *data,
229  cs_real_t *field_val);
230 
231 /*----------------------------------------------------------------------------*/
242 /*----------------------------------------------------------------------------*/
243 
244 typedef cs_equation_balance_t *
247  void *context);
248 
249 /*----------------------------------------------------------------------------*/
259 /*----------------------------------------------------------------------------*/
260 
261 typedef void
262 (cs_equation_extra_op_t)(const char *eqname,
263  const cs_field_t *field,
264  const cs_equation_param_t *eqp,
266  void *data);
267 
268 /*----------------------------------------------------------------------------*/
279 /*----------------------------------------------------------------------------*/
280 
281 typedef cs_real_t *
282 (cs_equation_get_values_t)(void *scheme_context);
283 
284 /*----------------------------------------------------------------------------*/
293 /*----------------------------------------------------------------------------*/
294 
295 typedef void
297  const char *eqname,
298  void *scheme_context);
299 
300 /*----------------------------------------------------------------------------
301  * Structure type
302  *----------------------------------------------------------------------------*/
303 
311 
312  int id;
313 
314  cs_equation_param_t *param; /* Set of parameters related to an equation */
315 
316  /* Variable attached to this equation is defined as a cs_field_t structure */
318  int field_id;
320 
321  /* Algebraic system */
322  /* ---------------- */
323 
324  /* There are possibly two different sizes for the linear system to handle
325  - One for "scatter"-type operations based on the number of geometrical
326  entities owned by the local instance of the mesh
327  - One for "gather"-type operations based on a balance of the number of
328  DoFs from a algebraic point of view. In parallel runs, these two sizes
329  can be different.
330  n_sles_gather_elts <= n_sles_scatter_elts
331  */
332 
335 
336  /* Right-hand side defined by a local cellwise building. This may be
337  different from the rhs given to cs_sles_solve() in parallel mode. */
339 
340  /* Matrix to inverse with cs_sles_solve() The matrix size can be different
341  from the rhs size in parallel mode since the decomposition is different */
343 
344  /* Range set to handle parallelism. Shared with cs_cdo_connect_t struct.*/
346 
347  /* \var builder
348  * Common members for building the algebraic system between the numerical
349  * schemes
350  */
352 
353  /* Data depending on the numerical scheme (cast on-the-fly) */
355 
356  /* Pointer to functions (see prototypes just above) */
359 
363 
368 
372 
373  /* Deprecated functions --> use rather solve() and solve_steady_state() */
379 
380  /* Timer statistic for a coarse profiling */
381  int main_ts_id; /* Id of the main timer stats for this equation */
382 
383 };
384 
385 /*============================================================================
386  * Public function prototypes
387  *============================================================================*/
388 
389 
390 /*----------------------------------------------------------------------------*/
391 
393 
394 #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:296
cs_equation_solve_t
void() cs_equation_solve_t(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_t::get_cell_values
cs_equation_get_values_t * get_cell_values
Definition: cs_equation_priv.h:370
cs_equation_balance_t
Definition: cs_equation_common.h:156
_cs_equation_t::field_id
int field_id
Definition: cs_equation_priv.h:318
_cs_equation_t::rhs
cs_real_t * rhs
Definition: cs_equation_priv.h:338
_cs_equation_t::prepare_solving
cs_equation_prepare_solve_t * prepare_solving
Definition: cs_equation_priv.h:377
cs_equation_common.h
field
Definition: field.f90:27
restrict
#define restrict
Definition: cs_defs.h:127
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
_cs_equation_t::write_restart
cs_equation_restart_t * write_restart
Definition: cs_equation_priv.h:367
_cs_equation_t::get_face_values
cs_equation_get_values_t * get_face_values
Definition: cs_equation_priv.h:369
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:141
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
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:224
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:245
_cs_equation_t
Definition: cs_equation_priv.h:310
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_matrix_t
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:90
_cs_equation_t::solve_steady_state
cs_equation_solve_t * solve_steady_state
Definition: cs_equation_priv.h:361
_cs_equation_t::initialize_system
cs_equation_initialize_system_t * initialize_system
Definition: cs_equation_priv.h:374
_cs_equation_t::compute_balance
cs_equation_get_balance_t * compute_balance
Definition: cs_equation_priv.h:364
_cs_equation_t::get_vertex_values
cs_equation_get_values_t * get_vertex_values
Definition: cs_equation_priv.h:371
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:163
_cs_equation_t::builder
cs_equation_builder_t * builder
Definition: cs_equation_priv.h:351
mesh
Definition: mesh.f90:26
_cs_equation_t::n_sles_scatter_elts
cs_lnum_t n_sles_scatter_elts
Definition: cs_equation_priv.h:333
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:205
_cs_equation_t::read_restart
cs_equation_restart_t * read_restart
Definition: cs_equation_priv.h:366
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:184
_cs_equation_t::varname
char *restrict varname
Definition: cs_equation_priv.h:317
cs_equation_param_t
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:148
_cs_equation_t::solve
cs_equation_solve_t * solve
Definition: cs_equation_priv.h:362
_cs_equation_t::update_field
cs_equation_update_field_t * update_field
Definition: cs_equation_priv.h:378
_cs_equation_t::param
cs_equation_param_t * param
Definition: cs_equation_priv.h:314
cs_field.h
_cs_equation_t::postprocess
cs_equation_extra_op_t * postprocess
Definition: cs_equation_priv.h:365
_cs_equation_t::init_context
cs_equation_init_context_t * init_context
Definition: cs_equation_priv.h:357
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:87
cs_range_set_t
Definition: cs_range_set.h:57
cs_equation_extra_op_t
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:262
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:101
_cs_equation_t::id
int id
Definition: cs_equation_priv.h:312
_cs_equation_t::main_ts_id
int main_ts_id
Definition: cs_equation_priv.h:381
_cs_equation_t::n_sles_gather_elts
cs_lnum_t n_sles_gather_elts
Definition: cs_equation_priv.h:334
_cs_equation_t::matrix
cs_matrix_t * matrix
Definition: cs_equation_priv.h:342
cs_equation_builder_t
Store common elements used when building an algebraic system related to an equation.
Definition: cs_equation_common.h:61
_cs_equation_t::scheme_context
void * scheme_context
Definition: cs_equation_priv.h:354
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:69
cs_equation_free_context_t
void *() cs_equation_free_context_t(void *scheme_context)
Destroy a scheme data structure.
Definition: cs_equation_priv.h:85
atincl::solu
double precision, dimension(:,:), allocatable solu
Definition: atincl.f90:265
_cs_equation_t::free_context
cs_equation_free_context_t * free_context
Definition: cs_equation_priv.h:358
_cs_equation_t::build_system
cs_equation_build_system_t * build_system
Definition: cs_equation_priv.h:376
_cs_equation_t::boundary_flux_id
int boundary_flux_id
Definition: cs_equation_priv.h:319
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:360
cs_equation_get_values_t
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,...
Definition: cs_equation_priv.h:282
_cs_equation_t::rset
const cs_range_set_t * rset
Definition: cs_equation_priv.h:345
cs_restart.h
cs_field_t
Field descriptor.
Definition: cs_field.h:124
_cs_equation_t::set_dir_bc
cs_equation_set_dir_bc_t * set_dir_bc
Definition: cs_equation_priv.h:375
cs_mesh_t
Definition: cs_mesh.h:63
cs_param.h