...
 
Commits (21)
  • J. Davison de St. Germain's avatar
    First round of Time Integration updates. We are replacing the Wrapper file with · ee633a94
    J. Davison de St. Germain authored
    each scheme being implemented in its own file.  In this commit, I have added a
    the new object (and the new term) TimeIntegrator.  A TimeIntegrator is just a
    Time Integration Scheme, but allows for multiple sub-schemes - this correlates directly
    to the term "Master Scheme" used in TimeIntegrationScheme.cpp.  However, after
    talking to Mike and Chris and learning more about the correct terminology, I plan
    (soon) to commit another refactoring to go back to just the use of "Scheme" which
    will encompass both single level and multi-level (master) schemes.
    
    The code commited here passes all but one of the ctests:
    
    	326 - LibUtilities_TimeIntegrationDemoIMEXOrder2 (Failed)
    
    Note 1: The code in library/Demos/LibUtilities/TimeIntegrationDemo.cpp previously
    implemented (duplicated) the scheme creation code found in library/LibUtilities/TimeIntegration/TimeIntegrationWrapper.cpp.
    I have removed this duplicate code and just use the Time Integrator object directly.
    Note, the code was exactly the same between the Wrapper and the Demo, with the
    exception of the implementation of IMEX Order2 (see note 2).
    
    Note 2: To make this failing test past, TimeIntegration/IMEXOrder2TimeIntegrator.h
    can be modifed to use eIMEXdirk_2_3_2 (see comment in that file) as the 1st sub-scheme.
    However, if I make that change, then 9 other tests will fail as they rely on
    IMEX Order 2 using IMEXOrder1 as the 1st sub-scheme.  It is most likely more correct
    to use eIMEXdirk_2_3_2... however making this change causes some significant
    differences in the answers to the failing tests.  Once Chris finishes looking at this,
    we will update the sub-scheme and the test answers as appropriate.
    
    TimeIntegrationDemo.cpp:
     - I have changed the command line parameters to be more clear: (eg: points -> Npoints).
     - Originally the demo was calculating and outputting the time 0 exact solution twice, I have removed this.
     - Added a comment that the L2 Norm being calcuated is actually the "relative error l2 norm".
     - Added a comment to clarify that the demo is using periodic boundary conditions
         where the 1st and last points are actually the same point.
    
    IMEXOrder1TimeIntegrator.h (and all other TimeIntegrator.h files):
     - Consolidated all the setup code from the Wrapper file and the Scheme file for each of these
         Time Integrators (Master Schemes), see: v_InitObject() and SetupScheme() routines.
     - I don't like the way I still have a giant swtich statement in TimeIntegrationScheme.cpp
         and the use of friend classes in TimeIntegrationScheme.h.  However, I believe that both
         of these will be removed with the next update (see next refactor below).
    
    With respect to the coming/next refactor...  I am happy enough with the current
    refactor to commit it to this branch, but it is not as clean as it could be, and
    now that I understand more about the code and the "master scheme" concept, I plan
    to fix this.  Note, this next refactor, while doing some major re-organization, will
    be more of a semantic change.
    ee633a94
  • J. Davison de St. Germain's avatar
    This is round 2 of the Time Integration refactoring. I like this arrangement... · e66dd8da
    J. Davison de St. Germain authored
    This is round 2 of the Time Integration refactoring.  I like this arrangement better.  I have removed
    from the "Integrators" (that I added in the previous commit) and just refer to them as schemes now.
    A scheme (also called a "master scheme") can have a number of phases (or sub-schemes).  Each sub-scheme
    uses a "scheme" to set up the data for that phase.
    
    I have put the code that creates the (full/master) scheme in the corresponding file, eg:
    
    AdamsBashforthOrder2TimeIntegrationScheme.h  (see the constructor)
    
    Additionally, the code that sets the data for the sub-scheme/phase that corresponds to
    the master scheme is also in the same file (see the SetupSchemeData() method).
    The data for each phase of the scheme is contained in the TimeIntegrationSchemeData object.
    
    This code refactoring removes the giant switch statement that was used to initialize
    the schemes.  It also removes the use the Memory Manager that was returning shared
    pointers to each sub-scheme - which, while it worked, would not have allowed multiple
    schemes to be used in the same executable.
    
    I have also moved the TimeIntegrationSolution object into its own file.
    
    --------------
    
    Note, to create an integration scheme, do something like the following (using the factory):
    
        LibUtilities::TimeIntegrationSchemeSharedPtr tiScheme;
    
        TimeIntegrationSchemeFactory & factory = LibUtilities::GetTimeIntegrationSchemeFactory();
    
        tiScheme = factory.CreateInstance( "IMEXOrder1" );
    
    Note, as I go to commit this, it occurs to me that instead of passing a string to CreateInstance(),
    we should be passing the enum type.  I'll update this soon.
    
    --------------
    
    There are currently 3 failing tests (of 459):
    
    	275 - IncNavierStokesSolver_Prism_channel_varP (Failed)
    	326 - LibUtilities_TimeIntegrationDemoIMEXOrder2 (Failed)
    	341 - StdRegions_StdProject2D_Quad_Mod_P6_Q7 (Failed)
    
    Note, "326 - LibUtilities_TimeIntegrationDemoIMEXOrder2" is failing because IMEXOrder2 is done
    differently between the TimeIntegration/ directory and the original TimeIntegrationDemo code
    (which "re-implemented" the creation of the schemes).  (IMEXOrder2 should use IMEXdirk_2_3_2 as
    the 1st phase, but it is currently set to IMEXOrder1 instead.  Once a definitive determination
    on this is made, this needs to be updated one way or the other.)
    
    It is unclear to me why the other 2 are failing (and the errors are very minuscule).  For example:
    
    275:   Expected: 0 +/- 1e-12
    275:   Result:   1.27742e-12
    
    Before this branch gets merged in, we need to track down the reason for these differences.
    e66dd8da
  • J. Davison de St. Germain's avatar
    - Removed the use of a string as the key to the TimeIntegrationScheme Factory... · 140ab26e
    J. Davison de St. Germain authored
    - Removed the use of a string as the key to the TimeIntegrationScheme Factory (to avoid confusion/misspellings, etc.
      Now using the enumerated type directly.
    
    - Added a couple of missing Time Integation Schemes.  Note, these originally were not refactored
      as there are no tests for them.  I've asked Chris and Kak to look to see if they can add new tests.
    
      - library/LibUtilities/TimeIntegration/AdamsMoultonOrder1TimeIntegrationScheme.h
      - library/LibUtilities/TimeIntegration/IMEXdirk_1_2_1TimeIntegrationScheme.h
      - library/LibUtilities/TimeIntegration/IMEXdirk_2_3_3TimeIntegrationScheme.h
      - library/LibUtilities/TimeIntegration/IMEXdirk_4_4_3TimeIntegrationScheme.h
    
    - Note, AdamsMoultonOrder1TimeIntegrationScheme.h appears to just be BackwardEuler - need input
      on whether this is the way we want to implement it.
    
    - Removed a lot of commented out / dead code from the refactoring.  Some still left to do.
    140ab26e
  • J. Davison de St. Germain's avatar
    This commit cleans up a number of files and fixes the output of the TimeIntegrationDemo code. · 2cc5bc69
    J. Davison de St. Germain authored
    Previously, this refactored version (and the baseline) output the results in the wrong order
    (ie, the exact solution was one timestep offset from the computed solution).  Now, if you
    run the gnuplot of the output, you will see that they actually line up.
    
    Note, the TimeIntegrationDemo ctests now fail... I'm not sure why this is, but will look into
    it after this commit.
    
    Specific changes:
    
    * Demos/LibUtilities/TimeIntegrationDemo.cpp
    
      - Updated paper citation to include full info on paper.
      - Added code demarcations (////////...) and more white space for readability,
          Better indentation on some function definitions, lined up some variables, etc.
      - Compute the initial exact solution and set initial derived solution to that value too.
      - Renamed GetTimeStep() to GetDeltaT() to be more clear.
      - Added a lot of comments to the data file to make it much easier to decipher its
          contents/layout when someone looks at it directly.
      - The main time loop now starts with time step 1 (as you don't actually
          calculate timestep 0 (ts 0 is the initial conditions). *Please let me know if this is incorrect wrt Nektar!
      - Replaced evil endl's with \n.
      - Use ' instead of " in output script to make code cleaner.
           Added "pause mouse any" at end of gnuplot script so it stays up until user is done.
    
    * LibUtilities/BasicUtils/Vmath.hpp
    
      - Was unfamiliar with naming convention for these functions, so added a comment (once I figured it out)
           to make it easier for the next person to decipher them.
      - Some indentation and white space, line up of parameters, etc.
    
    * LibUtilities/TimeIntegration/IMEXOrder1TimeIntegrationScheme.h
    * LibUtilities/TimeIntegration/TimeIntegrationScheme.cpp
    
      - Removed debug print statements.
    
    * LibUtilities/TimeIntegration/TimeIntegrationScheme.h
    
      - Lined up function declarations and used one line to make easier to read.  Some white space and indentation.
    
    * LibUtilities/TimeIntegration/TimeIntegrationSchemeData.cpp
    
      - White space and indentation, vars lined up.  Use more meaningful name than 'i' (ie: 'stage').
    
    * LibUtilities/TimeIntegration/TimeIntegrationSchemeData.h
    
      - Group friend statments.
      - Correct my use of inconsistent indentation.
      - Put a number of one-line functions on a single line (as the .h file is about
           more easily seeing the spec, not the implementation.
    
    * LibUtilities/TimeIntegration/TimeIntegrationSolution.cpp
    
      - Removed outdated FIXME, debug comment.
      - Added a FIXME to verify.
    
    * LibUtilities/TimeIntegration/TimeIntegrationSolution.h
    
      - White space, variable line up.
    2cc5bc69
  • Chris Cantwell's avatar
  • Chris Cantwell's avatar
    a72b0508
  • Chris Cantwell's avatar
    39ba5170
  • J. Davison de St. Germain's avatar
    Based on feedback from Dave M and Chris C, made the following updates: · a05c2422
    J. Davison de St. Germain authored
    - Returned to using a string name (instead of enum) for the factory creation of the scheme.
    - Moved the scheme factory registrations out of the TimeIntegrationScheme.cpp file
        and into the separate SchemeInitializor.cpp file.  This was a compromise
        from creating a separate .cpp file for every specific scheme file to do the registration.
    - Grouped the related Time Integrators into shared .h files.  (For example, all
        Runge Kutta type Time Integrators are now defined in the RungeKuttaTimeIntegrationSchemes.h
        file.
    
    As this is mostly a "cosmetic" update, all Ctests (that were passing) are still passing.
    The ones that are not passing are related to the difference in implementations of time
    integrators between the wrappers (that are being replaced in this branch) and the time
    integrator demo.  See details as specified in my previous commit:
    
       commit e66dd8da
       Author: J. Davison de St. Germain <dav@sci.utah.edu>
       Date:   Sun May 19 22:01:22 2019 -0600
    
    This still needs to be addressed and I believe is on Chris' to-do list.
    a05c2422
  • J. Davison de St. Germain's avatar
    Apparently in my previous commit (just a few minutes ago), I didn't specifically · 656e3158
    J. Davison de St. Germain authored
    add the following files...
    
    This commit finishes the previous commit which did the following:
    
    > Based on feedback from Dave M and Chris C, made the following updates:
    >
    > - Returned to using a string name (instead of enum) for the factory creation of the scheme.
    > - Moved the scheme factory registrations out of the TimeIntegrationScheme.cpp file
    >     and into the separate SchemeInitializor.cpp file.  This was a compromise
    >     from creating a separate .cpp file for every specific scheme file to do the registration.
    > - Grouped the related Time Integrators into shared .h files.  (For example, all
    >     Runge Kutta type Time Integrators are now defined in the RungeKuttaTimeIntegrationSchemes.h
    >     file.
    >
    > As this is mostly a "cosmetic" update, all Ctests (that were passing) are still passing.
    > The ones that are not passing are related to the difference in implementations of time
    > integrators between the wrappers (that are being replaced in this branch) and the time
    > integrator demo.  See details as specified in my previous commit:
    >
    >    commit e66dd8da
    >    Author: J. Davison de St. Germain <dav@sci.utah.edu>
    >    Date:   Sun May 19 22:01:22 2019 -0600
    >
    > This still needs to be addressed and I believe is on Chris' to-do list.
    
    One other note:
    
    I removed the TimeIntegrationWrapper.* files as they aren't being used.  I vaguely recall
    maybe seeing something about them being put back for testing purposes, but can't find
    any reference to this.  If someone wanted them back in this branch, I apologize for removing
    them - feel free to add them back (or let me know and I will).
    656e3158
  • Chris Cantwell's avatar
  • Chris Cantwell's avatar
  • Chris Cantwell's avatar
  • Chris Cantwell's avatar
  • Chris Cantwell's avatar
    ffea0ed2
  • Chris Cantwell's avatar
    Fix compiler warnings / errors. · 48ee3d6f
    Chris Cantwell authored
    48ee3d6f
  • Chris Cantwell's avatar
    Updated CHANGELOG. · e17121e2
    Chris Cantwell authored
    e17121e2
  • Chris Cantwell's avatar
  • Chris Cantwell's avatar
    Fix another Windows error. · aa67675d
    Chris Cantwell authored
    aa67675d
  • Chris Cantwell's avatar
    072f1228
  • Chris Cantwell's avatar
    925ddb6c
  • Chris Cantwell's avatar
    Merge branch 'ticket/139-TimeIntegrationRefactor' into 'master' · 45ef448c
    Chris Cantwell authored
    Ticket/139 time integration refactor
    
    Closes #139
    
    See merge request !1034
    45ef448c
Changelog
=========
v5.1.0
------
**Library**
- Refactored time integration code using factory pattern (!1034)
v5.0.0
------
**Library**
......
......@@ -5,7 +5,7 @@
<parameters>--points 100 --timesteps 100 --method 2</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.0798986</value>
<value tolerance="1e-12">0.0789181</value>
</metric>
</metrics>
</test>
......@@ -30,6 +30,15 @@
//
// Description: Collection of templated functions for vector mathematics
//
// Note: For those unfamiliar with the vector routines notation, it is
// reverse polish notation (RPN). For example:
//
// In the function "Vvtvp()", it is "Vvt" means vector vector times,
// which in infix notation is "v * v". So "Vvtvp" is:
//
// RPN: vector vector times vector plus
// Infix: ( vector * vector ) + vector
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_LIBUTILITIES_BASSICUTILS_VECTORMATH_HPP
......@@ -40,18 +49,14 @@
namespace Vmath
{
/***************** Math routines ***************/
/// \brief Fill a vector with a constant value
template<class T> LIB_UTILITIES_EXPORT void Fill( int n, const T alpha, T *x, const int incx );
/// \brief Generates a number from ~Normal(0,1)
template<class T> LIB_UTILITIES_EXPORT T ran2 (long* idum);
/// \brief Fills a vector with white noise.
template<class T> LIB_UTILITIES_EXPORT void FillWhiteNoise(
int n, const T eps, T *x, const int incx, int seed = 9999);
......@@ -136,37 +141,40 @@ namespace Vmath
T *y, const int incy);
/********** Triad routines ***********************/
/// \brief vvtvp (vector times vector plus vector): z = w*x + y
template<class T> LIB_UTILITIES_EXPORT void Vvtvp(int n,
const T *w, const int incw,
const T *x, const int incx,
const T *y, const int incy,
T *z, const int incz);
template<class T> LIB_UTILITIES_EXPORT void Vvtvp( int n,
const T *w, const int incw,
const T *x, const int incx,
const T *y, const int incy,
T *z, const int incz );
/// \brief vvtvm (vector times vector plus vector): z = w*x - y
template<class T> LIB_UTILITIES_EXPORT void Vvtvm(int n, const T *w, const int incw, const T *x,
const int incx, const T *y, const int incy,
T *z, const int incz);
/// \brief svtvp (scalar times vector plus vector): z = alpha*x + y
/// \brief Svtvp (scalar times vector plus vector): z = alpha*x + y
template<class T> LIB_UTILITIES_EXPORT void Svtvp(int n, const T alpha, const T *x,
const int incx, const T *y, const int incy,
T *z, const int incz);
/// \brief svtvp (scalar times vector plus vector): z = alpha*x - y
template<class T> LIB_UTILITIES_EXPORT void Svtvm(int n, const T alpha, const T *x,
const int incx, const T *y, const int incy,
T *z, const int incz);
/// \brief Svtvm (scalar times vector minus vector): z = alpha*x - y
template<class T> LIB_UTILITIES_EXPORT void Svtvm ( int n, const T alpha, const T *x,
const int incx, const T *y, const int incy,
T *z, const int incz );
/// \brief vvtvvtp (vector times vector plus vector times vector):
// z = v*w + x*y
template<class T> LIB_UTILITIES_EXPORT void Vvtvvtp (int n,
const T* v, int incv,
const T* w, int incw,
const T* x, int incx,
const T* y, int incy,
T* z, int incz);
//
// @param n Number of items in each vector.
template<class T> LIB_UTILITIES_EXPORT void Vvtvvtp ( int n,
const T* v, int incv,
const T* w, int incw,
const T* x, int incx,
const T* y, int incy,
T* z, int incz );
/// \brief vvtvvtm (vector times vector minus vector times vector):
// z = v*w - x*y
template<class T> LIB_UTILITIES_EXPORT void Vvtvvtm (int n,
......
......@@ -258,15 +258,30 @@ SET(PolylibSources
)
SET(TimeIntegrationHeaders
./TimeIntegration/AdamsBashforthTimeIntegrationSchemes.h
./TimeIntegration/AdamsMoultonTimeIntegrationSchemes.h
./TimeIntegration/BDFImplicitTimeIntegrationSchemes.h
./TimeIntegration/EulerTimeIntegrationSchemes.h
./TimeIntegration/CNABTimeIntegrationScheme.h
./TimeIntegration/DIRKTimeIntegrationSchemes.h
./TimeIntegration/IMEXGearTimeIntegrationScheme.h
./TimeIntegration/IMEXTimeIntegrationSchemes.h
./TimeIntegration/IMEXdirkTimeIntegrationSchemes.h
./TimeIntegration/MCNABTimeIntegrationScheme.h
./TimeIntegration/RungeKuttaTimeIntegrationSchemes.h
./TimeIntegration/TimeIntegrationScheme.h
./TimeIntegration/TimeIntegrationWrapper.h
./TimeIntegration/TimeIntegrationSchemeData.h
./TimeIntegration/TimeIntegrationSolution.h
)
SET(TimeIntegrationSources
./TimeIntegration/SchemeInitializer.cpp
./TimeIntegration/TimeIntegrationScheme.cpp
./TimeIntegration/TimeIntegrationWrapper.cpp
./TimeIntegration/TimeIntegrationSchemeData.cpp
./TimeIntegration/TimeIntegrationSolution.cpp
)
SET(BaseHeaders
LibUtilitiesDeclspec.h
)
......
///////////////////////////////////////////////////////////////////////////////
//
// File: AdamsMoultonTimeIntegrationSchemes.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2018 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: Combined header file for all Adams Moulton based time
// integration schemes.
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#define LUE LIB_UTILITIES_EXPORT
#include <LibUtilities/TimeIntegration/EulerTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
namespace Nektar
{
namespace LibUtilities
{
///////////////////////////////////////////////////////////////////////////////
// Adams Bashforth Order 2
class AdamsMoultonOrder1TimeIntegrationScheme : public TimeIntegrationScheme
{
public:
AdamsMoultonOrder1TimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(1);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
AdamsMoultonOrder1TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
}
virtual ~AdamsMoultonOrder1TimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p = MemoryManager<
AdamsMoultonOrder1TimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eAdamsMoultonOrder1;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
BackwardEulerTimeIntegrationScheme::SetupSchemeData(phase);
}
}; // end class AdamsMoultonOrder1TimeIntegrationScheme
///////////////////////////////////////////////////////////////////////////////
// Adams Bashforth Order 2
class AdamsMoultonOrder2TimeIntegrationScheme : public TimeIntegrationScheme
{
public:
AdamsMoultonOrder2TimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(2);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
m_integration_phases[1] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
ForwardEulerTimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
AdamsMoultonOrder2TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[1]);
}
virtual ~AdamsMoultonOrder2TimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p = MemoryManager<
AdamsMoultonOrder2TimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eAdamsMoultonOrder2;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_schemeType = eDiagonallyImplicit;
phase->m_method = TimeIntegrationMethod::eAdamsMoultonOrder2;
phase->m_numsteps = 2;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_A[0] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.5);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
phase->m_B[0][0][0] = 0.5;
phase->m_B[0][1][0] = 1.0;
phase->m_U[0][0] = 1.0;
phase->m_U[0][1] = 0.5;
phase->m_V[0][0] = 1.0;
phase->m_V[0][1] = 0.5;
phase->m_numMultiStepValues = 1;
phase->m_numMultiStepDerivs = 1;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_timeLevelOffset[1] = 0;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration scheme coefficients do not match its type");
}
}; // end class AdamsMoultonOrder2TimeIntegrationScheme
} // end namespace LibUtilities
} // end namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File: BDFImplicitTimeIntegrationSchemes.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2018 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: Combined header file for all BDF Implicit based time integration
// schemes.
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#define LUE LIB_UTILITIES_EXPORT
#include <LibUtilities/TimeIntegration/EulerTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
namespace Nektar
{
namespace LibUtilities
{
///////////////////////////////////////////////////////////////////////////////
// BDF Implicit Order 1
class BDFImplicitOrder1TimeIntegrationScheme : public TimeIntegrationScheme
{
public:
BDFImplicitOrder1TimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(1);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
BDFImplicitOrder1TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
}
virtual ~BDFImplicitOrder1TimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p = MemoryManager<
BDFImplicitOrder1TimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eBDFImplicitOrder1;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
BackwardEulerTimeIntegrationScheme::SetupSchemeData(phase);
}
}; // end class BDFImplicitOrder1TimeIntegrationScheme
///////////////////////////////////////////////////////////////////////////////
// BDF Implicit Order 2
class BDFImplicitOrder2TimeIntegrationScheme : public TimeIntegrationScheme
{
public:
BDFImplicitOrder2TimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(2);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
m_integration_phases[1] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
BackwardEulerTimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
BDFImplicitOrder2TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[1]);
}
virtual ~BDFImplicitOrder2TimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p = MemoryManager<
BDFImplicitOrder2TimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eBDFImplicitOrder2;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eBDFImplicitOrder2;
phase->m_schemeType = eDiagonallyImplicit;
phase->m_numsteps = 2;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
NekDouble third = 1.0 / 3.0;
phase->m_A[0] = Array<TwoD, NekDouble>(phase->m_numstages,
phase->m_numstages, 2 * third);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
phase->m_B[0][0][0] = 2 * third;
phase->m_B[0][1][0] = 0.0;
phase->m_U[0][0] = 4 * third;
phase->m_U[0][1] = -third;
phase->m_V[0][0] = 4 * third;
phase->m_V[0][1] = -third;
phase->m_V[1][0] = 1.0;
phase->m_numMultiStepValues = 2;
phase->m_numMultiStepDerivs = 0;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_timeLevelOffset[1] = 1;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration scheme coefficients do not match its type");
}
}; // end class BDFImplicitOrder2TimeIntegrator
} // end namespace LibUtilities
} // end namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File: CNABTimeIntegrationScheme.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2018 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 time integration scheme wrappers
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
#include <LibUtilities/TimeIntegration/IMEXdirkTimeIntegrationSchemes.h>
#define LUE LIB_UTILITIES_EXPORT
namespace Nektar
{
namespace LibUtilities
{
class CNABTimeIntegrationScheme : public TimeIntegrationScheme
{
public:
CNABTimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(3);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
m_integration_phases[1] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
m_integration_phases[2] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
IMEXdirk_3_4_3TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]); // dirk 3 4 3
IMEXdirk_3_4_3TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[1]); // dirk 3 4 3
CNABTimeIntegrationScheme::SetupSchemeData(
m_integration_phases[2]); // CNAB
}
virtual ~CNABTimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p =
MemoryManager<CNABTimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eCNAB;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eCNAB;
phase->m_schemeType = eIMEX;
phase->m_numsteps = 4;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(2);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(2);
NekDouble secondth = 1.0 / 2.0;
phase->m_A[0] = Array<TwoD, NekDouble>(phase->m_numstages,
phase->m_numstages, secondth);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_A[1] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
phase->m_B[1] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_U = Array<TwoD, NekDouble>(phase->m_numstages,
phase->m_numsteps, secondth);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
phase->m_B[0][0][0] = secondth;
phase->m_B[0][1][0] = 1.0;
phase->m_B[1][2][0] = 1.0;
phase->m_U[0][0] = 2 * secondth;
phase->m_U[0][2] = 3 * secondth;
phase->m_U[0][3] = -1 * secondth;
phase->m_V[0][0] = 2 * secondth;
phase->m_V[0][1] = secondth;
phase->m_V[0][2] = 3 * secondth;
phase->m_V[0][3] = -1 * secondth;
phase->m_V[3][2] = 1.0;
phase->m_numMultiStepValues = 1;
phase->m_numMultiStepDerivs = 3;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_timeLevelOffset[1] = 0;
phase->m_timeLevelOffset[2] = 0;
phase->m_timeLevelOffset[3] = 1;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration scheme coefficients do not match its type");
}
}; // end class CNABTimeIntegrationScheme
} // end namespace LibUtilities
} // end namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File: DIRKTimeIntegrationSchemes.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2018 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: Combined header file for all basic DIRK based time integration
// schemes.
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
#define LUE LIB_UTILITIES_EXPORT
namespace Nektar
{
namespace LibUtilities
{
///////////////////////////////////////////////////////////////////////////////
// DIRK Order 2
class DIRKOrder2TimeIntegrationScheme : public TimeIntegrationScheme
{
public:
DIRKOrder2TimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(1);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
DIRKOrder2TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
}
virtual ~DIRKOrder2TimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p =
MemoryManager<DIRKOrder2TimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eIMEXdirk_3_4_3;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eIMEXdirk_3_4_3;
phase->m_schemeType = eDiagonallyImplicit;
phase->m_numsteps = 1;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_A[0] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
NekDouble lambda = (2.0 - sqrt(2.0)) / 2.0;
phase->m_A[0][0][0] = lambda;
phase->m_A[0][1][0] = 1.0 - lambda;
phase->m_A[0][1][1] = lambda;
phase->m_B[0][0][0] = 1.0 - lambda;
phase->m_B[0][0][1] = lambda;
phase->m_numMultiStepValues = 1;
phase->m_numMultiStepDerivs = 0;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration scheme coefficients do not match its type");
}
}; // end class DIRKOrder2TimeIntegrator
///////////////////////////////////////////////////////////////////////////////
// DIRK Order 3
class DIRKOrder3TimeIntegrationScheme : public TimeIntegrationScheme
{
public:
DIRKOrder3TimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(1);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
DIRKOrder3TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
}
virtual ~DIRKOrder3TimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p =
MemoryManager<DIRKOrder3TimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eDIRKOrder3;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eDIRKOrder3;
phase->m_schemeType = eDiagonallyImplicit;
phase->m_numsteps = 1;
phase->m_numstages = 3;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_A[0] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
NekDouble lambda = 0.4358665215;
phase->m_A[0][0][0] = lambda;
phase->m_A[0][1][0] = 0.5 * (1.0 - lambda);
phase->m_A[0][2][0] =
0.25 * (-6.0 * lambda * lambda + 16.0 * lambda - 1.0);
phase->m_A[0][1][1] = lambda;
phase->m_A[0][2][1] =
0.25 * (6.0 * lambda * lambda - 20.0 * lambda + 5.0);
phase->m_A[0][2][2] = lambda;
phase->m_B[0][0][0] =
0.25 * (-6.0 * lambda * lambda + 16.0 * lambda - 1.0);
phase->m_B[0][0][1] =
0.25 * (6.0 * lambda * lambda - 20.0 * lambda + 5.0);
phase->m_B[0][0][2] = lambda;
phase->m_numMultiStepValues = 1;
phase->m_numMultiStepDerivs = 0;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration scheme coefficients do not match its type");
}
}; // end class DIRKOrder3TimeIntegrationScheme
} // end namespace LibUtilities
} // end namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File: EulerTimeIntegrationSchemes.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2018 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: Combined header file for all basic Euler based time integration
// schemes.
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#define LUE LIB_UTILITIES_EXPORT
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
#include <LibUtilities/TimeIntegration/TimeIntegrationSchemeData.h>
namespace Nektar
{
namespace LibUtilities
{
///////////////////////////////////////////////////////////////////////////////
// Backward Euler
class BackwardEulerTimeIntegrationScheme : public TimeIntegrationScheme
{
public:
BackwardEulerTimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(1);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
BackwardEulerTimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
}
virtual ~BackwardEulerTimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p = MemoryManager<
BackwardEulerTimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eBackwardEuler;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eBackwardEuler;
phase->m_schemeType = eDiagonallyImplicit;
phase->m_numsteps = 1;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_A[0] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 1.0);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 1.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
phase->m_numMultiStepValues = 1;
phase->m_numMultiStepDerivs = 0;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration scheme coefficients do not match its type");
}
}; // end class BackwardEulerTimeIntegrator
///////////////////////////////////////////////////////////////////////////////
// Forward Euler
class ForwardEulerTimeIntegrationScheme : public TimeIntegrationScheme
{
public:
ForwardEulerTimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(1);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
ForwardEulerTimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
}
virtual ~ForwardEulerTimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p = MemoryManager<
ForwardEulerTimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eForwardEuler;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eForwardEuler;
phase->m_schemeType = eExplicit;
phase->m_numsteps = 1;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(1);
phase->m_A[0] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 1.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 1.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 1.0);
phase->m_numMultiStepValues = 1;
phase->m_numMultiStepDerivs = 0;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration phase coefficients do not match its type");
}
}; // end class ForwardEulerTimeIntegrator
} // end namespace LibUtilities
} // end namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File: IMEXGearTimeIntegrationScheme.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2018 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 time integration scheme wrappers
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
#include <LibUtilities/TimeIntegration/IMEXdirkTimeIntegrationSchemes.h>
#define LUE LIB_UTILITIES_EXPORT
namespace Nektar
{
namespace LibUtilities
{
class IMEXGearTimeIntegrationScheme : public TimeIntegrationScheme
{
public:
IMEXGearTimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(2);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
m_integration_phases[1] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
IMEXdirk_2_2_2TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
IMEXGearTimeIntegrationScheme::SetupSchemeData(m_integration_phases[1]);
}
virtual ~IMEXGearTimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p =
MemoryManager<IMEXGearTimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eIMEXGear;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eIMEXGear;
phase->m_schemeType = eIMEX;
phase->m_numsteps = 3;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(2);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(2);
NekDouble twothirds = 2.0 / 3.0;
phase->m_A[0] = Array<TwoD, NekDouble>(phase->m_numstages,
phase->m_numstages, twothirds);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_A[1] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
phase->m_B[1] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
phase->m_B[0][0][0] = twothirds;
phase->m_B[1][2][0] = 1.0;
phase->m_U[0][0] = 2.0 * twothirds;
phase->m_U[0][1] = -0.5 * twothirds;
phase->m_U[0][2] = twothirds;
phase->m_V[0][0] = 2.0 * twothirds;
phase->m_V[0][1] = -0.5 * twothirds;
phase->m_V[0][2] = twothirds;
phase->m_V[1][0] = 1.0;
phase->m_numMultiStepValues = 2;
phase->m_numMultiStepDerivs = 1;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_timeLevelOffset[1] = 1;
phase->m_timeLevelOffset[2] = 0;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration phase coefficients do not match its type");
}
}; // end class IMEXGearTimeIntegrationScheme
} // end namespace LibUtilities
} // end namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File: MCNABTimeIntegrationScheme.h
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2018 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 time integration scheme wrappers
//
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
#define LUE LIB_UTILITIES_EXPORT
namespace Nektar
{
namespace LibUtilities
{
class MCNABTimeIntegrationScheme : public TimeIntegrationScheme
{
public:
MCNABTimeIntegrationScheme() : TimeIntegrationScheme()
{
m_integration_phases = TimeIntegrationSchemeDataVector(3);
m_integration_phases[0] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
m_integration_phases[1] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
m_integration_phases[2] = TimeIntegrationSchemeDataSharedPtr(
new TimeIntegrationSchemeData(this));
IMEXdirk_3_4_3TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[0]);
IMEXdirk_3_4_3TimeIntegrationScheme::SetupSchemeData(
m_integration_phases[1]);
MCNABTimeIntegrationScheme::SetupSchemeData(m_integration_phases[2]);
}
virtual ~MCNABTimeIntegrationScheme()
{
}
static TimeIntegrationSchemeSharedPtr create()
{
TimeIntegrationSchemeSharedPtr p =
MemoryManager<MCNABTimeIntegrationScheme>::AllocateSharedPtr();
return p;
}
static std::string className;
LUE virtual TimeIntegrationMethod GetIntegrationMethod() const
{
return TimeIntegrationMethod::eMCNAB;
}
LUE static void SetupSchemeData(TimeIntegrationSchemeDataSharedPtr &phase)
{
phase->m_method = TimeIntegrationMethod::eMCNAB;
phase->m_schemeType = eIMEX;
phase->m_numsteps = 5;
phase->m_numstages = 1;
phase->m_A = Array<OneD, Array<TwoD, NekDouble>>(2);
phase->m_B = Array<OneD, Array<TwoD, NekDouble>>(2);
NekDouble sixthx = 9.0 / 16.0;
phase->m_A[0] = Array<TwoD, NekDouble>(phase->m_numstages,
phase->m_numstages, sixthx);
phase->m_B[0] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_A[1] =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numstages, 0.0);
phase->m_B[1] =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numstages, 0.0);
phase->m_U =
Array<TwoD, NekDouble>(phase->m_numstages, phase->m_numsteps, 0.0);
phase->m_V =
Array<TwoD, NekDouble>(phase->m_numsteps, phase->m_numsteps, 0.0);
phase->m_B[0][0][0] = sixthx;
phase->m_B[0][1][0] = 1.0;
phase->m_B[1][3][0] = 1.0;
phase->m_U[0][0] = 1.0;
phase->m_U[0][1] = 6.0 / 16.0;
phase->m_U[0][2] = 1.0 / 16.0;
phase->m_U[0][3] = 1.5;
phase->m_U[0][4] = -0.5;
phase->m_V[0][0] = 1.0;
phase->m_V[0][1] = 6.0 / 16.0;
phase->m_V[0][2] = 1.0 / 16.0;
phase->m_V[0][3] = 1.5;
phase->m_V[0][4] = -0.5;
phase->m_V[2][1] = 1.0;
phase->m_V[4][3] = 1.0;
phase->m_numMultiStepValues = 1;
phase->m_numMultiStepDerivs = 4;
phase->m_timeLevelOffset = Array<OneD, unsigned int>(phase->m_numsteps);
phase->m_timeLevelOffset[0] = 0;
phase->m_timeLevelOffset[1] = 0;
phase->m_timeLevelOffset[2] = 1;
phase->m_timeLevelOffset[3] = 0;
phase->m_timeLevelOffset[4] = 1;
phase->m_firstStageEqualsOldSolution =
phase->CheckIfFirstStageEqualsOldSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
phase->m_lastStageEqualsNewSolution =
phase->CheckIfLastStageEqualsNewSolution(phase->m_A, phase->m_B,
phase->m_U, phase->m_V);
ASSERTL1(phase->VerifyIntegrationSchemeType(phase->m_schemeType,
phase->m_A, phase->m_B,
phase->m_U, phase->m_V),
"Time integration scheme coefficients do not match its type");
}
}; // end class MCNABTimeIntegrationScheme
} // end namespace LibUtilities
} // end namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File SchemeInitializor.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: This file isused to add each of the Time Integration Schemes
// to the NekFactory.
//
///////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/TimeIntegration/AdamsBashforthTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/AdamsMoultonTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/BDFImplicitTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/EulerTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/CNABTimeIntegrationScheme.h>
#include <LibUtilities/TimeIntegration/DIRKTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/IMEXGearTimeIntegrationScheme.h>
#include <LibUtilities/TimeIntegration/IMEXTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/IMEXdirkTimeIntegrationSchemes.h>
#include <LibUtilities/TimeIntegration/MCNABTimeIntegrationScheme.h>
#include <LibUtilities/TimeIntegration/RungeKuttaTimeIntegrationSchemes.h>