Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AdvectionWeakDG.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: AdvectionWeakDG.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: Weak DG advection class.
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 #include <iostream>
38 #include <iomanip>
39 
40 namespace Nektar
41 {
42  namespace SolverUtils
43  {
45  RegisterCreatorFunction("WeakDG", AdvectionWeakDG::create);
46 
48  {
49  }
50 
51  /**
52  * @brief Initialise AdvectionWeakDG objects and store them before
53  * 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 
65  /**
66  * @brief Compute the advection term at each time-step using the
67  * Discontinuous Glaerkin approach (DG).
68  *
69  * @param nConvectiveFields Number of fields.
70  * @param fields Pointer to fields.
71  * @param advVel Advection velocities.
72  * @param inarray Solution at the previous time-step.
73  * @param outarray Advection term to be passed at the
74  * time integration class.
75  */
77  const int nConvectiveFields,
78  const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
79  const Array<OneD, Array<OneD, NekDouble> > &advVel,
80  const Array<OneD, Array<OneD, NekDouble> > &inarray,
81  Array<OneD, Array<OneD, NekDouble> > &outarray,
82  const NekDouble &time)
83  {
84  int nDim = fields[0]->GetCoordim(0);
85  int nPointsTot = fields[0]->GetTotPoints();
86  int nCoeffs = fields[0]->GetNcoeffs();
87  int nTracePointsTot = fields[0]->GetTrace()->GetTotPoints();
88  int i, j;
89 
90  Array<OneD, Array<OneD, NekDouble> > tmp(nConvectiveFields);
91  Array<OneD, Array<OneD, Array<OneD, NekDouble> > > fluxvector(
92  nConvectiveFields);
93 
94  // Allocate storage for flux vector F(u).
95  for (i = 0; i < nConvectiveFields; ++i)
96  {
97  fluxvector[i] =
98  Array<OneD, Array<OneD, NekDouble> >(m_spaceDim);
99  for (j = 0; j < m_spaceDim; ++j)
100  {
101  fluxvector[i][j] = Array<OneD, NekDouble>(nPointsTot);
102  }
103  }
104 
106  "Riemann solver must be provided for AdvectionWeakDG.");
107 
108  m_fluxVector(inarray, fluxvector);
109 
110  // Get the advection part (without numerical flux)
111  for(i = 0; i < nConvectiveFields; ++i)
112  {
113  tmp[i] = Array<OneD, NekDouble>(nCoeffs, 0.0);
114 
115  for (j = 0; j < nDim; ++j)
116  {
117  fields[i]->IProductWRTDerivBase(j, fluxvector[i][j],
118  outarray[i]);
119  Vmath::Vadd(nCoeffs, outarray[i], 1, tmp[i], 1, tmp[i], 1);
120  }
121  }
122 
123  // Store forwards/backwards space along trace space
124  Array<OneD, Array<OneD, NekDouble> > Fwd (nConvectiveFields);
125  Array<OneD, Array<OneD, NekDouble> > Bwd (nConvectiveFields);
126  Array<OneD, Array<OneD, NekDouble> > numflux(nConvectiveFields);
127 
128  for(i = 0; i < nConvectiveFields; ++i)
129  {
130  Fwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
131  Bwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
132  numflux[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
133  fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
134  }
135 
136  m_riemann->Solve(m_spaceDim, Fwd, Bwd, numflux);
137 
138  // Evaulate <\phi, \hat{F}\cdot n> - OutField[i]
139  for(i = 0; i < nConvectiveFields; ++i)
140  {
141  Vmath::Neg (nCoeffs, tmp[i], 1);
142  fields[i]->AddTraceIntegral (numflux[i], tmp[i]);
143  fields[i]->MultiplyByElmtInvMass(tmp[i], tmp[i]);
144  fields[i]->BwdTrans (tmp[i], outarray[i]);
145  }
146  }
147  }//end of namespace SolverUtils
148 }//end of namespace Nektar