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  */
60  Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
61  {
62  Advection::v_InitObject(pSession, pFields);
63  }
64 
66  const int nConvectiveFields,
67  const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
68  const Array<OneD, Array<OneD, NekDouble> > &advVel,
69  const Array<OneD, Array<OneD, NekDouble> > &inarray,
70  Array<OneD, Array<OneD, NekDouble> > &outarray)
71  {
72  int nDim = advVel.num_elements();
73  int nPointsTot = fields[0]->GetNpoints();
74  Array<OneD, NekDouble> grad0,grad1,grad2;
75 
76  grad0 = Array<OneD, NekDouble> (nPointsTot);
77 
78  if (nDim > 1)
79  {
80  grad1 = Array<OneD,NekDouble>(nPointsTot);
81  }
82 
83  if (nDim > 2)
84  {
85  grad2 = Array<OneD,NekDouble>(nPointsTot);
86  }
87 
88 
89  for (int i = 0; i < nConvectiveFields; ++i)
90  {
91  // Evaluate V \cdot Grad(u)
92  switch(nDim)
93  {
94  case 1:
95  fields[0]->PhysDeriv(inarray[i], grad0);
96 
97  Vmath::Vmul(nPointsTot,
98  grad0, 1,
99  advVel[0], 1,
100  outarray[i], 1);
101  break;
102  case 2:
103  fields[0]->PhysDeriv(inarray[i], grad0, grad1);
104 
105 
106  // Calculate advection terms
107  Vmath::Vmul (nPointsTot,
108  grad0, 1,
109  advVel[0], 1,
110  outarray[i], 1);
111 
112  Vmath::Vvtvp(nPointsTot,
113  grad1, 1,
114  advVel[1], 1,
115  outarray[i], 1,
116  outarray[i], 1);
117 
118  break;
119  case 3:
120  fields[0]->PhysDeriv(inarray[i], grad0, grad1, grad2);
121 
122  // Calculate advection terms
123  Vmath::Vmul (nPointsTot,
124  grad0, 1,
125  advVel[0], 1,
126  outarray[i], 1);
127 
128  Vmath::Vvtvp(nPointsTot,
129  grad1, 1,
130  advVel[1], 1,
131  outarray[i], 1,
132  outarray[i], 1);
133 
134  Vmath::Vvtvp(nPointsTot,
135  grad2, 1,
136  advVel[2], 1,
137  outarray[i], 1,
138  outarray[i], 1);
139  break;
140  default:
141  ASSERTL0(false,"dimension unknown");
142  }
143  }
144  }
145  }
146 }