Commit 2ec14eaf authored by Peter Vos's avatar Peter Vos
Browse files

Updated time integration manager into general linear method format


git-svn-id: https://gforge.sci.utah.edu/svn/nektar/trunk@1444 305cdda6-5ce1-45b3-a98d-dfc68c8b3305
parent 0faee98e
......@@ -58,8 +58,6 @@ SET(FoundationHeaders
./Foundations/NodalTriEvenlySpaced.h
./Foundations/NodalTetEvenlySpaced.h
./Foundations/TimeIntegrationScheme.h
./Foundations/ForwardMultiStepIntegrationScheme.h
./Foundations/RungeKuttaScheme.h
)
SET(InterpreterHeaders
......@@ -144,8 +142,6 @@ SET(FoundationSources
./Foundations/NodalTriEvenlySpaced.cpp
./Foundations/NodalTetEvenlySpaced.cpp
./Foundations/TimeIntegrationScheme.cpp
./Foundations/ForwardMultiStepIntegrationScheme.cpp
./Foundations/RungeKuttaScheme.cpp
)
SET(InterpreterSources
......
///////////////////////////////////////////////////////////////////////////////
//
// File ForwardMultiStepIntegrationScheme.cpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Implementation of forward multi-step time integration schemes
//
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/LibUtilities.h>
#include <LibUtilities/Foundations/ForwardMultiStepIntegrationScheme.h>
#include <LibUtilities/Foundations/Foundations.hpp>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
namespace Nektar
{
namespace LibUtilities
{
ForwardMultiStepIntegrationScheme::ForwardMultiStepIntegrationScheme(const TimeIntegrationSchemeKey &tkey):
TimeIntegrationScheme(tkey),
m_beta(4)
{
switch(tkey.GetIntegrationSchemeType())
{
case eAdamsBashforth:
{
switch(tkey.GetOrder())
{
case 1:
{
m_beta[0] = 0.0;
m_beta[1] = 1.0;
m_beta[2] = 0.0;
m_beta[3] = 0.0;
}
break;
case 2:
{
m_beta[0] = 0.0;
m_beta[1] = 3.0/2.0;
m_beta[2] = -1.0/2.0;
m_beta[3] = 0.0;
}
break;
case 3:
{
m_beta[0] = 0.0;
m_beta[1] = 23.0/12.0;
m_beta[2] = -16.0/12.0;
m_beta[3] = 5.0/12.0;
}
break;
default:
{
NEKERROR(ErrorUtil::efatal,"The Adams-Bashforth scheme is only supported for orders 1,2 and 3");
}
}
}
break;
case eAdamsMoulton:
{
switch(tkey.GetOrder())
{
case 1:
{
m_beta[0] = 1.0;
m_beta[1] = 0.0;
m_beta[2] = 0.0;
m_beta[3] = 0.0;
}
break;
case 2:
{
m_beta[0] = 1.0/2.0;
m_beta[1] = 1.0/2.0;
m_beta[2] = 0.0;
m_beta[3] = 0.0;
}
break;
case 3:
{
m_beta[0] = 5.0/12.0;
m_beta[1] = 8.0/12.0;
m_beta[2] = -1.0/12.0;
m_beta[3] = 0.0;
}
break;
default:
{
NEKERROR(ErrorUtil::efatal,"The Adams-Moulton scheme is only supported for orders 1,2 and 3");
}
}
}
break;
default:
{
NEKERROR(ErrorUtil::efatal,"Invalid integration type");
}
}
}
boost::shared_ptr<TimeIntegrationScheme> ForwardMultiStepIntegrationScheme::Create(const TimeIntegrationSchemeKey &tkey)
{
boost::shared_ptr<TimeIntegrationScheme> returnval(new ForwardMultiStepIntegrationScheme(tkey));
return returnval;
}
} // end of namespace LibUtilities
} // end of namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File ForwardMultiStepIntegrationScheme.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Header file of forward multi-step time integration schemes
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_FOUNDATIONS_FORWARDMULTISTEPINTEGRATIONSCHEME_H
#define NEKTAR_LIB_UTILITIES_FOUNDATIONS_FORWARDMULTISTEPINTEGRATIONSCHEME_H
#include <math.h>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/mem_fn.hpp>
#include <LibUtilities/Foundations/Foundations.hpp>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/Foundations/TimeIntegrationScheme.h>
#include <LibUtilities/Memory/NekMemoryManager.hpp>
namespace Nektar
{
namespace LibUtilities
{
class ForwardMultiStepIntegrationScheme: public TimeIntegrationScheme
{
public:
virtual ~ForwardMultiStepIntegrationScheme()
{
}
static boost::shared_ptr<TimeIntegrationScheme> Create(const TimeIntegrationSchemeKey &tkey);
virtual const Array<OneD, const NekDouble>& GetBetaCoefficients(void) const
{
return m_beta;
}
protected:
Array<OneD,NekDouble> m_beta;
private:
ForwardMultiStepIntegrationScheme(const TimeIntegrationSchemeKey &tkey);
/// These should not be called. All creation is done
/// using the constructor requiring the key, declared
/// above.
ForwardMultiStepIntegrationScheme(const ForwardMultiStepIntegrationScheme &in)
{
NEKERROR(ErrorUtil::efatal,"Copy Constructor for the ForwardMultiStepIntegrationScheme class should not be called");
}
ForwardMultiStepIntegrationScheme():
TimeIntegrationScheme()
{
NEKERROR(ErrorUtil::efatal,"Default Constructor for the ForwardMultiStepIntegrationScheme class should not be called");
}
};
} // end of namespace
} // end of namespace
#endif //NEKTAR_LIB_UTILITIES_FOUNDATIONS_FORWARDMULTISTEPINTEGRATIONSCHEME_H
......@@ -131,18 +131,26 @@ namespace Nektar
enum TimeIntegrationType
{
eNoTimeIntegrationType,
eAdamsBashforth, //!< Adams-Bashforth Forward multi-step scheme
eAdamsMoulton, //!< Adams-Moulton Forward multi-step scheme
eRungeKutta, //!< Rungi-Kutta multi-stage scheme
eAdamsBashforthOrder1, //!< Adams-Bashforth Forward multi-step scheme of order 1
eAdamsBashforthOrder2, //!< Adams-Bashforth Forward multi-step scheme of order 2
eAdamsMoultonOrder1, //!< Adams-Moulton Forward multi-step scheme of order 1
eAdamsMoultonOrder2, //!< Adams-Moulton Forward multi-step scheme of order 2
eClassiscalRungeKutta4, //!< Runge-Kutta multi-stage scheme
eForwardEuler, //!< Forward euler scheme
eBackwardEuler, //!< Backward euler scheme
SIZE_TimeIntegrationType //!< Length of enum list
};
const char* const TimeIntegrationTypeMap[] =
{
"NoTimeIntegrationType",
"Adams-Bashforth",
"Adams-Moulton",
"Runge-Kutta"
"1st order Adams-Bashforth",
"2nd order Adams-Bashforth",
"1st order Adams-Moulton",
"2nd order Adams-Moulton",
"Classical Runge-Kutta 4",
"Forward Euler",
"Backward Euler"
};
} // end of namespace
} // end of namespace
......
......@@ -44,8 +44,7 @@
#include <LibUtilities/Foundations/NodalTriEvenlySpaced.h>
#include <LibUtilities/Foundations/NodalTetEvenlySpaced.h>
#include <LibUtilities/Foundations/Basis.h>
#include <LibUtilities/Foundations/ForwardMultiStepIntegrationScheme.h>
#include <LibUtilities/Foundations/RungeKuttaScheme.h>
#include <LibUtilities/Foundations/TimeIntegrationScheme.h>
#include <LibUtilities/Foundations/Foundations.hpp>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/Foundations/ManagerAccess.h>
......@@ -90,9 +89,13 @@ namespace Nektar
const bool Chebyshev_Inited = BasisManager().RegisterCreator(BasisKey(eChebyshev, 0, NullPointsKey), Basis::Create);
const bool Monomial_Inited = BasisManager().RegisterCreator(BasisKey(eMonomial, 0, NullPointsKey), Basis::Create);
const bool AdamsBashforth_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eAdamsBashforth, 0), ForwardMultiStepIntegrationScheme::Create);
const bool AdamsMoulton_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eAdamsMoulton, 0), ForwardMultiStepIntegrationScheme::Create);
const bool RungeKutta_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eRungeKutta, 0), RungeKuttaScheme::Create);
const bool AdamsBashforthOrder1_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eAdamsBashforthOrder1), TimeIntegrationScheme::Create);
const bool AdamsBashforthOrder2_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eAdamsBashforthOrder2), TimeIntegrationScheme::Create);
const bool AdamsMoultonOrder1_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eAdamsMoultonOrder1), TimeIntegrationScheme::Create);
const bool AdamsMoultonOrder2_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eAdamsMoultonOrder2), TimeIntegrationScheme::Create);
const bool ClassiscalRungeKutta4_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eClassiscalRungeKutta4), TimeIntegrationScheme::Create);
const bool ForwardEuler_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eForwardEuler), TimeIntegrationScheme::Create);
const bool BackwardEuler_Inited = TimeIntegrationSchemeManager().RegisterCreator(TimeIntegrationSchemeKey(eBackwardEuler), TimeIntegrationScheme::Create);
};
PointsManagerT &PointsManager(void)
......@@ -116,6 +119,9 @@ namespace Nektar
/**
$Log: ManagerAccess.cpp,v $
Revision 1.19 2008/07/12 11:37:53 pvos
Added time integration scheme manager
Revision 1.18 2008/05/27 20:05:50 ehan
Added NodalTetEvenlySpaced points.
......
///////////////////////////////////////////////////////////////////////////////
//
// File RungeKuttaScheme.cpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Implementation of forward multi-step time integration schemes
//
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/LibUtilities.h>
#include <LibUtilities/Foundations/RungeKuttaScheme.h>
#include <LibUtilities/Foundations/Foundations.hpp>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
namespace Nektar
{
namespace LibUtilities
{
RungeKuttaScheme::RungeKuttaScheme(const TimeIntegrationSchemeKey &tkey):
TimeIntegrationScheme(tkey),
m_a(tkey.GetOrder(),tkey.GetOrder(),0.0),
m_b(tkey.GetOrder()),
m_c(tkey.GetOrder())
{
ASSERTL0(tkey.GetIntegrationSchemeType() == eRungeKutta,"Invalid integration type");
switch(tkey.GetOrder())
{
case 1:
{
m_a[0][0] = 0.0;
m_b[0] = 1.0;
m_c[0] = 0.0;
}
break;
case 2:
{
m_a[1][0] = 1.0;
m_b[0] = 0.5;
m_b[1] = 0.5;
m_c[0] = 0.0;
m_c[1] = 1.0;
}
break;
case 3:
{
m_a[1][0] = 0.5;
m_a[2][0] = -1.0;
m_a[2][1] = 2.0;
m_b[0] = 1.0/6.0;
m_b[1] = 2.0/3.0;
m_b[2] = 1.0/6.0;
m_c[0] = 0.0;
m_c[1] = 0.5;
m_c[2] = 1.0;
}
break;
case 4:
{
m_a[1][0] = 0.5;
m_a[2][0] = 0.0;
m_a[3][0] = 0.0;
m_a[2][1] = 0.5;
m_a[3][1] = 0.0;
m_a[3][2] = 1.0;
m_b[0] = 1.0/6.0;
m_b[1] = 1.0/3.0;
m_b[2] = 1.0/3.0;
m_b[3] = 1.0/6.0;
m_c[0] = 0.0;
m_c[1] = 0.5;
m_c[2] = 0.5;
m_c[3] = 1.0;
}
break;
default:
{
NEKERROR(ErrorUtil::efatal,"The Adams-Bashforth scheme is only supported for orders 1,2 and 3");
}
}
}
boost::shared_ptr<TimeIntegrationScheme> RungeKuttaScheme::Create(const TimeIntegrationSchemeKey &tkey)
{
boost::shared_ptr<TimeIntegrationScheme> returnval(new RungeKuttaScheme(tkey));
return returnval;
}
} // end of namespace LibUtilities
} // end of namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File RungekuttaScheme.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Header file of forward multi-step time integration schemes
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_FOUNDATIONS_RUNGEKUTTASCHEME_H
#define NEKTAR_LIB_UTILITIES_FOUNDATIONS_RUNGEKUTTASCHEME_H
#include <math.h>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/mem_fn.hpp>
#include <LibUtilities/Foundations/Foundations.hpp>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/Foundations/TimeIntegrationScheme.h>
#include <LibUtilities/Memory/NekMemoryManager.hpp>
namespace Nektar
{
namespace LibUtilities
{
class RungeKuttaScheme: public TimeIntegrationScheme
{
public:
virtual ~RungeKuttaScheme()
{
}
static boost::shared_ptr<TimeIntegrationScheme> Create(const TimeIntegrationSchemeKey &tkey);
virtual const Array<TwoD, const NekDouble>& GetAcoefficients(void) const
{
return m_a;
}
virtual const Array<OneD, const NekDouble>& GetBcoefficients(void) const
{
return m_b;
}
virtual const Array<OneD, const NekDouble>& GetCcoefficients(void) const
{
return m_c;
}
protected:
Array<TwoD,NekDouble> m_a;
Array<OneD,NekDouble> m_b;
Array<OneD,NekDouble> m_c;
private:
RungeKuttaScheme(const TimeIntegrationSchemeKey &tkey);
/// These should not be called. All creation is done
/// using the constructor requiring the key, declared
/// above.
RungeKuttaScheme(const RungeKuttaScheme &in)
{
NEKERROR(ErrorUtil::efatal,"Copy Constructor for the RungeKuttaScheme class should not be called");
}
RungeKuttaScheme():
TimeIntegrationScheme()
{
NEKERROR(ErrorUtil::efatal,"Default Constructor for the RungeKuttaScheme class should not be called");
}
};
} // end of namespace
} // end of namespace
#endif //NEKTAR_LIB_UTILITIES_FOUNDATIONS_RUNGEKUTTASCHEME_H
......@@ -43,22 +43,11 @@ namespace Nektar
{
bool operator==(const TimeIntegrationSchemeKey &lhs, const TimeIntegrationSchemeKey &rhs)
{
return (lhs.m_order == rhs.m_order &&
lhs.m_integrationtype == rhs.m_integrationtype);
return (lhs.m_integrationtype == rhs.m_integrationtype);
}
bool operator<(const TimeIntegrationSchemeKey &lhs, const TimeIntegrationSchemeKey &rhs)
{
if (lhs.m_order < rhs.m_order)
{
return true;
}
if (lhs.m_order > rhs.m_order)
{
return false;
}
{
return (lhs.m_integrationtype < rhs.m_integrationtype);
}
......@@ -69,11 +58,151 @@ namespace Nektar
std::ostream& operator<<(std::ostream& os, const TimeIntegrationSchemeKey& rhs)
{
os << "Integration Scheme: " << TimeIntegrationTypeMap[rhs.GetIntegrationSchemeType()];
os << ", Order: " << rhs.GetOrder() << std::endl;
os << "Time Integration Scheme: " << TimeIntegrationTypeMap[rhs.GetIntegrationSchemeType()] << endl;
return os;
}
TimeIntegrationSchemeSharedPtr TimeIntegrationScheme::Create(const TimeIntegrationSchemeKey &key)
{
TimeIntegrationSchemeSharedPtr returnval(new TimeIntegrationScheme(key));
return returnval;
}
TimeIntegrationScheme::TimeIntegrationScheme(const TimeIntegrationSchemeKey &key):
m_schemeKey(key)
{
switch(key.GetIntegrationSchemeType())
{
case eForwardEuler:
case eAdamsBashforthOrder1:
{