Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // 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: Evaluation of the Navier Stokes advective term
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42 
43 string AlternateSkewAdvection::className =
45  "AlternateSkew", AlternateSkewAdvection::create);
46 
47 /**
48  * Constructor. Creates ...
49  *
50  * \param
51  * \param
52  */
53 AlternateSkewAdvection::AlternateSkewAdvection()
54  : Advection()
55 {
56 }
57 
59 {
60 }
61 
65 {
66  pSession->MatchSolverInfo("ModeType","SingleMode",m_SingleMode,false);
67  pSession->MatchSolverInfo("ModeType","HalfMode",m_HalfMode,false);
68 }
69 
71  const int nConvectiveFields,
73  const Array<OneD, Array<OneD, NekDouble> > &advVel,
74  const Array<OneD, Array<OneD, NekDouble> > &inarray,
75  Array<OneD, Array<OneD, NekDouble> > &outarray,
76  const NekDouble &time,
77  const Array<OneD, Array<OneD, NekDouble> > &pFwd,
78  const Array<OneD, Array<OneD, NekDouble> > &pBwd)
79 {
80  // use dimension of Velocity vector to dictate dimension of operation
81  int ndim = advVel.num_elements();
82  int nPointsTot = fields[0]->GetNpoints();
83  Array<OneD, Array<OneD, NekDouble> > velocity(ndim);
84  for(int i = 0; i < ndim; ++i)
85  {
86  if(fields[i]->GetWaveSpace() && !m_SingleMode && !m_HalfMode)
87  {
88  velocity[i] = Array<OneD, NekDouble>(nPointsTot,0.0);
89  fields[i]->HomogeneousBwdTrans(advVel[i],velocity[i]);
90  }
91  else
92  {
93  velocity[i] = advVel[i];
94  }
95  }
96  for(int n = 0; n < nConvectiveFields; ++n)
97  {
98  // ToDo: here we should add a check that V has right dimension
99  Array<OneD, NekDouble> gradV0,gradV1,gradV2, tmp, Up;
100 
101  gradV0 = Array<OneD, NekDouble> (nPointsTot);
102  tmp = Array<OneD, NekDouble> (nPointsTot);
103 
104  // Evaluate V\cdot Grad(u)
105  switch(ndim)
106  {
107  case 1:
108  if(m_advectioncalls % 2 == 0)
109  {
110  fields[0]->PhysDeriv(inarray[n],gradV0);
111  Vmath::Vmul(nPointsTot,gradV0,1,velocity[0],1,outarray[n],1);
112  }
113  else
114  {
115  Vmath::Vmul(nPointsTot,inarray[n],1,velocity[0],1,gradV0,1);
116  fields[0]->PhysDeriv(gradV0,outarray[n]);
117  }
118  Vmath::Smul(nPointsTot,0.5,outarray[n],1,outarray[n],1); //must be mult by 0.5????
119  break;
120  case 2:
121  gradV1 = Array<OneD, NekDouble> (nPointsTot);
122  if(m_advectioncalls % 2 == 0)
123  {
124  fields[0]->PhysDeriv(inarray[n],gradV0,gradV1);
125  Vmath::Vmul (nPointsTot,gradV0,1,velocity[0],1,outarray[n],1);
126  Vmath::Vvtvp(nPointsTot,gradV1,1,velocity[1],1,outarray[n],1,outarray[n],1);
127  }
128  else
129  {
130  Vmath::Vmul(nPointsTot,inarray[n],1,velocity[0],1,gradV0,1);
131  Vmath::Vmul(nPointsTot,inarray[n],1,velocity[1],1,gradV1,1);
132  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,outarray[n]);
133  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
134  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
135  }
136  Vmath::Smul(nPointsTot,1.0,outarray[n],1,outarray[n],1); //must be mult by 0.5????
137  break;
138  case 3:
139  gradV1 = Array<OneD, NekDouble> (nPointsTot);
140  gradV2 = Array<OneD, NekDouble> (nPointsTot);
141 
142  //outarray[n] = 1/2(u*du/dx + v*du/dy + w*du/dz + duu/dx + duv/dy + duw/dz)
143 
144  if(fields[0]->GetWaveSpace() == true)
145  {
146  if(m_advectioncalls % 2 == 0)
147  {
148  //vector reused to avoid even more memory requirements
149  //names may be misleading
150  fields[0]->PhysDeriv(inarray[n],gradV0,gradV1,gradV2);
151  fields[0]->HomogeneousBwdTrans(gradV0,tmp);
152  Vmath::Vmul(nPointsTot,tmp,1,velocity[0],1,outarray[n],1); // + u*du/dx
153  fields[0]->HomogeneousBwdTrans(gradV1,tmp);
154  Vmath::Vvtvp(nPointsTot,tmp,1,velocity[1],1,outarray[n],1,outarray[n],1);// + v*du/dy
155  fields[0]->HomogeneousBwdTrans(gradV2,tmp);
156  Vmath::Vvtvp(nPointsTot,tmp,1,velocity[2],1,outarray[n],1,outarray[n],1);// + w*du/dz
157  }
158  else
159  {
160  Up = Array<OneD, NekDouble> (nPointsTot);
161  fields[0]->HomogeneousBwdTrans(inarray[n],Up);
162  Vmath::Vmul(nPointsTot,Up,1,velocity[0],1,gradV0,1);
163  Vmath::Vmul(nPointsTot,Up,1,velocity[1],1,gradV1,1);
164  Vmath::Vmul(nPointsTot,Up,1,velocity[2],1,gradV2,1);
165 
166  fields[0]->SetWaveSpace(false);
167  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,outarray[n]);//duu/dx
168  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);//duv/dy
169  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
170  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);//duw/dz
171  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
172  fields[0]->SetWaveSpace(true);
173  }
174 
175  Vmath::Smul(nPointsTot,1.0,outarray[n],1,tmp,1); //must be mult by 0.5????
176  fields[0]->HomogeneousFwdTrans(tmp,outarray[n]);
177  }
178  else
179  {
180  if(m_advectioncalls % 2 == 0)
181  {
182  fields[0]->PhysDeriv(inarray[n],gradV0,gradV1,gradV2);
183  Vmath::Vmul(nPointsTot,gradV0,1,velocity[0],1,outarray[n],1);
184  Vmath::Vvtvp(nPointsTot,gradV1,1,velocity[1],1,outarray[n],1,outarray[n],1);
185  Vmath::Vvtvp(nPointsTot,gradV2,1,velocity[2],1,outarray[n],1,outarray[n],1);
186  }
187  else
188  {
189  Vmath::Vmul(nPointsTot,inarray[n],1,velocity[0],1,gradV0,1);
190  Vmath::Vmul(nPointsTot,inarray[n],1,velocity[1],1,gradV1,1);
191  Vmath::Vmul(nPointsTot,inarray[n],1,velocity[2],1,gradV2,1);
192  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,outarray[n]);
193  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
194  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
195  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);
196  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
197  }
198  Vmath::Smul(nPointsTot,1.0,outarray[n],1,outarray[n],1); //must be mult by 0.5????
199  }
200  break;
201  default:
202  ASSERTL0(false,"dimension unknown");
203  }
204  }
205 }
206 
207 } //end of namespace
208 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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.
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:442
STL namespace.
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:213
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:46
double NekDouble
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:86
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:299
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:183
Defines a callback function which evaluates the flux vector.
Definition: Advection.h:69
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215