programmer's documentation
Macros | Functions | Variables
cs_cdovb_scaleq.c File Reference
#include "cs_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#include <assert.h>
#include <string.h>
#include <bft_mem.h>
#include <bft_printf.h>
#include "cs_log.h"
#include "cs_search.h"
#include "cs_post.h"
#include "cs_quadrature.h"
#include "cs_evaluate.h"
#include "cs_cdo_bc.h"
#include "cs_hodge.h"
#include "cs_cdovb_advection.h"
#include "cs_cdovb_diffusion.h"
#include "cs_cdovb_scaleq.h"
Include dependency graph for cs_cdovb_scaleq.c:

Macros

#define CS_CDOVB_SCALEQ_DBG   0
 

Functions

static void _add_source_terms (cs_cdovb_scaleq_t *builder, cs_real_t full_rhs[])
 Compute the contribution of source terms to the rhs for this time step. More...
 
static void _build_hvpcd_conf (cs_cdovb_scaleq_t *builder)
 Compute a discrete Hodge op. Vp–>Cd using conforming reco. op. More...
 
static cs_sla_matrix_t_init_time_matrix (cs_cdovb_scaleq_t *builder)
 Initialize the matrix related to the unsteady term. More...
 
static void _apply_time_scheme (const cs_real_t *field_val, const cs_sla_matrix_t *time_mat, double dt_cur, cs_cdovb_scaleq_t *builder, cs_real_t *rhs, cs_sla_matrix_t *sys_mat)
 Apply the time discretization to all the terms of the equation excepted for the unsteady term and the source term. More...
 
static void _compute_dir_values (const cs_mesh_t *mesh, const cs_real_t *field_val, const cs_cdovb_scaleq_t *builder)
 Compute the values of the Dirichlet BCs. More...
 
static void _add_advection_bc (cs_cdovb_scaleq_t *builder, cs_cdovb_adv_t *adv, cs_real_t *rhs, cs_sla_matrix_t *matrix)
 Update the matrix of the linear system to take into account the boundary contribution of the convection term. More...
 
static void _weak_bc_enforcement (cs_cdovb_scaleq_t *builder, cs_cdovb_diff_t *diff_builder, cs_real_t full_rhs[], cs_sla_matrix_t *full_matrix)
 Apply Dirichlet boundary conditions arising from the diffusion op. Only useful if boundary conditions are weakly imposed using a Nitsche technique. Right-hand side and the system matrix are updated. More...
 
static void _strong_bc_enforcement (cs_cdovb_scaleq_t *builder, cs_real_t **rhs, cs_sla_matrix_t **matrix)
 Apply boundary conditions. Update right-hand side and the system matrix. More...
 
static void _enforce_bc (cs_cdovb_scaleq_t *builder, cs_real_t **rhs, cs_sla_matrix_t **matrix)
 Modify the matrix of the linear system and its right hand side to take into account a strong enforcement or a large penalization of the boundary conditions. Nothing to do in case of weak enforcement. More...
 
void cs_cdovb_scaleq_init_buffer (const cs_cdo_connect_t *connect)
 Allocate work buffer related to cdo vertex-based schemes. More...
 
void cs_cdovb_scaleq_free_buffer (void)
 Free work buffer related to cdo vertex-based schemes. More...
 
cs_real_tcs_cdovb_scaleq_get_tmpbuf (void)
 Retrieve a pointer to a temporary buffer related to scalar equations discretized with CDO vertex-based schemes. More...
 
void * cs_cdovb_scaleq_init (const cs_equation_param_t *eqp, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *time_step)
 Initialize a cs_cdovb_scaleq_t structure. More...
 
void * cs_cdovb_scaleq_free (void *builder)
 Destroy a cs_cdovb_scaleq_t structure. More...
 
void cs_cdovb_scaleq_compute_source (void *builder)
 Compute the contributions of source terms (store inside builder) More...
 
void cs_cdovb_scaleq_build_system (const cs_mesh_t *mesh, const cs_real_t *field_val, double dt_cur, void *builder, cs_real_t **rhs, cs_sla_matrix_t **sla_mat)
 Build the linear system arising from a scalar convection/diffusion equation with a CDO vertex-based scheme. One works cellwise and then process to the assembly. More...
 
void cs_cdovb_scaleq_update_field (const cs_real_t *solu, void *builder, cs_real_t *field_val)
 Post-process the solution of a scalar convection/diffusion equation solved with a CDO vertex-based scheme. More...
 
void cs_cdovb_scaleq_post (const char *eqname, const cs_field_t *field, void *builder)
 Post-processing related to this equation. More...
 

Variables

static const cs_real_t cs_weak_nitsche_pena_coef = 500
 
static const cs_real_t cs_weak_penalization_weight = 0.01
 
static size_t _vbscal_work_size = 0
 
static cs_real_t_vbscal_work = NULL
 

Macro Definition Documentation

#define CS_CDOVB_SCALEQ_DBG   0

Function Documentation

static void _add_advection_bc ( cs_cdovb_scaleq_t *  builder,
cs_cdovb_adv_t adv,
cs_real_t rhs,
cs_sla_matrix_t matrix 
)
static

Update the matrix of the linear system to take into account the boundary contribution of the convection term.

Parameters
[in,out]advpointer to an advection builder structure
[in,out]rhspointer of pointer to the right-hand side
[in,out]matrixpointer to a matrix structure
static void _add_source_terms ( cs_cdovb_scaleq_t *  builder,
cs_real_t  full_rhs[] 
)
static

Compute the contribution of source terms to the rhs for this time step.

Parameters
[in]builderpointer to a cs_cdovb_scaleq_t structure
[in,out]full_rhsright-hand side
static void _apply_time_scheme ( const cs_real_t field_val,
const cs_sla_matrix_t time_mat,
double  dt_cur,
cs_cdovb_scaleq_t *  builder,
cs_real_t rhs,
cs_sla_matrix_t sys_mat 
)
static

Apply the time discretization to all the terms of the equation excepted for the unsteady term and the source term.

Parameters
[in]field_valpointer to the current value of the field
[in]time_matpointer to a cs_sla_matrix_t structure
[in]dt_curcurrent value of the time step
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
[in,out]rhspointer to the right-hand side array
[in,out]sys_matpointer to a cs_sla_matrix_t structure
static void _build_hvpcd_conf ( cs_cdovb_scaleq_t *  builder)
static

Compute a discrete Hodge op. Vp–>Cd using conforming reco. op.

Parameters
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
static void _compute_dir_values ( const cs_mesh_t mesh,
const cs_real_t field_val,
const cs_cdovb_scaleq_t *  builder 
)
static

Compute the values of the Dirichlet BCs.

Parameters
[in]meshpointer to a cs_mesh_t structure
[in]field_valpointer to the current value of the field
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
static void _enforce_bc ( cs_cdovb_scaleq_t *  builder,
cs_real_t **  rhs,
cs_sla_matrix_t **  matrix 
)
static

Modify the matrix of the linear system and its right hand side to take into account a strong enforcement or a large penalization of the boundary conditions. Nothing to do in case of weak enforcement.

Parameters
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
[in,out]rhsright-hand side
[in,out]matrixmatrix of the linear system
static cs_sla_matrix_t* _init_time_matrix ( cs_cdovb_scaleq_t *  builder)
static

Initialize the matrix related to the unsteady term.

Parameters
[in]builderpointer to a cs_cdovb_scaleq_t structure
Returns
a pointer to a cs_sla_matrix_t structure
static void _strong_bc_enforcement ( cs_cdovb_scaleq_t *  builder,
cs_real_t **  rhs,
cs_sla_matrix_t **  matrix 
)
static

Apply boundary conditions. Update right-hand side and the system matrix.

Parameters
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
[in,out]full_rhsright-hand side
[in,out]full_matrixmatrix of the linear system
static void _weak_bc_enforcement ( cs_cdovb_scaleq_t *  builder,
cs_cdovb_diff_t diff_builder,
cs_real_t  full_rhs[],
cs_sla_matrix_t full_matrix 
)
static

Apply Dirichlet boundary conditions arising from the diffusion op. Only useful if boundary conditions are weakly imposed using a Nitsche technique. Right-hand side and the system matrix are updated.

Parameters
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
[in,out]diff_builderpointer to a cs_cdovb_diff_t structure
[in,out]full_rhsright-hand side
[in,out]full_matrixmatrix of the linear system
void cs_cdovb_scaleq_build_system ( const cs_mesh_t mesh,
const cs_real_t field_val,
double  dt_cur,
void *  builder,
cs_real_t **  rhs,
cs_sla_matrix_t **  sla_mat 
)

Build the linear system arising from a scalar convection/diffusion equation with a CDO vertex-based scheme. One works cellwise and then process to the assembly.

Parameters
[in]meshpointer to a cs_mesh_t structure
[in]field_valpointer to the current value of the field
[in]dt_curcurrent value of the time step
[in,out]builderpointer to cs_cdovb_scaleq_t structure
[in,out]rhsright-hand side
[in,out]sla_matpointer to cs_sla_matrix_t structure pointer
void cs_cdovb_scaleq_compute_source ( void *  builder)

Compute the contributions of source terms (store inside builder)

Parameters
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
void* cs_cdovb_scaleq_free ( void *  builder)

Destroy a cs_cdovb_scaleq_t structure.

Parameters
[in,out]builderpointer to a cs_cdovb_scaleq_t structure
Returns
a NULL pointer
void cs_cdovb_scaleq_free_buffer ( void  )

Free work buffer related to cdo vertex-based schemes.

cs_real_t* cs_cdovb_scaleq_get_tmpbuf ( void  )

Retrieve a pointer to a temporary buffer related to scalar equations discretized with CDO vertex-based schemes.

Returns
a pointer to an array of double
void* cs_cdovb_scaleq_init ( const cs_equation_param_t eqp,
const cs_mesh_t mesh,
const cs_cdo_connect_t connect,
const cs_cdo_quantities_t quant,
const cs_time_step_t time_step 
)

Initialize a cs_cdovb_scaleq_t structure.

Parameters
[in]eqppointer to a cs_equation_param_t structure
[in]meshpointer to a cs_mesh_t structure
[in]connectpointer to a cs_cdo_connect_t structure
[in]quantpointer to a cs_cdo_quantities_t structure
[in]time_steptime_step structure
Returns
a pointer to a new allocated cs_cdovb_scaleq_t structure
void cs_cdovb_scaleq_init_buffer ( const cs_cdo_connect_t connect)

Allocate work buffer related to cdo vertex-based schemes.

Parameters
[in]connectpointer to a cs_cdo_connect_t structure
void cs_cdovb_scaleq_post ( const char *  eqname,
const cs_field_t field,
void *  builder 
)

Post-processing related to this equation.

Parameters
[in]eqnamename of the equation
[in]fieldpointer to a field strufcture
[in,out]builderpointer to builder structure
void cs_cdovb_scaleq_update_field ( const cs_real_t solu,
void *  builder,
cs_real_t field_val 
)

Post-process the solution of a scalar convection/diffusion equation solved with a CDO vertex-based scheme.

Parameters
[in]solusolution array
[in,out]builderpointer to cs_cdovb_scaleq_t structure
[in,out]field_valpointer to the current value of the field

Variable Documentation

cs_real_t* _vbscal_work = NULL
static
size_t _vbscal_work_size = 0
static
const cs_real_t cs_weak_nitsche_pena_coef = 500
static
const cs_real_t cs_weak_penalization_weight = 0.01
static