Nektar++
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 // 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: Weak DG advection class.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
38 #include <iostream>
39 #include <iomanip>
40 
41 namespace Nektar
42 {
43  namespace SolverUtils
44  {
46  RegisterCreatorFunction("WeakDG", AdvectionWeakDG::create);
47 
49  {
50  }
51 
52  /**
53  * @brief Initialise AdvectionWeakDG objects and store them before
54  * 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 
66  /**
67  * @brief Compute the advection term at each time-step using the
68  * Discontinuous Galerkin approach (DG).
69  *
70  * @param nConvectiveFields Number of fields.
71  * @param fields Pointer to fields.
72  * @param advVel Advection velocities.
73  * @param inarray Solution at the previous time-step.
74  * @param outarray Advection term to be passed at the
75  * time integration class.
76  */
78  const int nConvectiveFields,
80  const Array<OneD, Array<OneD, NekDouble> > &advVel,
81  const Array<OneD, Array<OneD, NekDouble> > &inarray,
82  Array<OneD, Array<OneD, NekDouble> > &outarray,
83  const NekDouble &time,
84  const Array<OneD, Array<OneD, NekDouble> > &pFwd,
85  const Array<OneD, Array<OneD, NekDouble> > &pBwd)
86  {
87  boost::ignore_unused(advVel, time);
88 
89  int nPointsTot = fields[0]->GetTotPoints();
90  int nCoeffs = fields[0]->GetNcoeffs();
91  int nTracePointsTot = fields[0]->GetTrace()->GetTotPoints();
92  int i, j;
93 
94  Array<OneD, Array<OneD, NekDouble> > tmp(nConvectiveFields);
96  nConvectiveFields);
97 
98  // Allocate storage for flux vector F(u).
99  for (i = 0; i < nConvectiveFields; ++i)
100  {
101  fluxvector[i] =
103  for (j = 0; j < m_spaceDim; ++j)
104  {
105  fluxvector[i][j] = Array<OneD, NekDouble>(nPointsTot);
106  }
107  }
108 
110  "Riemann solver must be provided for AdvectionWeakDG.");
111 
112  m_fluxVector(inarray, fluxvector);
113 
114  // Get the advection part (without numerical flux)
115  for(i = 0; i < nConvectiveFields; ++i)
116  {
117  tmp[i] = Array<OneD, NekDouble>(nCoeffs, 0.0);
118 
119  fields[i]->IProductWRTDerivBase(fluxvector[i],tmp[i]);
120  }
121 
122  // Store forwards/backwards space along trace space
123  Array<OneD, Array<OneD, NekDouble> > Fwd (nConvectiveFields);
124  Array<OneD, Array<OneD, NekDouble> > Bwd (nConvectiveFields);
125  Array<OneD, Array<OneD, NekDouble> > numflux(nConvectiveFields);
126 
127  if (pFwd == NullNekDoubleArrayofArray ||
129  {
130  for(i = 0; i < nConvectiveFields; ++i)
131  {
132  Fwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
133  Bwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
134  numflux[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
135  fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
136  }
137  }
138  else
139  {
140  for(i = 0; i < nConvectiveFields; ++i)
141  {
142  Fwd[i] = pFwd[i];
143  Bwd[i] = pBwd[i];
144  numflux[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
145  }
146  }
147 
148  m_riemann->Solve(m_spaceDim, Fwd, Bwd, numflux);
149 
150  // Evaulate <\phi, \hat{F}\cdot n> - OutField[i]
151  for(i = 0; i < nConvectiveFields; ++i)
152  {
153  Vmath::Neg (nCoeffs, tmp[i], 1);
154  fields[i]->AddTraceIntegral (numflux[i], tmp[i]);
155  fields[i]->MultiplyByElmtInvMass(tmp[i], tmp[i]);
156  fields[i]->BwdTrans (tmp[i], outarray[i]);
157  }
158  }
159  }//end of namespace SolverUtils
160 }//end of namespace Nektar
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialise AdvectionWeakDG objects and store them before starting the time-stepping.
RiemannSolverSharedPtr m_riemann
Riemann solver for DG-type schemes.
Definition: Advection.h:143
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:47
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:399
double NekDouble
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)
Compute the advection term at each time-step using the Discontinuous Galerkin approach (DG)...
AdvectionFluxVecCB m_fluxVector
Callback function to the flux vector (set when advection is in conservative form).
Definition: Advection.h:141
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
int m_spaceDim
Storage for space dimension. Used for homogeneous extension.
Definition: Advection.h:145
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
static AdvectionSharedPtr create(std::string advType)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:98