Add new integrator constructors in SAIntegrator #1096

This commit is contained in:
Penn, John M 047828115 2021-01-27 12:09:33 -06:00
parent be407eaf13
commit 99f42bb6c4
2 changed files with 51 additions and 1 deletions

View File

@ -1,3 +1,5 @@
#ifndef SAINTEGRATOR_HH
#define SAINTEGRATOR_HH
#include "Rootfinder.hh"
#include <iostream>
@ -84,6 +86,7 @@ namespace SA {
double *derivs;
EulerIntegrator();
EulerIntegrator( double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc dfunc, void* udata);
EulerIntegrator( double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
EulerIntegrator(const EulerIntegrator& other);
EulerIntegrator& operator=( const EulerIntegrator& rhs);
~EulerIntegrator();
@ -98,6 +101,7 @@ namespace SA {
double *derivs[2];
HeunsMethod();
HeunsMethod( double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc dfunc, void* udata);
HeunsMethod( double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
HeunsMethod(const HeunsMethod& other);
HeunsMethod& operator=( const HeunsMethod& rhs);
~HeunsMethod();
@ -112,6 +116,7 @@ namespace SA {
double *derivs[2];
RK2Integrator();
RK2Integrator( double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc derivs_func, void* udata);
RK2Integrator( double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
RK2Integrator(const RK2Integrator& other);
RK2Integrator& operator=( const RK2Integrator& rhs);
~RK2Integrator();
@ -127,6 +132,7 @@ namespace SA {
RK4Integrator();
RK4Integrator( double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc dfunc, void* udata);
RK4Integrator( double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
RK4Integrator(const RK4Integrator& other);
RK4Integrator& operator=( const RK4Integrator& rhs);
~RK4Integrator();
@ -142,6 +148,7 @@ namespace SA {
RK3_8Integrator();
RK3_8Integrator( double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc dfunc, void* udata);
RK3_8Integrator( double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
RK3_8Integrator(const RK3_8Integrator& other);
RK3_8Integrator& operator=( const RK3_8Integrator& rhs);
~RK3_8Integrator();
@ -193,6 +200,7 @@ namespace SA {
unsigned int currentHistorySize;
public:
ABMIntegrator(unsigned int history_size, double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc dfunc, void* udata);
ABMIntegrator(unsigned int history_size, double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
ABMIntegrator(const ABMIntegrator& other);
ABMIntegrator& operator=( const ABMIntegrator& rhs);
~ABMIntegrator();
@ -213,6 +221,7 @@ namespace SA {
RK2Integrator* priming_integrator;
public:
ABM2Integrator( double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc dfunc, void* udata);
ABM2Integrator( double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
ABM2Integrator(const ABM2Integrator& other);
ABM2Integrator& operator=( const ABM2Integrator& rhs);
~ABM2Integrator();
@ -233,6 +242,7 @@ namespace SA {
RK4Integrator* priming_integrator;
public:
ABM4Integrator( double h, unsigned int N, double* in_vars[], double* out_vars[], DerivsFunc dfunc, void* udata);
ABM4Integrator( double h, unsigned int N, double* in_out_vars[], DerivsFunc derivs_func, void* udata);
ABM4Integrator(const ABM4Integrator& other);
ABM4Integrator& operator=( const ABM4Integrator& rhs);
~ABM4Integrator();
@ -242,3 +252,4 @@ namespace SA {
};
std::ostream& operator<<(std::ostream& os, const ABM4Integrator& I);
}
#endif /* SAINTEGRATOR_HH */

View File

@ -228,6 +228,7 @@ SA::FirstOrderODEVariableStepIntegrator::FirstOrderODEVariableStepIntegrator(
root_finder = (RootFinder*) NULL;
root_error_func = (RootErrorFunc) NULL;
}
// Copy Constructor
SA::FirstOrderODEVariableStepIntegrator::FirstOrderODEVariableStepIntegrator(
const FirstOrderODEVariableStepIntegrator& other)
@ -333,6 +334,11 @@ SA::EulerIntegrator::EulerIntegrator(
: FirstOrderODEVariableStepIntegrator(h, N, in_vars, out_vars, dfunc, udata) {
derivs = new double[N];
}
// Constructor
SA::EulerIntegrator::EulerIntegrator(
double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: EulerIntegrator(h, N, in_out_vars, in_out_vars, dfunc, udata) {}
// Copy Constructor
SA::EulerIntegrator::EulerIntegrator(const EulerIntegrator& other)
: FirstOrderODEVariableStepIntegrator(other) {
@ -395,6 +401,11 @@ SA::HeunsMethod::HeunsMethod(
derivs[i] = new double[N];
}
}
// Constructor
SA::HeunsMethod::HeunsMethod(
double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: HeunsMethod(h, N, in_out_vars, in_out_vars, dfunc, udata) {}
// Copy Constructor
SA::HeunsMethod::HeunsMethod(const HeunsMethod& other)
: FirstOrderODEVariableStepIntegrator(other) {
@ -479,7 +490,13 @@ SA::RK2Integrator::RK2Integrator(
for (unsigned int i = 0; i < 2 ; i++) {
derivs[i] = new double[N];
}
std::cout << "RK2 Constructor" << std::endl;
}
// EXPERIMENTAL
SA::RK2Integrator::RK2Integrator(
double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: RK2Integrator(h, N, in_out_vars, in_out_vars, dfunc, udata) {}
// Copy Constructor
SA::RK2Integrator::RK2Integrator(const RK2Integrator& other)
: FirstOrderODEVariableStepIntegrator(other) {
@ -569,6 +586,11 @@ SA::RK4Integrator::RK4Integrator(
derivs[i] = new double[N];
}
}
// Constructor
SA::RK4Integrator::RK4Integrator(
double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: RK4Integrator(h, N, in_out_vars, in_out_vars, dfunc, udata) {}
// Copy Constructor
SA::RK4Integrator::RK4Integrator(const RK4Integrator& other)
: FirstOrderODEVariableStepIntegrator(other) {
@ -682,6 +704,11 @@ SA::RK3_8Integrator::RK3_8Integrator(
derivs[i] = new double[N];
}
}
// Constructor
SA::RK3_8Integrator::RK3_8Integrator(
double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: RK3_8Integrator(h, N, in_out_vars, in_out_vars, dfunc, udata) {}
// Copy Constructor
SA::RK3_8Integrator::RK3_8Integrator(const RK3_8Integrator& other)
: FirstOrderODEVariableStepIntegrator(other) {
@ -977,6 +1004,11 @@ SA::ABMIntegrator::ABMIntegrator ( unsigned int history_size, double h, unsigned
}
composite_deriv = new double[state_size];
}
// Constructor
SA::ABMIntegrator::ABMIntegrator(
unsigned int history_size, double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: ABMIntegrator(history_size, h, N, in_out_vars, in_out_vars, dfunc, udata) {}
// Copy Constructor
SA::ABMIntegrator::ABMIntegrator(const ABMIntegrator& other)
: FirstOrderODEIntegrator(other) {
@ -1111,7 +1143,10 @@ SA::ABM2Integrator::ABM2Integrator (
}
priming_integrator = new SA::RK2Integrator(h, N, priming_integrator_in_vars, priming_integrator_out_vars, dfunc, udata);
}
// Constructor
SA::ABM2Integrator::ABM2Integrator(
double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: ABM2Integrator(h, N, in_out_vars, in_out_vars, dfunc, udata) {}
SA::ABM2Integrator::ABM2Integrator(const ABM2Integrator& other)
: FirstOrderODEIntegrator(other) {
@ -1254,6 +1289,10 @@ SA::ABM4Integrator::ABM4Integrator (
}
priming_integrator = new SA::RK4Integrator(h, N, priming_integrator_in_vars, priming_integrator_out_vars, dfunc, udata);
}
// Constructor
SA::ABM4Integrator::ABM4Integrator(
double h, unsigned int N, double* in_out_vars[], DerivsFunc dfunc, void* udata)
: ABM4Integrator(h, N, in_out_vars, in_out_vars, dfunc, udata) {}
SA::ABM4Integrator::ABM4Integrator(const ABM4Integrator& other)
: FirstOrderODEIntegrator(other) {