Nektar++
AdvectionNonConservative.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: AdvectionNonConservative.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: Non-conservative advection class.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
38 
39 namespace Nektar
40 {
41  namespace SolverUtils
42  {
44  RegisterCreatorFunction("NonConservative",
46 
48  {
49 
50  }
51 
52  /**
53  * @brief Initialise AdvectionNonConservative objects and store them
54  * before starting the time-stepping.
55  *
56  * @param pSession Pointer to session reader.
57  * @param pFields Pointer to fields.
58  */
62  {
63  Advection::v_InitObject(pSession, pFields);
64  }
65 
67  const int nConvectiveFields,
69  const Array<OneD, Array<OneD, NekDouble> > &advVel,
70  const Array<OneD, Array<OneD, NekDouble> > &inarray,
71  Array<OneD, Array<OneD, NekDouble> > &outarray,
72  const NekDouble &time,
73  const Array<OneD, Array<OneD, NekDouble> > &pFwd,
74  const Array<OneD, Array<OneD, NekDouble> > &pBwd)
75  {
76  boost::ignore_unused(time, pFwd, pBwd);
77 
78  int nDim = advVel.size();
79  int nPointsTot = fields[0]->GetNpoints();
80  Array<OneD, NekDouble> grad0,grad1,grad2;
81 
82  grad0 = Array<OneD, NekDouble> (nPointsTot);
83 
84  if (nDim > 1)
85  {
86  grad1 = Array<OneD,NekDouble>(nPointsTot);
87  }
88 
89  if (nDim > 2)
90  {
91  grad2 = Array<OneD,NekDouble>(nPointsTot);
92  }
93 
94 
95  for (int i = 0; i < nConvectiveFields; ++i)
96  {
97  // Evaluate V \cdot Grad(u)
98  switch(nDim)
99  {
100  case 1:
101  fields[0]->PhysDeriv(inarray[i], grad0);
102 
103  Vmath::Vmul(nPointsTot,
104  grad0, 1,
105  advVel[0], 1,
106  outarray[i], 1);
107  break;
108  case 2:
109  fields[0]->PhysDeriv(inarray[i], grad0, grad1);
110 
111 
112  // Calculate advection terms
113  Vmath::Vmul (nPointsTot,
114  grad0, 1,
115  advVel[0], 1,
116  outarray[i], 1);
117 
118  Vmath::Vvtvp(nPointsTot,
119  grad1, 1,
120  advVel[1], 1,
121  outarray[i], 1,
122  outarray[i], 1);
123 
124  break;
125  case 3:
126  fields[0]->PhysDeriv(inarray[i], grad0, grad1, grad2);
127 
128  // Calculate advection terms
129  Vmath::Vmul (nPointsTot,
130  grad0, 1,
131  advVel[0], 1,
132  outarray[i], 1);
133 
134  Vmath::Vvtvp(nPointsTot,
135  grad1, 1,
136  advVel[1], 1,
137  outarray[i], 1,
138  outarray[i], 1);
139 
140  Vmath::Vvtvp(nPointsTot,
141  grad2, 1,
142  advVel[2], 1,
143  outarray[i], 1,
144  outarray[i], 1);
145  break;
146  default:
147  ASSERTL0(false,"dimension unknown");
148  }
149  }
150  }
151  }
152 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:366
virtual void v_Advect(const int nConvective, 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.
static AdvectionSharedPtr create(std::string advType)
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialise AdvectionNonConservative objects and store them before starting the time-stepping.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
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:192
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:513