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 {
45  "NonConservative", AdvectionNonConservative::create,
46  "Non Conservative");
47 
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, const NekDouble &time,
72  const Array<OneD, Array<OneD, NekDouble>> &pFwd,
73  const Array<OneD, Array<OneD, NekDouble>> &pBwd)
74 {
75  boost::ignore_unused(time, pFwd, pBwd);
76 
77  int nDim = advVel.size();
78  int nPointsTot = fields[0]->GetNpoints();
79  Array<OneD, NekDouble> grad0, grad1, grad2;
80 
81  grad0 = Array<OneD, NekDouble>(nPointsTot);
82 
83  if (nDim > 1)
84  {
85  grad1 = Array<OneD, NekDouble>(nPointsTot);
86  }
87 
88  if (nDim > 2)
89  {
90  grad2 = Array<OneD, NekDouble>(nPointsTot);
91  }
92 
93  for (int i = 0; i < nConvectiveFields; ++i)
94  {
95  // Evaluate V \cdot Grad(u)
96  switch (nDim)
97  {
98  case 1:
99  fields[0]->PhysDeriv(inarray[i], grad0);
100 
101  Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
102  break;
103  case 2:
104  fields[0]->PhysDeriv(inarray[i], grad0, grad1);
105 
106  // Calculate advection terms
107  Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
108 
109  Vmath::Vvtvp(nPointsTot, grad1, 1, advVel[1], 1, outarray[i], 1,
110  outarray[i], 1);
111 
112  break;
113  case 3:
114  fields[0]->PhysDeriv(inarray[i], grad0, grad1, grad2);
115 
116  // Calculate advection terms
117  Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
118 
119  Vmath::Vvtvp(nPointsTot, grad1, 1, advVel[1], 1, outarray[i], 1,
120  outarray[i], 1);
121 
122  Vmath::Vvtvp(nPointsTot, grad2, 1, advVel[2], 1, outarray[i], 1,
123  outarray[i], 1);
124  break;
125  default:
126  ASSERTL0(false, "dimension unknown");
127  }
128  }
129 }
130 } // namespace SolverUtils
131 } // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:353
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) override
Advects a vector field.
static AdvectionSharedPtr create(std::string advType)
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields) override
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: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:209
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:574