Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkewSymmetricAdvection.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File SkewSymmetricAdvection.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 string SkewSymmetricAdvection::className
44  "SkewSymmetric",
45  SkewSymmetricAdvection::create);
46 
47 /**
48  *
49  */
50 SkewSymmetricAdvection::SkewSymmetricAdvection():
51  Advection()
52 
53 {
54 }
55 
56 
57 /**
58  *
59  */
61 {
62 }
63 
64 
65 /**
66  *
67  */
71 {
72  Advection::v_InitObject(pSession, pFields);
73 
75  m_homogen_dealiasing = pSession->DefinesSolverInfo("dealiasing");
76  pSession->MatchSolverInfo("ModeType","SingleMode",m_SingleMode,false);
77  pSession->MatchSolverInfo("ModeType","HalfMode",m_HalfMode,false);
78 }
79 
80 
81 /**
82  *
83  */
85  const int nConvectiveFields,
87  const Array<OneD, Array<OneD, NekDouble> > &advVel,
88  const Array<OneD, Array<OneD, NekDouble> > &inarray,
89  Array<OneD, Array<OneD, NekDouble> > &outarray,
90  const NekDouble &time)
91 {
92  int nqtot = fields[0]->GetTotPoints();
93  ASSERTL1(nConvectiveFields == inarray.num_elements(),"Number of convective fields and Inarray are not compatible");
94 
95  Array<OneD, NekDouble > Deriv = Array<OneD, NekDouble> (nqtot*nConvectiveFields);
96 
97  for(int n = 0; n < nConvectiveFields; ++n)
98  {
99  // use dimension of Velocity vector to dictate dimension of operation
100  int ndim = advVel.num_elements();
101 
102  // ToDo: here we should add a check that V has right dimension
103 
104  int nPointsTot = fields[0]->GetNpoints();
105  Array<OneD, NekDouble> gradV0,gradV1,gradV2, tmp, Up;
106 
107  gradV0 = Array<OneD, NekDouble> (nPointsTot);
108  tmp = Array<OneD, NekDouble> (nPointsTot);
109 
110  // Evaluate V\cdot Grad(u)
111  switch(ndim)
112  {
113  case 1:
114  fields[0]->PhysDeriv(inarray[n],gradV0);
115  Vmath::Vmul(nPointsTot,gradV0,1,advVel[0],1,outarray[n],1);
116  Vmath::Vmul(nPointsTot,inarray[n],1,advVel[0],1,gradV0,1);
117  fields[0]->PhysDeriv(gradV0,tmp);
118  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
119  Vmath::Smul(nPointsTot,0.5,outarray[n],1,outarray[n],1);
120  break;
121  case 2:
122  gradV1 = Array<OneD, NekDouble> (nPointsTot);
123  fields[0]->PhysDeriv(inarray[n],gradV0,gradV1);
124  Vmath::Vmul (nPointsTot,gradV0,1,advVel[0],1,outarray[n],1);
125  Vmath::Vvtvp(nPointsTot,gradV1,1,advVel[1],1,outarray[n],1,outarray[n],1);
126  Vmath::Vmul(nPointsTot,inarray[n],1,advVel[0],1,gradV0,1);
127  Vmath::Vmul(nPointsTot,inarray[n],1,advVel[1],1,gradV1,1);
128  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);
129  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
130  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
131  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
132  Vmath::Smul(nPointsTot,0.5,outarray[n],1,outarray[n],1);
133  break;
134  case 3:
135  gradV1 = Array<OneD, NekDouble> (nPointsTot);
136  gradV2 = Array<OneD, NekDouble> (nPointsTot);
137 
138  fields[0]->PhysDeriv(inarray[n],gradV0,gradV1,gradV2);
139 
140  //outarray[n] = 1/2(u*du/dx + v*du/dy + w*du/dz + duu/dx + duv/dy + duw/dz)
141 
142  if(m_homogen_dealiasing == true && fields[0]->GetWaveSpace() == false)
143  {
144  fields[0]->DealiasedProd(advVel[0],gradV0,gradV0,m_CoeffState);
145  fields[0]->DealiasedProd(advVel[1],gradV1,gradV1,m_CoeffState);
146  fields[0]->DealiasedProd(advVel[2],gradV2,gradV2,m_CoeffState);
147  Vmath::Vadd(nPointsTot,gradV0,1,gradV1,1,outarray[n],1);
148  Vmath::Vadd(nPointsTot,gradV2,1,outarray[n],1,outarray[n],1);
149  fields[0]->DealiasedProd(inarray[n],advVel[0],gradV0,m_CoeffState);
150  fields[0]->DealiasedProd(inarray[n],advVel[1],gradV1,m_CoeffState);
151  fields[0]->DealiasedProd(inarray[n],advVel[2],gradV2,m_CoeffState);
152  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);
153  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
154  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
155  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
156  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);
157  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
158  Vmath::Smul(nPointsTot,0.5,outarray[n],1,outarray[n],1);
159  }
160  else if(fields[0]->GetWaveSpace() == true && m_homogen_dealiasing == false)
161  {
162  Up = Array<OneD, NekDouble> (nPointsTot);
163  //vector reused to avoid even more memory requirements
164  //names may be misleading
165  fields[0]->HomogeneousBwdTrans(gradV0,tmp);
166  Vmath::Vmul(nPointsTot,tmp,1,advVel[0],1,outarray[n],1); // + u*du/dx
167  fields[0]->HomogeneousBwdTrans(gradV1,tmp);
168  Vmath::Vvtvp(nPointsTot,tmp,1,advVel[1],1,outarray[n],1,outarray[n],1);// + v*du/dy
169  fields[0]->HomogeneousBwdTrans(gradV2,tmp);
170  Vmath::Vvtvp(nPointsTot,tmp,1,advVel[2],1,outarray[n],1,outarray[n],1);// + w*du/dz
171 
172  fields[0]->HomogeneousBwdTrans(inarray[n],Up);
173  Vmath::Vmul(nPointsTot,Up,1,advVel[0],1,gradV0,1);
174  Vmath::Vmul(nPointsTot,Up,1,advVel[1],1,gradV1,1);
175  Vmath::Vmul(nPointsTot,Up,1,advVel[2],1,gradV2,1);
176 
177  fields[0]->SetWaveSpace(false);
178  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);//duu/dx
179  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
180  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);//duv/dy
181  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
182  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);//duw/dz
183  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
184  fields[0]->SetWaveSpace(true);
185 
186  Vmath::Smul(nPointsTot,0.5,outarray[n],1,tmp,1);
187  fields[0]->HomogeneousFwdTrans(tmp,outarray[n]);
188  }
189  else if(fields[0]->GetWaveSpace() == false && m_homogen_dealiasing == false)
190  {
191  Vmath::Vmul(nPointsTot,gradV0,1,advVel[0],1,outarray[n],1);
192  Vmath::Vvtvp(nPointsTot,gradV1,1,advVel[1],1,outarray[n],1,outarray[n],1);
193  Vmath::Vvtvp(nPointsTot,gradV2,1,advVel[2],1,outarray[n],1,outarray[n],1);
194  Vmath::Vmul(nPointsTot,inarray[n],1,advVel[0],1,gradV0,1);
195  Vmath::Vmul(nPointsTot,inarray[n],1,advVel[1],1,gradV1,1);
196  Vmath::Vmul(nPointsTot,inarray[n],1,advVel[2],1,gradV2,1);
197  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);
198  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
199  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
200  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
201  fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);
202  Vmath::Vadd(nPointsTot,tmp,1,outarray[n],1,outarray[n],1);
203  Vmath::Smul(nPointsTot,0.5,outarray[n],1,outarray[n],1);
204  }
205  else
206  {
207  ASSERTL0(false, "Dealiasing is not allowed in combination "
208  "with the Skew-Symmetric advection form for "
209  "efficiency reasons.");
210  }
211  break;
212  default:
213  ASSERTL0(false,"dimension unknown");
214  }
215 
216  Vmath::Neg(nqtot,outarray[n],1);
217  }
218 
219 }
220 
221 } //end of namespace
222 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
Local coefficients.
MultiRegions::CoeffState m_CoeffState
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:428
STL namespace.
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:199
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:46
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:382
double NekDouble
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:86
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
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)
Advects a vector field.
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:97
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:285
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:169
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
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.