7.1
general documentation
cs_equation_common.h File Reference
#include "cs_cdo_bc.h"
#include "cs_cdo_connect.h"
#include "cs_cdo_local.h"
#include "cs_cdo_quantities.h"
#include "cs_enforcement.h"
#include "cs_equation_param.h"
#include "cs_flag.h"
#include "cs_matrix.h"
#include "cs_time_step.h"
#include "cs_timer.h"
#include "cs_sles.h"
#include "cs_source_term.h"
+ Include dependency graph for cs_equation_common.h:

Go to the source code of this file.

Data Structures

struct  cs_equation_builder_t
 
struct  cs_equation_balance_t
 

Macros

#define CS_EQUATION_SYNC_ZERO_VALUE   1
 
#define CS_EQUATION_SYNC_MEAN_VALUE   2
 

Typedefs

typedef void() cs_equation_user_hook_t(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const void *eq_context, const cs_cell_mesh_t *cm, cs_hodge_t *mass_hodge, cs_hodge_t *diff_hodge, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
 Generic function prototype for a hook during the cellwise building of the linear system Enable an advanced user to get a fine control of the discretization. More...
 

Functions

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 eb_flag, cs_flag_t fb_flag, cs_flag_t vb_flag, cs_flag_t vcb_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 when dealing with equations The size of the temporary buffer can be bigger according to the numerical settings Set also shared pointers from the main domain members. More...
 
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 when dealing with equations Call specific structure allocation related to a numerical scheme according to the scheme flag The size of the temporary buffer can be bigger according to the numerical settings. More...
 
cs_equation_builder_tcs_equation_builder_init (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 structure. More...
 
void cs_equation_builder_free (cs_equation_builder_t **p_builder)
 Free a cs_equation_builder_t structure. More...
 
void cs_equation_builder_reset (cs_equation_builder_t *eqb)
 Free some members of a cs_equation_builder_t structure. More...
 
void cs_equation_sync_rhs_normalization (cs_param_resnorm_type_t type, cs_lnum_t rhs_size, const cs_real_t rhs[], double *normalization)
 Compute the value of the renormalization coefficient for the the residual norm of the linear system A pre-computation arising from cellwise contribution may have been done before this call according to the requested type of renormalization. More...
 
void cs_equation_prepare_system (int stride, cs_lnum_t x_size, const cs_matrix_t *matrix, const cs_range_set_t *rset, bool rhs_redux, cs_real_t *x, cs_real_t *b)
 Prepare a linear system and synchronize buffers to handle parallelism. Transfer a mesh-based description of arrays x0 and rhs into an algebraic description for the linear system in x and b. More...
 
int cs_equation_solve_scalar_cell_system (cs_lnum_t n_dofs, const cs_param_sles_t *slesp, const cs_matrix_t *matrix, cs_real_t normalization, cs_sles_t *sles, cs_real_t *x, cs_real_t *b)
 Solve a linear system arising with scalar-valued cell-based DoFs No rotation is taken into account when synchronizing halo. More...
 
int cs_equation_solve_scalar_system (cs_lnum_t n_scatter_dofs, const cs_param_sles_t *slesp, const cs_matrix_t *matrix, const cs_range_set_t *rset, cs_real_t normalization, bool rhs_redux, cs_sles_t *sles, cs_real_t *x, cs_real_t *b)
 Solve a linear system arising from CDO schemes with scalar-valued degrees of freedom. More...
 
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. More...
 
void cs_equation_init_reaction_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 reaction properties. This function is shared across all CDO schemes. The cs_cell_builder_t structure stores the computed property values. More...
 
void cs_equation_set_reaction_properties_cw (const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb)
 Initialize all reaction properties. This function is shared across all CDO schemes. The cs_cell_builder_t structure stores the computed property values. If the property is uniform, a first call to the function cs_equation_init_reaction_properties or to the function cs_equation_init_properties has to be done before the loop on cells. More...
 
void cs_equation_init_properties (const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, cs_hodge_t *diffusion_hodge, cs_cell_builder_t *cb)
 Initialize all properties potentially useful to build the algebraic system. This function is shared across all CDO schemes. The cs_cell_builder_t structure stores property values related to the reaction term, unsteady term and grad-div term. More...
 
void cs_equation_build_dof_enforcement (cs_lnum_t n_x, const cs_adjacency_t *c2x, const cs_interface_set_t *ifs, const cs_equation_param_t *eqp, cs_lnum_t *p_dof_ids[])
 Build the list of degrees of freedom (DoFs) related to an internal enforcement. If set to NULL, the array dof_ids (storing the indirection) is allocated to n_x. More...
 
void cs_equation_enforced_internal_dofs (const cs_equation_builder_t *eqb, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
 Take into account the enforcement of internal DoFs. Apply an algebraic manipulation. Update members of the cs_cell_sys_t structure related to the internal enforcement. More...
 
void cs_equation_enforced_internal_block_dofs (const cs_equation_builder_t *eqb, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
 Take into account the enforcement of internal DoFs. Case of matrices defined by blocks. Apply an algebraic manipulation. Update members of the cs_cell_sys_t structure related to the internal enforcement. More...
 
cs_real_tcs_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 bigger according to the numerical settings. More...
 
size_t cs_equation_get_tmpbuf_size (void)
 Get the allocation size of the temporary buffer. More...
 
cs_equation_balance_tcs_equation_balance_create (cs_flag_t location, cs_lnum_t size)
 Allocate a cs_equation_balance_t structure. More...
 
void cs_equation_balance_reset (cs_equation_balance_t *b)
 Reset a cs_equation_balance_t structure. More...
 
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. More...
 
void cs_equation_balance_destroy (cs_equation_balance_t **p_balance)
 Free a cs_equation_balance_t structure. More...
 
void cs_equation_sync_vol_def_at_vertices (const cs_cdo_connect_t *connect, int n_defs, cs_xdef_t **defs, cs_lnum_t def2v_idx[], cs_lnum_t def2v_ids[])
 Synchronize the volumetric definitions to consider at each vertex. More...
 
void cs_equation_sync_vol_def_at_edges (const cs_cdo_connect_t *connect, int n_defs, cs_xdef_t **defs, cs_lnum_t def2e_idx[], cs_lnum_t def2e_ids[])
 Synchronize the volumetric definitions to consider at each edge. More...
 
void cs_equation_sync_vol_def_at_faces (const cs_cdo_connect_t *connect, int n_defs, cs_xdef_t **defs, cs_lnum_t def2f_idx[], cs_lnum_t def2f_ids[])
 Synchronize the volumetric definitions to consider at each face. More...
 
void cs_equation_sync_vertex_mean_values (const cs_cdo_connect_t *connect, int dim, int *counter, cs_real_t *values)
 Compute the mean-value across ranks at each vertex. More...
 

Macro Definition Documentation

◆ CS_EQUATION_SYNC_MEAN_VALUE

#define CS_EQUATION_SYNC_MEAN_VALUE   2

◆ CS_EQUATION_SYNC_ZERO_VALUE

#define CS_EQUATION_SYNC_ZERO_VALUE   1

Typedef Documentation

◆ cs_equation_user_hook_t

typedef void() cs_equation_user_hook_t(const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const void *eq_context, const cs_cell_mesh_t *cm, cs_hodge_t *mass_hodge, cs_hodge_t *diff_hodge, cs_cell_sys_t *csys, cs_cell_builder_t *cb)

Generic function prototype for a hook during the cellwise building of the linear system Enable an advanced user to get a fine control of the discretization.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]eqbpointer to a cs_equation_builder_t structure
[in]eqccontext to cast for this discretization
[in]cmpointer to a cellwise view of the mesh
[in,out]mass_hodgepointer to a cs_hodge_t structure (mass matrix)
[in,out]diff_hodgepointer to a cs_hodge_t structure (diffusion)
[in,out]csyspointer to a cellwise view of the system
[in,out]cbpointer to a cellwise builder

Function Documentation

◆ cs_equation_balance_create()

cs_equation_balance_t* cs_equation_balance_create ( cs_flag_t  location,
cs_lnum_t  size 
)

Allocate a cs_equation_balance_t structure.

Parameters
[in]locationwhere the balance is performed
[in]sizesize of arrays in the structure
Returns
a pointer to the new allocated structure

◆ cs_equation_balance_destroy()

void cs_equation_balance_destroy ( cs_equation_balance_t **  p_balance)

Free a cs_equation_balance_t structure.

Parameters
[in,out]p_balancepointer to the pointer to free

◆ cs_equation_balance_reset()

void cs_equation_balance_reset ( cs_equation_balance_t b)

Reset a cs_equation_balance_t structure.

Parameters
[in,out]bpointer to a cs_equation_balance_t to reset

◆ cs_equation_balance_sync()

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.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in,out]bpointer to a cs_equation_balance_t to rsync

◆ cs_equation_build_dof_enforcement()

void cs_equation_build_dof_enforcement ( cs_lnum_t  n_x,
const cs_adjacency_t c2x,
const cs_interface_set_t ifs,
const cs_equation_param_t eqp,
cs_lnum_t p_dof_ids[] 
)

Build the list of degrees of freedom (DoFs) related to an internal enforcement. If set to NULL, the array dof_ids (storing the indirection) is allocated to n_x.

Parameters
[in]n_xnumber of entities where DoFs are defined
[in]c2xcell –> x connectivity
[in]ifspointer to a fvm_interface_set_t structure
[in]eqpset of parameters related to an equation
[in,out]p_dof_idsdouble pointer on DoF ids subject to enforcement

◆ cs_equation_builder_free()

void cs_equation_builder_free ( cs_equation_builder_t **  p_builder)

Free a cs_equation_builder_t structure.

Parameters
[in,out]p_builderpointer of pointer to the cs_equation_builder_t structure to free

◆ cs_equation_builder_init()

cs_equation_builder_t* cs_equation_builder_init ( 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 structure.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]meshpointer to a cs_mesh_t structure
Returns
a pointer to a new allocated cs_equation_builder_t structure

Allocate a new structure to handle the building of algebraic system related to an cs_equation_t structure.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]meshpointer to a cs_mesh_t structure
Returns
a pointer to a new allocated cs_equation_builder_t structure

◆ cs_equation_builder_reset()

void cs_equation_builder_reset ( cs_equation_builder_t eqb)

Free some members of a cs_equation_builder_t structure.

Parameters
[in,out]eqbpointer to the cs_equation_builder_t structure

◆ cs_equation_common_finalize()

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 when dealing with equations Call specific structure allocation related to a numerical scheme according to the scheme flag The size of the temporary buffer can be bigger according to the numerical settings.

Allocate a pointer to a buffer of size at least the 2*n_cells for managing temporary usage of memory when dealing with equations Call specific structure allocation related to a numerical scheme according to the scheme flag The size of the temporary buffer can be bigger according to the numerical settings.

◆ cs_equation_common_init()

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  eb_flag,
cs_flag_t  fb_flag,
cs_flag_t  vb_flag,
cs_flag_t  vcb_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 when dealing with equations The size of the temporary buffer can be bigger according to the numerical settings Set also shared pointers from the main domain members.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]quantpointer to additional mesh quantities struct.
[in]time_steppointer to a time step structure
[in]eb_flagmetadata for Edge-based schemes
[in]fb_flagmetadata for Face-based schemes
[in]vb_flagmetadata for Vertex-based schemes
[in]vcb_flagmetadata for Vertex+Cell-basde schemes
[in]hho_flagmetadata for HHO schemes

◆ cs_equation_enforced_internal_block_dofs()

void cs_equation_enforced_internal_block_dofs ( const cs_equation_builder_t eqb,
cs_cell_builder_t cb,
cs_cell_sys_t csys 
)

Take into account the enforcement of internal DoFs. Case of matrices defined by blocks. Apply an algebraic manipulation. Update members of the cs_cell_sys_t structure related to the internal enforcement.

| | | | | | | | | | | Aii | Aie | | Aii | 0 | |bi| |bi -Aid.x_enf| |---------—| –> |---------—| and |–| –> |----------—| | | | | | | | | | | | Aei | Aee | | 0 | Id | |be| | x_enf |

where x_enf is the value of the enforcement for the selected internal DoFs

Parameters
[in]eqbpointer to a cs_equation_builder_t structure
[in,out]cbpointer to a cs_cell_builder_t structure
[in,out]csysstructure storing the cell-wise system

◆ cs_equation_enforced_internal_dofs()

void cs_equation_enforced_internal_dofs ( const cs_equation_builder_t eqb,
cs_cell_builder_t cb,
cs_cell_sys_t csys 
)

Take into account the enforcement of internal DoFs. Apply an algebraic manipulation. Update members of the cs_cell_sys_t structure related to the internal enforcement.

| | | | | | | | | | | Aii | Aie | | Aii | 0 | |bi| |bi -Aid.x_enf| |---------—| –> |---------—| and |–| –> |----------—| | | | | | | | | | | | Aei | Aee | | 0 | Id | |be| | x_enf |

where x_enf is the value of the enforcement for the selected internal DoFs

Parameters
[in]eqbpointer to a cs_equation_builder_t structure
[in,out]cbpointer to a cs_cell_builder_t structure
[in,out]csysstructure storing the cell-wise system

◆ cs_equation_get_tmpbuf()

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 bigger according to the numerical settings.

Returns
a pointer to an array of double

◆ cs_equation_get_tmpbuf_size()

size_t cs_equation_get_tmpbuf_size ( void  )

Get the allocation size of the temporary buffer.

Returns
the size of the temporary buffer

◆ cs_equation_init_properties()

void cs_equation_init_properties ( const cs_equation_param_t eqp,
const cs_equation_builder_t eqb,
cs_hodge_t diffusion_hodge,
cs_cell_builder_t cb 
)

Initialize all properties potentially useful to build the algebraic system. This function is shared across all CDO schemes. The cs_cell_builder_t structure stores property values related to the reaction term, unsteady term and grad-div term.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]eqbpointer to a cs_equation_builder_t structure
[in,out]diffusion_hodgepointer to the diffusion hodge structure
[in,out]cbpointer to a cs_cell_builder_t structure

◆ cs_equation_init_reaction_properties()

void cs_equation_init_reaction_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 reaction properties. This function is shared across all CDO schemes. The cs_cell_builder_t structure stores the computed property values.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]eqbpointer to a cs_equation_builder_t structure
[in]t_evaltime at which one performs the evaluation
[in,out]cbpointer to a cs_cell_builder_t structure

◆ cs_equation_prepare_system()

void cs_equation_prepare_system ( int  stride,
cs_lnum_t  x_size,
const cs_matrix_t matrix,
const cs_range_set_t rset,
bool  rhs_redux,
cs_real_t x,
cs_real_t b 
)

Prepare a linear system and synchronize buffers to handle parallelism. Transfer a mesh-based description of arrays x0 and rhs into an algebraic description for the linear system in x and b.

Parameters
[in]stridestride to apply to the range set operations
[in]x_sizesize of the vector unknowns (scatter view)
[in]matrixpointer to a cs_matrix_t structure
[in]rsetpointer to a range set structure
[in]rhs_reduxdo or not a parallel sum reduction on the RHS
[in,out]xarray of unknowns (in: initial guess)
[in,out]bright-hand side

◆ cs_equation_set_reaction_properties_cw()

void cs_equation_set_reaction_properties_cw ( const cs_equation_param_t eqp,
const cs_equation_builder_t eqb,
const cs_cell_mesh_t cm,
cs_cell_builder_t cb 
)

Initialize all reaction properties. This function is shared across all CDO schemes. The cs_cell_builder_t structure stores the computed property values. If the property is uniform, a first call to the function cs_equation_init_reaction_properties or to the function cs_equation_init_properties has to be done before the loop on cells.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]eqbpointer to a cs_equation_builder_t structure
[in]cmpointer to a cs_cell_mesh_t structure
[in,out]cbpointer to a cs_cell_builder_t structure

◆ cs_equation_solve_scalar_cell_system()

int cs_equation_solve_scalar_cell_system ( cs_lnum_t  n_dofs,
const cs_param_sles_t slesp,
const cs_matrix_t matrix,
cs_real_t  normalization,
cs_sles_t sles,
cs_real_t x,
cs_real_t b 
)

Solve a linear system arising with scalar-valued cell-based DoFs No rotation is taken into account when synchronizing halo.

Parameters
[in]n_dofslocal number of DoFs
[in]slesppointer to a cs_param_sles_t structure
[in]matrixpointer to a cs_matrix_t structure
[in]normalizationvalue used for the residual normalization
[in,out]slespointer to a cs_sles_t structure
[in,out]xsolution of the linear system (in: initial guess)
[in,out]bright-hand side (scatter/gather if needed)
Returns
the number of iterations of the linear solver

Solve a linear system arising with scalar-valued cell-based DoFs No rotation is taken into account when synchronizing halo.

Parameters
[in]n_dofslocal number of DoFs
[in]slesppointer to a cs_param_sles_t structure
[in]matrixpointer to a cs_matrix_t structure
[in]normalizationvalue used for the residual normalization
[in,out]slespointer to a cs_sles_t structure
[in,out]xsolution of the linear system (in: initial guess)
[in,out]bright-hand side (scatter/gather if needed)
Returns
the number of iterations of the linear solver

◆ cs_equation_solve_scalar_system()

int cs_equation_solve_scalar_system ( cs_lnum_t  n_scatter_dofs,
const cs_param_sles_t slesp,
const cs_matrix_t matrix,
const cs_range_set_t rset,
cs_real_t  normalization,
bool  rhs_redux,
cs_sles_t sles,
cs_real_t x,
cs_real_t b 
)

Solve a linear system arising from CDO schemes with scalar-valued degrees of freedom.

Parameters
[in]n_scatter_dofslocal number of DoFs (may be != n_gather_elts)
[in]slesppointer to a cs_param_sles_t structure
[in]matrixpointer to a cs_matrix_t structure
[in]rspointer to a cs_range_set_t structure
[in]normalizationvalue used for the residual normalization
[in]rhs_reduxdo or not a parallel sum reduction on the RHS
[in,out]slespointer to a cs_sles_t structure
[in,out]xsolution of the linear system (in: initial guess)
[in,out]bright-hand side (scatter/gather if needed)
Returns
the number of iterations of the linear solver

◆ cs_equation_sync_rhs_normalization()

void cs_equation_sync_rhs_normalization ( cs_param_resnorm_type_t  type,
cs_lnum_t  rhs_size,
const cs_real_t  rhs[],
double *  normalization 
)

Compute the value of the renormalization coefficient for the the residual norm of the linear system A pre-computation arising from cellwise contribution may have been done before this call according to the requested type of renormalization.

Parameters
[in]typetype of renormalization
[in]rhs_sizesize of the rhs array
[in]rhsarray related to the right-hand side
[in,out]normalizationvalue of the residual normalization

◆ cs_equation_sync_vertex_mean_values()

void cs_equation_sync_vertex_mean_values ( const cs_cdo_connect_t connect,
int  dim,
int *  counter,
cs_real_t values 
)

Compute the mean-value across ranks at each vertex.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]dimnumber of entries for each vertex
[in]counternumber of occurences on this rank
[in,out]valuesarray to update

◆ cs_equation_sync_vol_def_at_edges()

void cs_equation_sync_vol_def_at_edges ( const cs_cdo_connect_t connect,
int  n_defs,
cs_xdef_t **  defs,
cs_lnum_t  def2e_idx[],
cs_lnum_t  def2e_ids[] 
)

Synchronize the volumetric definitions to consider at each edge.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]n_defsnumber of definitions
[in]defsnumber of times the values has been updated
[in,out]def2e_idxindex array to define
[in,out]def2e_idsarray of ids to define

◆ cs_equation_sync_vol_def_at_faces()

void cs_equation_sync_vol_def_at_faces ( const cs_cdo_connect_t connect,
int  n_defs,
cs_xdef_t **  defs,
cs_lnum_t  def2f_idx[],
cs_lnum_t  def2f_ids[] 
)

Synchronize the volumetric definitions to consider at each face.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]n_defsnumber of definitions
[in]defsnumber of times the values has been updated
[in,out]def2f_idxindex array to define
[in,out]def2f_idsarray of ids to define

◆ cs_equation_sync_vol_def_at_vertices()

void cs_equation_sync_vol_def_at_vertices ( const cs_cdo_connect_t connect,
int  n_defs,
cs_xdef_t **  defs,
cs_lnum_t  def2v_idx[],
cs_lnum_t  def2v_ids[] 
)

Synchronize the volumetric definitions to consider at each vertex.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]n_defsnumber of definitions
[in]defsnumber of times the values has been updated
[in,out]def2v_idxindex array to define
[in,out]def2v_idsarray of ids to define

◆ cs_equation_write_monitoring()

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.

Parameters
[in]eqnamepointer to the name of the current equation
[in]eqbpointer to a cs_equation_builder_t structure