My Project
programmer's documentation
Loading...
Searching...
No Matches
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-2019 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_local.h"
36#include "cs_cdo_quantities.h"
37#include "cs_equation_param.h"
38#include "cs_flag.h"
39#include "cs_matrix.h"
40#include "cs_time_step.h"
41#include "cs_timer.h"
42#include "cs_source_term.h"
43
44/*----------------------------------------------------------------------------*/
45
47
48/*============================================================================
49 * Macro definitions
50 *============================================================================*/
51
52/*============================================================================
53 * Type definitions
54 *============================================================================*/
55
151
152/*
153 * Structure used to store information generated during the analysis
154 * of the balance of each term of an equation
155 */
156typedef struct {
157
158 /* where balance is computed: primal vertices or primal cells */
162
163 /* Balance for each main term */
170
172
173/*============================================================================
174 * Inline public function prototypes
175 *============================================================================*/
176
177/*----------------------------------------------------------------------------*/
186/*----------------------------------------------------------------------------*/
187
188static inline cs_flag_t
190 const cs_equation_builder_t *eqb)
191{
192 cs_flag_t _flag = eqb->msh_flag | eqb->st_msh_flag;
193
194 if (cell_flag & CS_FLAG_BOUNDARY_CELL_BY_FACE)
195 _flag |= eqb->bd_msh_flag;
196
197 return _flag;
198}
199
200/*----------------------------------------------------------------------------*/
210/*----------------------------------------------------------------------------*/
211
212static inline void
214 const cs_lnum_t c_id,
215 const cs_real_t t_eval,
216 const cs_flag_t c_flag,
218{
220 t_eval,
223 cb->dpty_mat);
224
226 cb->dpty_val = cb->dpty_mat[0][0];
227
228 /* Set additional quantities in case of more advanced way of enforcing the
229 Dirichlet BCs */
230 if (c_flag & CS_FLAG_BOUNDARY_CELL_BY_FACE) {
233 cs_math_33_eigen((const cs_real_t (*)[3])cb->dpty_mat,
234 &(cb->eig_ratio),
235 &(cb->eig_max));
236 }
237}
238
239/*----------------------------------------------------------------------------*/
250/*----------------------------------------------------------------------------*/
251
252static inline void
254 const cs_cell_mesh_t *cm,
255 const cs_real_t t_eval,
256 const cs_flag_t c_flag,
258{
261 t_eval,
263 cb->dpty_mat);
264
266 cb->dpty_val = cb->dpty_mat[0][0];
267
268 /* Set additional quantities in case of more advanced way of enforcing the
269 Dirichlet BCs */
270 if (c_flag & CS_FLAG_BOUNDARY_CELL_BY_FACE) {
273 cs_math_33_eigen((const cs_real_t (*)[3])cb->dpty_mat,
274 &(cb->eig_ratio),
275 &(cb->eig_max));
276 }
277}
278
279/*============================================================================
280 * Public function prototypes
281 *============================================================================*/
282
283/*----------------------------------------------------------------------------*/
299/*----------------------------------------------------------------------------*/
300
301void
303 const cs_cdo_quantities_t *quant,
304 const cs_time_step_t *time_step,
305 cs_flag_t vb_flag,
306 cs_flag_t vcb_flag,
307 cs_flag_t fb_flag,
308 cs_flag_t hho_flag);
309
310/*----------------------------------------------------------------------------*/
319/*----------------------------------------------------------------------------*/
320
321void
323
324/*----------------------------------------------------------------------------*/
334/*----------------------------------------------------------------------------*/
335
338 const cs_mesh_t *mesh);
339
340/*----------------------------------------------------------------------------*/
347/*----------------------------------------------------------------------------*/
348
349void
351
352/*----------------------------------------------------------------------------*/
367/*----------------------------------------------------------------------------*/
368
369cs_gnum_t
371 cs_lnum_t x_size,
372 const cs_matrix_t *matrix,
373 cs_range_set_t *rset,
374 cs_real_t *x,
375 cs_real_t *b);
376
377/*----------------------------------------------------------------------------*/
385/*----------------------------------------------------------------------------*/
386
387void
388cs_equation_write_monitoring(const char *eqname,
389 const cs_equation_builder_t *eqb);
390
391/*----------------------------------------------------------------------------*/
401/*----------------------------------------------------------------------------*/
402
403void
405 const cs_equation_builder_t *eqb,
406 const cs_real_t t_eval,
408
409/*----------------------------------------------------------------------------*/
424/*----------------------------------------------------------------------------*/
425
426void
428 const cs_equation_builder_t *eqb,
429 const cs_real_t t_eval,
430 const cs_flag_t cell_flag,
431 const cs_cell_mesh_t *cm,
433
434/*----------------------------------------------------------------------------*/
444/*----------------------------------------------------------------------------*/
445
446void
448 cs_lnum_t c_id,
449 cs_real_t t_eval,
450 cs_flag_t c_flag,
452
453/*----------------------------------------------------------------------------*/
464/*----------------------------------------------------------------------------*/
465
466void
468 const cs_cell_mesh_t *cm,
469 cs_real_t t_eval,
470 cs_flag_t c_flag,
472
473/*----------------------------------------------------------------------------*/
490/*----------------------------------------------------------------------------*/
491
492void
495 cs_cell_sys_t *csys);
496
497/*----------------------------------------------------------------------------*/
514/*----------------------------------------------------------------------------*/
515
516void
519 cs_cell_sys_t *csys);
520
521/*----------------------------------------------------------------------------*/
529/*----------------------------------------------------------------------------*/
530
531cs_real_t *
533
534/*----------------------------------------------------------------------------*/
540/*----------------------------------------------------------------------------*/
541
542size_t
544
545/*----------------------------------------------------------------------------*/
554/*----------------------------------------------------------------------------*/
555
558 cs_lnum_t size);
559
560/*----------------------------------------------------------------------------*/
566/*----------------------------------------------------------------------------*/
567
568void
570
571/*----------------------------------------------------------------------------*/
578/*----------------------------------------------------------------------------*/
579
580void
583
584/*----------------------------------------------------------------------------*/
590/*----------------------------------------------------------------------------*/
591
592void
594
595/*----------------------------------------------------------------------------*/
596
598
599#endif /* __CS_EQUATION_COMMON_H__ */
#define BEGIN_C_DECLS
Definition cs_defs.h:467
double cs_real_t
Floating-point value.
Definition cs_defs.h:302
#define END_C_DECLS
Definition cs_defs.h:468
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:298
unsigned short int cs_flag_t
Definition cs_defs.h:304
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:588
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:243
void cs_equation_balance_reset(cs_equation_balance_t *b)
Reset a cs_equation_balance_t structure.
Definition cs_equation_common.c:809
void cs_equation_init_properties(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_real_t t_eval, cs_cell_builder_t *cb)
Initialize all properties for an algebraic system.
Definition cs_equation_common.c:482
cs_gnum_t cs_equation_prepare_system(int stride, cs_lnum_t x_size, const cs_matrix_t *matrix, cs_range_set_t *rset, cs_real_t *x, cs_real_t *b)
Prepare a linear system and synchronize buffers to handle parallelism. Transfer a mesh-based descript...
Definition cs_equation_common.c:363
void cs_equation_init_properties_cw(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_real_t t_eval, const cs_flag_t cell_flag, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb)
Initialize all properties for a given cell when building the algebraic system. If the property is uni...
Definition cs_equation_common.c:536
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:189
static void cs_equation_set_diffusion_property_cw(const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, const cs_real_t t_eval, const 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.h:253
void cs_equation_balance_destroy(cs_equation_balance_t **p_balance)
Free a cs_equation_balance_t structure.
Definition cs_equation_common.c:865
void cs_equation_enforced_internal_block_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. Case of matrices defined by blocks....
Definition cs_equation_common.c:653
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:773
static void cs_equation_set_diffusion_property(const cs_equation_param_t *eqp, const cs_lnum_t c_id, const cs_real_t t_eval, const 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.h:213
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:444
void cs_equation_common_init(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step, cs_flag_t vb_flag, cs_flag_t vcb_flag, cs_flag_t fb_flag, cs_flag_t hho_flag)
Allocate a pointer to a buffer of size at least the n_cells for managing temporary usage of memory wh...
Definition cs_equation_common.c:115
void cs_equation_free_builder(cs_equation_builder_t **p_builder)
Free a cs_equation_builder_t structure.
Definition cs_equation_common.c:325
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:742
size_t cs_equation_get_tmpbuf_size(void)
Get the allocation size of the temporary buffer.
Definition cs_equation_common.c:756
void cs_equation_common_finalize(void)
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:221
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:834
Structure and routines handling the specific settings related to a cs_equation_t structure.
#define CS_FLAG_BOUNDARY_CELL_BY_FACE
Definition cs_flag.h:49
unsigned char cs_mask_t
Definition cs_flag.h:150
void cs_math_33_eigen(const cs_real_t m[3][3], cs_real_t *eig_ratio, cs_real_t *eig_max)
Compute max/min eigenvalues ratio and max. eigenvalue of a 3x3 symmetric matrix with non-symmetric st...
Definition cs_math.c:303
struct _cs_matrix_t cs_matrix_t
Definition cs_matrix.h:90
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
@ CS_PARAM_BC_ENFORCE_WEAK_SYM
Definition cs_param.h:348
@ CS_PARAM_BC_ENFORCE_WEAK_NITSCHE
Definition cs_param.h:347
#define CS_CDO_N_MAX_REACTIONS
Definition cs_param_cdo.h:68
void cs_property_get_cell_tensor(cs_lnum_t c_id, cs_real_t t_eval, const cs_property_t *pty, bool do_inversion, cs_real_3_t *tensor)
Compute the value of the tensor attached a property at the cell center.
Definition cs_property.c:1026
void cs_property_tensor_in_cell(const cs_cell_mesh_t *cm, const cs_property_t *pty, cs_real_t t_eval, bool do_inversion, cs_real_3_t *tensor)
Compute the value of the tensor attached a property at the cell center Version using a cs_cell_mesh_t...
Definition cs_property.c:1178
static bool cs_property_is_isotropic(const cs_property_t *pty)
returns true if the property is isotropic, otherwise false
Definition cs_property.h:276
#define CS_N_MAX_SOURCE_TERMS
Definition cs_source_term.h:49
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
Definition mesh.f90:26
Definition cs_cdo_bc.h:86
Definition cs_cdo_connect.h:74
Definition cs_cdo_quantities.h:94
Set of local and temporary buffers useful for building the algebraic system with a cellwise process....
Definition cs_cdo_local.h:56
double eig_max
Definition cs_cdo_local.h:60
double dpty_val
Definition cs_cdo_local.h:64
double eig_ratio
Definition cs_cdo_local.h:59
cs_real_33_t dpty_mat
Definition cs_cdo_local.h:63
Set of local quantities and connectivities related to a mesh cell This is a key structure for all cel...
Definition cs_cdo_local.h:146
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:93
Definition cs_equation_common.h:156
cs_real_t * boundary_term
Definition cs_equation_common.h:169
cs_real_t * unsteady_term
Definition cs_equation_common.h:164
cs_real_t * advection_term
Definition cs_equation_common.h:167
cs_real_t * reaction_term
Definition cs_equation_common.h:165
cs_real_t * source_term
Definition cs_equation_common.h:168
cs_lnum_t size
Definition cs_equation_common.h:160
cs_flag_t location
Definition cs_equation_common.h:159
cs_real_t * balance
Definition cs_equation_common.h:161
cs_real_t * diffusion_term
Definition cs_equation_common.h:166
Store common elements used when building an algebraic system related to an equation.
Definition cs_equation_common.h:61
cs_timer_counter_t tcr
Definition cs_equation_common.h:140
cs_timer_counter_t tcs
Definition cs_equation_common.h:142
cs_flag_t sys_flag
Definition cs_equation_common.h:79
cs_cdo_bc_face_t * face_bc
Definition cs_equation_common.h:122
bool init_step
Definition cs_equation_common.h:63
cs_mask_t * source_mask
Definition cs_equation_common.h:98
cs_flag_t msh_flag
Definition cs_equation_common.h:70
cs_timer_counter_t tcb
Definition cs_equation_common.h:134
cs_timer_counter_t tcd
Definition cs_equation_common.h:136
cs_timer_counter_t tce
Definition cs_equation_common.h:144
cs_flag_t bd_msh_flag
Definition cs_equation_common.h:73
bool diff_pty_uniform
Definition cs_equation_common.h:87
cs_timer_counter_t tca
Definition cs_equation_common.h:138
bool time_pty_uniform
Definition cs_equation_common.h:88
cs_flag_t st_msh_flag
Definition cs_equation_common.h:76
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition cs_equation_param.h:148
cs_param_bc_enforce_t default_enforcement
Definition cs_equation_param.h:219
cs_property_t * diffusion_property
Definition cs_equation_param.h:286
cs_param_hodge_t diffusion_hodge
Definition cs_equation_param.h:285
Definition cs_mesh.h:63
bool inv_pty
Definition cs_param_cdo.h:132
Definition cs_range_set.h:57
time step descriptor
Definition cs_time_step.h:51
Definition cs_timer.h:57