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
36
37namespace Nektar::SolverUtils
38{
41 "NonConservative", AdvectionNonConservative::create,
42 "Non Conservative");
43
45{
46}
47
48/**
49 * @brief Initialise AdvectionNonConservative objects and store them
50 * before starting the time-stepping.
51 *
52 * @param pSession Pointer to session reader.
53 * @param pFields Pointer to fields.
54 */
58{
59 Advection::v_InitObject(pSession, pFields);
60}
61
62/**
63 *
64 */
66 const int nConvectiveFields,
68 const Array<OneD, Array<OneD, NekDouble>> &advVel,
69 const Array<OneD, Array<OneD, NekDouble>> &inarray,
71 [[maybe_unused]] const NekDouble &time,
72 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &pFwd,
73 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &pBwd)
74{
75 int nDim = advVel.size();
76 int nPointsTot = fields[0]->GetNpoints();
77 Array<OneD, NekDouble> grad0, grad1, grad2;
78
79 grad0 = Array<OneD, NekDouble>(nPointsTot);
80
81 if (nDim > 1)
82 {
83 grad1 = Array<OneD, NekDouble>(nPointsTot);
84 }
85
86 if (nDim > 2)
87 {
88 grad2 = Array<OneD, NekDouble>(nPointsTot);
89 }
90
91 for (int i = 0; i < nConvectiveFields; ++i)
92 {
93 // Evaluate V \cdot Grad(u)
94 switch (nDim)
95 {
96 case 1:
97 fields[0]->PhysDeriv(inarray[i], grad0);
98
99 Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
100 break;
101 case 2:
102 fields[0]->PhysDeriv(inarray[i], grad0, grad1);
103
104 // Calculate advection terms
105 Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
106
107 Vmath::Vvtvp(nPointsTot, grad1, 1, advVel[1], 1, outarray[i], 1,
108 outarray[i], 1);
109
110 break;
111 case 3:
112 fields[0]->PhysDeriv(inarray[i], grad0, grad1, grad2);
113
114 // Calculate advection terms
115 Vmath::Vmul(nPointsTot, grad0, 1, advVel[0], 1, outarray[i], 1);
116
117 Vmath::Vvtvp(nPointsTot, grad1, 1, advVel[1], 1, outarray[i], 1,
118 outarray[i], 1);
119
120 Vmath::Vvtvp(nPointsTot, grad2, 1, advVel[2], 1, outarray[i], 1,
121 outarray[i], 1);
122 break;
123 default:
124 ASSERTL0(false, "dimension unknown");
125 }
126 }
127}
128} // namespace Nektar::SolverUtils
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Definition: Advection.cpp:295
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)
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:43
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.hpp:72
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.hpp:366