Initialize explicit Runge-Kutta time integrators.
More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <basic.h>
#include <arrayfunctions.h>
#include <timeintegration.h>
Go to the source code of this file.
Initialize explicit Runge-Kutta time integrators.
- Author
- Debojyoti Ghosh
Definition in file TimeExplicitRKInitialize.c.
◆ TimeExplicitRKInitialize()
int TimeExplicitRKInitialize |
( |
char * |
class, |
|
|
char * |
type, |
|
|
void * |
s, |
|
|
void * |
m |
|
) |
| |
Initialize the explicit Runge-Kutta time integrator: Depending on the specific explicit Runge-Kutta (ERK) method chosen, this function allocates memory for the Butcher tableaux and sets their coefficients.
- Parameters
-
class | Name of time integrator class; must match _RK_ |
type | Type of explicit Runge-Kutta method |
s | Object of type ExplicitRKParameters |
m | Unused argument |
Definition at line 17 of file TimeExplicitRKInitialize.c.
26 if (!strcmp(
class,
_RK_)) {
29 params->
A = (
double*) calloc (params->
nstages*params->
nstages,
sizeof(
double));
30 params->
b = (
double*) calloc (params->
nstages ,
sizeof(
double));
31 params->
c = (
double*) calloc (params->
nstages ,
sizeof(
double));
36 }
else if (!strcmp(type,
_RK_22_)) {
38 params->
A = (
double*) calloc (params->
nstages*params->
nstages,
sizeof(
double));
39 params->
b = (
double*) calloc (params->
nstages ,
sizeof(
double));
40 params->
c = (
double*) calloc (params->
nstages ,
sizeof(
double));
46 params->
b[0] = params->
b[1] = 0.5;
47 }
else if (!strcmp(type,
_RK_33_)) {
49 params->
A = (
double*) calloc (params->
nstages*params->
nstages,
sizeof(
double));
50 params->
b = (
double*) calloc (params->
nstages ,
sizeof(
double));
51 params->
c = (
double*) calloc (params->
nstages ,
sizeof(
double));
55 params->
A[3] = 2.0/3.0; params->
A[6] = 2.0/3.0-1.0/4.0; params->
A[7] = 1.0/4.0;
56 params->
c[1] = 2.0/3.0; params->
c[2] = 2.0/3.0;
57 params->
b[0] = 1.0/4.0; params->
b[1] = -1.0/4.0; params->
b[2] = 1.0;
58 }
else if (!strcmp(type,
_RK_44_)) {
60 params->
A = (
double*) calloc (params->
nstages*params->
nstages,
sizeof(
double));
61 params->
b = (
double*) calloc (params->
nstages ,
sizeof(
double));
62 params->
c = (
double*) calloc (params->
nstages ,
sizeof(
double));
66 params->
A[4] = 0.5; params->
A[9] = 0.5; params->
A[14] = 1.0;
67 params->
c[1] = params->
c[2] = 0.5; params->
c[3] = 1.0;
68 params->
b[0] = 1.0/6.0; params->
b[1] = 1.0/3.0; params->
b[2] = 1.0/3.0; params->
b[3] = 1.0/6.0;
71 params->
A = (
double*) calloc (params->
nstages*params->
nstages,
sizeof(
double));
72 params->
b = (
double*) calloc (params->
nstages ,
sizeof(
double));
73 params->
c = (
double*) calloc (params->
nstages ,
sizeof(
double));
77 params->
A[3] = 1.0; params->
A[6] = 0.25; params->
A[7] = 0.25;
78 params->
c[1] = 1.0; params->
c[2] = 0.5;
79 params->
b[0] = params->
b[1] = 1.0/6.0; params->
b[2] = 2.0/3.0;
81 fprintf(stderr,
"Error in TimeExplicitRKInitialize(): %s is not a supported ",type);
82 fprintf(stderr,
"multi-stage time integration scheme of class %s.\n",
class);
86 fprintf(stderr,
"Error in TimeExplicitRKInitialize(): Code should not have ");
87 fprintf(stderr,
"reached here for %s class of time-integrators. This is a ",
class);
88 fprintf(stderr,
"coding mistake.\n");
#define _ArraySetValue_(x, size, value)
Structure containing the parameters for an explicit Runge-Kutta method.