Nektar++
TimeIntegrationSchemeGLM.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File TimeIntegrationSchemeGLM.cpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: implementation of time integration scheme GLM class
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <iostream>
36 
39 
40 namespace Nektar
41 {
42 namespace LibUtilities
43 {
44 
45 // Access Methods
47 {
48  ASSERTL0(!m_integration_phases.empty(), "No scheme")
49 
50  return m_integration_phases[m_integration_phases.size() - 1]->m_variant;
51 }
52 
54 {
55  ASSERTL0(!m_integration_phases.empty(), "No scheme")
56 
57  return m_integration_phases[m_integration_phases.size() - 1]->m_order;
58 }
59 
60 std::vector< NekDouble > TimeIntegrationSchemeGLM::GetFreeParams() const
61 {
62  ASSERTL0(!m_integration_phases.empty(), "No scheme")
63 
64  return m_integration_phases[m_integration_phases.size() - 1]->m_freeParams;
65 }
66 
68  const
69 {
70  ASSERTL0(!m_integration_phases.empty(), "No scheme")
71 
72  return m_integration_phases[m_integration_phases.size() - 1]->m_schemeType;
73 }
74 
76 {
77  return m_integration_phases.size();
78 }
79 
80 /**
81  * @brief Worker method to initialize the integration scheme.
82  */
84  InitializeScheme(const NekDouble deltaT,
85  ConstDoubleArray &y_0,
86  const NekDouble time,
88 {
89  m_solVector =
90  m_integration_phases.back()->InitializeData(deltaT, y_0, time, op);
91 }
92 
93 /**
94  * @brief Worker method that actually does the time integration.
95  */
97  const int timestep,
98  const NekDouble delta_t,
100 {
101  int nPhases = m_integration_phases.size();
102 
104  m_integration_phases[std::min(timestep, nPhases - 1)];
105 
106  return algorithm->TimeIntegrate(delta_t, m_solVector, op);
107 }
108 
111  NekDouble deltaT) const
112 {
113  boost::ignore_unused(phase, deltaT);
114 
115  ASSERTL0(false, "No InitializeSecondaryData method for scheme " +
116  GetFullName());
117 }
118 
119 /**
120  * @brief Worker method to print details on the integration scheme
121  */
122 void TimeIntegrationSchemeGLM::print(std::ostream &os) const
123 {
124  os << "Time Integration Scheme: " << GetFullName() << std::endl
125  << " Has " << m_integration_phases.size() << " phase(s)"
126  << std::endl;
127 
128  for (int i = 0; i < m_integration_phases.size(); i++)
129  {
130  os << " - "
131  << m_integration_phases[i]->m_name << std::endl;
132  }
133 }
134 
135 void TimeIntegrationSchemeGLM::printFull(std::ostream &os) const
136 {
137  os << "Time Integration Scheme: " << GetFullName() << std::endl
138  << " Has " << m_integration_phases.size() << " phase(s)"
139  << std::endl;
140 
141  for (int i = 0; i < m_integration_phases.size(); i++)
142  {
143  os << " - "
144  << m_integration_phases[i]->m_name << std::endl;
145 
146  os << " - "
147  << m_integration_phases[i] << std::endl;
148  }
149 }
150 
151 // Friend Operators
152 std::ostream &operator<<(std::ostream &os, const TimeIntegrationSchemeGLM &rhs)
153 {
154  rhs.print( os );
155 
156  return os;
157 }
158 
159 std::ostream &operator<<(std::ostream &os,
161 {
162  os << *rhs.get();
163 
164  return os;
165 }
166 
167 } // end namespace LibUtilities
168 } // end namespace NekTar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
Base class for GLM time integration schemes.
TimeIntegrationAlgorithmGLMVector m_integration_phases
virtual LUE void InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op)
Worker method to initialize the integration scheme.
virtual LUE void print(std::ostream &os) const
Worker method to print details on the integration scheme.
virtual LUE ConstDoubleArray & TimeIntegrate(const int timestep, const NekDouble delta_t, const TimeIntegrationSchemeOperators &op)
Worker method that actually does the time integration.
virtual LUE void InitializeSecondaryData(TimeIntegrationAlgorithmGLM *phase, NekDouble deltaT) const
virtual LUE std::vector< NekDouble > GetFreeParams() const
virtual LUE void printFull(std::ostream &os) const
virtual LUE TimeIntegrationSchemeType GetIntegrationSchemeType() const
Binds a set of functions for use by time integration schemes.
std::shared_ptr< TimeIntegrationAlgorithmGLM > TimeIntegrationAlgorithmGLMSharedPtr
std::shared_ptr< TimeIntegrationSchemeGLM > TimeIntegrationSchemeGLMSharedPtr
std::ostream & operator<<(std::ostream &os, const BasisKey &rhs)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble