111 CS_MALLOC(_name, strlen(name) + 1,
char);
126 _rhs_stages.reshape(_n_stages, _n_elts, _stride);
127 _u_old.reshape(_n_elts, _stride);
128 _u_new.reshape(_n_elts, _stride);
129 _mass.reshape(_n_elts);
164 auto mass = _mass.view();
165 auto u_old = _u_old.view();
166 const int stride = _stride;
169 mass[e_id] =
rho[e_id] * vol[e_id];
171 u_old(e_id, i) = pvara[
stride*e_id + i];
191 auto dt = _dt.view_1d();
192 auto mass = _mass.view();
194 const int i_stg = _i_stage;
195 const int stride = _stride;
197 auto u0 = _u_old.view();
198 auto u_new = _u_new.view();
199 auto rhs_stage = _rhs_stages.view();
201 const auto a = _a.sub_view(i_stg);
205 u_new(e_id, i) = u0(e_id, i);
207 for (
int j_stg = 0; j_stg <= i_stg; j_stg++) {
209 u_new(e_id, i) += rhs_stage(j_stg, e_id, i)* a[j_stg] *
dt[e_id]
214 pvar_stage[
stride*e_id + i] = u_new(e_id, i);
236 const int i_stg = _i_stage - 1;
237 const auto a = _a.sub_view(i_stg);
239 auto rhs = _rhs_stages.sub_view(i_stg);
240 auto mass = _mass.view();
241 const int stride = _stride;
245 rhs(e_id, i) -= grad_dp[
stride*e_id + i] * mass[e_id];
246 grad_dp[
stride*e_id + i] *= a[i_stg];
270 const int i_stg = _i_stage;
271 auto rhs = _rhs_stages.sub_view(i_stg);
272 const int stride = _stride;
276 rhs(e_id, i) = rhs_pvar[
stride*e_id + i];
307 return (_i_stage < _n_stages);
385 return _rhs_stages.sub_array(stage_id);
402 return _a.sub_view(i);
444 _a(1,0) = 0.5, _a(1,1) = 0.5;
454 _a(1,0) = 0. , _a(1,1) = 1.;
467 _a(1,0) = 1./4., _a(1,1) = 5./12.;
468 _a(2,0) = 1./4., _a(2,1) = 0., _a(2,2) = 3./4.;
479 _a(1,0) = 1./4., _a(1,1) = 1./4.;
480 _a(2,0) = 1./6., _a(2,1) = 1./6., _a(2,2) = 2./3.;
491 _a(1,0) = 3./8., _a(1,1) = 1./8.;
492 _a(2,0) = -1./8., _a(2,1) = -3./8., _a(2,2) = 3./2.;
493 _a(3,0) = 1./6., _a(3,1) = -1./18., _a(3,2) = 2./3., _a(3,3) = 2./9.;
504 "%s: Type of Runge-Kutta not available.\n"
505 "%s: Stop building Runge-Kutta integrator.\n",
516 char *_name{
nullptr};
754 assert(rk !=
nullptr);
755 assert(stride == rk->
stride());
758 const int i_stg = rk->
i_stage();
801 else if (stride == 6)
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.cpp:187
Define a templated array class (owner of data)
Definition: cs_array.h:1118
Define a templated mdspan class (non owner of data)
Definition: cs_mdspan.h:68
Generic Runge-Kutta integrator class.
Definition: cs_runge_kutta_integrator.h:75
CS_F_HOST cs_real_t * get_rhs_stage_sub_array(int stage_id)
Get raw pointer to rhs of a given stage.
Definition: cs_runge_kutta_integrator.h:381
CS_F_HOST_DEVICE int stride() const
Get solved variable stride.
Definition: cs_runge_kutta_integrator.h:365
CS_F_HOST void stage_set_initial_rhs(cs_dispatch_context &ctx, cs_real_t *rhs_pvar)
Set initial rhs per stage for Runge-Kutta integrator. Align with legacy equations' building sequence....
Definition: cs_runge_kutta_integrator.h:265
CS_F_HOST void solve_stage(cs_dispatch_context &ctx, cs_real_t *pvar_stage)
Perform one Runge-Kutta staging.
Definition: cs_runge_kutta_integrator.h:185
CS_F_HOST void stage_projection_rhs(cs_dispatch_context &ctx, cs_real_t *grad_dp)
Perform one Runge-Kutta staging for the potential in the NS system.
Definition: cs_runge_kutta_integrator.h:231
CS_F_HOST ~runge_kutta_integrator()
Destructor method.
Definition: cs_runge_kutta_integrator.h:139
CS_F_HOST runge_kutta_integrator(cs_runge_kutta_scheme_t scheme, const char *name, const cs_real_t *dt, int dim, cs_lnum_t n_elts)
Constructor method with input arguments.
Definition: cs_runge_kutta_integrator.h:101
CS_F_HOST cs_span< cs_real_t > get_stage_coeff_a(int i)
Get "a" coefficients for a given stage.
Definition: cs_runge_kutta_integrator.h:398
CS_F_HOST void init_state(cs_dispatch_context &ctx, const cs_real_t *rho, const cs_real_t *vol, cs_real_t *pvara)
IDefault constructor method.
Definition: cs_runge_kutta_integrator.h:153
CS_F_HOST_DEVICE cs_runge_kutta_scheme_t scheme() const
Get scheme used by integrator.
Definition: cs_runge_kutta_integrator.h:320
CS_F_HOST runge_kutta_integrator()
Default constructor method.
Definition: cs_runge_kutta_integrator.h:90
CS_F_HOST_DEVICE cs_lnum_t n_elts() const
Get number of elements used for resolution.
Definition: cs_runge_kutta_integrator.h:335
CS_F_HOST_DEVICE bool is_active() const
Check if integrator is active.
Definition: cs_runge_kutta_integrator.h:290
CS_F_HOST_DEVICE int i_stage() const
Get current stage of RK resolution.
Definition: cs_runge_kutta_integrator.h:350
CS_F_HOST_DEVICE bool is_staging() const
Check if integrator is still in the staging process.
Definition: cs_runge_kutta_integrator.h:305
auto parallel_for(cs_lnum_t n, F &&f, Args &&... args)
Definition: cs_dispatch.h:2146
void wait(void)
Wait (synchronize) until launched computations have finished.
Definition: cs_dispatch.h:2211
Definition: cs_dispatch.h:2288
Field boundary condition descriptor (for variables)
Definition: cs_field.h:107
void cs_balance_tensor(int idtvar, int f_id, int imasac, int inc, cs_equation_param_t *eqp, cs_real_6_t pvar[], const cs_real_6_t pvara[], 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_6_t c_visc[], const cs_real_2_t weighf[], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_6_t rhs[])
Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport...
Definition: cs_balance.cpp:889
void cs_balance_vector(int idtvar, int f_id, int imasac, int inc, int ivisep, cs_equation_param_t *eqp, cs_real_3_t pvar[], const cs_real_3_t pvara[], 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 secvif[], const cs_real_t secvib[], cs_real_6_t c_visc[], const cs_real_2_t weighf[], const cs_real_t weighb[], int icvflb, const int icvfli[], cs_real_3_t i_pvar[], cs_real_3_t b_pvar[], cs_real_3_t smbr[])
Wrapper to the function which adds the explicit part of the convection/diffusion terms of a transport...
Definition: cs_balance.cpp:690
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:555
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
#define CS_LAMBDA
Definition: cs_defs.h:564
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:351
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
#define CS_F_HOST
Definition: cs_defs.h:553
@ rho
Definition: cs_field_pointer.h:96
@ dt
Definition: cs_field_pointer.h:61
#define CS_FREE(_ptr)
Definition: cs_mem.h:151
#define CS_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: cs_mem.h:75
void cs_runge_kutta_integrators_initialize()
Create RK integrator structures.
Definition: cs_runge_kutta_integrator.cpp:115
void cs_runge_kutta_integrators_destroy()
Clean all Runge-Kutta integrators.
Definition: cs_runge_kutta_integrator.cpp:168
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.
Definition: cs_runge_kutta_integrator.cpp:87
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 ...
Definition: cs_runge_kutta_integrator.h:733
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 ...
Definition: cs_runge_kutta_integrator.cpp:263
bool cs_runge_kutta_is_active(cs_runge_kutta_integrator_t *rk)
Indicate if Runge-Kutta integrator is activated.
Definition: cs_runge_kutta_integrator.h:834
void cs_runge_kutta_staging_potential(cs_dispatch_context &ctx, cs_runge_kutta_integrator_t *rk, cs_real_t *phi_stage)
Perform one Runge-Kutta staging for the potential in the NS system.
Definition: cs_runge_kutta_integrator.cpp:188
cs_runge_kutta_integrator_t * cs_runge_kutta_integrator_by_id(int rk_id)
Return a Runge-Kutta integrator by id.
Definition: cs_runge_kutta_integrator.cpp:152
bool cs_runge_kutta_is_staging(cs_runge_kutta_integrator_t *rk)
indicate if the Runge-Kutta integrator is staging.
Definition: cs_runge_kutta_integrator.h:851
#define RK_HIGHEST_ORDER
Definition: cs_runge_kutta_integrator_param.h:62
cs_runge_kutta_scheme_t
Definition: cs_runge_kutta_integrator_param.h:71
@ CS_RK2_HEUN
Definition: cs_runge_kutta_integrator_param.h:75
@ CS_RK2
Definition: cs_runge_kutta_integrator_param.h:74
@ CS_RK3_WRAY
Definition: cs_runge_kutta_integrator_param.h:78
@ CS_RK_NONE
Definition: cs_runge_kutta_integrator_param.h:72
@ CS_RK4
Definition: cs_runge_kutta_integrator_param.h:80
@ CS_RK3_SSP
Definition: cs_runge_kutta_integrator_param.h:79
@ CS_RK2_MP
Definition: cs_runge_kutta_integrator_param.h:76
@ CS_RK3
Definition: cs_runge_kutta_integrator_param.h:77
@ CS_RK1
Definition: cs_runge_kutta_integrator_param.h:73
integer(c_int), pointer, save idtvar
option for a variable time step
Definition: optcal.f90:70
Definition: cs_algorithm.h:51
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:190
double theta
Definition: cs_equation_param.h:512