Nektar++
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// 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: Non-conservative advection class.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include <boost/core/ignore_unused.hpp>
36
38
39namespace Nektar
40{
41namespace SolverUtils
42{
45 "NonConservative", AdvectionNonConservative::create,
46 "Non Conservative");
47
49{
50}
51
52/**
53 * @brief Initialise AdvectionNonConservative objects and store them
54 * before 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 *
68 */
70 const int nConvectiveFields,
72 const Array<OneD, Array<OneD, NekDouble>> &advVel,
73 const Array<OneD, Array<OneD, NekDouble>> &inarray,
74 Array<OneD, Array<OneD, NekDouble>> &outarray, const NekDouble &time,
75 const Array<OneD, Array<OneD, NekDouble>> &pFwd,
76 const Array<OneD, Array<OneD, NekDouble>> &pBwd)
77{
78 boost::ignore_unused(time, pFwd, pBwd);
79
80 int nDim = advVel.size();
81 int nPointsTot = fields[0]->GetNpoints();
82 Array<OneD, NekDouble> grad0, grad1, grad2;
83
84 grad0 = Array<OneD, NekDouble>(nPointsTot);
85
86 if (nDim > 1)
87 {
88 grad1 = Array<OneD, NekDouble>(nPointsTot);
89 }
90
91 if (nDim > 2)
92 {
93 grad2 = Array<OneD, NekDouble>(nPointsTot);
94 }
95
96 for (int i = 0; i < nConvectiveFields; ++i)
97 {
98 // Evaluate V \cdot Grad(u)
99 switch (nDim)
100 {
101 case 1:
102 fields[0]->PhysDeriv(inarray[i], grad0);
103
104 Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
105 break;
106 case 2:
107 fields[0]->PhysDeriv(inarray[i], grad0, grad1);
108
109 // Calculate advection terms
110 Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
111
112 Vmath::Vvtvp(nPointsTot, grad1, 1, advVel[1], 1, outarray[i], 1,
113 outarray[i], 1);
114
115 break;
116 case 3:
117 fields[0]->PhysDeriv(inarray[i], grad0, grad1, grad2);
118
119 // Calculate advection terms
120 Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
121
122 Vmath::Vvtvp(nPointsTot, grad1, 1, advVel[1], 1, outarray[i], 1,
123 outarray[i], 1);
124
125 Vmath::Vvtvp(nPointsTot, grad2, 1, advVel[2], 1, outarray[i], 1,
126 outarray[i], 1);
127 break;
128 default:
129 ASSERTL0(false, "dimension unknown");
130 }
131 }
132}
133} // namespace SolverUtils
134} // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:299
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) override
Advects a vector field.
static AdvectionSharedPtr create(std::string advType)
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields) override
Initialise AdvectionNonConservative objects and store them before starting the time-stepping.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition: Advection.cpp:47
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:207
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:569