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 
43 
44 namespace Nektar
45 {
46 namespace LibUtilities
47 {
48 
50 {
51 public:
52  // Constructor for single step methods
54  const TimeIntegrationAlgorithmGLM *schemeAlgorithm,
55  const DoubleArray &y, const NekDouble time, const NekDouble timestep);
56 
57  // Constructor for multi-step methods
59  const TimeIntegrationAlgorithmGLM *schemeAlgorithm,
60  const TripleArray &y, const Array<OneD, NekDouble> &t);
61 
63  const TimeIntegrationAlgorithmGLM *schemeAlgorithm,
64  const unsigned int nvar, const unsigned int npoints);
65 
67  const TimeIntegrationAlgorithmGLM *schemeAlgorithm);
68 
70  {
71  return m_schemeAlgorithm;
72  }
73 
74  inline const TripleArray &GetSolutionVector() const
75  {
76  return m_solVector;
77  }
79  {
80  return m_solVector;
81  }
82 
83  inline const DoubleArray &GetSolution() const
84  {
85  return m_solVector[0];
86  }
88  {
89  return m_solVector[0];
90  }
91 
92  // Sets the solution Vector
93  inline void SetSolutionVector(const int Offset, const DoubleArray &y)
94  {
95  m_solVector[Offset] = y;
96  }
97 
99  {
100  return m_t;
101  }
103  {
104  return m_t;
105  }
106 
107  inline NekDouble GetTime() const
108  {
109  return m_t[0];
110  }
111  int GetNsteps()
112  {
114  }
115 
116  inline int GetFirstDim() const
117  {
118  return m_solVector[0].size();
119  }
120  inline int GetSecondDim() const
121  {
122  return m_solVector[0][0].size();
123  }
124 
125  // Return the number of entries in the solution vector that correspond to
126  // (multi-step) values.
127  inline unsigned int GetNvalues() const
128  {
130  }
131 
132  // Return the number of entries in the solution vector that correspond to
133  // (multi-step) derivatives.
134  inline unsigned int GetNimplicitderivs() const
135  {
137  }
138  inline unsigned int GetNderivs() 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 unsigned int timeLevelOffset)
153  {
154  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
155  const Array<OneD, const unsigned int> &offsetvec =
157 
158  for (int i = 0; i < nMultiStepVals; i++)
159  {
160  if (timeLevelOffset == offsetvec[i])
161  {
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  // (multi-step) derivative at the time-level with specified offset
173  const unsigned int timeLevelOffset)
174  {
175  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
176  int nMultiStepImplicitDerivs =
178  const Array<OneD, const unsigned int> &offsetvec =
180 
181  for (int i = nMultiStepVals;
182  i < nMultiStepVals + nMultiStepImplicitDerivs; i++)
183  {
184  if (timeLevelOffset == offsetvec[i])
185  {
186  return m_solVector[i];
187  }
188  }
189  ASSERTL1(false, "The solution vector of this scheme does not contain a "
190  "derivative at the requested time-level");
191  return m_solVector[0];
192  }
193  inline DoubleArray &GetDerivative(const unsigned int timeLevelOffset)
194  {
195  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
196  int nMultiStepImplicitDerivs =
198  int size = m_schemeAlgorithm->m_numsteps;
199  const Array<OneD, const unsigned int> &offsetvec =
201 
202  for (int i = nMultiStepVals + nMultiStepImplicitDerivs; i < size; i++)
203  {
204  if (timeLevelOffset == offsetvec[i])
205  {
206  return m_solVector[i];
207  }
208  }
209  ASSERTL1(false, "The solution vector of this scheme does not contain a "
210  "derivative at the requested time-level");
211  return m_solVector[0];
212  }
213 
214  // returns the time associated with the (multi-step) value at the time-level
215  // with the given offset
216  inline NekDouble GetValueTime(const unsigned int timeLevelOffset)
217  {
218  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
219  const Array<OneD, const unsigned int> &offsetvec =
221 
222  for (int i = 0; i < nMultiStepVals; i++)
223  {
224  if (timeLevelOffset == offsetvec[i])
225  {
226  return m_t[i];
227  }
228  }
229  ASSERTL1(false, "The solution vector of this scheme does not contain a "
230  "value at the requested time-level");
231  return m_t[0];
232  }
233 
234  // sets the (multi-step) value and time in the solution
235  // vector which corresponds to
236  // the value at the time-level with specified offset
237  inline void SetValue(const unsigned int timeLevelOffset,
238  const DoubleArray &y, const NekDouble t)
239  {
240  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
241  const Array<OneD, const unsigned int> &offsetvec =
243 
244  for (int i = 0; i < nMultiStepVals; i++)
245  {
246  if (timeLevelOffset == offsetvec[i])
247  {
248  m_solVector[i] = y;
249  m_t[i] = t;
250  return;
251  }
252  }
253  }
254 
255  // sets the (multi-step) derivative and time in the
256  // solution vector which corresponds to
257  // the derivative at the time-level with specified offset
258  inline void SetImplicitDerivative(const unsigned int timeLevelOffset,
259  const DoubleArray &y,
260  const NekDouble timestep)
261  {
262  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
263  int nMultiStepImplicitDerivs =
265  const Array<OneD, const unsigned int> &offsetvec =
267 
268  for (int i = nMultiStepVals;
269  i < nMultiStepVals + nMultiStepImplicitDerivs; i++)
270  {
271  if (timeLevelOffset == offsetvec[i])
272  {
273  m_solVector[i] = y;
274  m_t[i] = timestep;
275  return;
276  }
277  }
278  }
279  inline void SetDerivative(const unsigned int timeLevelOffset,
280  const DoubleArray &y, const NekDouble timestep)
281  {
282  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
283  int nMultiStepImplicitDerivs =
285  int size = m_schemeAlgorithm->m_numsteps;
286  const Array<OneD, const unsigned int> &offsetvec =
288 
289  for (int i = nMultiStepVals + nMultiStepImplicitDerivs; i < size; i++)
290  {
291  if (timeLevelOffset == offsetvec[i])
292  {
293  m_solVector[i] = y;
294  m_t[i] = timestep;
295  return;
296  }
297  }
298  }
299 
300  // Rotate the solution vector
301  // (i.e. updating without calculating/inserting new values)
302  inline void RotateSolutionVector()
303  {
304  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
305  int nMultiStepImpDerivs =
307  int size = m_schemeAlgorithm->m_numsteps;
308  for (int i = (nMultiStepVals - 1); i > 0; i--)
309  {
310  m_solVector[i] = m_solVector[i - 1];
311  }
312 
313  for (int i = (nMultiStepVals + nMultiStepImpDerivs - 1);
314  i > nMultiStepVals; i--)
315  {
316  m_solVector[i] = m_solVector[i - 1];
317  }
318 
319  for (int i = (size - 1); i > nMultiStepVals + nMultiStepImpDerivs; i--)
320  {
321  m_solVector[i] = m_solVector[i - 1];
322  }
323  }
324 
325 private:
327 
330 
331 }; // end class TimeIntegrationSolutionGLM
332 
333 } // end of namespace LibUtilities
334 } // end of namespace Nektar
335 
336 #endif
#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 unsigned int > & GetTimeLevelOffset() const
DoubleArray & GetDerivative(const unsigned int timeLevelOffset)
const Array< OneD, const unsigned int > & GetTimeLevelOffset()
void SetDerivative(const unsigned int timeLevelOffset, const DoubleArray &y, const NekDouble timestep)
LUE TimeIntegrationSolutionGLM(const TimeIntegrationAlgorithmGLM *schemeAlgorithm, const DoubleArray &y, const NekDouble time, const NekDouble timestep)
DoubleArray & GetImplicitDerivative(const unsigned int timeLevelOffset)
void SetSolutionVector(const int Offset, const DoubleArray &y)
void SetValue(const unsigned int timeLevelOffset, const DoubleArray &y, const NekDouble t)
void SetImplicitDerivative(const unsigned int timeLevelOffset, const DoubleArray &y, const NekDouble timestep)
const Array< OneD, const NekDouble > & GetTimeVector() const
const TimeIntegrationAlgorithmGLM * GetIntegrationSchemeData() const
DoubleArray & GetValue(const unsigned int timeLevelOffset)
NekDouble GetValueTime(const unsigned int timeLevelOffset)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble