Nektar++
TimeIntegrationSolutionGLM.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TimeIntegrationSolutionGLM.h
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// License for the specific language governing rights and limitations under
14// Permission is hereby granted, free of charge, to any person obtaining a
15// copy of this software and associated documentation files (the "Software"),
16// to deal in the Software without restriction, including without limitation
17// the rights to use, copy, modify, merge, publish, distribute, sublicense,
18// and/or sell copies of the Software, and to permit persons to whom the
19// Software is furnished to do so, subject to the following conditions:
20//
21// The above copyright notice and this permission notice shall be included
22// in all copies or substantial portions of the Software.
23//
24// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30// DEALINGS IN THE SOFTWARE.
31//
32// Description: Header file of time integration solution class
33//
34///////////////////////////////////////////////////////////////////////////////
35
36#ifndef NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SOLUTION_GLM
37#define NEKTAR_LIB_UTILITIES_TIME_INTEGRATION_TIME_INTEGRATION_SOLUTION_GLM
38
39#define LUE LIB_UTILITIES_EXPORT
40
42
44{
45
47{
48public:
50 const TimeIntegrationAlgorithmGLM *schemeAlgorithm,
51 const DoubleArray &y, const NekDouble time, const NekDouble timestep);
52
54 const TimeIntegrationAlgorithmGLM *schemeAlgorithm, const size_t nvar,
55 const size_t npoints);
56
58 const TimeIntegrationAlgorithmGLM *schemeAlgorithm);
59
61 {
62 return m_schemeAlgorithm;
63 }
64
65 inline const TripleArray &GetSolutionVector() const
66 {
67 return m_solVector;
68 }
69
71 {
72 return m_solVector;
73 }
74
75 inline const DoubleArray &GetSolution() const
76 {
77 return m_solVector[0];
78 }
79
81 {
82 return m_solVector[0];
83 }
84
85 inline void SetSolutionVector(const size_t Offset, const DoubleArray &y)
86 {
87 m_solVector[Offset] = y;
88 }
89
91 {
92 return m_t;
93 }
94
96 {
97 return m_t;
98 }
99
100 inline NekDouble GetTime() const
101 {
102 return m_t[0];
103 }
104
105 size_t GetNsteps()
106 {
108 }
109
110 inline size_t GetFirstDim() const
111 {
112 return m_solVector[0].size();
113 }
114
115 inline size_t GetSecondDim() const
116 {
117 return m_solVector[0][0].size();
118 }
119
120 // Return the number of entries in the solution vector that correspond to
121 // (multi-step) values.
122 inline size_t GetNvalues() const
123 {
125 }
126
127 // Return the number of entries in the solution vector that correspond to
128 // implicit (multi-step) derivatives.
129 inline size_t GetNimplicitderivs() const
130 {
132 }
133
134 // Return the number of entries in the solution vector that correspond to
135 // explicit (multi-step) derivatives.
136 inline size_t GetNexplicitderivs() const
137 {
139 }
140
141 // Returns an array which indicates to which time-level the entries in the
142 // solution vector correspond.
144 {
146 }
147
148 // Returns the entry in the solution vector which corresponds to the
149 // (multi-step) value at the time-level with specified offset
150 inline DoubleArray &GetValue(const size_t timeLevelOffset)
151 {
152 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
153 const Array<OneD, const size_t> &offsetvec =
155
156 for (size_t i = 0; i < nMultiStepVals; i++)
157 {
158 if (timeLevelOffset == offsetvec[i])
159 {
161 "Solution vector is not set at this time level");
162 return m_solVector[i];
163 }
164 }
165 ASSERTL1(false, "The solution vector of this scheme does not contain a "
166 "value at the requested time-level");
167 return m_solVector[0];
168 }
169
170 // returns the entry in the solution vector which corresponds to the
171 // implicit (multi-step) derivative at the time-level with specified offset
172 inline DoubleArray &GetImplicitDerivative(const size_t timeLevelOffset)
173 {
174 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
175 size_t nMultiStepImplicitDerivs =
177 const Array<OneD, const size_t> &offsetvec =
179
180 for (size_t i = nMultiStepVals;
181 i < nMultiStepVals + nMultiStepImplicitDerivs; i++)
182 {
183 if (timeLevelOffset == offsetvec[i])
184 {
186 "Implicit derivative solution vector is not set at "
187 "this time level");
188 return m_solVector[i];
189 }
190 }
191 ASSERTL1(false, "The solution vector of this scheme does not contain a "
192 "derivative at the requested time-level");
193 return m_solVector[0];
194 }
195
196 // returns the entry in the solution vector which corresponds to the
197 // explicit (multi-step) derivative at the time-level with specified offset
198 inline DoubleArray &GetExplicitDerivative(const size_t timeLevelOffset)
199 {
200 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
201 size_t nMultiStepImplicitDerivs =
203 size_t size = m_schemeAlgorithm->m_numsteps;
204 const Array<OneD, const size_t> &offsetvec =
206
207 for (size_t i = nMultiStepVals + nMultiStepImplicitDerivs; i < size;
208 i++)
209 {
210 if (timeLevelOffset == offsetvec[i])
211 {
213 "Explicit derivative solution vector is not set at "
214 "this time level");
215 return m_solVector[i];
216 }
217 }
218 ASSERTL1(false, "The solution vector of this scheme does not contain a "
219 "derivative at the requested time-level");
220 return m_solVector[0];
221 }
222
223 // returns the time associated with the (multi-step) value at the time-level
224 // with the given offset
225 inline NekDouble GetValueTime(const size_t timeLevelOffset)
226 {
227 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
228 const Array<OneD, const size_t> &offsetvec =
230
231 for (size_t i = 0; i < nMultiStepVals; i++)
232 {
233 if (timeLevelOffset == offsetvec[i])
234 {
235 return m_t[i];
236 }
237 }
238 ASSERTL1(false, "The solution vector of this scheme does not contain a "
239 "value at the requested time-level");
240 return m_t[0];
241 }
242
243 // sets the (multi-step) value and time in the solution vector which
244 // corresponds to the value at the time-level with specified offset
245 inline void SetValue(const size_t timeLevelOffset, const DoubleArray &y,
246 const NekDouble t)
247 {
248 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
249 const Array<OneD, const size_t> &offsetvec =
251
252 for (size_t i = 0; i < nMultiStepVals; i++)
253 {
254 if (timeLevelOffset == offsetvec[i])
255 {
256 m_solVector[i] = y;
257 m_t[i] = t;
258 m_setflag[i] = true;
259 return;
260 }
261 }
262 }
263
264 // sets the (multi-step) derivative and time in the solution vector which
265 // corresponds to the implicit derivative at the time-level with specified
266 // offset
267 inline void SetImplicitDerivative(const size_t timeLevelOffset,
268 const DoubleArray &y,
269 const NekDouble timestep)
270 {
271 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
272 size_t nMultiStepImplicitDerivs =
274 const Array<OneD, const size_t> &offsetvec =
276
277 for (size_t i = nMultiStepVals;
278 i < nMultiStepVals + nMultiStepImplicitDerivs; i++)
279 {
280 if (timeLevelOffset == offsetvec[i])
281 {
282 m_solVector[i] = y;
283 m_t[i] = timestep;
284 m_setflag[i] = true;
285 return;
286 }
287 }
288 }
289
290 // sets the (multi-step) derivative and time in the solution vector which
291 // corresponds to the explicit derivative at the time-level with specified
292 // offset
293 inline void SetExplicitDerivative(const size_t timeLevelOffset,
294 const DoubleArray &y,
295 const NekDouble timestep)
296 {
297 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
298 size_t nMultiStepImplicitDerivs =
300 size_t size = m_schemeAlgorithm->m_numsteps;
301 const Array<OneD, const size_t> &offsetvec =
303
304 for (size_t i = nMultiStepVals + nMultiStepImplicitDerivs; i < size;
305 i++)
306 {
307 if (timeLevelOffset == offsetvec[i])
308 {
309 m_solVector[i] = y;
310 m_t[i] = timestep;
311 m_setflag[i] = true;
312 return;
313 }
314 }
315 }
316
317 // Rotate the solution vector
318 // (i.e. updating without calculating/inserting new values)
320 {
321 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
322 size_t nMultiStepImpDerivs =
324 size_t size = m_schemeAlgorithm->m_numsteps;
325 for (size_t i = (nMultiStepVals - 1); i > 0; i--)
326 {
327 m_solVector[i] = m_solVector[i - 1];
328 m_setflag[i] = m_setflag[i - 1];
329 }
330
331 for (size_t i = (nMultiStepVals + nMultiStepImpDerivs - 1);
332 i > nMultiStepVals; i--)
333 {
334 m_solVector[i] = m_solVector[i - 1];
335 m_setflag[i] = m_setflag[i - 1];
336 }
337
338 for (size_t i = (size - 1); i > nMultiStepVals + nMultiStepImpDerivs;
339 i--)
340 {
341 m_solVector[i] = m_solVector[i - 1];
342 m_setflag[i] = m_setflag[i - 1];
343 }
344 }
345
346private:
348
352
353}; // end class TimeIntegrationSolutionGLM
354
355} // namespace Nektar::LibUtilities
356
357#endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
#define LUE
const Array< OneD, const size_t > & GetTimeLevelOffset() const
const Array< OneD, const NekDouble > & GetTimeVector() const
const TimeIntegrationAlgorithmGLM * GetIntegrationSchemeData() const
void SetExplicitDerivative(const size_t timeLevelOffset, const DoubleArray &y, const NekDouble timestep)
LUE TimeIntegrationSolutionGLM(const TimeIntegrationAlgorithmGLM *schemeAlgorithm, const DoubleArray &y, const NekDouble time, const NekDouble timestep)
void SetSolutionVector(const size_t Offset, const DoubleArray &y)
void SetImplicitDerivative(const size_t timeLevelOffset, const DoubleArray &y, const NekDouble timestep)
const Array< OneD, const size_t > & GetTimeLevelOffset()
void SetValue(const size_t timeLevelOffset, const DoubleArray &y, const NekDouble t)
NekDouble GetValueTime(const size_t timeLevelOffset)
DoubleArray & GetExplicitDerivative(const size_t timeLevelOffset)
DoubleArray & GetValue(const size_t timeLevelOffset)
DoubleArray & GetImplicitDerivative(const size_t timeLevelOffset)
double NekDouble