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
43namespace Nektar
44{
45namespace LibUtilities
46{
47
49{
50public:
52 const TimeIntegrationAlgorithmGLM *schemeAlgorithm,
53 const DoubleArray &y, const NekDouble time, const NekDouble timestep);
54
56 const TimeIntegrationAlgorithmGLM *schemeAlgorithm, const size_t nvar,
57 const size_t npoints);
58
60 const TimeIntegrationAlgorithmGLM *schemeAlgorithm);
61
63 {
64 return m_schemeAlgorithm;
65 }
66
67 inline const TripleArray &GetSolutionVector() const
68 {
69 return m_solVector;
70 }
71
73 {
74 return m_solVector;
75 }
76
77 inline const DoubleArray &GetSolution() const
78 {
79 return m_solVector[0];
80 }
81
83 {
84 return m_solVector[0];
85 }
86
87 inline void SetSolutionVector(const size_t Offset, const DoubleArray &y)
88 {
89 m_solVector[Offset] = y;
90 }
91
93 {
94 return m_t;
95 }
96
98 {
99 return m_t;
100 }
101
102 inline NekDouble GetTime() const
103 {
104 return m_t[0];
105 }
106
107 size_t GetNsteps()
108 {
110 }
111
112 inline size_t GetFirstDim() const
113 {
114 return m_solVector[0].size();
115 }
116
117 inline size_t GetSecondDim() const
118 {
119 return m_solVector[0][0].size();
120 }
121
122 // Return the number of entries in the solution vector that correspond to
123 // (multi-step) values.
124 inline size_t GetNvalues() const
125 {
127 }
128
129 // Return the number of entries in the solution vector that correspond to
130 // implicit (multi-step) derivatives.
131 inline size_t GetNimplicitderivs() const
132 {
134 }
135
136 // Return the number of entries in the solution vector that correspond to
137 // explicit (multi-step) derivatives.
138 inline size_t GetNexplicitderivs() const
139 {
141 }
142
143 // Returns an array which indicates to which time-level the entries in the
144 // solution vector correspond.
146 {
148 }
149
150 // Returns the entry in the solution vector which corresponds to the
151 // (multi-step) value at the time-level with specified offset
152 inline DoubleArray &GetValue(const size_t timeLevelOffset)
153 {
154 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
155 const Array<OneD, const size_t> &offsetvec =
157
158 for (size_t i = 0; i < nMultiStepVals; i++)
159 {
160 if (timeLevelOffset == offsetvec[i])
161 {
163 "Solution vector is not set at this time level");
164 return m_solVector[i];
165 }
166 }
167 ASSERTL1(false, "The solution vector of this scheme does not contain a "
168 "value at the requested time-level");
169 return m_solVector[0];
170 }
171
172 // returns the entry in the solution vector which corresponds to the
173 // implicit (multi-step) derivative at the time-level with specified offset
174 inline DoubleArray &GetImplicitDerivative(const size_t timeLevelOffset)
175 {
176 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
177 size_t nMultiStepImplicitDerivs =
179 const Array<OneD, const size_t> &offsetvec =
181
182 for (size_t i = nMultiStepVals;
183 i < nMultiStepVals + nMultiStepImplicitDerivs; i++)
184 {
185 if (timeLevelOffset == offsetvec[i])
186 {
188 "Implicit derivative solution vector is not set at "
189 "this time level");
190 return m_solVector[i];
191 }
192 }
193 ASSERTL1(false, "The solution vector of this scheme does not contain a "
194 "derivative at the requested time-level");
195 return m_solVector[0];
196 }
197
198 // returns the entry in the solution vector which corresponds to the
199 // explicit (multi-step) derivative at the time-level with specified offset
200 inline DoubleArray &GetExplicitDerivative(const size_t timeLevelOffset)
201 {
202 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
203 size_t nMultiStepImplicitDerivs =
205 size_t size = m_schemeAlgorithm->m_numsteps;
206 const Array<OneD, const size_t> &offsetvec =
208
209 for (size_t i = nMultiStepVals + nMultiStepImplicitDerivs; i < size;
210 i++)
211 {
212 if (timeLevelOffset == offsetvec[i])
213 {
215 "Explicit derivative solution vector is not set at "
216 "this time level");
217 return m_solVector[i];
218 }
219 }
220 ASSERTL1(false, "The solution vector of this scheme does not contain a "
221 "derivative at the requested time-level");
222 return m_solVector[0];
223 }
224
225 // returns the time associated with the (multi-step) value at the time-level
226 // with the given offset
227 inline NekDouble GetValueTime(const size_t timeLevelOffset)
228 {
229 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
230 const Array<OneD, const size_t> &offsetvec =
232
233 for (size_t i = 0; i < nMultiStepVals; i++)
234 {
235 if (timeLevelOffset == offsetvec[i])
236 {
237 return m_t[i];
238 }
239 }
240 ASSERTL1(false, "The solution vector of this scheme does not contain a "
241 "value at the requested time-level");
242 return m_t[0];
243 }
244
245 // sets the (multi-step) value and time in the solution vector which
246 // corresponds to the value at the time-level with specified offset
247 inline void SetValue(const size_t timeLevelOffset, const DoubleArray &y,
248 const NekDouble t)
249 {
250 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
251 const Array<OneD, const size_t> &offsetvec =
253
254 for (size_t i = 0; i < nMultiStepVals; i++)
255 {
256 if (timeLevelOffset == offsetvec[i])
257 {
258 m_solVector[i] = y;
259 m_t[i] = t;
260 m_setflag[i] = true;
261 return;
262 }
263 }
264 }
265
266 // sets the (multi-step) derivative and time in the solution vector which
267 // corresponds to the implicit derivative at the time-level with specified
268 // offset
269 inline void SetImplicitDerivative(const size_t timeLevelOffset,
270 const DoubleArray &y,
271 const NekDouble timestep)
272 {
273 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
274 size_t nMultiStepImplicitDerivs =
276 const Array<OneD, const size_t> &offsetvec =
278
279 for (size_t i = nMultiStepVals;
280 i < nMultiStepVals + nMultiStepImplicitDerivs; i++)
281 {
282 if (timeLevelOffset == offsetvec[i])
283 {
284 m_solVector[i] = y;
285 m_t[i] = timestep;
286 m_setflag[i] = true;
287 return;
288 }
289 }
290 }
291
292 // sets the (multi-step) derivative and time in the solution vector which
293 // corresponds to the explicit derivative at the time-level with specified
294 // offset
295 inline void SetExplicitDerivative(const size_t timeLevelOffset,
296 const DoubleArray &y,
297 const NekDouble timestep)
298 {
299 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
300 size_t nMultiStepImplicitDerivs =
302 size_t size = m_schemeAlgorithm->m_numsteps;
303 const Array<OneD, const size_t> &offsetvec =
305
306 for (size_t i = nMultiStepVals + nMultiStepImplicitDerivs; i < size;
307 i++)
308 {
309 if (timeLevelOffset == offsetvec[i])
310 {
311 m_solVector[i] = y;
312 m_t[i] = timestep;
313 m_setflag[i] = true;
314 return;
315 }
316 }
317 }
318
319 // Rotate the solution vector
320 // (i.e. updating without calculating/inserting new values)
322 {
323 size_t nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
324 size_t nMultiStepImpDerivs =
326 size_t size = m_schemeAlgorithm->m_numsteps;
327 for (size_t i = (nMultiStepVals - 1); i > 0; i--)
328 {
329 m_solVector[i] = m_solVector[i - 1];
330 m_setflag[i] = m_setflag[i - 1];
331 }
332
333 for (size_t i = (nMultiStepVals + nMultiStepImpDerivs - 1);
334 i > nMultiStepVals; i--)
335 {
336 m_solVector[i] = m_solVector[i - 1];
337 m_setflag[i] = m_setflag[i - 1];
338 }
339
340 for (size_t i = (size - 1); i > nMultiStepVals + nMultiStepImpDerivs;
341 i--)
342 {
343 m_solVector[i] = m_solVector[i - 1];
344 m_setflag[i] = m_setflag[i - 1];
345 }
346 }
347
348private:
350
354
355}; // end class TimeIntegrationSolutionGLM
356
357} // end of namespace LibUtilities
358} // end of namespace Nektar
359
360#endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
#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)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble