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
38
39namespace Nektar
40{
41namespace LibUtilities
42{
43
44// Access Methods
46{
47 ASSERTL0(!m_integration_phases.empty(), "No scheme")
48
49 return m_integration_phases.back()->m_variant;
50}
51
53{
54 ASSERTL0(!m_integration_phases.empty(), "No scheme")
55
56 return m_integration_phases.back()->m_order;
57}
58
59std::vector<NekDouble> TimeIntegrationSchemeGLM::v_GetFreeParams() const
60{
61 ASSERTL0(!m_integration_phases.empty(), "No scheme")
62
63 return m_integration_phases.back()->m_freeParams;
64}
65
67 const
68{
69 ASSERTL0(!m_integration_phases.empty(), "No scheme")
70
71 return m_integration_phases.back()->m_schemeType;
72}
73
75{
76 return m_integration_phases.size();
77}
78
79/**
80 * @brief Worker method to initialize the integration scheme.
81 */
83 const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time,
85{
86 for (int i = 0; i < m_integration_phases.size(); i++)
87 {
88 m_integration_phases[i]->InitializeScheme(op);
89 }
90
92 m_integration_phases.back()->InitializeData(deltaT, y_0, time);
93}
94
95/**
96 * @brief Worker method that actually does the time integration.
97 */
99 const size_t timestep, const NekDouble delta_t)
100{
101 size_t nPhases = m_integration_phases.size();
102
104 m_integration_phases[std::min(timestep, nPhases - 1)];
105
106 return algorithm->TimeIntegrate(delta_t, m_solVector);
107}
108
110 TimeIntegrationAlgorithmGLM *phase, NekDouble deltaT) const
111{
112 boost::ignore_unused(phase, deltaT);
113
114 ASSERTL0(false,
115 "No InitializeSecondaryData method for scheme " + GetFullName());
116}
117
118/**
119 * @brief Worker method to print details on the integration scheme
120 */
121void TimeIntegrationSchemeGLM::v_print(std::ostream &os) const
122{
123 os << "Time Integration Scheme: " << GetFullName() << std::endl
124 << " Has " << m_integration_phases.size() << " phase(s)"
125 << std::endl;
126
127 for (size_t i = 0; i < m_integration_phases.size(); i++)
128 {
129 os << " - " << m_integration_phases[i]->m_name << std::endl;
130 }
131}
132
133void TimeIntegrationSchemeGLM::v_printFull(std::ostream &os) const
134{
135 os << "Time Integration Scheme: " << GetFullName() << std::endl
136 << " Has " << m_integration_phases.size() << " phase(s)"
137 << std::endl;
138
139 for (size_t i = 0; i < m_integration_phases.size(); i++)
140 {
141 os << " - " << m_integration_phases[i]->m_name << std::endl;
142
143 os << " - " << m_integration_phases[i] << std::endl;
144 }
145}
146
147// Friend Operators
148std::ostream &operator<<(std::ostream &os, const TimeIntegrationSchemeGLM &rhs)
149{
150 rhs.print(os);
151
152 return os;
153}
154
155std::ostream &operator<<(std::ostream &os,
157{
158 os << *rhs.get();
159
160 return os;
161}
162
163} // end namespace LibUtilities
164} // 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 TimeIntegrationSchemeType v_GetIntegrationSchemeType() const override
virtual LUE size_t v_GetNumIntegrationPhases() 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 size_t timestep, const NekDouble delta_t) override
Worker method that actually does the time integration.
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