9.1
general documentation
cs_runge_kutta_integrator_priv.h
Go to the documentation of this file.
1#ifndef __RK_INTEGRATOR_PRIV_H__
2#define __RK_INTEGRATOR_PRIV_H__
3
4/*============================================================================
5 * Explicit Runge-Kutta integrator utilities.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2025 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30#include "base/cs_defs.h"
31
32/*----------------------------------------------------------------------------
33 * Standard C library headers
34 *----------------------------------------------------------------------------*/
35
36#include <assert.h>
37#include <stdarg.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>
41
42/*----------------------------------------------------------------------------
43 * Local headers
44 *----------------------------------------------------------------------------*/
45
46#include "bft/bft_error.h"
47#include "bft/bft_printf.h"
48
49#include "alge/cs_blas.h"
50
51#include "base/cs_base_accel.h"
52#include "base/cs_dispatch.h"
53#include "mesh/cs_mesh.h"
55
56/*----------------------------------------------------------------------------*/
57
58/*=============================================================================
59 * Macro definitions
60 *============================================================================*/
61
62#define RK_HIGHEST_ORDER 4
63
64/*============================================================================
65 * Type definitions
66 *============================================================================*/
67
68/* Available Runge-Kutta schemes */
69/* ----------------------------- */
70
71typedef enum {
76 CS_RK4
78
79/* Coeffients adapted from the Butcher tableau */
80/* ------------------------------------------- */
81
82typedef struct {
83
84 double *a;
85 double *c;
86
88
89/* Descriptor of a Runge-Kutta integrator */
90/* --------------------------------------- */
91
92typedef struct {
93
94 int rk_id;
96
98
99/* Generic Runge-Kutta integrator */
100/* -------------------------------*/
101
102typedef struct {
103
104 cs_runge_kutta_scheme_t scheme; // Selected RK scheme
105 char *name; // associated equation's or field's name
106 int n_stages; // number of stages
107 int i_stage; // Current stage index
108
109 const cs_real_t *dt; // time step array
110 cs_real_t *scaled_dt; // scaled time step used in projection
111 // step per stage
112 cs_lnum_t n_elts; // number of computational elements
113
114 /* variable storage */
115 cs_real_t *u_old; // variable at beginning of the time stepping
116 cs_real_t *u_new; // updated variable
117
118 cs_real_t *rhs_stages; // RHS temporary storage
119
120
121 cs_real_t *mass; // mass array for the variables, equivalent to
122 // diag elements of mass matrix in an explicit
123 // time scheme
124
126
128
129#endif /* __RK_INTEGRATOR_PRIV_H__ */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:350
cs_runge_kutta_scheme_t
Definition: cs_runge_kutta_integrator_priv.h:71
@ CS_RK2
Definition: cs_runge_kutta_integrator_priv.h:74
@ CS_RK_NONE
Definition: cs_runge_kutta_integrator_priv.h:72
@ CS_RK4
Definition: cs_runge_kutta_integrator_priv.h:76
@ CS_RK3
Definition: cs_runge_kutta_integrator_priv.h:75
@ CS_RK1
Definition: cs_runge_kutta_integrator_priv.h:73
Definition: cs_runge_kutta_integrator_priv.h:82
double * a
Definition: cs_runge_kutta_integrator_priv.h:84
double * c
Definition: cs_runge_kutta_integrator_priv.h:85
Definition: cs_runge_kutta_integrator_priv.h:92
int rk_id
Definition: cs_runge_kutta_integrator_priv.h:94
cs_runge_kutta_scheme_t scheme
Definition: cs_runge_kutta_integrator_priv.h:95
Definition: cs_runge_kutta_integrator_priv.h:102
int i_stage
Definition: cs_runge_kutta_integrator_priv.h:107
cs_real_t * scaled_dt
Definition: cs_runge_kutta_integrator_priv.h:110
cs_runge_kutta_coeff_t rk_coeff
Definition: cs_runge_kutta_integrator_priv.h:125
const cs_real_t * dt
Definition: cs_runge_kutta_integrator_priv.h:109
char * name
Definition: cs_runge_kutta_integrator_priv.h:105
cs_lnum_t n_elts
Definition: cs_runge_kutta_integrator_priv.h:112
cs_real_t * rhs_stages
Definition: cs_runge_kutta_integrator_priv.h:118
cs_real_t * u_old
Definition: cs_runge_kutta_integrator_priv.h:115
cs_runge_kutta_scheme_t scheme
Definition: cs_runge_kutta_integrator_priv.h:104
int n_stages
Definition: cs_runge_kutta_integrator_priv.h:106
cs_real_t * u_new
Definition: cs_runge_kutta_integrator_priv.h:116
cs_real_t * mass
Definition: cs_runge_kutta_integrator_priv.h:121