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 DoubleArray &y, const NekDouble time,
55  const NekDouble timestep);
56 
57  // Constructor for multi-step methods
59  const TripleArray &y,
60  const Array<OneD, NekDouble> &t);
61 
63  const unsigned int nvar,
64  const unsigned int npoints);
65 
67 
69  {
70  return m_schemeAlgorithm;
71  }
72 
73  inline const TripleArray &GetSolutionVector() const
74  {
75  return m_solVector;
76  }
78  {
79  return m_solVector;
80  }
81 
82  inline const DoubleArray &GetSolution() const
83  {
84  return m_solVector[0];
85  }
87  {
88  return m_solVector[0];
89  }
90 
91  // Sets the solution Vector
92  inline void SetSolutionVector(const int Offset, const DoubleArray &y)
93  {
94  m_solVector[Offset] = y;
95  }
96 
98  {
99  return m_t;
100  }
102  {
103  return m_t;
104  }
105 
106  inline NekDouble GetTime() const
107  {
108  return m_t[0];
109  }
110  int GetNsteps()
111  {
113  }
114 
115  inline int GetFirstDim() const
116  {
117  return m_solVector[0].size();
118  }
119  inline int GetSecondDim() const
120  {
121  return m_solVector[0][0].size();
122  }
123 
124  // Return the number of entries in the solution vector that correspond to
125  // (multi-step) values.
126  inline unsigned int GetNvalues() const
127  {
129  }
130 
131  // Return the number of entries in the solution vector that correspond to
132  // (multi-step) derivatives.
133  inline unsigned int GetNderivs() const
134  {
136  }
137 
138  // Returns an array which indicates to which time-level the entries in the
139  // solution vector correspond.
141  {
143  }
144 
145  // Returns the entry in the solution vector which corresponds to the
146  // (multi-step) value at the time-level with specified offset
147  inline DoubleArray &GetValue(const unsigned int timeLevelOffset)
148  {
149  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
150  const Array<OneD, const unsigned int> &offsetvec =
152 
153  for (int i = 0; i < nMultiStepVals; i++)
154  {
155  if (timeLevelOffset == offsetvec[i])
156  {
157  return m_solVector[i];
158  }
159  }
160  ASSERTL1(false, "The solution vector of this scheme does not contain a "
161  "value at the requested time-level");
162  return m_solVector[0];
163  }
164 
165  // returns the entry in the solution vector which corresponds to the
166  // (multi-step) derivative at the time-level with specified offset
167  inline DoubleArray &GetDerivative(const unsigned int timeLevelOffset)
168  {
169  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
170  int size = m_schemeAlgorithm->m_numsteps;
171  const Array<OneD, const unsigned int> &offsetvec =
173 
174  for (int i = nMultiStepVals; i < size; i++)
175  {
176  if (timeLevelOffset == offsetvec[i])
177  {
178  return m_solVector[i];
179  }
180  }
181  ASSERTL1(false, "The solution vector of this scheme does not contain a "
182  "derivative at the requested time-level");
183  return m_solVector[0];
184  }
185 
186  // returns the time associated with the (multi-step) value at the time-level
187  // with the given offset
188  inline NekDouble GetValueTime(const unsigned int timeLevelOffset)
189  {
190  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
191  const Array<OneD, const unsigned int> &offsetvec =
193 
194  for (int i = 0; i < nMultiStepVals; i++)
195  {
196  if (timeLevelOffset == offsetvec[i])
197  {
198  return m_t[i];
199  }
200  }
201  ASSERTL1(false, "The solution vector of this scheme does not contain a "
202  "value at the requested time-level");
203  return m_t[0];
204  }
205 
206  // sets the (multi-step) value and time in the solution
207  // vector which corresponds to
208  // the value at the time-level with specified offset
209  inline void SetValue(const unsigned int timeLevelOffset,
210  const DoubleArray &y, const NekDouble t)
211  {
212  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
213  const Array<OneD, const unsigned int> &offsetvec =
215 
216  for (int i = 0; i < nMultiStepVals; i++)
217  {
218  if (timeLevelOffset == offsetvec[i])
219  {
220  m_solVector[i] = y;
221  m_t[i] = t;
222  return;
223  }
224  }
225  }
226 
227  // sets the (multi-step) derivative and time in the
228  // solution vector which corresponds to
229  // the derivative at the time-level with specified offset
230  inline void SetDerivative(const unsigned int timeLevelOffset,
231  const DoubleArray &y, const NekDouble timestep)
232  {
233  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
234  int size = m_schemeAlgorithm->m_numsteps;
235  const Array<OneD, const unsigned int> &offsetvec =
237 
238  for (int i = nMultiStepVals; i < size; i++)
239  {
240  if (timeLevelOffset == offsetvec[i])
241  {
242  m_solVector[i] = y;
243  m_t[i] = timestep;
244  return;
245  }
246  }
247  }
248 
249  // Rotate the solution vector
250  // (i.e. updating without calculating/inserting new values)
251  inline void RotateSolutionVector()
252  {
253  int nMultiStepVals = m_schemeAlgorithm->GetNmultiStepValues();
254  int size = m_schemeAlgorithm->m_numsteps;
255  for (int i = (nMultiStepVals - 1); i > 0; i--)
256  {
257  m_solVector[i] = m_solVector[i - 1];
258  }
259 
260  for (int i = (size - 1); i > nMultiStepVals; i--)
261  {
262  m_solVector[i] = m_solVector[i - 1];
263  }
264  }
265 
266 private:
268 
271 
272 }; // end class TimeIntegrationSolutionGLM
273 
274 } // end of namespace LibUtilities
275 } // end of namespace Nektar
276 
277 #endif
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
#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