Commit e1249a77 authored by Peter Vos's avatar Peter Vos
Browse files

Added time integration scheme manager


git-svn-id: https://gforge.sci.utah.edu/svn/nektar/trunk@1430 305cdda6-5ce1-45b3-a98d-dfc68c8b3305
parent 0ec41a04
......@@ -57,6 +57,9 @@ SET(FoundationHeaders
./Foundations/NodalUtil.h
./Foundations/NodalTriEvenlySpaced.h
./Foundations/NodalTetEvenlySpaced.h
./Foundations/TimeIntegrationScheme.h
./Foundations/ForwardMultiStepIntegrationScheme.h
./Foundations/RungeKuttaScheme.h
)
SET(InterpreterHeaders
......@@ -138,8 +141,11 @@ SET(FoundationSources
./Foundations/Points.cpp
./Foundations/PolyEPoints.cpp
./Foundations/NodalUtil.cpp
./Foundations/NodalTriEvenlySpaced.cpp
./Foundations/NodalTetEvenlySpaced.cpp
./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
......@@ -127,6 +127,23 @@ namespace Nektar
"NodalTetEvenlySpaced",
"NodalTetElec",
};
enum TimeIntegrationType
{
eNoTimeIntegrationType,
eAdamsBashforth, //!< Adams-Bashforth Forward multi-step scheme
eAdamsMoulton, //!< Adams-Moulton Forward multi-step scheme
eRungeKutta, //!< Rungi-Kutta multi-stage scheme
SIZE_TimeIntegrationType //!< Length of enum list
};
const char* const TimeIntegrationTypeMap[] =
{
"NoTimeIntegrationType",
"Adams-Bashforth",
"Adams-Moulton",
"Runge-Kutta"
};
} // end of namespace
} // end of namespace
......
......@@ -41,12 +41,14 @@
#include <LibUtilities/Foundations/NodalTriElec.h>
#include <LibUtilities/Foundations/NodalTetElec.h>
#include <LibUtilities/Foundations/NodalTriFekete.h>
#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/Foundations.hpp>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/Foundations/ManagerAccess.h>
#include <LibUtilities/Foundations/NodalTriEvenlySpaced.h>
#include <LibUtilities/Foundations/NodalTetEvenlySpaced.h>
namespace Nektar
{
......@@ -87,6 +89,10 @@ namespace Nektar
const bool Legendre_Inited = BasisManager().RegisterCreator(BasisKey(eLegendre, 0, NullPointsKey), Basis::Create);
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);
};
PointsManagerT &PointsManager(void)
......@@ -99,12 +105,20 @@ namespace Nektar
return Loki::SingletonHolder<BasisManagerT>::Instance();
}
TimeIntegrationSchemeManagerT &TimeIntegrationSchemeManager(void)
{
return Loki::SingletonHolder<TimeIntegrationSchemeManagerT>::Instance();
}
} // end of namespace LibUtilities
} // end of namespace Nektar
/**
$Log: ManagerAccess.cpp,v $
Revision 1.18 2008/05/27 20:05:50 ehan
Added NodalTetEvenlySpaced points.
Revision 1.17 2008/05/23 20:02:13 ehan
Added NodalTriEvenlySpaced points.
......
......@@ -39,6 +39,7 @@
#include <LibUtilities/BasicUtils/NekManager.hpp>
#include <LibUtilities/Foundations/Points.h>
#include <LibUtilities/Foundations/Basis.h>
#include <LibUtilities/Foundations/TimeIntegrationScheme.h>
namespace Nektar
{
......@@ -50,12 +51,18 @@ namespace Nektar
typedef NekManager<BasisKey, Basis, BasisKey::opLess> BasisManagerT;
BasisManagerT &BasisManager(void);
typedef NekManager<TimeIntegrationSchemeKey, TimeIntegrationScheme, TimeIntegrationSchemeKey::opLess> TimeIntegrationSchemeManagerT;
TimeIntegrationSchemeManagerT &TimeIntegrationSchemeManager(void);
} // end of namespace LibUtilities
} // end of namespace Nektar
#endif //#NEKTAR_LIB_UTILIITIES_FOUNDATIONS_MANAGER_ACCESS_H
#endif //NEKTAR_LIB_UTILIITIES_FOUNDATIONS_MANAGER_ACCESS_H
/**
$Log: ManagerAccess.h,v $
Revision 1.9 2007/04/29 03:09:47 jfrazier
More conversion to multi_arrays.
Revision 1.8 2007/02/06 17:12:31 jfrazier
Fixed a problem with global initialization in libraries.
......
///////////////////////////////////////////////////////////////////////////////
//
// 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
///////////////////////////////////////////////////////////////////////////////
//
// File TimeIntegrationScheme.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