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  */
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  {
84  int nPointsTot = fields[0]->GetTotPoints();
85  int nCoeffs = fields[0]->GetNcoeffs();
86  int nTracePointsTot = fields[0]->GetTrace()->GetTotPoints();
87  int i, j;
88 
89  Array<OneD, Array<OneD, NekDouble> > tmp(nConvectiveFields);
91  nConvectiveFields);
92 
93  // Allocate storage for flux vector F(u).
94  for (i = 0; i < nConvectiveFields; ++i)
95  {
96  fluxvector[i] =
98  for (j = 0; j < m_spaceDim; ++j)
99  {
100  fluxvector[i][j] = Array<OneD, NekDouble>(nPointsTot);
101  }
102  }
103 
105  "Riemann solver must be provided for AdvectionWeakDG.");
106 
107  m_fluxVector(inarray, fluxvector);
108 
109  // Get the advection part (without numerical flux)
110  for(i = 0; i < nConvectiveFields; ++i)
111  {
112  tmp[i] = Array<OneD, NekDouble>(nCoeffs, 0.0);
113 
114  fields[i]->IProductWRTDerivBase(fluxvector[i],tmp[i]);
115  }
116 
117  // Store forwards/backwards space along trace space
118  Array<OneD, Array<OneD, NekDouble> > Fwd (nConvectiveFields);
119  Array<OneD, Array<OneD, NekDouble> > Bwd (nConvectiveFields);
120  Array<OneD, Array<OneD, NekDouble> > numflux(nConvectiveFields);
121 
122  for(i = 0; i < nConvectiveFields; ++i)
123  {
124  Fwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
125  Bwd[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
126  numflux[i] = Array<OneD, NekDouble>(nTracePointsTot, 0.0);
127  fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
128  }
129 
130  m_riemann->Solve(m_spaceDim, Fwd, Bwd, numflux);
131 
132  // Evaulate <\phi, \hat{F}\cdot n> - OutField[i]
133  for(i = 0; i < nConvectiveFields; ++i)
134  {
135  Vmath::Neg (nCoeffs, tmp[i], 1);
136  fields[i]->AddTraceIntegral (numflux[i], tmp[i]);
137  fields[i]->MultiplyByElmtInvMass(tmp[i], tmp[i]);
138  fields[i]->BwdTrans (tmp[i], outarray[i]);
139  }
140  }
141  }//end of namespace SolverUtils
142 }//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:134
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:382
double NekDouble
AdvectionFluxVecCB m_fluxVector
Callback function to the flux vector (set when advection is in conservative form).
Definition: Advection.h:132
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)
Compute the advection term at each time-step using the Discontinuous Glaerkin approach (DG)...
int m_spaceDim
Storage for space dimension. Used for homogeneous extension.
Definition: Advection.h:136
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:218
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:97