Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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  const Array<OneD, Array<OneD, NekDouble> > &pFwd,
73  const Array<OneD, Array<OneD, NekDouble> > &pBwd)
74  {
75  int nDim = advVel.num_elements();
76  int nPointsTot = fields[0]->GetNpoints();
77  Array<OneD, NekDouble> grad0,grad1,grad2;
78 
79  grad0 = Array<OneD, NekDouble> (nPointsTot);
80 
81  if (nDim > 1)
82  {
83  grad1 = Array<OneD,NekDouble>(nPointsTot);
84  }
85 
86  if (nDim > 2)
87  {
88  grad2 = Array<OneD,NekDouble>(nPointsTot);
89  }
90 
91 
92  for (int i = 0; i < nConvectiveFields; ++i)
93  {
94  // Evaluate V \cdot Grad(u)
95  switch(nDim)
96  {
97  case 1:
98  fields[0]->PhysDeriv(inarray[i], grad0);
99 
100  Vmath::Vmul(nPointsTot,
101  grad0, 1,
102  advVel[0], 1,
103  outarray[i], 1);
104  break;
105  case 2:
106  fields[0]->PhysDeriv(inarray[i], grad0, grad1);
107 
108 
109  // Calculate advection terms
110  Vmath::Vmul (nPointsTot,
111  grad0, 1,
112  advVel[0], 1,
113  outarray[i], 1);
114 
115  Vmath::Vvtvp(nPointsTot,
116  grad1, 1,
117  advVel[1], 1,
118  outarray[i], 1,
119  outarray[i], 1);
120 
121  break;
122  case 3:
123  fields[0]->PhysDeriv(inarray[i], grad0, grad1, grad2);
124 
125  // Calculate advection terms
126  Vmath::Vmul (nPointsTot,
127  grad0, 1,
128  advVel[0], 1,
129  outarray[i], 1);
130 
131  Vmath::Vvtvp(nPointsTot,
132  grad1, 1,
133  advVel[1], 1,
134  outarray[i], 1,
135  outarray[i], 1);
136 
137  Vmath::Vvtvp(nPointsTot,
138  grad2, 1,
139  advVel[2], 1,
140  outarray[i], 1,
141  outarray[i], 1);
142  break;
143  default:
144  ASSERTL0(false,"dimension unknown");
145  }
146  }
147  }
148  }
149 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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:442
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
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.
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:100
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:183