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 namespace Nektar
39 {
41 
42 
43  /**
44  * Constructor. Creates ...
45  *
46  * \param
47  * \param
48  */
49 
53  AdvectionTerm(pSession, pGraph)
54 
55  {
56 
57  }
58 
60  {
61  }
62 
63  //Advection function
64 
65 
66  //Evaluation of the advective terms
68  Array<OneD, MultiRegions::ExpListSharedPtr > &pFields,
69  const Array<OneD, Array<OneD, NekDouble> > &pV,
70  const Array<OneD, const NekDouble> &pU,
71  Array<OneD, NekDouble> &pOutarray,
72  int pVelocityComponent,
73  NekDouble m_time,
74  Array<OneD, NekDouble> &pWk)
75  {
76  // use dimension of Velocity vector to dictate dimension of operation
77  int ndim = pV.num_elements();
78 
79  // ToDo: here we should add a check that V has right dimension
80 
81  int nPointsTot = pFields[0]->GetNpoints();
82  Array<OneD, NekDouble> gradV0,gradV1,gradV2, tmp, Up;
83 
84  gradV0 = Array<OneD, NekDouble> (nPointsTot);
85  tmp = Array<OneD, NekDouble> (nPointsTot);
86 
87  // Evaluate V\cdot Grad(u)
88  switch(ndim)
89  {
90  case 1:
91  pFields[0]->PhysDeriv(pU,gradV0);
92  Vmath::Vmul(nPointsTot,gradV0,1,pV[0],1,pOutarray,1);
93  Vmath::Vmul(nPointsTot,pU,1,pV[0],1,gradV0,1);
94  pFields[0]->PhysDeriv(gradV0,tmp);
95  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
96  Vmath::Smul(nPointsTot,0.5,pOutarray,1,pOutarray,1);
97  break;
98  case 2:
99  gradV1 = Array<OneD, NekDouble> (nPointsTot);
100  pFields[0]->PhysDeriv(pU,gradV0,gradV1);
101  Vmath::Vmul (nPointsTot,gradV0,1,pV[0],1,pOutarray,1);
102  Vmath::Vvtvp(nPointsTot,gradV1,1,pV[1],1,pOutarray,1,pOutarray,1);
103  Vmath::Vmul(nPointsTot,pU,1,pV[0],1,gradV0,1);
104  Vmath::Vmul(nPointsTot,pU,1,pV[1],1,gradV1,1);
105  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);
106  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
107  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
108  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
109  Vmath::Smul(nPointsTot,0.5,pOutarray,1,pOutarray,1);
110  break;
111  case 3:
112  gradV1 = Array<OneD, NekDouble> (nPointsTot);
113  gradV2 = Array<OneD, NekDouble> (nPointsTot);
114 
115  pFields[0]->PhysDeriv(pU,gradV0,gradV1,gradV2);
116 
117  //pOutarray = 1/2(u*du/dx + v*du/dy + w*du/dz + duu/dx + duv/dy + duw/dz)
118 
119  if(m_homogen_dealiasing == true && pFields[0]->GetWaveSpace() == false)
120  {
121  pFields[0]->DealiasedProd(pV[0],gradV0,gradV0,m_CoeffState);
122  pFields[0]->DealiasedProd(pV[1],gradV1,gradV1,m_CoeffState);
123  pFields[0]->DealiasedProd(pV[2],gradV2,gradV2,m_CoeffState);
124  Vmath::Vadd(nPointsTot,gradV0,1,gradV1,1,pOutarray,1);
125  Vmath::Vadd(nPointsTot,gradV2,1,pOutarray,1,pOutarray,1);
126  pFields[0]->DealiasedProd(pU,pV[0],gradV0,m_CoeffState);
127  pFields[0]->DealiasedProd(pU,pV[1],gradV1,m_CoeffState);
128  pFields[0]->DealiasedProd(pU,pV[2],gradV2,m_CoeffState);
129  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);
130  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
131  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
132  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
133  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);
134  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
135  Vmath::Smul(nPointsTot,0.5,pOutarray,1,pOutarray,1);
136  }
137  else if(pFields[0]->GetWaveSpace() == true && m_homogen_dealiasing == false)
138  {
139  Up = Array<OneD, NekDouble> (nPointsTot);
140  //vector reused to avoid even more memory requirements
141  //names may be misleading
142  pFields[0]->HomogeneousBwdTrans(gradV0,tmp);
143  Vmath::Vmul(nPointsTot,tmp,1,pV[0],1,pOutarray,1); // + u*du/dx
144  pFields[0]->HomogeneousBwdTrans(gradV1,tmp);
145  Vmath::Vvtvp(nPointsTot,tmp,1,pV[1],1,pOutarray,1,pOutarray,1);// + v*du/dy
146  pFields[0]->HomogeneousBwdTrans(gradV2,tmp);
147  Vmath::Vvtvp(nPointsTot,tmp,1,pV[2],1,pOutarray,1,pOutarray,1);// + w*du/dz
148 
149  pFields[0]->HomogeneousBwdTrans(pU,Up);
150  Vmath::Vmul(nPointsTot,Up,1,pV[0],1,gradV0,1);
151  Vmath::Vmul(nPointsTot,Up,1,pV[1],1,gradV1,1);
152  Vmath::Vmul(nPointsTot,Up,1,pV[2],1,gradV2,1);
153 
154  pFields[0]->SetWaveSpace(false);
155  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);//duu/dx
156  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
157  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);//duv/dy
158  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
159  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);//duw/dz
160  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
161  pFields[0]->SetWaveSpace(true);
162 
163  Vmath::Smul(nPointsTot,0.5,pOutarray,1,tmp,1);
164  pFields[0]->HomogeneousFwdTrans(tmp,pOutarray);
165  }
166  else if(pFields[0]->GetWaveSpace() == false && m_homogen_dealiasing == false)
167  {
168  Vmath::Vmul(nPointsTot,gradV0,1,pV[0],1,pOutarray,1);
169  Vmath::Vvtvp(nPointsTot,gradV1,1,pV[1],1,pOutarray,1,pOutarray,1);
170  Vmath::Vvtvp(nPointsTot,gradV2,1,pV[2],1,pOutarray,1,pOutarray,1);
171  Vmath::Vmul(nPointsTot,pU,1,pV[0],1,gradV0,1);
172  Vmath::Vmul(nPointsTot,pU,1,pV[1],1,gradV1,1);
173  Vmath::Vmul(nPointsTot,pU,1,pV[2],1,gradV2,1);
174  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],gradV0,tmp);
175  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
176  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],gradV1,tmp);
177  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
178  pFields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],gradV2,tmp);
179  Vmath::Vadd(nPointsTot,tmp,1,pOutarray,1,pOutarray,1);
180  Vmath::Smul(nPointsTot,0.5,pOutarray,1,pOutarray,1);
181  }
182  else
183  {
184  ASSERTL0(false, "Dealiasing is not allowed in combination "
185  "with the Skew-Symmetric advection form for "
186  "efficiency reasons.");
187  }
188  break;
189  default:
190  ASSERTL0(false,"dimension unknown");
191  }
192  }
193 
194 } //end of namespace
195