8.3
general documentation
cs_macfb_vecteq.cpp File Reference
#include "cs_defs.h"
#include <assert.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <bft_mem.h>
#include "cs_array.h"
#include "cs_cdo_advection.h"
#include "cs_cdo_bc.h"
#include "cs_cdo_diffusion.h"
#include "cs_cdo_solve.h"
#include "cs_cdo_toolbox.h"
#include "cs_equation_bc.h"
#include "cs_evaluate.h"
#include "cs_hodge.h"
#include "cs_log.h"
#include "cs_math.h"
#include "cs_mesh_location.h"
#include "cs_post.h"
#include "cs_quadrature.h"
#include "cs_reco.h"
#include "cs_search.h"
#include "cs_macfb_vecteq.h"
+ Include dependency graph for cs_macfb_vecteq.cpp:

Functions

void cs_macfb_vecteq_setup (cs_real_t t_eval, const cs_mesh_t *mesh, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb)
 Set the boundary conditions known from the settings Define an indirection array for the enforcement of internal DoFs only if needed. This is stored inside eqb. More...
 
void cs_macfb_vecteq_init_cell_system (const cs_cell_mesh_t *cm, const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_real_t val_f_n[], const cs_real_t val_f_nm1[], cs_macfb_builder_t *macb, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
 Initialize the local structure for the current cell The algebraic system for time t^{n+1} is going to be built knowing previous field at time t^{n} and potentially the field at time t^{n-1}. Make sure to be consistent between the call to current_to_previous and the parameters vel_{f}_n/nm1 given. More...
 
void cs_macfb_vecteq_init_build (const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_lnum_t c_id, const cs_real_t vel_f_n[], cs_cell_mesh_t *cm, cs_macfb_builder_t *macb, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
 Initialize stuctures for a gven cell. More...
 
void cs_macfb_vecteq_sourceterm (const cs_cell_mesh_t *cm, const cs_equation_param_t *eqp, cs_macfb_builder_t *macb, const cs_real_t t_eval, const cs_real_t coef, cs_equation_builder_t *eqb, cs_cell_builder_t *cb, cs_cell_sys_t *csys)
 Compute the source term for a vector-valued MAC scheme and add it to the local rhs. More...
 
void cs_macfb_vecteq_diffusion (const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, const cs_property_t *diff_pty, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
 Build the local matrices arising from the diffusion term in the vector-valued CDO-Fb schemes. More...
 
void cs_macfb_vecteq_advection (const cs_equation_param_t *eqp, const cs_macfb_vecteq_t *eqc, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
 Build the local matrices arising from the convection term in the vector-valued MAC-Fb schemes. More...
 
void cs_macfb_vecteq_conv_diff_reac (const cs_equation_param_t *eqp, const cs_equation_builder_t *eqb, const cs_macfb_vecteq_t *eqc, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, const cs_property_data_t *diff_pty, cs_cell_sys_t *csys, cs_cell_builder_t *cb)
 Build the local matrices arising from the convection, diffusion, reaction terms in vector-valued MAC-Fb schemes. mass_hodge could be set to nullptr if a Voronoi algo. is used. Otherwise, the mass matrix should be pre-computed. More...
 
void cs_macfb_vecteq_euler_implicit_term (const cs_equation_param_t *eqp, const cs_cell_mesh_t *cm, const cs_macfb_builder_t *macb, const cs_cell_builder_t *cb, const cs_real_t dt, cs_cell_sys_t *csys)
 Compute the matrix and rhs for a vector-valued MAC scheme and Euler implicit. Values are added in place. More...
 
void cs_macfb_vecteq_assembly (const cs_cell_sys_t *csys, cs_cdo_system_block_t *block, cs_real_t *rhs, cs_cdo_assembly_t *asb)
 Perform the assembly stage for a vector-valued system obtained with MAC-fb scheme. More...
 
void cs_macfb_vecteq_update_fields (cs_timer_counter_t *tce, cs_field_t *fld, bool cur2prev)
 Update the variables associated to cells in case of a MAC-Fb scheme. This has to be done after a resolution. More...
 
void cs_macfb_vecteq_solve_steady_implicit (bool cur2prev, const cs_mesh_t *mesh, const int field_id, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
 Build and solve the linear system arising from a vector diffusion equation with a MAC-Fb scheme: More...
 
void cs_macfb_vecteq_solve_theta (bool cur2prev, const cs_mesh_t *mesh, const int field_id, const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
 Build and solve the linear system arising from a vector diffusion equation with a MAC-Fb scheme and an implicit/explicit theta scheme. One works cellwise and then process to the assembly. More...
 
bool cs_macfb_vecteq_is_initialized (void)
 Check if the generic structures for building a MAC-Fb scheme are allocated. More...
 
void cs_macfb_vecteq_init_sharing (const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect, const cs_time_step_t *time_step)
 Allocate work buffer and general structures related to MAC vector-valued face-based schemes. Set shared pointers from the main domain members. More...
 
void cs_macfb_vecteq_get (cs_cell_sys_t **csys, cs_cell_builder_t **cb)
 Retrieve work buffers used for building a CDO system cellwise. More...
 
void cs_macfb_vecteq_finalize_sharing (void)
 Free work buffer and general structure related to CDO face-based schemes. More...
 
void * cs_macfb_vecteq_init_context (cs_equation_param_t *eqp, int var_id, int bflux_id, cs_equation_builder_t *eqb)
 Initialize a cs_macfb_vecteq_t structure storing data useful for building and managing such a scheme. More...
 
void * cs_macfb_vecteq_free_context (void *data)
 Destroy a cs_macfb_vecteq_t structure. More...
 
void cs_macfb_vecteq_init_values (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)
 Set the initial values of the variable field taking into account the boundary conditions. Case of vector-valued Mac-Fb schemes. More...
 
void cs_macfb_vecteq_current_to_previous (const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
 Operate a current to previous operation for the field associated to this equation and potentially for related fields/arrays. More...
 
void cs_macfb_vecteq_extra_post (const cs_equation_param_t *eqp, cs_equation_builder_t *eqb, void *context)
 Predefined extra-operations related to this equation. More...
 
cs_real_tcs_macfb_vecteq_get_cell_values (void *context, bool previous)
 Get the computed values at mesh cells from the inverse operation w.r.t. the static condensation (DoF used in the linear system are located at primal faces) The lifecycle of this array is managed by the code. So one does not have to free the return pointer. More...
 
cs_real_tcs_macfb_vecteq_get_face_values (void *context, bool previous)
 Retrieve an array of values at mesh faces for the current context. The lifecycle of this array is managed by the code. So one does not have to free the return pointer. More...
 
void cs_macfb_vecteq_read_restart (cs_restart_t *restart, const char *eqname, void *scheme_context)
 Read additional arrays (not defined as fields) but useful for the checkpoint/restart process. More...
 
void cs_macfb_vecteq_write_restart (cs_restart_t *restart, const char *eqname, void *scheme_context)
 Write additional arrays (not defined as fields) but useful for the checkpoint/restart process. More...
 

Function Documentation

◆ cs_macfb_vecteq_advection()

void cs_macfb_vecteq_advection ( const cs_equation_param_t eqp,
const cs_macfb_vecteq_t *  eqc,
const cs_cell_mesh_t cm,
const cs_macfb_builder_t macb,
cs_cell_sys_t csys,
cs_cell_builder_t cb 
)

Build the local matrices arising from the convection term in the vector-valued MAC-Fb schemes.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]eqccontext for this kind of discretization
[in]cmpointer to a cellwise view of the mesh
[in]macbpointer to a cs_macfb_builder_t structure
[in,out]csyspointer to a cellwise view of the system
[in,out]cbpointer to a cellwise builder

◆ cs_macfb_vecteq_assembly()

void cs_macfb_vecteq_assembly ( const cs_cell_sys_t csys,
cs_cdo_system_block_t block,
cs_real_t rhs,
cs_cdo_assembly_t *  asb 
)

Perform the assembly stage for a vector-valued system obtained with MAC-fb scheme.

Perform the assembly stage for a vector-valued system obtained with MAC scheme.

Parameters
[in]csyspointer to a cs_cell_sys_t structure
[in,out]blockpointer to a block structure
[in,out]rhsarray of values for the rhs
[in,out]asbpointer to cs_cdo_assembly_t

◆ cs_macfb_vecteq_conv_diff_reac()

void cs_macfb_vecteq_conv_diff_reac ( const cs_equation_param_t eqp,
const cs_equation_builder_t eqb,
const cs_macfb_vecteq_t *  eqc,
const cs_cell_mesh_t cm,
const cs_macfb_builder_t macb,
const cs_property_data_t diff_pty,
cs_cell_sys_t csys,
cs_cell_builder_t cb 
)

Build the local matrices arising from the convection, diffusion, reaction terms in vector-valued MAC-Fb schemes. mass_hodge could be set to nullptr if a Voronoi algo. is used. Otherwise, the mass matrix should be pre-computed.

Build the local matrices arising from the convection, diffusion, reaction terms in vector-valued MAC-Fb schemes. mass_hodge could be set to null if a Voronoi algo. is used. Otherwise, the mass matrix should be pre-computed.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]eqbpointer to a cs_equation_builder_t structure
[in]eqccontext for this kind of discretization
[in]cmpointer to a cellwise view of the mesh
[in]macbpointer to a cs_macfb_builder_t structure
[in]diff_ptypointer to a cs_property_data_t structure for diffusion
[in,out]csyspointer to a cellwise view of the system
[in,out]cbpointer to a cellwise builder

◆ cs_macfb_vecteq_current_to_previous()

void cs_macfb_vecteq_current_to_previous ( const cs_equation_param_t eqp,
cs_equation_builder_t eqb,
void *  context 
)

Operate a current to previous operation for the field associated to this equation and potentially for related fields/arrays.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in,out]eqbpointer to a cs_equation_builder_t structure
[in,out]contextpointer to cs_macfb_vecteq_t structure

◆ cs_macfb_vecteq_diffusion()

void cs_macfb_vecteq_diffusion ( const cs_equation_param_t eqp,
const cs_cell_mesh_t cm,
const cs_macfb_builder_t macb,
const cs_property_t diff_pty,
cs_cell_sys_t csys,
cs_cell_builder_t cb 
)

Build the local matrices arising from the diffusion term in the vector-valued CDO-Fb schemes.

Build the local matrices arising from the diffusion term in the vector-valued MAC schemes.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]cmpointer to a cellwise view of the mesh
[in]macbpointer to a cs_macfb_builder_t structure
[in]diff_ptypointer to a cs_property_t structure for diffusion
[in,out]csyspointer to a cellwise view of the system
[in,out]cbpointer to a cellwise builder

◆ cs_macfb_vecteq_euler_implicit_term()

void cs_macfb_vecteq_euler_implicit_term ( const cs_equation_param_t eqp,
const cs_cell_mesh_t cm,
const cs_macfb_builder_t macb,
const cs_cell_builder_t cb,
const cs_real_t  dt,
cs_cell_sys_t csys 
)

Compute the matrix and rhs for a vector-valued MAC scheme and Euler implicit. Values are added in place.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]cmpointer to a cellwise view of the mesh
[in]macbpointer to a cs_macfb_builder_t structure
[in]cbpointer to a cs_cell_builder_t structure
[in]dtvalue of the time step
[in,out]csyspointer to a cs_cell_sys_t structure

◆ cs_macfb_vecteq_extra_post()

void cs_macfb_vecteq_extra_post ( const cs_equation_param_t eqp,
cs_equation_builder_t eqb,
void *  context 
)

Predefined extra-operations related to this equation.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in,out]eqbpointer to a cs_equation_builder_t structure
[in,out]contextpointer to cs_macfb_vecteq_t structure

◆ cs_macfb_vecteq_finalize_sharing()

void cs_macfb_vecteq_finalize_sharing ( void  )

Free work buffer and general structure related to CDO face-based schemes.

◆ cs_macfb_vecteq_free_context()

void * cs_macfb_vecteq_free_context ( void *  data)

Destroy a cs_macfb_vecteq_t structure.

Parameters
[in,out]datapointer to a cs_macfb_vecteq_t structure
Returns
a null pointer

◆ cs_macfb_vecteq_get()

void cs_macfb_vecteq_get ( cs_cell_sys_t **  csys,
cs_cell_builder_t **  cb 
)

Retrieve work buffers used for building a CDO system cellwise.

Parameters
[out]csysdouble pointer to a cs_cell_sys_t structure
[out]cbdouble pointer to a cs_cell_builder_t structure

◆ cs_macfb_vecteq_get_cell_values()

cs_real_t * cs_macfb_vecteq_get_cell_values ( void *  context,
bool  previous 
)

Get the computed values at mesh cells from the inverse operation w.r.t. the static condensation (DoF used in the linear system are located at primal faces) The lifecycle of this array is managed by the code. So one does not have to free the return pointer.

Parameters
[in,out]contextpointer to a data structure cast on-the-fly
[in]previousretrieve the previous state (true/false)
Returns
a pointer to an array of cs_real_t (size 3*n_cells)

◆ cs_macfb_vecteq_get_face_values()

cs_real_t * cs_macfb_vecteq_get_face_values ( void *  context,
bool  previous 
)

Retrieve an array of values at mesh faces for the current context. The lifecycle of this array is managed by the code. So one does not have to free the return pointer.

Parameters
[in,out]contextpointer to a data structure cast on-the-fly
[in]previousretrieve the previous state (true/false)
Returns
a pointer to an array of cs_real_t (size 3*n_faces)

◆ cs_macfb_vecteq_init_build()

void cs_macfb_vecteq_init_build ( const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
const cs_equation_param_t eqp,
const cs_equation_builder_t eqb,
const cs_lnum_t  c_id,
const cs_real_t  vel_f_n[],
cs_cell_mesh_t cm,
cs_macfb_builder_t macb,
cs_cell_sys_t csys,
cs_cell_builder_t cb 
)

Initialize stuctures for a gven cell.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
[in]quantpointer to a cs_cdo_quantities_t structure
[in]eqppointer to a cs_equation_param_t structure
[in]eqbpointer to a cs_equation_builder_t structure
[in]c_idcell id
[in]vel_f_nvelocity face DoFs of the previous time step
[in,out]cmpointer to a cellwise view of the mesh
[in,out]macbpointer to a cs_macfb_builder_t structure
[in,out]csyspointer to a cellwise view of the system
[in,out]cbpointer to a cellwise builder

◆ cs_macfb_vecteq_init_cell_system()

void cs_macfb_vecteq_init_cell_system ( const cs_cell_mesh_t cm,
const cs_equation_param_t eqp,
const cs_equation_builder_t eqb,
const cs_real_t  val_f_n[],
const cs_real_t  val_f_nm1[],
cs_macfb_builder_t macb,
cs_cell_sys_t csys,
cs_cell_builder_t cb 
)

Initialize the local structure for the current cell The algebraic system for time t^{n+1} is going to be built knowing previous field at time t^{n} and potentially the field at time t^{n-1}. Make sure to be consistent between the call to current_to_previous and the parameters vel_{f}_n/nm1 given.

Parameters
[in]cmpointer to a cellwise view of the mesh
[in]eqppointer to a cs_equation_param_t structure
[in]eqbpointer to a cs_equation_builder_t structure
[in]val_f_nface DoFs at time step n
[in]val_f_nm1face DoFs at time step n-1 or nullptr
[in,out]macbpointer to a cs_macfb_builder_t structure
[in,out]csyspointer to a cellwise view of the system
[in,out]cbpointer to a cellwise builder

◆ cs_macfb_vecteq_init_context()

void * cs_macfb_vecteq_init_context ( cs_equation_param_t eqp,
int  var_id,
int  bflux_id,
cs_equation_builder_t eqb 
)

Initialize a cs_macfb_vecteq_t structure storing data useful for building and managing such a scheme.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]var_idid of the variable field
[in]bflux_idid of the boundary flux field
[in,out]eqbpointer to a cs_equation_builder_t structure
Returns
a pointer to a new allocated cs_macfb_vecteq_t structure

◆ cs_macfb_vecteq_init_sharing()

void cs_macfb_vecteq_init_sharing ( const cs_cdo_quantities_t quant,
const cs_cdo_connect_t connect,
const cs_time_step_t time_step 
)

Allocate work buffer and general structures related to MAC vector-valued face-based schemes. Set shared pointers from the main domain members.

Allocate work buffer and general structures related to CDO vector-valued face-based schemes. Set shared pointers from the main domain members.

Parameters
[in]quantadditional mesh quantities struct.
[in]connectpointer to a cs_cdo_connect_t struct.
[in]time_steppointer to a time step structure

◆ cs_macfb_vecteq_init_values()

void cs_macfb_vecteq_init_values ( 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 
)

Set the initial values of the variable field taking into account the boundary conditions. Case of vector-valued Mac-Fb schemes.

Set the initial values of the variable field taking into account the boundary conditions. Case of vector-valued MAC schemes.

Parameters
[in]t_evaltime at which one evaluates BCs
[in]field_idid related to the variable field of this equation
[in]meshpointer to a cs_mesh_t structure
[in]eqppointer to a cs_equation_param_t structure
[in,out]eqbpointer to a cs_equation_builder_t structure
[in,out]contextpointer to the scheme context (cast on-the-fly)

◆ cs_macfb_vecteq_is_initialized()

bool cs_macfb_vecteq_is_initialized ( void  )

Check if the generic structures for building a MAC-Fb scheme are allocated.

Check if the generic structures for building a MAC scheme are allocated.

Returns
true or false

◆ cs_macfb_vecteq_read_restart()

void cs_macfb_vecteq_read_restart ( cs_restart_t restart,
const char *  eqname,
void *  scheme_context 
)

Read additional arrays (not defined as fields) but useful for the checkpoint/restart process.

Parameters
[in,out]restartpointer to cs_restart_t structure
[in]eqnamename of the related equation
[in]scheme_contextpointer to a data structure cast on-the-fly

◆ cs_macfb_vecteq_setup()

void cs_macfb_vecteq_setup ( cs_real_t  t_eval,
const cs_mesh_t mesh,
const cs_equation_param_t eqp,
cs_equation_builder_t eqb 
)

Set the boundary conditions known from the settings Define an indirection array for the enforcement of internal DoFs only if needed. This is stored inside eqb.

DOXYGEN_SHOULD_SKIP_THIS

Parameters
[in]t_evaltime at which one evaluates BCs
[in]meshpointer to a cs_mesh_t structure
[in]eqppointer to a cs_equation_param_t structure
[in,out]eqbpointer to a cs_equation_builder_t structure

◆ cs_macfb_vecteq_solve_steady_implicit()

void cs_macfb_vecteq_solve_steady_implicit ( bool  cur2prev,
const cs_mesh_t mesh,
const int  field_id,
const cs_equation_param_t eqp,
cs_equation_builder_t eqb,
void *  context 
)

Build and solve the linear system arising from a vector diffusion equation with a MAC-Fb scheme:

  • steady scheme
  • implicit Euler scheme One works cellwise and then process to the assembly
Parameters
[in]cur2prevtrue="current to previous" operation is performed
[in]meshpointer to a cs_mesh_t structure
[in]field_idid of the variable field related to this equation
[in]eqppointer to a cs_equation_param_t structure
[in,out]eqbpointer to a cs_equation_builder_t structure
[in,out]contextpointer to cs_macfb_vecteq_t structure

◆ cs_macfb_vecteq_solve_theta()

void cs_macfb_vecteq_solve_theta ( bool  cur2prev,
const cs_mesh_t mesh,
const int  field_id,
const cs_equation_param_t eqp,
cs_equation_builder_t eqb,
void *  context 
)

Build and solve the linear system arising from a vector diffusion equation with a MAC-Fb scheme and an implicit/explicit theta scheme. One works cellwise and then process to the assembly.

Build and solve the linear system arising from a vector diffusion equation with a MAC scheme and an implicit/explicit theta scheme. One works cellwise and then process to the assembly.

Parameters
[in]cur2prevtrue="current to previous" operation is performed
[in]meshpointer to a cs_mesh_t structure
[in]field_idid of the variable field related to this equation
[in]eqppointer to a cs_equation_param_t structure
[in,out]eqbpointer to a cs_equation_builder_t structure
[in,out]contextpointer to cs_macfb_vecteq_t structure

◆ cs_macfb_vecteq_sourceterm()

void cs_macfb_vecteq_sourceterm ( const cs_cell_mesh_t cm,
const cs_equation_param_t eqp,
cs_macfb_builder_t macb,
const cs_real_t  t_eval,
const cs_real_t  coef,
cs_equation_builder_t eqb,
cs_cell_builder_t cb,
cs_cell_sys_t csys 
)

Compute the source term for a vector-valued MAC scheme and add it to the local rhs.

Parameters
[in]cmpointer to a cs_cell_mesh_t structure
[in]eqppointer to a cs_equation_param_t structure
[in]macbpointer to a cs_macfb_builder_t structure
[in]t_evaltime at which the source term is evaluated
[in]coefscaling of the time source (for theta schemes)
[in,out]eqbpointer to a cs_equation_builder_t structure
[in,out]cbpointer to a cs_cell_builder_t structure
[in,out]csyspointer to a cs_cell_sys_t structure

◆ cs_macfb_vecteq_update_fields()

void cs_macfb_vecteq_update_fields ( cs_timer_counter_t tce,
cs_field_t fld,
bool  cur2prev 
)

Update the variables associated to cells in case of a MAC-Fb scheme. This has to be done after a resolution.

Update the variables associated to cells in case of a MAC-fb scheme. This has to be done after a resolution.

Parameters
[in,out]tcepointer to a timer counter
[in,out]fldpointer to a cs_field_t structure
[in]cur2prevtrue if one performs "current to previous" op.

◆ cs_macfb_vecteq_write_restart()

void cs_macfb_vecteq_write_restart ( cs_restart_t restart,
const char *  eqname,
void *  scheme_context 
)

Write additional arrays (not defined as fields) but useful for the checkpoint/restart process.

Parameters
[in,out]restartpointer to cs_restart_t structure
[in]eqnamename of the related equation
[in]scheme_contextpointer to a data structure cast on-the-fly