9.1
general documentation
cs_runge_kutta_integrator.h File Reference
#include "base/cs_defs.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "alge/cs_balance.h"
#include "alge/cs_blas.h"
#include "base/cs_array.h"
#include "base/cs_base_accel.h"
#include "base/cs_boundary_conditions_set_coeffs.h"
#include "base/cs_dispatch.h"
#include "mesh/cs_mesh.h"
#include "base/cs_runge_kutta_integrator_priv.h"
+ Include dependency graph for cs_runge_kutta_integrator.h:

Go to the source code of this file.

Functions

int cs_runge_kutta_integrator_create (cs_runge_kutta_scheme_t scheme, const char *name, const cs_real_t *dt, int dim, cs_lnum_t n_elts)
 Create a RK integrator. More...
 
void cs_runge_kutta_integrators_initialize ()
 Create RK integrator structures. More...
 
template<cs_lnum_t stride>
void cs_runge_kutta_init_state (cs_dispatch_context &ctx, cs_runge_kutta_integrator_t *rk, const cs_real_t *rho, const cs_real_t *vol, cs_real_t *pvara)
 Initialize a RK integrator at the begining of a time step. More...
 
template<cs_lnum_t stride>
void cs_runge_kutta_staging (cs_dispatch_context &ctx, cs_runge_kutta_integrator_t *rk, cs_real_t *pvar_stage)
 Perform one Runge-Kutta staging. More...
 
template<int stride>
void cs_runge_kutta_stage_set_initial_rhs (cs_dispatch_context &ctx, cs_runge_kutta_integrator_t *rk, cs_real_t *rhs_pvar)
 Set initial rhs per stage for Runge-Kutta integrator. Align with legacy equations' building sequence. 1) Collect initial rhs done in cs_solve_navier_stokes/cs_solve_equation_scalar 2) Complete rhs with adding explicit part of the convection/diffusion balance. More...
 
void cs_runge_kutta_stage_complete_scalar_rhs (cs_dispatch_context &ctx, cs_runge_kutta_integrator_t *rk, int idtvar, int f_id, int imucpp, cs_equation_param_t *eqp, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_t viscel[][6], const cs_real_t weighf[][2], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_t pvar[], const cs_real_t xcpp[])
 prepare and complete rhs per stage for Runge-Kutta integrator. Align with legacy equations' building sequence. 1) Collect initial rhs done in cs_solve_navier_stokes/cs_solve_equation_scalar 2) Complete rhs with adding explicit part of the convection/diffusion balance More precisely, the right hand side $ \vect{Rhs} $ is updated as follows: More...
 
template<int stride>
void cs_runge_kutta_stage_complete_rhs (cs_dispatch_context &ctx, cs_runge_kutta_integrator_t *rk, int idtvar, int f_id, int ivisep, cs_equation_param_t *eqp, cs_field_bc_coeffs_t *bc_coeffs, 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 i_secvis[], const cs_real_t b_secvis[], cs_real_t viscel[][6], const cs_real_t weighf[][2], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_t pvar[][stride])
 prepare and complete rhs per stage for Runge-Kutta integrator. Align with legacy equations' building sequence. 1) Collect initial rhs done in cs_solve_navier_stokes/cs_solve_equation_scalar 2) Complete rhs with adding explicit part of the convection/diffusion balance More precisely, the right hand side $ \vect{Rhs} $ is updated as follows: More...
 
bool cs_runge_kutta_is_active (cs_runge_kutta_integrator_t *rk)
 Indicate if Runge-Kutta integrator is activated. More...
 
cs_real_tcs_runge_kutta_get_projection_time_scale_by_stage (cs_dispatch_context &ctx, cs_runge_kutta_integrator_t *rk)
 Get the scaling factor when conducting a projection per stage. More...
 
bool cs_runge_kutta_is_staging (cs_runge_kutta_integrator_t *rk)
 indicate if the Runge-Kutta integrator is staging. More...
 
cs_runge_kutta_integrator_tcs_runge_kutta_integrator_by_id (int rk_id)
 Return a Runge-Kutta integrator by id. More...
 
void cs_runge_kutta_integrators_destroy ()
 Clean all Runge-Kutta integrators. More...
 

Function Documentation

◆ cs_runge_kutta_get_projection_time_scale_by_stage()

cs_real_t * cs_runge_kutta_get_projection_time_scale_by_stage ( cs_dispatch_context ctx,
cs_runge_kutta_integrator_t rk 
)
inline

Get the scaling factor when conducting a projection per stage.

Parameters
[in]rkpointer to a Runge-Kutta integrator

◆ cs_runge_kutta_init_state()

void cs_runge_kutta_init_state ( cs_dispatch_context ctx,
cs_runge_kutta_integrator_t rk,
const cs_real_t rho,
const cs_real_t vol,
cs_real_t pvara 
)

Initialize a RK integrator at the begining of a time step.

Parameters
[in]ctxReference to dispatch context
[in,out]rkpointer to a Runge-Kutta integrator
[in]rhomass density within the geometry support
[in]volmeasure of the geometry support
[in]pvarahigh level variable array at the begining of a time step

◆ cs_runge_kutta_integrator_by_id()

cs_runge_kutta_integrator_t * cs_runge_kutta_integrator_by_id ( int  rk_id)

Return a Runge-Kutta integrator by id.

◆ cs_runge_kutta_integrator_create()

int cs_runge_kutta_integrator_create ( cs_runge_kutta_scheme_t  scheme,
const char *  name,
const cs_real_t dt,
int  dim,
cs_lnum_t  n_elts 
)

Create a RK integrator.

Parameters
[in]schemeRK scheme type (RK_NONE, RK1, RK2, RK3, RK4)
[in]nameassociated equation or field's name
[in]dttime step
[in]dimvariable dimentsion
[in]n_eltsnumber of computational elements

return the RK integrator's id in the RK list

◆ cs_runge_kutta_integrators_destroy()

void cs_runge_kutta_integrators_destroy ( )

Clean all Runge-Kutta integrators.

◆ cs_runge_kutta_integrators_initialize()

void cs_runge_kutta_integrators_initialize ( )

Create RK integrator structures.

◆ cs_runge_kutta_is_active()

bool cs_runge_kutta_is_active ( cs_runge_kutta_integrator_t rk)
inline

Indicate if Runge-Kutta integrator is activated.

Parameters
[in]rkpointer to a Runge-Kutta integrator

◆ cs_runge_kutta_is_staging()

bool cs_runge_kutta_is_staging ( cs_runge_kutta_integrator_t rk)
inline

indicate if the Runge-Kutta integrator is staging.

Parameters
[in]rkpointer to a runge-kutta integrator

◆ cs_runge_kutta_stage_complete_rhs()

void cs_runge_kutta_stage_complete_rhs ( cs_dispatch_context ctx,
cs_runge_kutta_integrator_t rk,
int  idtvar,
int  f_id,
int  ivisep,
cs_equation_param_t eqp,
cs_field_bc_coeffs_t bc_coeffs,
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  i_secvis[],
const cs_real_t  b_secvis[],
cs_real_t  viscel[][6],
const cs_real_t  weighf[][2],
const cs_real_t  weighb[],
int  icvflb,
const int  icvfli[],
cs_real_t  pvar[][stride] 
)

prepare and complete rhs per stage for Runge-Kutta integrator. Align with legacy equations' building sequence. 1) Collect initial rhs done in cs_solve_navier_stokes/cs_solve_equation_scalar 2) Complete rhs with adding explicit part of the convection/diffusion balance More precisely, the right hand side $ \vect{Rhs} $ is updated as follows:

\[
\vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}}      \left(
       \dot{m}_\ij \left( \vect{\varia}_\fij - \vect{\varia}_\celli \right)
     - \mu_\fij \gradt_\fij \vect{\varia} \cdot \vect{S}_\ij  \right)
\]

Remark: if ivisep = 1, then we also take $ \mu \transpose{\gradt\vect{\varia}}
+ \lambda \trace{\gradt\vect{\varia}} $, where $ \lambda $ is the secondary viscosity, i.e. usually $ -\frac{2}{3} \mu $.

Warning:

  • $ \vect{Rhs} $ has already been initialized before calling cs_balance_vector!
  • mind the sign minus
Parameters
[in]ctxReference to dispatch context
[in,out]rkpointer to a Runge-Kutta integrator
[in]idtvarindicator of the temporal scheme
[in]f_idfield id (or -1)
[in]ivisepindicator to take $ \divv
                               \left(\mu \gradt \transpose{\vect{a}} \right)
                               -2/3 \grad\left( \mu \dive \vect{a} \right)$
  • 1 take into account,
  • 0 otherwise
[in]eqppointer to a cs_equation_param_t structure which contains variable calculation options
[in]bc_coeffsboundary condition structure for the variable
[in]i_massfluxmass flux at interior faces
[in]b_massfluxmass flux at boundary faces
[in]i_visc$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} $ at interior faces for the r.h.s.
[in]b_visc$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} $ at boundary faces for the r.h.s.
[in]secvifsecondary viscosity at interior faces
[in]secvibsecondary viscosity at boundary faces
[in]viscelsymmetric cell tensor $ \tens{\mu}_\celli $
[in]weighfinternal face weight between cells i j in case of tensor diffusion
[in]weighbboundary face weight for cells i in case of tensor diffusion
[in]icvflbglobal indicator of boundary convection flux
  • 0 upwind scheme at all boundary faces
  • 1 imposed flux at some boundary faces
[in]icvfliboundary face indicator array of convection flux
  • 0 upwind scheme
  • 1 imposed flux
[in]pvarsolved velocity (current time step)
[in]rhs_pvarpointer to high level rhs array

◆ cs_runge_kutta_stage_complete_scalar_rhs()

void cs_runge_kutta_stage_complete_scalar_rhs ( cs_dispatch_context ctx,
cs_runge_kutta_integrator_t rk,
int  idtvar,
int  f_id,
int  imucpp,
cs_equation_param_t eqp,
cs_field_bc_coeffs_t bc_coeffs,
const cs_real_t  i_massflux[],
const cs_real_t  b_massflux[],
const cs_real_t  i_visc[],
const cs_real_t  b_visc[],
cs_real_t  viscel[][6],
const cs_real_t  weighf[][2],
const cs_real_t  weighb[],
int  icvflb,
const int  icvfli[],
cs_real_t  pvar[],
const cs_real_t  xcpp[] 
)

prepare and complete rhs per stage for Runge-Kutta integrator. Align with legacy equations' building sequence. 1) Collect initial rhs done in cs_solve_navier_stokes/cs_solve_equation_scalar 2) Complete rhs with adding explicit part of the convection/diffusion balance More precisely, the right hand side $ \vect{Rhs} $ is updated as follows:

\[
\vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}}      \left(
       \dot{m}_\ij \left( \vect{\varia}_\fij - \vect{\varia}_\celli \right)
     - \mu_\fij \gradt_\fij \vect{\varia} \cdot \vect{S}_\ij  \right)
\]

Warning:

  • $ \vect{Rhs} $ has already been initialized before calling cs_balance_vector!
  • mind the sign minus
Parameters
[in]ctxReference to dispatch context
[in,out]rkpointer to a Runge-Kutta integrator
[in]idtvarindicator of the temporal scheme
[in]f_idfield id (or -1)
[in]imucppindicator
  • 0 do not multiply the convectiv term by Cp
  • 1 do multiply the convectiv term by Cp
[in]eqppointer to a cs_equation_param_t structure which contains variable calculation options
[in]bc_coeffsboundary condition structure for the variable
[in]i_massfluxmass flux at interior faces
[in]b_massfluxmass flux at boundary faces
[in]i_visc$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} $ at interior faces for the r.h.s.
[in]b_visc$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} $ at boundary faces for the r.h.s.
[in]viscelsymmetric cell tensor $ \tens{\mu}_\celli $
[in]weighfinternal face weight between cells i j in case of tensor diffusion
[in]weighbboundary face weight for cells i in case of tensor diffusion
[in]icvflbglobal indicator of boundary convection flux
  • 0 upwind scheme at all boundary faces
  • 1 imposed flux at some boundary faces
[in]icvfliboundary face indicator array of convection flux
  • 0 upwind scheme
  • 1 imposed flux
[in]pvarsolved variable (current time step)
[in]xcpparray of specific heat (Cp)

◆ cs_runge_kutta_stage_set_initial_rhs()

void cs_runge_kutta_stage_set_initial_rhs ( cs_dispatch_context ctx,
cs_runge_kutta_integrator_t rk,
cs_real_t rhs_pvar 
)

Set initial rhs per stage for Runge-Kutta integrator. Align with legacy equations' building sequence. 1) Collect initial rhs done in cs_solve_navier_stokes/cs_solve_equation_scalar 2) Complete rhs with adding explicit part of the convection/diffusion balance.

Parameters
[in]ctxReference to dispatch context
[in,out]rkpointer to a Runge-Kutta integrator
[in]rhs_pvarpointer to high level rhs array

◆ cs_runge_kutta_staging()

void cs_runge_kutta_staging ( cs_dispatch_context ctx,
cs_runge_kutta_integrator_t rk,
cs_real_t pvar_stage 
)

Perform one Runge-Kutta staging.

Parameters
[in]ctxReference to dispatch context
[in,out]rkpointer to a Runge-Kutta integrator
[in,out]pvar_stagehigh level variable array along stages