Commit 620b8b9c authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Updated IncNavierStokes to use new TimeIntegrationWrapper classes.

parent ad6e7524
......@@ -238,10 +238,12 @@ SET(PolylibSources
SET(TimeIntegrationHeaders
./TimeIntegration/TimeIntegrationScheme.h
./TimeIntegration/TimeIntegrationWrapper.h
)
SET(TimeIntegrationSources
./TimeIntegration/TimeIntegrationScheme.cpp
./TimeIntegration/TimeIntegrationWrapper.cpp
)
SET(ExpressionTemplates
......
/*
* TimeIntegrationWrapper.cpp
*
* Created on: 16 Jul 2013
* Author: cc
*/
#include <LibUtilities/TimeIntegration/TimeIntegrationWrapper.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
namespace Nektar {
namespace LibUtilities {
TimeIntegrationWrapperFactory& GetTimeIntegrationWrapperFactory()
{
typedef Loki::SingletonHolder<TimeIntegrationWrapperFactory,
Loki::CreateUsingNew,
Loki::NoDestroy > Type;
return Type::Instance();
}
TimeIntegrationWrapper::TimeIntegrationWrapper()
{
}
void TimeIntegrationWrapper::v_InitObject()
{
}
// --------------
// IMEX Order 1
// --------------
string TimeIntegrationIMEXOrder1::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("IMEXOrder1", TimeIntegrationIMEXOrder1::create);
void TimeIntegrationIMEXOrder1::v_InitObject()
{
m_intSteps = 1;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eIMEXOrder1);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
}
// --------------
// IMEX Order 2
// --------------
string TimeIntegrationIMEXOrder2::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("IMEXOrder2", TimeIntegrationIMEXOrder2::create);
void TimeIntegrationIMEXOrder2::v_InitObject()
{
m_intSteps = 2;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eIMEXOrder1);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
TimeIntegrationSchemeKey IntKey1(eIMEXOrder2);
m_integrationScheme[1] = TimeIntegrationSchemeManager()[IntKey1];
}
// --------------
// IMEX Order 3
// --------------
string TimeIntegrationIMEXOrder3::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("IMEXOrder3", TimeIntegrationIMEXOrder3::create);
void TimeIntegrationIMEXOrder3::v_InitObject()
{
m_intSteps = 3;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eIMEXdirk_3_4_3);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
TimeIntegrationSchemeKey IntKey1(eIMEXdirk_3_4_3);
m_integrationScheme[1] = TimeIntegrationSchemeManager()[IntKey1];
TimeIntegrationSchemeKey IntKey2(eIMEXOrder3);
m_integrationScheme[2] = TimeIntegrationSchemeManager()[IntKey2];
}
// --------------
// ForwardEuler
// --------------
string TimeIntegrationForwardEuler::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("ForwardEuler", TimeIntegrationForwardEuler::create);
void TimeIntegrationForwardEuler::v_InitObject()
{
m_intSteps = 1;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eForwardEuler);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
}
// --------------
// BackwardEuler
// --------------
string TimeIntegrationBackwardEuler::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("BackwardEuler", TimeIntegrationBackwardEuler::create);
void TimeIntegrationBackwardEuler::v_InitObject()
{
m_intSteps = 1;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eBackwardEuler);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
}
// --------------
// BDFImplicitOrder1
// --------------
string TimeIntegrationBDFImplicitOrder1::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("BDFImplicitOrder1", TimeIntegrationBDFImplicitOrder1::create);
void TimeIntegrationBDFImplicitOrder1::v_InitObject()
{
m_intSteps = 1;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eBDFImplicitOrder1);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
}
// --------------
// BDFImplicitOrder2
// --------------
string TimeIntegrationBDFImplicitOrder2::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("BDFImplicitOrder2", TimeIntegrationBDFImplicitOrder2::create);
void TimeIntegrationBDFImplicitOrder2::v_InitObject()
{
m_intSteps = 2;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eBackwardEuler);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
TimeIntegrationSchemeKey IntKey1(eBDFImplicitOrder2);
m_integrationScheme[1] = TimeIntegrationSchemeManager()[IntKey1];
}
// --------------
// BDFImplicitOrder2
// --------------
string TimeIntegrationRungeKutta2_ImprovedEuler::className = GetTimeIntegrationWrapperFactory().RegisterCreatorFunction("RungeKutta2_ImprovedEuler", TimeIntegrationRungeKutta2_ImprovedEuler::create);
void TimeIntegrationRungeKutta2_ImprovedEuler::v_InitObject()
{
m_intSteps = 1;
m_integrationScheme = std::vector<TimeIntegrationSchemeSharedPtr> (m_intSteps);
TimeIntegrationSchemeKey IntKey0(eRungeKutta2_ImprovedEuler);
m_integrationScheme[0] = TimeIntegrationSchemeManager()[IntKey0];
}
}
}
/*
* TimeIntegrationWrapper.h
*
* Created on: 16 Jul 2013
* Author: cc
*/
#ifndef TIMEINTEGRATIONWRAPPER_H_
#define TIMEINTEGRATIONWRAPPER_H_
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
namespace Nektar {
namespace LibUtilities {
class TimeIntegrationWrapper;
/// Datatype of the NekFactory used to instantiate classes derived from
/// the EquationSystem class.
typedef NekFactory<
std::string, TimeIntegrationWrapper
> TimeIntegrationWrapperFactory;
TimeIntegrationWrapperFactory& GetTimeIntegrationWrapperFactory();
typedef boost::shared_ptr<TimeIntegrationWrapper> TimeIntegrationWrapperSharedPtr;
class TimeIntegrationWrapper
{
public:
virtual ~TimeIntegrationWrapper() {}
inline void InitObject()
{
v_InitObject();
}
TimeIntegrationSolutionSharedPtr InitializeScheme(
const NekDouble timestep,
TimeIntegrationScheme::ConstDoubleArray &y_0,
const NekDouble time ,
const TimeIntegrationSchemeOperators &op)
{
return m_integrationScheme[m_intSteps-1]->InitializeScheme(timestep, y_0, time, op);
}
TimeIntegrationScheme::ConstDoubleArray&
TimeIntegrate(
const int timestep,
const NekDouble delta_t,
TimeIntegrationSolutionSharedPtr &solvector,
const TimeIntegrationSchemeOperators &op)
{
return m_integrationScheme[min(timestep,m_intSteps-1)]->TimeIntegrate(delta_t, solvector, op);
}
TimeIntegrationMethod GetIntegrationMethod()
{
return m_method;
}
unsigned int GetIntegrationSteps()
{
return m_intSteps;
}
protected:
TimeIntegrationMethod m_method;
int m_intSteps;
std::vector<TimeIntegrationSchemeSharedPtr> m_integrationScheme;
/// Constructor
TimeIntegrationWrapper();
virtual void v_InitObject();
private:
};
// --------
// IMEX Order 1
// --------
class TimeIntegrationIMEXOrder1;
typedef boost::shared_ptr<TimeIntegrationIMEXOrder1> TimeIntegrationIMEXOrder1SharedPtr;
class TimeIntegrationIMEXOrder1 : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationIMEXOrder1>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationIMEXOrder1>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationIMEXOrder1() {}
protected:
virtual void v_InitObject();
};
class TimeIntegrationIMEXOrder2 : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationIMEXOrder2>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationIMEXOrder2>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationIMEXOrder2() {}
protected:
virtual void v_InitObject();
};
class TimeIntegrationIMEXOrder3 : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationIMEXOrder3>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationIMEXOrder3>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationIMEXOrder3() {}
protected:
virtual void v_InitObject();
};
class TimeIntegrationForwardEuler : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationForwardEuler>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationForwardEuler>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationForwardEuler() {}
protected:
virtual void v_InitObject();
};
class TimeIntegrationBackwardEuler : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationBackwardEuler>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationBackwardEuler>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationBackwardEuler() {}
protected:
virtual void v_InitObject();
};
class TimeIntegrationBDFImplicitOrder1 : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationBDFImplicitOrder1>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationBDFImplicitOrder1>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationBDFImplicitOrder1() {}
protected:
virtual void v_InitObject();
};
class TimeIntegrationBDFImplicitOrder2 : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationBDFImplicitOrder2>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationBDFImplicitOrder2>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationBDFImplicitOrder2() {}
protected:
virtual void v_InitObject();
};
class TimeIntegrationRungeKutta2_ImprovedEuler : public TimeIntegrationWrapper
{
public:
friend class MemoryManager<TimeIntegrationRungeKutta2_ImprovedEuler>;
/// Creates an instance of this class
static TimeIntegrationWrapperSharedPtr create() {
TimeIntegrationWrapperSharedPtr p = MemoryManager<TimeIntegrationRungeKutta2_ImprovedEuler>::AllocateSharedPtr();
p->InitObject();
return p;
}
/// Name of class
static std::string className;
virtual ~TimeIntegrationRungeKutta2_ImprovedEuler() {}
protected:
virtual void v_InitObject();
};
}
}
#endif /* TIMEINTEGRATIONWRAPPER_H_ */
......@@ -33,6 +33,7 @@
// Navier Stokes equations
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/TimeIntegration/TimeIntegrationWrapper.h>
#include <IncNavierStokesSolver/EquationSystems/CoupledLinearNS.h>
#include <LibUtilities/BasicUtils/Timer.h>
#include <LocalRegions/MatrixKey.h>
......@@ -1199,30 +1200,31 @@ namespace Nektar
ASSERTL0(i != (int) LibUtilities::SIZE_TimeIntegrationMethod, "Invalid time integration type.");
switch(intMethod)
{
case LibUtilities::eIMEXOrder1:
{
m_intSteps = 1;
m_integrationScheme = Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr> (m_intSteps);
LibUtilities::TimeIntegrationSchemeKey IntKey0(intMethod);
m_integrationScheme[0] = LibUtilities::TimeIntegrationSchemeManager()[IntKey0];
}
break;
case LibUtilities::eIMEXOrder2:
{
m_intSteps = 2;
m_integrationScheme = Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr> (m_intSteps);
LibUtilities::TimeIntegrationSchemeKey IntKey0(LibUtilities::eIMEXOrder1);
m_integrationScheme[0] = LibUtilities::TimeIntegrationSchemeManager()[IntKey0];
LibUtilities::TimeIntegrationSchemeKey IntKey1(intMethod);
m_integrationScheme[1] = LibUtilities::TimeIntegrationSchemeManager()[IntKey1];
}
break;
default:
ASSERTL0(0,"Integration method not setup: Options include ImexOrder1, ImexOrder2");
break;
}
m_integrationScheme = LibUtilities::GetTimeIntegrationWrapperFactory().CreateInstance(LibUtilities::TimeIntegrationMethodMap[intMethod]);
// switch(intMethod)
// {
// case LibUtilities::eIMEXOrder1:
// {
// m_intSteps = 1;
// m_integrationScheme = Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr> (m_intSteps);
// LibUtilities::TimeIntegrationSchemeKey IntKey0(intMethod);
// m_integrationScheme[0] = LibUtilities::TimeIntegrationSchemeManager()[IntKey0];
// }
// break;
// case LibUtilities::eIMEXOrder2:
// {
// m_intSteps = 2;
// m_integrationScheme = Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr> (m_intSteps);
// LibUtilities::TimeIntegrationSchemeKey IntKey0(LibUtilities::eIMEXOrder1);
// m_integrationScheme[0] = LibUtilities::TimeIntegrationSchemeManager()[IntKey0];
// LibUtilities::TimeIntegrationSchemeKey IntKey1(intMethod);
// m_integrationScheme[1] = LibUtilities::TimeIntegrationSchemeManager()[IntKey1];
// }
// break;
// default:
// ASSERTL0(0,"Integration method not setup: Options include ImexOrder1, ImexOrder2");
// break;
// }
// Could defind this from IncNavierStokes class?
m_integrationOps.DefineOdeRhs(&CoupledLinearNS::EvaluateAdvection, this);
......
......@@ -285,7 +285,7 @@ namespace Nektar
// Initialise NS solver which is set up to use a GLM method
// with calls to EvaluateAdvection_SetPressureBCs and
// SolveUnsteadyStokesSystem
m_integrationSoln = m_integrationScheme[m_intSteps-1]->InitializeScheme(m_timestep, fields, m_time, m_integrationOps);
m_integrationSoln = m_integrationScheme->InitializeScheme(m_timestep, fields, m_time, m_integrationOps);
std::vector<SolverUtils::FilterSharedPtr>::iterator x;
for (x = m_filters.begin(); x != m_filters.end(); ++x)
......@@ -306,7 +306,7 @@ namespace Nektar
}
fields = m_integrationScheme[min(n,m_intSteps-1)]->TimeIntegrate(m_timestep, m_integrationSoln, m_integrationOps);
fields = m_integrationScheme->TimeIntegrate(n, m_timestep, m_integrationSoln, m_integrationOps);
m_time += m_timestep;
......@@ -517,7 +517,7 @@ namespace Nektar
{
fields = m_subStepIntegrationScheme->
TimeIntegrate(
dt, SubIntegrationSoln, m_subStepIntegrationOps);
n, dt, SubIntegrationSoln, m_subStepIntegrationOps);
}
// Reset time integrated solution in m_integrationSoln
......
......@@ -36,6 +36,7 @@
#ifndef NEKTAR_SOLVERS_INCNAVIERSTOKES_H
#define NEKTAR_SOLVERS_INCNAVIERSTOKES_H
#include <LibUtilities/TimeIntegration/TimeIntegrationWrapper.h>
#include <SolverUtils/UnsteadySystem.h>
#include <IncNavierStokesSolver/AdvectionTerms/AdvectionTerm.h>
#include <LibUtilities/BasicUtils/SessionReader.h>
......@@ -142,7 +143,7 @@ namespace Nektar
// This function gives back the convective filed in the standard
// element to calculate the stability region of the problem in a
// unique way.
Array<OneD,NekDouble> GetStdVelocity(
Array<OneD,NekDouble> GetMaxStdVelocity(
const Array<OneD, Array<OneD,NekDouble> > inarray);
......@@ -177,7 +178,8 @@ namespace Nektar
/// bool to identify if advection term smoothing is requested
bool m_SmoothAdvection;
LibUtilities::TimeIntegrationSchemeSharedPtr m_subStepIntegrationScheme;
LibUtilities::TimeIntegrationWrapperSharedPtr m_subStepIntegrationScheme;
//LibUtilities::TimeIntegrationSchemeSharedPtr m_subStepIntegrationScheme;
LibUtilities::TimeIntegrationSchemeOperators m_subStepIntegrationOps;
Array<OneD, Array<OneD, NekDouble> > m_previousVelFields;
......@@ -218,8 +220,7 @@ namespace Nektar
/// Time integration classes
LibUtilities::TimeIntegrationSchemeOperators m_integrationOps;
Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr>
m_integrationScheme;
LibUtilities::TimeIntegrationWrapperSharedPtr m_integrationScheme;
/// Number of time integration steps AND Order of extrapolation for
/// pressure boundary conditions.
......
......@@ -149,6 +149,9 @@ namespace Nektar
m_session->LoadParameter("SubStepCFL", m_cflSafetyFactor, 0.5);
m_integrationScheme = LibUtilities::GetTimeIntegrationWrapperFactory().CreateInstance(LibUtilities::TimeIntegrationMethodMap[intMethod]);
m_intSteps = m_integrationScheme->GetIntegrationSteps();
// Set to 1 for first step and it will then be increased in
// time advance routines
switch(intMethod)
......@@ -156,13 +159,14 @@ namespace Nektar
case LibUtilities::eBackwardEuler:
case LibUtilities::eBDFImplicitOrder1:
{
m_intSteps = 1;
m_integrationScheme = Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr> (m_intSteps);
LibUtilities::TimeIntegrationSchemeKey IntKey0(intMethod);
m_integrationScheme[0] = LibUtilities::TimeIntegrationSchemeManager()[IntKey0];
LibUtilities::TimeIntegrationSchemeKey SubIntKey(LibUtilities::eForwardEuler);
m_subStepIntegrationScheme = LibUtilities::TimeIntegrationSchemeManager()[SubIntKey];
// m_intSteps = 1;
// m_integrationScheme = Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr> (m_intSteps);
// LibUtilities::TimeIntegrationSchemeKey IntKey0(intMethod);
// m_integrationScheme[0] = LibUtilities::TimeIntegrationSchemeManager()[IntKey0];
m_subStepIntegrationScheme = LibUtilities::GetTimeIntegrationWrapperFactory().CreateInstance(LibUtilities::TimeIntegrationMethodMap[LibUtilities::eForwardEuler]);
// LibUtilities::TimeIntegrationSchemeKey SubIntKey(LibUtilities::eForwardEuler);
// m_subStepIntegrationScheme = LibUtilities::TimeIntegrationSchemeManager()[SubIntKey];
// Fields for linear interpolation
m_previousVelFields = Array<OneD, Array<OneD, NekDouble> >(2*m_fields.num_elements());
......@@ -177,18 +181,19 @@ namespace Nektar
break;
case LibUtilities::eBDFImplicitOrder2:
{
m_intSteps = 2;
m_integrationScheme = Array<OneD, LibUtilities::TimeIntegrationSchemeSharedPtr> (m_intSteps);
LibUtilities::Ti