44 namespace LibUtilities
56 std::string variant,
unsigned int order, std::vector<NekDouble> freeParams)
58 m_name(
"FractionalInTime")
66 "FractionalInTime Time integration scheme bad order: " +
67 std::to_string(order));
70 freeParams.size() == 1 ||
71 freeParams.size() == 2 ||
72 freeParams.size() == 6,
73 "FractionalInTime Time integration scheme invalid number "
74 "of free parameters, expected zero, one <alpha>, "
75 "two <alpha, base>, or "
76 "six <alpha, base, nQuadPts, sigma, mu0, nu> received " +
77 std::to_string(freeParams.size()));
79 if (freeParams.size() >= 1)
84 if (freeParams.size() >= 2)
89 if (freeParams.size() == 6)
93 m_mu0 = freeParams[4];
106 boost::ignore_unused(op);
135 for (
unsigned int m = 0; m <=
m_order; ++m)
139 for (
unsigned int i = 0; i <
m_nvars; ++i)
143 for (
unsigned int j = 0; j <
m_npoints; ++j)
162 for (
unsigned int i = 0; i <
m_nvars; ++i)
174 for (
unsigned int m = 1, m_1 = 0; m <
m_order; ++m, ++m_1)
183 for (
unsigned int m = 1; m <=
m_order; ++m)
187 for (
unsigned int n = 0; n < m; ++n)
243 for (
unsigned int j = 2; j <= m; ++j)
245 for (
unsigned int i = 0; i < m; ++i)
247 m_Ahats[m][j - 1][i] = pow((1 - j), i);
251 ASSERTL1(
false,
"No matrix inverse.");
262 for (
unsigned int i = 0; i <
m_order; ++i)
264 for (
unsigned int j = 0; j <
m_order; ++j)
272 for (
int l = 0; l <
m_Lmax; ++l)
282 const int timestep,
const NekDouble delta_t,
285 boost::ignore_unused(delta_t);
288 "Delta T has changed which is not permitted.");
291 int timeStep = timestep + 1;
295 for (
int l = 0; l <
m_Lmax; ++l)
307 for (
int l = 0; l <
L; ++l)
313 for (
int i = 0; i <
m_nvars; ++i)
323 for (
int m =
m_order; m > 0; --m)
325 for (
int i = 0; i <
m_nvars; ++i)
329 m_u[m][i][j] =
m_u[m - 1][i][j];
335 for (
int i = 0; i <
m_nvars; ++i)
363 for (
int i = 0; i <
m_Lmax; ++i)
376 const int unsigned counter,
const int unsigned base)
const
378 return (counter + 1) % base;
386 const unsigned int base,
const unsigned int l)
const
388 unsigned int L = ceil(
log(l / 2.0) /
log(base));
390 if (l % (
unsigned int)(2 * pow(base,
L)) == 0)
406 const unsigned int base,
const unsigned int m)
413 for (
unsigned int i = 0; i <
L - 1; ++i)
415 m_qml[i] = floor(m / pow(base, i + 1)) - 1;
429 const unsigned int base,
const unsigned int m)
446 for (
unsigned int i = 1; i <
L; ++i)
476 for (
unsigned int q = 0; q < nQuadPts; ++q)
481 lamb[q] = sigma + mu * th * std::complex<NekDouble>(1. / tan(th), nu);
483 w[q] = std::complex<NekDouble>(0, -1. /
NekDouble(nQuadPts)) * mu *
484 std::complex<NekDouble>(1. / tan(th) - th / (sin(th) * sin(th)),
490 if (nQuadPts % 2 == 1)
492 unsigned int q = (nQuadPts + 1) / 2;
494 lamb[q] = std::complex<NekDouble>(sigma + mu, 0);
496 w[q] = std::complex<NekDouble>(nu * mu / nQuadPts, 0);
504 const unsigned int index,
Instance &instance)
const
539 instance.
index = index;
551 for (
unsigned int q = 0; q <
m_nvars; ++q)
559 for (
unsigned int i = 0; i <
m_npoints; ++i)
570 instance.
stage_ind = std::pair<int, int>(0, 0);
588 instance.
cstash_ind = std::pair<int, int>(0, 0);
599 instance.
fstash_ind = std::pair<int, int>(0, 0);
637 for (
unsigned int m = 1; m <=
m_order + 1; ++m)
641 for (
unsigned int n = 0; n < m; ++n)
663 As[m][1][0] = 1. / 2.;
665 As[m][1][2] = -1. / 2.;
666 As[m][2][0] = 1. / 2.;
668 As[m][2][2] = 1. / 2.;
677 As[m][1][0] = 1. / 3.;
678 As[m][1][1] = 1. / 2.;
680 As[m][1][3] = 1. / 6.;
682 As[m][2][0] = 1. / 2.;
684 As[m][2][2] = 1. / 2.;
687 As[m][3][0] = 1. / 6.;
688 As[m][3][1] = -1. / 2.;
689 As[m][3][2] = 1. / 2.;
690 As[m][3][3] = -1. / 6.;
700 As[m][1][0] = 1. / 4.;
701 As[m][1][1] = 5. / 6.;
702 As[m][1][2] = -3. / 2.;
703 As[m][1][3] = 1. / 2.;
704 As[m][1][4] = -1. / 12.;
706 As[m][2][0] = 11. / 24.;
707 As[m][2][1] = -5. / 6.;
708 As[m][2][2] = 1. / 4.;
709 As[m][2][3] = 1. / 6.;
710 As[m][2][4] = -1. / 24.;
712 As[m][3][0] = 1. / 4.;
713 As[m][3][1] = -5. / 6.;
715 As[m][3][3] = -1. / 2.;
716 As[m][3][4] = 1. / 12.;
718 As[m][4][0] = 1. / 24.;
719 As[m][4][1] = -1. / 6.;
720 As[m][4][2] = 1. / 4.;
721 As[m][4][3] = -1. / 6.;
722 As[m][4][4] = 1. / 24.;
730 ASSERTL1(
false,
"No matrix inverse.");
752 instance.
E[q] = exp(instance.
z[q] *
m_deltaT);
757 for (
unsigned int m = 0; m <
m_order + 1; ++m)
765 1. / instance.
z[q] * (exp(instance.
z[q] *
m_deltaT) - 1.0);
767 instance.
Eh[m][q] = -1. / instance.
z[q] +
769 instance.
Eh[m - 1][q];
778 for (
unsigned int m = 0; m <=
m_order; ++m)
784 for (
unsigned int i = 0; i <=
m_order; ++i)
786 instance.
AtEh[m][q] +=
787 instance.
As[
m_order + 1][m][i] * instance.
Eh[i][q];
832 for (
unsigned int i = 0; i <
m_nvars; ++i)
834 for (
unsigned int j = 0; j <
m_npoints; ++j)
869 for (
unsigned int m = 0; m <
m_order; ++m)
873 for (
unsigned int i = 0; i <
m_nvars; ++i)
875 for (
unsigned int j = 0; j <
m_npoints; ++j)
888 const unsigned int timeStep,
const unsigned int tauml,
896 pow(instance.
z[q], -
m_alpha) * instance.
w[q];
899 for (
unsigned int i = 0; i <
m_nvars; ++i)
901 for (
unsigned int j = 0; j <
m_npoints; ++j)
910 if (
m_uInt[i][j].real() < 1e8)
937 for (
unsigned int m = 0; m <= order; ++m)
941 instance.
AtEh[m][q] = 0;
943 for (
unsigned int i = 0; i <= order; ++i)
945 instance.
AtEh[m][q] +=
946 instance.
As[order + 1][m][i] * instance.
Eh[i][q];
957 for (
unsigned int m = 0; m <= order; ++m)
961 for (
unsigned int i = 0; i <
m_nvars; ++i)
963 for (
unsigned int j = 0; j <
m_npoints; ++j)
969 y[i][j][q] *= instance.
E[q];
972 y[i][j][q] +=
m_F[i][j] * instance.
AtEh[m][q];
1011 for (
unsigned int i = 0; i <
m_nvars; ++i)
1013 for (
unsigned int j = 0; j <
m_npoints; ++j)
1015 for (
unsigned int q = 0; q <
m_nQuadPts; ++q)
1041 for (
unsigned int i = 0; i <
m_nvars; ++i)
1043 for (
unsigned int j = 0; j <
m_npoints; ++j)
1045 for (
unsigned int q = 0; q <
m_nQuadPts; ++q)
1060 instance.
fsandbox_ind = std::pair<int, int>(timeStep, timeStep);
1070 os <<
"Time Integration Scheme: " <<
GetFullName() << std::endl
1071 <<
" Alpha " <<
m_alpha << std::endl
1072 <<
" Base " <<
m_base << std::endl
1073 <<
" Number of instances " <<
m_Lmax << std::endl
1074 <<
" Number of quadature points " <<
m_nQuadPts << std::endl
1075 <<
" Talbot Parameter: sigma " <<
m_sigma << std::endl
1076 <<
" Talbot Parameter: mu0 " <<
m_mu0 << std::endl
1077 <<
" Talbot Parameter: nu " <<
m_nu << std::endl;
1082 os <<
"Time Integration Scheme: " <<
GetFullName() << std::endl
1083 <<
" Alpha " <<
m_alpha << std::endl
1084 <<
" Base " <<
m_base << std::endl
1085 <<
" Number of instances " <<
m_Lmax << std::endl
1086 <<
" Number of quadature points " <<
m_nQuadPts << std::endl
1087 <<
" Talbot Parameter: sigma " <<
m_sigma << std::endl
1088 <<
" Talbot Parameter: mu0 " <<
m_mu0 << std::endl
1089 <<
" Talbot Parameter: nu " <<
m_nu << std::endl;
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Class for fractional-in-time integration.
unsigned int modIncrement(const unsigned int counter, const unsigned int base) const
Method that increments the counter then performs mod calculation.
void updateStage(const unsigned int timeStep, Instance &instance)
Method to rearrange of staging/stashing for current time.
virtual LUE void v_InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op) override
Worker method to initialize the integration scheme.
void integralClassInitialize(const unsigned int index, Instance &instance) const
Method to initialize the integral class.
virtual LUE ConstDoubleArray & v_TimeIntegrate(const int timestep, const NekDouble delta_t, const TimeIntegrationSchemeOperators &op) override
Worker method that performs the time integration.
unsigned int computeQML(const unsigned int base, const unsigned int m)
Method to compute the demarcation integers q_{m, ell}.
Array< OneD, int > m_taus
unsigned int m_maxTimeSteps
unsigned int computeL(const unsigned int base, const unsigned int m) const
Method to compute the smallest integer L such that base < 2.
void timeAdvance(const unsigned int timeStep, const TimeIntegrationSchemeOperators &op, Instance &instance, ComplexTripleArray &y)
Method to get the solution to y' = z*y + f(u), using an exponential integrator with implicit order (m...
virtual LUE void v_print(std::ostream &os) const override
Worker method to print details on the integration scheme.
ComplexSingleArray m_expFactor
ComplexDoubleArray m_uInt
unsigned int computeTaus(const unsigned int base, const unsigned int m)
Method to compute the demarcation interval marker tau_{m, ell}.
void talbotQuadrature(const unsigned int nQuadPts, const NekDouble mu, const NekDouble nu, const NekDouble sigma, ComplexSingleArray &lamb, ComplexSingleArray &w) const
Method to compute the quadrature rule over Tablot contour.
void advanceSandbox(const unsigned int timeStep, const TimeIntegrationSchemeOperators &op, Instance &instance)
Method to update sandboxes to the current time.
Array< OneD, Instance > m_integral_classes
virtual LUE void v_printFull(std::ostream &os) const override
FractionalInTimeIntegrationScheme(std::string variant, unsigned int order, std::vector< NekDouble > freeParams)
Constructor.
void finalIncrement(const unsigned int timeStep, const TimeIntegrationSchemeOperators &op)
Method to approximate the integral.
void integralContribution(const unsigned int timeStep, const unsigned int tauml, const Instance &instance)
Method to get the integral contribution over [taus(i+1) taus(i)]. Stored in m_uInt.
std::vector< NekDouble > m_freeParams
Base class for time integration schemes.
LUE void print(std::ostream &os) const
LUE std::string GetFullName() const
Binds a set of functions for use by time integration schemes.
void DoOdeRhs(InArrayType &inarray, OutArrayType &outarray, const NekDouble time) const
AT< AT< NekDouble > > DoubleArray
AT< AT< std::complex< NekDouble > > > ComplexDoubleArray
AT< NekDouble > SingleArray
AT< std::complex< NekDouble > > ComplexSingleArray
AT< AT< AT< NekDouble > > > TripleArray
std::shared_ptr< FractionalInTimeIntegrationScheme > FractionalInTimeIntegrationSchemeSharedPtr
AT< AT< AT< std::complex< NekDouble > > > > ComplexTripleArray
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
The above copyright notice and this permission notice shall be included.
scalarT< T > log(scalarT< T > in)
ComplexTripleArray fstash_y
std::pair< int, int > stage_ind
ComplexTripleArray csandbox_y
std::pair< int, int > fstash_ind
ComplexTripleArray cstash_y
std::pair< int, int > cstash_ind
ComplexTripleArray stage_y
int fsandbox_stashincrement
std::pair< int, int > csandbox_ind
std::pair< int, int > fsandbox_ind
ComplexTripleArray fsandbox_y