programmer's documentation
cs_equation_common.h
Go to the documentation of this file.
1 #ifndef __CS_EQUATION_COMMON_H__
2 #define __CS_EQUATION_COMMON_H__
3 
4 /*============================================================================
5  * Routines to handle common equation features for building algebraic system
6  * in CDO schemes
7  *============================================================================*/
8 
9 /*
10  This file is part of Code_Saturne, a general-purpose CFD tool.
11 
12  Copyright (C) 1998-2018 EDF S.A.
13 
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22  details.
23 
24  You should have received a copy of the GNU General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26  Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28 
29 /*----------------------------------------------------------------------------
30  * Local headers
31  *----------------------------------------------------------------------------*/
32 
33 #include "cs_cdo_bc.h"
34 #include "cs_cdo_connect.h"
35 #include "cs_cdo_quantities.h"
36 #include "cs_cdo_time.h"
37 #include "cs_domain.h"
38 #include "cs_equation_param.h"
39 #include "cs_flag.h"
40 #include "cs_matrix.h"
41 #include "cs_range_set.h"
42 #include "cs_time_step.h"
43 #include "cs_timer.h"
44 #include "cs_source_term.h"
45 
46 /*----------------------------------------------------------------------------*/
47 
49 
50 /*============================================================================
51  * Macro definitions
52  *============================================================================*/
53 
54 /*============================================================================
55  * Type definitions
56  *============================================================================*/
57 
63 typedef struct {
64 
89  bool reac_pty_uniform[CS_CDO_N_MAX_REACTIONS];
108 
150 
151 /*
152  * Structure used to store information generated during the analysis
153  * of the balance of each term of an equation
154  */
155 typedef struct {
156 
157  /* where balance is computed: primal vertices or primal cells */
161 
162  /* Balance for each main term */
169 
171 
172 /*============================================================================
173  * Inline public function prototypes
174  *============================================================================*/
175 
176 /*----------------------------------------------------------------------------*/
185 /*----------------------------------------------------------------------------*/
186 
187 static inline cs_flag_t
189  const cs_equation_builder_t *eqb)
190 {
191  cs_flag_t _flag = eqb->msh_flag | eqb->st_msh_flag;
192 
193  if (cell_flag & CS_FLAG_BOUNDARY)
194  _flag |= eqb->bd_msh_flag;
195 
196  return _flag;
197 }
198 
199 /*============================================================================
200  * Public function prototypes
201  *============================================================================*/
202 
203 /*----------------------------------------------------------------------------*/
218 /*----------------------------------------------------------------------------*/
219 
220 void
222  const cs_cdo_quantities_t *quant,
223  const cs_time_step_t *time_step,
224  const cs_domain_cdo_context_t *cc);
225 
226 /*----------------------------------------------------------------------------*/
237 /*----------------------------------------------------------------------------*/
238 
239 void
241 
242 /*----------------------------------------------------------------------------*/
252 /*----------------------------------------------------------------------------*/
253 
256  const cs_mesh_t *mesh);
257 
258 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 
267 void
269 
270 /*----------------------------------------------------------------------------*/
287 /*----------------------------------------------------------------------------*/
288 
289 cs_gnum_t
290 cs_equation_prepare_system(int stride,
291  cs_lnum_t x_size,
292  const cs_real_t *x0,
293  const cs_real_t *rhs,
294  const cs_matrix_t *matrix,
296  cs_real_t *p_x[],
297  cs_real_t *p_rhs[]);
298 
299 /*----------------------------------------------------------------------------*/
307 /*----------------------------------------------------------------------------*/
308 
309 void
310 cs_equation_write_monitoring(const char *eqname,
311  const cs_equation_builder_t *eqb);
312 
313 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
325 void
327  const cs_cell_mesh_t *cm,
328  cs_cell_sys_t *csys);
329 
330 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 void
344  const cs_equation_builder_t *eqb,
345  cs_real_t t_eval,
346  cs_cell_builder_t *cb);
347 
348 /*----------------------------------------------------------------------------*/
358 /*----------------------------------------------------------------------------*/
359 
360 void
362  cs_lnum_t c_id,
363  cs_real_t t_eval,
364  cs_flag_t c_flag,
365  cs_cell_builder_t *cb);
366 
367 /*----------------------------------------------------------------------------*/
378 /*----------------------------------------------------------------------------*/
379 
380 void
382  const cs_cell_mesh_t *cm,
383  cs_real_t t_eval,
384  cs_flag_t c_flag,
385  cs_cell_builder_t *cb);
386 
387 /*----------------------------------------------------------------------------*/
404 /*----------------------------------------------------------------------------*/
405 
406 void
408  cs_cell_builder_t *cb,
409  cs_cell_sys_t *csys);
410 
411 /*----------------------------------------------------------------------------*/
419 /*----------------------------------------------------------------------------*/
420 
421 void
423  const cs_range_set_t *rset,
425 
426 /*----------------------------------------------------------------------------*/
436 /*----------------------------------------------------------------------------*/
437 
438 void
440  const cs_range_set_t *rset,
441  int n_x_dofs,
443 
444 /*----------------------------------------------------------------------------*/
450 /*----------------------------------------------------------------------------*/
451 
452 const cs_adjacency_t *
454 
455 /*----------------------------------------------------------------------------*/
461 /*----------------------------------------------------------------------------*/
462 
463 const cs_adjacency_t *
465 
466 /*----------------------------------------------------------------------------*/
474 /*----------------------------------------------------------------------------*/
475 
476 cs_real_t *
478 
479 /*----------------------------------------------------------------------------*/
485 /*----------------------------------------------------------------------------*/
486 
487 size_t
489 
490 /*----------------------------------------------------------------------------*/
499 /*----------------------------------------------------------------------------*/
500 
503  cs_lnum_t size);
504 
505 /*----------------------------------------------------------------------------*/
511 /*----------------------------------------------------------------------------*/
512 
513 void
515 
516 /*----------------------------------------------------------------------------*/
523 /*----------------------------------------------------------------------------*/
524 
525 void
528 
529 /*----------------------------------------------------------------------------*/
535 /*----------------------------------------------------------------------------*/
536 
537 void
539 
540 /*----------------------------------------------------------------------------*/
541 
543 
544 #endif /* __CS_EQUATION_COMMON_H__ */
cs_timer_counter_t tca
Definition: cs_equation_common.h:137
Store common elements used when building an algebraic system related to an equation.
Definition: cs_equation_common.h:63
time step descriptor
Definition: cs_time_step.h:51
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:281
cs_timer_counter_t tcd
Definition: cs_equation_common.h:135
const cs_range_set_t * rset
Definition: cs_equation_priv.h:377
const cs_adjacency_t * cs_equation_get_f2f_index(void)
Get the connectivity face->faces for the local rank.
Definition: cs_equation_common.c:1392
unsigned char cs_mask_t
Definition: cs_flag.h:129
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources...
Definition: cs_equation_param.h:159
struct _cs_matrix_assembler_values_t cs_matrix_assembler_values_t
Definition: cs_matrix_assembler.h:66
cs_timer_counter_t tcr
Definition: cs_equation_common.h:139
void cs_equation_free_builder(cs_equation_builder_t **p_builder)
Free a cs_equation_builder_t structure.
Definition: cs_equation_common.c:817
Definition: cs_mesh_adjacencies.h:90
cs_real_t * boundary_term
Definition: cs_equation_common.h:168
void cs_equation_assemble_matrix(const cs_cell_sys_t *csys, const cs_range_set_t *rset, cs_matrix_assembler_values_t *mav)
Assemble a cellwise system into the global algebraic system.
Definition: cs_equation_common.c:1237
#define BEGIN_C_DECLS
Definition: cs_defs.h:462
cs_real_t * balance
Definition: cs_equation_common.h:160
cs_lnum_t size
Definition: cs_equation_common.h:159
Set of local quantities and connectivities related to a mesh cell This is a key structure for all cel...
Definition: cs_cdo_local.h:163
cs_equation_balance_t * cs_equation_balance_create(cs_flag_t location, cs_lnum_t size)
Allocate a cs_equation_balance_t structure.
Definition: cs_equation_common.c:1439
Definition: cs_cdo_bc.h:95
cs_flag_t msh_flag
Definition: cs_equation_common.h:70
cs_flag_t location
Definition: cs_equation_common.h:158
#define CS_FLAG_BOUNDARY
Definition: cs_flag.h:49
void cs_equation_set_diffusion_property_cw(const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, cs_real_t t_eval, cs_flag_t c_flag, cs_cell_builder_t *cb)
Set the diffusion property inside a cell and its related quantities. Cellwise version using a cs_cell...
Definition: cs_equation_common.c:1135
Definition: cs_cdo_connect.h:74
cs_cdo_bc_t * face_bc
Definition: cs_equation_common.h:122
cs_timer_counter_t tcb
Definition: cs_equation_common.h:133
High-level metadata for handling CDO/HHO schemes.
Definition: cs_domain.h:63
void cs_equation_enforced_internal_dofs(const cs_equation_param_t *eqp, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
Take into account the enforcement of internal DoFs. Apply an algebraic manipulation.
Definition: cs_equation_common.c:1181
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:94
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:112
cs_real_t * advection_term
Definition: cs_equation_common.h:166
struct _cs_matrix_t cs_matrix_t
Definition: cs_matrix.h:90
Definition: cs_mesh.h:63
bool time_pty_uniform
Definition: cs_equation_common.h:88
cs_flag_t bd_msh_flag
Definition: cs_equation_common.h:73
cs_real_t * source_term
Definition: cs_equation_common.h:167
Definition: cs_equation_common.h:155
cs_flag_t st_msh_flag
Definition: cs_equation_common.h:76
const cs_adjacency_t * cs_equation_get_v2v_index(void)
Get the connectivity vertex->vertices for the local rank.
Definition: cs_equation_common.c:1378
cs_real_t * reaction_term
Definition: cs_equation_common.h:164
cs_equation_builder_t * cs_equation_init_builder(const cs_equation_param_t *eqp, const cs_mesh_t *mesh)
Allocate a new structure to handle the building of algebraic system related to an cs_equation_t struc...
Definition: cs_equation_common.c:739
cs_real_t * cs_equation_get_tmpbuf(void)
Retrieve a pointer to a buffer of size at least the 2*n_cells The size of the temporary buffer can be...
Definition: cs_equation_common.c:1408
Definition: cs_range_set.h:57
cs_timer_counter_t tce
Definition: cs_equation_common.h:143
Set of local and temporary buffers useful for building the algebraic system with a cellwise process...
Definition: cs_cdo_local.h:75
cs_timer_counter_t tcs
Definition: cs_equation_common.h:141
void cs_equation_set_diffusion_property(const cs_equation_param_t *eqp, cs_lnum_t c_id, cs_real_t t_eval, cs_flag_t c_flag, cs_cell_builder_t *cb)
Set the diffusion property inside a cell and its related quantities.
Definition: cs_equation_common.c:1095
void cs_equation_common_free(const cs_domain_cdo_context_t *cc)
Allocate a pointer to a buffer of size at least the 2*n_cells for managing temporary usage of memory ...
Definition: cs_equation_common.c:663
void cs_equation_balance_reset(cs_equation_balance_t *b)
Reset a cs_equation_balance_t structure.
Definition: cs_equation_common.c:1472
cs_flag_t sys_flag
Definition: cs_equation_common.h:79
cs_real_t * rhs
Definition: cs_equation_priv.h:370
#define CS_CDO_N_MAX_REACTIONS
Definition: cs_param_cdo.h:52
bool diff_pty_uniform
Definition: cs_equation_common.h:87
cs_real_t * diffusion_term
Definition: cs_equation_common.h:165
cs_gnum_t cs_equation_prepare_system(int stride, cs_lnum_t x_size, const cs_real_t *x0, const cs_real_t *rhs, const cs_matrix_t *matrix, cs_range_set_t *rset, cs_real_t *p_x[], cs_real_t *p_rhs[])
Prepare a linear system and synchronize buffers to handle parallelism. Transfer a mesh-based descript...
Definition: cs_equation_common.c:857
void cs_equation_write_monitoring(const char *eqname, const cs_equation_builder_t *eqb)
Print a message in the performance output file related to the monitoring of equation.
Definition: cs_equation_common.c:974
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void cs_equation_balance_sync(const cs_cdo_connect_t *connect, cs_equation_balance_t *b)
Synchronize balance terms if this is a parallel computation.
Definition: cs_equation_common.c:1497
#define END_C_DECLS
Definition: cs_defs.h:463
unsigned short int cs_flag_t
Definition: cs_defs.h:299
void cs_equation_common_allocate(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, const cs_domain_cdo_context_t *cc)
Allocate a pointer to a buffer of size at least the 2*n_cells for managing temporary usage of memory ...
Definition: cs_equation_common.c:347
#define CS_N_MAX_SOURCE_TERMS
Definition: cs_source_term.h:49
cs_real_t * unsteady_term
Definition: cs_equation_common.h:163
static cs_flag_t cs_equation_cell_mesh_flag(cs_flag_t cell_flag, const cs_equation_builder_t *eqb)
Retrieve the flag to give for building a cs_cell_mesh_t structure.
Definition: cs_equation_common.h:188
size_t cs_equation_get_tmpbuf_size(void)
Get the allocation size of the temporary buffer.
Definition: cs_equation_common.c:1422
void cs_equation_init_cell_sys_bc(const cs_equation_builder_t *eqb, const cs_cell_mesh_t *cm, cs_cell_sys_t *csys)
Set members of the cs_cell_sys_t structure related to the boundary conditions. Only the generic part ...
Definition: cs_equation_common.c:1012
cs_mask_t * source_mask
Definition: cs_equation_common.h:98
void cs_equation_balance_destroy(cs_equation_balance_t **p_balance)
Free a cs_equation_balance_t structure.
Definition: cs_equation_common.c:1528
Structure and routines handling the specific settings related to a cs_equation_t structure.
void cs_equation_assemble_block_matrix(const cs_cell_sys_t *csys, const cs_range_set_t *rset, int n_x_dofs, cs_matrix_assembler_values_t *mav)
Assemble a cellwise system defined by blocks into the global algebraic system.
Definition: cs_equation_common.c:1300
Definition: mesh.f90:26
void() cs_source_term_cellwise_t(const cs_xdef_t *source, const cs_cell_mesh_t *cm, cs_real_t time_eval, cs_cell_builder_t *cb, void *input, double *values)
Compute the contribution for a cell related to a source term and add it the given array of values...
Definition: cs_source_term.h:70
void cs_equation_init_properties(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, cs_real_t t_eval, cs_cell_builder_t *cb)
Initialize all properties for an algebraic system.
Definition: cs_equation_common.c:1047
Definition: cs_timer.h:57
double precision, save b
Definition: cs_fuel_incl.f90:146
cs_matrix_t * matrix
Definition: cs_equation_priv.h:374