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::v_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  const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time,
86 {
87  m_solVector =
88  m_integration_phases.back()->InitializeData(deltaT, y_0, time, op);
89 }
90 
91 /**
92  * @brief Worker method that actually does the time integration.
93  */
95  const int timestep, const NekDouble delta_t,
97 {
98  int nPhases = m_integration_phases.size();
99 
101  m_integration_phases[std::min(timestep, nPhases - 1)];
102 
103  return algorithm->TimeIntegrate(delta_t, m_solVector, op);
104 }
105 
107  TimeIntegrationAlgorithmGLM *phase, NekDouble deltaT) const
108 {
109  boost::ignore_unused(phase, deltaT);
110 
111  ASSERTL0(false,
112  "No InitializeSecondaryData method for scheme " + GetFullName());
113 }
114 
115 /**
116  * @brief Worker method to print details on the integration scheme
117  */
118 void TimeIntegrationSchemeGLM::v_print(std::ostream &os) const
119 {
120  os << "Time Integration Scheme: " << GetFullName() << std::endl
121  << " Has " << m_integration_phases.size() << " phase(s)"
122  << std::endl;
123 
124  for (int i = 0; i < m_integration_phases.size(); i++)
125  {
126  os << " - " << m_integration_phases[i]->m_name << std::endl;
127  }
128 }
129 
130 void TimeIntegrationSchemeGLM::v_printFull(std::ostream &os) const
131 {
132  os << "Time Integration Scheme: " << GetFullName() << std::endl
133  << " Has " << m_integration_phases.size() << " phase(s)"
134  << std::endl;
135 
136  for (int i = 0; i < m_integration_phases.size(); i++)
137  {
138  os << " - " << m_integration_phases[i]->m_name << std::endl;
139 
140  os << " - " << m_integration_phases[i] << std::endl;
141  }
142 }
143 
144 // Friend Operators
145 std::ostream &operator<<(std::ostream &os, const TimeIntegrationSchemeGLM &rhs)
146 {
147  rhs.print(os);
148 
149  return os;
150 }
151 
152 std::ostream &operator<<(std::ostream &os,
154 {
155  os << *rhs.get();
156 
157  return os;
158 }
159 
160 } // end namespace LibUtilities
161 } // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
Base class for GLM time integration schemes.
TimeIntegrationAlgorithmGLMVector m_integration_phases
virtual LUE void v_InitializeSecondaryData(TimeIntegrationAlgorithmGLM *phase, NekDouble deltaT) const
virtual LUE void v_InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op) override
Worker method to initialize the integration scheme.
virtual LUE std::string v_GetVariant() const override
virtual LUE unsigned int v_GetOrder() const override
virtual LUE TimeIntegrationSchemeType v_GetIntegrationSchemeType() const override
virtual LUE void v_printFull(std::ostream &os) const override
virtual LUE void v_print(std::ostream &os) const override
Worker method to print details on the integration scheme.
virtual LUE ConstDoubleArray & v_TimeIntegrate(const int timestep, const NekDouble delta_t, const TimeIntegrationSchemeOperators &op) override
Worker method that actually does the time integration.
virtual LUE unsigned int v_GetNumIntegrationPhases() const override
virtual LUE std::vector< NekDouble > v_GetFreeParams() const override
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:2
double NekDouble