Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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  */
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,
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  const Array<OneD, Array<OneD, NekDouble> > &pFwd,
84  const Array<OneD, Array<OneD, NekDouble> > &pBwd)
85  {
86  int nPointsTot = fields[0]->GetTotPoints();
87  int nCoeffs = fields[0]->GetNcoeffs();
88  int nTracePointsTot = fields[0]->GetTrace()->GetTotPoints();
89  int i, j;
90 
91  Array<OneD, Array<OneD, NekDouble> > tmp(nConvectiveFields);
93  nConvectiveFields);
94 
95  // Allocate storage for flux vector F(u).
96  for (i = 0; i < nConvectiveFields; ++i)
97  {
98  fluxvector[i] =
100  for (j = 0; j < m_spaceDim; ++j)
101  {
102  fluxvector[i][j] = Array<OneD, NekDouble>(nPointsTot);
103  }
104  }
105 
107  "Riemann solver must be provided for AdvectionWeakDG.");
108 
109  m_fluxVector(inarray, fluxvector);
110 
111  // Get the advection part (without numerical flux)
112  for(i = 0; i < nConvectiveFields; ++i)
113  {
114  tmp[i] = Array<OneD, NekDouble>(nCoeffs, 0.0);
115 
116  fields[i]->IProductWRTDerivBase(fluxvector[i],tmp[i]);
117  }
118 
119  // Store forwards/backwards space along trace space
120  Array<OneD, Array<OneD, NekDouble> > Fwd (nConvectiveFields);
121  Array<OneD, Array<OneD, NekDouble> > Bwd (nConvectiveFields);
122  Array<OneD, Array<OneD, NekDouble> > numflux(nConvectiveFields);
123 
124  if (pFwd == NullNekDoubleArrayofArray ||
126  {
127  for(i = 0; i < nConvectiveFields; ++i)
128  {
129  Fwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
130  Bwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
131  numflux[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
132  fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
133  }
134  }
135  else
136  {
137  for(i = 0; i < nConvectiveFields; ++i)
138  {
139  Fwd[i] = pFwd[i];
140  Bwd[i] = pBwd[i];
141  numflux[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
142  }
143  }
144 
145  m_riemann->Solve(m_spaceDim, Fwd, Bwd, numflux);
146 
147  // Evaulate <\phi, \hat{F}\cdot n> - OutField[i]
148  for(i = 0; i < nConvectiveFields; ++i)
149  {
150  Vmath::Neg (nCoeffs, tmp[i], 1);
151  fields[i]->AddTraceIntegral (numflux[i], tmp[i]);
152  fields[i]->MultiplyByElmtInvMass(tmp[i], tmp[i]);
153  fields[i]->BwdTrans (tmp[i], outarray[i]);
154  }
155  }
156  }//end of namespace SolverUtils
157 }//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:138
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:46
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:396
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 Glaerkin approach (DG)...
AdvectionFluxVecCB m_fluxVector
Callback function to the flux vector (set when advection is in conservative form).
Definition: Advection.h:136
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
int m_spaceDim
Storage for space dimension. Used for homogeneous extension.
Definition: Advection.h:140
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
static AdvectionSharedPtr create(std::string advType)
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:100