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 GetNderivs() const
135  {
137  }
138 
139  // Returns an array which indicates to which time-level the entries in the
140  // solution vector correspond.
142  {
144  }
145 
146  // Returns the entry in the solution vector which corresponds to the
147  // (multi-step) value at the time-level with specified offset
148  inline DoubleArray &GetValue(const unsigned int timeLevelOffset)
149  {
150  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
151  const Array<OneD, const unsigned int> &offsetvec =
153 
154  for (int i = 0; i < nMultiStepVals; i++)
155  {
156  if (timeLevelOffset == offsetvec[i])
157  {
158  return m_solVector[i];
159  }
160  }
161  ASSERTL1(false, "The solution vector of this scheme does not contain a "
162  "value at the requested time-level");
163  return m_solVector[0];
164  }
165 
166  // returns the entry in the solution vector which corresponds to the
167  // (multi-step) derivative at the time-level with specified offset
168  inline DoubleArray &GetDerivative(const unsigned int timeLevelOffset)
169  {
170  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
171  int size = m_schemeAlgorithm->m_numsteps;
172  const Array<OneD, const unsigned int> &offsetvec =
174 
175  for (int i = nMultiStepVals; i < size; i++)
176  {
177  if (timeLevelOffset == offsetvec[i])
178  {
179  return m_solVector[i];
180  }
181  }
182  ASSERTL1(false, "The solution vector of this scheme does not contain a "
183  "derivative at the requested time-level");
184  return m_solVector[0];
185  }
186 
187  // returns the time associated with the (multi-step) value at the time-level
188  // with the given offset
189  inline NekDouble GetValueTime(const unsigned int timeLevelOffset)
190  {
191  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
192  const Array<OneD, const unsigned int> &offsetvec =
194 
195  for (int i = 0; i < nMultiStepVals; i++)
196  {
197  if (timeLevelOffset == offsetvec[i])
198  {
199  return m_t[i];
200  }
201  }
202  ASSERTL1(false, "The solution vector of this scheme does not contain a "
203  "value at the requested time-level");
204  return m_t[0];
205  }
206 
207  // sets the (multi-step) value and time in the solution
208  // vector which corresponds to
209  // the value at the time-level with specified offset
210  inline void SetValue(const unsigned int timeLevelOffset,
211  const DoubleArray &y, const NekDouble t)
212  {
213  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
214  const Array<OneD, const unsigned int> &offsetvec =
216 
217  for (int i = 0; i < nMultiStepVals; i++)
218  {
219  if (timeLevelOffset == offsetvec[i])
220  {
221  m_solVector[i] = y;
222  m_t[i] = t;
223  return;
224  }
225  }
226  }
227 
228  // sets the (multi-step) derivative and time in the
229  // solution vector which corresponds to
230  // the derivative at the time-level with specified offset
231  inline void SetDerivative(const unsigned int timeLevelOffset,
232  const DoubleArray &y, const NekDouble timestep)
233  {
234  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
235  int size = m_schemeAlgorithm->m_numsteps;
236  const Array<OneD, const unsigned int> &offsetvec =
238 
239  for (int i = nMultiStepVals; i < size; i++)
240  {
241  if (timeLevelOffset == offsetvec[i])
242  {
243  m_solVector[i] = y;
244  m_t[i] = timestep;
245  return;
246  }
247  }
248  }
249 
250  // Rotate the solution vector
251  // (i.e. updating without calculating/inserting new values)
252  inline void RotateSolutionVector()
253  {
254  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
255  int size = m_schemeAlgorithm->m_numsteps;
256  for (int i = (nMultiStepVals - 1); i > 0; i--)
257  {
258  m_solVector[i] = m_solVector[i - 1];
259  }
260 
261  for (int i = (size - 1); i > nMultiStepVals; i--)
262  {
263  m_solVector[i] = m_solVector[i - 1];
264  }
265  }
266 
267 private:
269 
272 
273 }; // end class TimeIntegrationSolutionGLM
274 
275 } // end of namespace LibUtilities
276 } // end of namespace Nektar
277 
278 #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)
void SetSolutionVector(const int Offset, const DoubleArray &y)
void SetValue(const unsigned int timeLevelOffset, const DoubleArray &y, const NekDouble t)
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:1
double NekDouble