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
40{
41
42// Access Methods
44{
45 ASSERTL0(!m_integration_phases.empty(), "No scheme")
46
47 return m_integration_phases.back()->m_variant;
48}
49
51{
52 ASSERTL0(!m_integration_phases.empty(), "No scheme")
53
54 return m_integration_phases.back()->m_order;
55}
56
57std::vector<NekDouble> TimeIntegrationSchemeGLM::v_GetFreeParams() const
58{
59 ASSERTL0(!m_integration_phases.empty(), "No scheme")
60
61 return m_integration_phases.back()->m_freeParams;
62}
63
65 const
66{
67 ASSERTL0(!m_integration_phases.empty(), "No scheme")
68
69 return m_integration_phases.back()->m_schemeType;
70}
71
73{
74 return m_integration_phases.size();
75}
76
77/**
78 * @brief Worker method to initialize the integration scheme.
79 */
81 const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time,
83{
84 for (int i = 0; i < m_integration_phases.size(); i++)
85 {
86 m_integration_phases[i]->InitializeScheme(op);
87 }
88
90 m_integration_phases.back()->InitializeData(deltaT, y_0, time);
91}
92
93/**
94 * @brief Worker method that actually does the time integration.
95 */
97 const size_t timestep, const NekDouble delta_t)
98{
99 size_t nPhases = m_integration_phases.size();
100
102 m_integration_phases[std::min(timestep, nPhases - 1)];
103
104 return algorithm->TimeIntegrate(delta_t, m_solVector);
105}
106
108 [[maybe_unused]] TimeIntegrationAlgorithmGLM *phase,
109 [[maybe_unused]] NekDouble deltaT) const
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 */
118void 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 (size_t i = 0; i < m_integration_phases.size(); i++)
125 {
126 os << " - " << m_integration_phases[i]->m_name << std::endl;
127 }
128}
129
130void 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 (size_t 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
145std::ostream &operator<<(std::ostream &os, const TimeIntegrationSchemeGLM &rhs)
146{
147 rhs.print(os);
148
149 return os;
150}
151
152std::ostream &operator<<(std::ostream &os,
154{
155 os << *rhs.get();
156
157 return os;
158}
159
160} // namespace Nektar::LibUtilities
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
Base class for GLM time integration schemes.
TimeIntegrationAlgorithmGLMVector m_integration_phases
virtual LUE void v_InitializeSecondaryData(TimeIntegrationAlgorithmGLM *phase, NekDouble deltaT) const
LUE void v_InitializeScheme(const NekDouble deltaT, ConstDoubleArray &y_0, const NekDouble time, const TimeIntegrationSchemeOperators &op) override
Worker method to initialize the integration scheme.
LUE TimeIntegrationSchemeType v_GetIntegrationSchemeType() const override
LUE void v_printFull(std::ostream &os) const override
LUE void v_print(std::ostream &os) const override
Worker method to print details on the integration scheme.
LUE ConstDoubleArray & v_TimeIntegrate(const size_t timestep, const NekDouble delta_t) override
Worker method that actually does the time integration.
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)
double NekDouble