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
37using namespace std;
38
39namespace Nektar
40{
41
44 "AlternateSkew", AlternateSkewAdvection::create,
45 "Alternating Skew Symmetric");
46
47/**
48 * Constructor. Creates ...
49 *
50 * \param
51 * \param
52 */
54{
55}
56
58{
59}
60
64{
65 boost::ignore_unused(fields);
66
67 pSession->MatchSolverInfo("ModeType", "SingleMode", m_SingleMode, false);
68 pSession->MatchSolverInfo("ModeType", "HalfMode", m_HalfMode, false);
69}
70
72 const int nConvectiveFields,
74 const Array<OneD, Array<OneD, NekDouble>> &advVel,
75 const Array<OneD, Array<OneD, NekDouble>> &inarray,
76 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble &time,
77 const Array<OneD, Array<OneD, NekDouble>> &pFwd,
78 const Array<OneD, Array<OneD, NekDouble>> &pBwd)
79{
80 boost::ignore_unused(time, pFwd, pBwd);
81
82 // use dimension of Velocity vector to dictate dimension of operation
83 int ndim = advVel.size();
84 int nPointsTot = fields[0]->GetNpoints();
86 for (int i = 0; i < ndim; ++i)
87 {
88 if (fields[i]->GetWaveSpace() && !m_SingleMode && !m_HalfMode)
89 {
90 velocity[i] = Array<OneD, NekDouble>(nPointsTot, 0.0);
91 fields[i]->HomogeneousBwdTrans(nPointsTot, advVel[i], velocity[i]);
92 }
93 else
94 {
95 velocity[i] = advVel[i];
96 }
97 }
98 for (int n = 0; n < nConvectiveFields; ++n)
99 {
100 // ToDo: here we should add a check that V has right dimension
101 Array<OneD, NekDouble> gradV0, gradV1, gradV2, tmp, Up;
102
103 gradV0 = Array<OneD, NekDouble>(nPointsTot);
104 tmp = Array<OneD, NekDouble>(nPointsTot);
105
106 // Evaluate V\cdot Grad(u)
107 switch (ndim)
108 {
109 case 1:
110 if (m_advectioncalls % 2 == 0)
111 {
112 fields[0]->PhysDeriv(inarray[n], gradV0);
113 Vmath::Vmul(nPointsTot, gradV0, 1, velocity[0], 1,
114 outarray[n], 1);
115 }
116 else
117 {
118 Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[0], 1,
119 gradV0, 1);
120 fields[0]->PhysDeriv(gradV0, outarray[n]);
121 }
122 Vmath::Smul(nPointsTot, 0.5, outarray[n], 1, outarray[n],
123 1); // must be mult by 0.5????
124 break;
125 case 2:
126 gradV1 = Array<OneD, NekDouble>(nPointsTot);
127 if (m_advectioncalls % 2 == 0)
128 {
129 fields[0]->PhysDeriv(inarray[n], gradV0, gradV1);
130 Vmath::Vmul(nPointsTot, gradV0, 1, velocity[0], 1,
131 outarray[n], 1);
132 Vmath::Vvtvp(nPointsTot, gradV1, 1, velocity[1], 1,
133 outarray[n], 1, outarray[n], 1);
134 }
135 else
136 {
137 Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[0], 1,
138 gradV0, 1);
139 Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[1], 1,
140 gradV1, 1);
141 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],
142 gradV0, outarray[n]);
143 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],
144 gradV1, tmp);
145 Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1, outarray[n],
146 1);
147 }
148 Vmath::Smul(nPointsTot, 1.0, outarray[n], 1, outarray[n],
149 1); // must be mult by 0.5????
150 break;
151 case 3:
152 gradV1 = Array<OneD, NekDouble>(nPointsTot);
153 gradV2 = Array<OneD, NekDouble>(nPointsTot);
154
155 // outarray[n] = 1/2(u*du/dx + v*du/dy + w*du/dz + duu/dx +
156 // duv/dy + duw/dz)
157
158 if (fields[0]->GetWaveSpace() == true)
159 {
160 if (m_advectioncalls % 2 == 0)
161 {
162 // vector reused to avoid even more memory requirements
163 // names may be misleading
164 fields[0]->PhysDeriv(inarray[n], gradV0, gradV1,
165 gradV2);
166 fields[0]->HomogeneousBwdTrans(nPointsTot, gradV0, tmp);
167 Vmath::Vmul(nPointsTot, tmp, 1, velocity[0], 1,
168 outarray[n], 1); // + u*du/dx
169 fields[0]->HomogeneousBwdTrans(nPointsTot, gradV1, tmp);
170 Vmath::Vvtvp(nPointsTot, tmp, 1, velocity[1], 1,
171 outarray[n], 1, outarray[n],
172 1); // + v*du/dy
173 fields[0]->HomogeneousBwdTrans(nPointsTot, gradV2, tmp);
174 Vmath::Vvtvp(nPointsTot, tmp, 1, velocity[2], 1,
175 outarray[n], 1, outarray[n],
176 1); // + w*du/dz
177 }
178 else
179 {
180 Up = Array<OneD, NekDouble>(nPointsTot);
181 fields[0]->HomogeneousBwdTrans(nPointsTot, inarray[n],
182 Up);
183 Vmath::Vmul(nPointsTot, Up, 1, velocity[0], 1, gradV0,
184 1);
185 Vmath::Vmul(nPointsTot, Up, 1, velocity[1], 1, gradV1,
186 1);
187 Vmath::Vmul(nPointsTot, Up, 1, velocity[2], 1, gradV2,
188 1);
189
190 fields[0]->SetWaveSpace(false);
191 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],
192 gradV0, outarray[n]); // duu/dx
193 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],
194 gradV1, tmp); // duv/dy
195 Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
196 outarray[n], 1);
197 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],
198 gradV2, tmp); // duw/dz
199 Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
200 outarray[n], 1);
201 fields[0]->SetWaveSpace(true);
202 }
203
204 Vmath::Smul(nPointsTot, 1.0, outarray[n], 1, tmp,
205 1); // must be mult by 0.5????
206 fields[0]->HomogeneousFwdTrans(nPointsTot, tmp,
207 outarray[n]);
208 }
209 else
210 {
211 if (m_advectioncalls % 2 == 0)
212 {
213 fields[0]->PhysDeriv(inarray[n], gradV0, gradV1,
214 gradV2);
215 Vmath::Vmul(nPointsTot, gradV0, 1, velocity[0], 1,
216 outarray[n], 1);
217 Vmath::Vvtvp(nPointsTot, gradV1, 1, velocity[1], 1,
218 outarray[n], 1, outarray[n], 1);
219 Vmath::Vvtvp(nPointsTot, gradV2, 1, velocity[2], 1,
220 outarray[n], 1, outarray[n], 1);
221 }
222 else
223 {
224 Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[0], 1,
225 gradV0, 1);
226 Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[1], 1,
227 gradV1, 1);
228 Vmath::Vmul(nPointsTot, inarray[n], 1, velocity[2], 1,
229 gradV2, 1);
230 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[0],
231 gradV0, outarray[n]);
232 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[1],
233 gradV1, tmp);
234 Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
235 outarray[n], 1);
236 fields[0]->PhysDeriv(MultiRegions::DirCartesianMap[2],
237 gradV2, tmp);
238 Vmath::Vadd(nPointsTot, tmp, 1, outarray[n], 1,
239 outarray[n], 1);
240 }
241 Vmath::Smul(nPointsTot, 1.0, outarray[n], 1, outarray[n],
242 1); // must be mult by 0.5????
243 }
244 break;
245 default:
246 ASSERTL0(false, "dimension unknown");
247 }
248 }
249}
250
251} // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
static SolverUtils::AdvectionSharedPtr create(std::string)
Creates an instance of this class.
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) override
Advects a vector field.
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields) override
Initialises the advection object.
static std::string className
Name of class.
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:83
std::shared_ptr< SessionReader > SessionReaderSharedPtr
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:90
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:2
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:207
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:569
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:354
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:245