Nektar++
AlternateSkewAdvection.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File AlternateSkewAdvection.cpp
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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Evaluation of the Navier Stokes advective term
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
36 
37 using namespace std;
38 
39 namespace Nektar
40 {
41 
42 string AlternateSkewAdvection::className =
44  "AlternateSkew", AlternateSkewAdvection::create,
45  "Alternating Skew Symmetric");
46 
47 /**
48  * Constructor. Creates ...
49  *
50  * \param
51  * \param
52  */
53 AlternateSkewAdvection::AlternateSkewAdvection() : Advection()
54 {
55 }
56 
58 {
59 }
60 
64 {
65  pSession->MatchSolverInfo("ModeType", "SingleMode", m_SingleMode, false);
66  pSession->MatchSolverInfo("ModeType", "HalfMode", m_HalfMode, false);
67 }
68 
70  const int nConvectiveFields,
72  const Array<OneD, Array<OneD, NekDouble>> &advVel,
73  const Array<OneD, Array<OneD, NekDouble>> &inarray,
74  Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble &time,
75  const Array<OneD, Array<OneD, NekDouble>> &pFwd,
76  const Array<OneD, Array<OneD, NekDouble>> &pBwd)
77 {
78  // use dimension of Velocity vector to dictate dimension of operation
79  int ndim = advVel.size();
80  int nPointsTot = fields[0]->GetNpoints();
81  Array<OneD, Array<OneD, NekDouble>> velocity(ndim);
82  for (int i = 0; i < ndim; ++i)
83  {
84  if (fields[i]->GetWaveSpace() && !m_SingleMode && !m_HalfMode)
85  {
86  velocity[i] = Array<OneD, NekDouble>(nPointsTot, 0.0);
87  fields[i]->HomogeneousBwdTrans(advVel[i], velocity[i]);
88  }
89  else
90  {
91  velocity[i] = advVel[i];
92  }
93  }
94  for (int n = 0; n < nConvectiveFields; ++n)
95  {
96  // ToDo: here we should add a check that V has right dimension
97  Array<OneD, NekDouble> gradV0, gradV1, gradV2, tmp, Up;
98 
99  gradV0 = Array<OneD, NekDouble>(nPointsTot);
100  tmp = Array<OneD, NekDouble>(nPointsTot);
101 
102  // Evaluate V\cdot Grad(u)
103  switch (ndim)
104  {
105  case 1:
106  if (m_advectioncalls % 2 == 0)
107  {
108  fields[0]->PhysDeriv(inarray[n], gradV0);
109  Vmath::Vmul(nPointsTot, gradV0, 1, velocity[0], 1,
110  outarray[n], 1);
111  }
112  else
113  {
114  Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[0], 1,
115  gradV0, 1);
116  fields[0]->PhysDeriv(gradV0, outarray[n]);
117  }
118  Vmath::Smul(nPointsTot, 0.5, outarray[n], 1, outarray[n],
119  1); // must be mult by 0.5????
120  break;
121  case 2:
122  gradV1 = Array<OneD, NekDouble>(nPointsTot);
123  if (m_advectioncalls % 2 == 0)
124  {
125  fields[0]->PhysDeriv(inarray[n], gradV0, gradV1);
126  Vmath::Vmul(nPointsTot, gradV0, 1, velocity[0], 1,
127  outarray[n], 1);
128  Vmath::Vvtvp(nPointsTot, gradV1, 1, velocity[1], 1,
129  outarray[n], 1, outarray[n], 1);
130  }
131  else
132  {
133  Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[0], 1,
134  gradV0, 1);
135  Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[1], 1,
136  gradV1, 1);
137  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],
138  gradV0, outarray[n]);
139  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],
140  gradV1, tmp);
141  Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1, outarray[n],
142  1);
143  }
144  Vmath::Smul(nPointsTot, 1.0, outarray[n], 1, outarray[n],
145  1); // must be mult by 0.5????
146  break;
147  case 3:
148  gradV1 = Array<OneD, NekDouble>(nPointsTot);
149  gradV2 = Array<OneD, NekDouble>(nPointsTot);
150 
151  // outarray[n] = 1/2(u*du/dx + v*du/dy + w*du/dz + duu/dx +
152  // duv/dy + duw/dz)
153 
154  if (fields[0]->GetWaveSpace() == true)
155  {
156  if (m_advectioncalls % 2 == 0)
157  {
158  // vector reused to avoid even more memory requirements
159  // names may be misleading
160  fields[0]->PhysDeriv(inarray[n], gradV0, gradV1,
161  gradV2);
162  fields[0]->HomogeneousBwdTrans(gradV0, tmp);
163  Vmath::Vmul(nPointsTot, tmp, 1, velocity[0], 1,
164  outarray[n], 1); // + u*du/dx
165  fields[0]->HomogeneousBwdTrans(gradV1, tmp);
166  Vmath::Vvtvp(nPointsTot, tmp, 1, velocity[1], 1,
167  outarray[n], 1, outarray[n],
168  1); // + v*du/dy
169  fields[0]->HomogeneousBwdTrans(gradV2, tmp);
170  Vmath::Vvtvp(nPointsTot, tmp, 1, velocity[2], 1,
171  outarray[n], 1, outarray[n],
172  1); // + w*du/dz
173  }
174  else
175  {
176  Up = Array<OneD, NekDouble>(nPointsTot);
177  fields[0]->HomogeneousBwdTrans(inarray[n], Up);
178  Vmath::Vmul(nPointsTot, Up, 1, velocity[0], 1, gradV0,
179  1);
180  Vmath::Vmul(nPointsTot, Up, 1, velocity[1], 1, gradV1,
181  1);
182  Vmath::Vmul(nPointsTot, Up, 1, velocity[2], 1, gradV2,
183  1);
184 
185  fields[0]->SetWaveSpace(false);
186  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],
187  gradV0, outarray[n]); // duu/dx
188  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],
189  gradV1, tmp); // duv/dy
190  Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
191  outarray[n], 1);
192  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],
193  gradV2, tmp); // duw/dz
194  Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
195  outarray[n], 1);
196  fields[0]->SetWaveSpace(true);
197  }
198 
199  Vmath::Smul(nPointsTot, 1.0, outarray[n], 1, tmp,
200  1); // must be mult by 0.5????
201  fields[0]->HomogeneousFwdTrans(tmp, outarray[n]);
202  }
203  else
204  {
205  if (m_advectioncalls % 2 == 0)
206  {
207  fields[0]->PhysDeriv(inarray[n], gradV0, gradV1,
208  gradV2);
209  Vmath::Vmul(nPointsTot, gradV0, 1, velocity[0], 1,
210  outarray[n], 1);
211  Vmath::Vvtvp(nPointsTot, gradV1, 1, velocity[1], 1,
212  outarray[n], 1, outarray[n], 1);
213  Vmath::Vvtvp(nPointsTot, gradV2, 1, velocity[2], 1,
214  outarray[n], 1, outarray[n], 1);
215  }
216  else
217  {
218  Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[0], 1,
219  gradV0, 1);
220  Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[1], 1,
221  gradV1, 1);
222  Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[2], 1,
223  gradV2, 1);
224  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],
225  gradV0, outarray[n]);
226  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],
227  gradV1, tmp);
228  Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
229  outarray[n], 1);
230  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],
231  gradV2, tmp);
232  Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
233  outarray[n], 1);
234  }
235  Vmath::Smul(nPointsTot, 1.0, outarray[n], 1, outarray[n],
236  1); // must be mult by 0.5????
237  }
238  break;
239  default:
240  ASSERTL0(false, "dimension unknown");
241  }
242  }
243 }
244 
245 } // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
virtual void v_Advect(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble >> &advVel, const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble &time, const Array< OneD, Array< OneD, NekDouble >> &pFwd=NullNekDoubleArrayOfArray, const Array< OneD, Array< OneD, NekDouble >> &pBwd=NullNekDoubleArrayOfArray)
Advects a vector field.
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
An abstract base class encapsulating the concept of advection of a vector field.
Definition: Advection.h:72
std::shared_ptr< SessionReader > SessionReaderSharedPtr
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:89
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:47
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:209
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:574
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:359
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.cpp:248