Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // 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: Non-conservative advection class.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 namespace Nektar
39 {
40  namespace SolverUtils
41  {
43  RegisterCreatorFunction("NonConservative",
45 
47  {
48 
49  }
50 
51  /**
52  * @brief Initialise AdvectionNonConservative objects and store them
53  * before starting the time-stepping.
54  *
55  * @param pSession Pointer to session reader.
56  * @param pFields Pointer to fields.
57  */
61  {
62  Advection::v_InitObject(pSession, pFields);
63  }
64 
66  const int nConvectiveFields,
68  const Array<OneD, Array<OneD, NekDouble> > &advVel,
69  const Array<OneD, Array<OneD, NekDouble> > &inarray,
70  Array<OneD, Array<OneD, NekDouble> > &outarray,
71  const NekDouble &time)
72  {
73  int nDim = advVel.num_elements();
74  int nPointsTot = fields[0]->GetNpoints();
75  Array<OneD, NekDouble> grad0,grad1,grad2;
76 
77  grad0 = Array<OneD, NekDouble> (nPointsTot);
78 
79  if (nDim > 1)
80  {
81  grad1 = Array<OneD,NekDouble>(nPointsTot);
82  }
83 
84  if (nDim > 2)
85  {
86  grad2 = Array<OneD,NekDouble>(nPointsTot);
87  }
88 
89 
90  for (int i = 0; i < nConvectiveFields; ++i)
91  {
92  // Evaluate V \cdot Grad(u)
93  switch(nDim)
94  {
95  case 1:
96  fields[0]->PhysDeriv(inarray[i], grad0);
97 
98  Vmath::Vmul(nPointsTot,
99  grad0, 1,
100  advVel[0], 1,
101  outarray[i], 1);
102  break;
103  case 2:
104  fields[0]->PhysDeriv(inarray[i], grad0, grad1);
105 
106 
107  // Calculate advection terms
108  Vmath::Vmul (nPointsTot,
109  grad0, 1,
110  advVel[0], 1,
111  outarray[i], 1);
112 
113  Vmath::Vvtvp(nPointsTot,
114  grad1, 1,
115  advVel[1], 1,
116  outarray[i], 1,
117  outarray[i], 1);
118 
119  break;
120  case 3:
121  fields[0]->PhysDeriv(inarray[i], grad0, grad1, grad2);
122 
123  // Calculate advection terms
124  Vmath::Vmul (nPointsTot,
125  grad0, 1,
126  advVel[0], 1,
127  outarray[i], 1);
128 
129  Vmath::Vvtvp(nPointsTot,
130  grad1, 1,
131  advVel[1], 1,
132  outarray[i], 1,
133  outarray[i], 1);
134 
135  Vmath::Vvtvp(nPointsTot,
136  grad2, 1,
137  advVel[2], 1,
138  outarray[i], 1,
139  outarray[i], 1);
140  break;
141  default:
142  ASSERTL0(false,"dimension unknown");
143  }
144  }
145  }
146  }
147 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
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
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)
Advects a vector field.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:46
double NekDouble
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.
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:97
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