Nektar++
Loading...
Searching...
No Matches
NSAdvectionLevelSet.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: NSAdvectionLevelSet.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: Evaluation of the Navier Stokes advective term for VCSLevelSet
32//
33///////////////////////////////////////////////////////////////////////////////
34
36
37namespace Nektar
38{
41 "NSLevelSet", NSAdvectionLevelSet::create, "NSLevelSet");
42
43/**
44 *
45 */
50
51/**
52 *
53 */
60
61/**
62 *
63 */
65 const int nConvectiveFields,
67 const Array<OneD, Array<OneD, NekDouble>> &advVel,
68 const Array<OneD, Array<OneD, NekDouble>> &inarray,
70 [[maybe_unused]] const NekDouble &time,
71 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &pFwd,
72 [[maybe_unused]] const Array<OneD, Array<OneD, NekDouble>> &pBwd)
73{
74 int nqtot = fields[0]->GetTotPoints();
75 ASSERTL1(nConvectiveFields == inarray.size(),
76 "Number of convective fields and Inarray are not compatible");
77
78 // use dimension of Velocity vector to dictate dimension of operation
79 int ndim = advVel.size();
80 Array<OneD, Array<OneD, NekDouble>> AdvVel(advVel.size());
81
83
84 // LibUtilities::Timer timer;
85 for (int i = 0; i < ndim; ++i)
86 {
87 velocity[i] = advVel[i];
88 }
89
90 int nPointsTot = fields[0]->GetNpoints();
91 Array<OneD, NekDouble> grad0, grad1, grad2, wkSp;
92
93 for (int i = 0; i < ndim; ++i)
94 {
95 AdvVel[i] = velocity[i];
96 }
97
98 wkSp = Array<OneD, NekDouble>(nPointsTot);
99
100 switch (ndim)
101 {
102 case 1:
103 {
104 grad0 = Array<OneD, NekDouble>(fields[0]->GetNpoints());
105 for (int n = 0; n < nConvectiveFields; ++n)
106 {
107 fields[0]->PhysDeriv(inarray[n], grad0);
108 Vmath::Vmul(nPointsTot, grad0, 1, AdvVel[0], 1, outarray[n], 1);
109 }
110 Vmath::Zero(nqtot, outarray[ndim + 1], 1);
111 Vmath::Zero(nqtot, outarray[ndim + 2], 1);
112 break;
113 }
114 case 2:
115 {
116 grad0 = Array<OneD, NekDouble>(nqtot);
117 grad1 = Array<OneD, NekDouble>(nqtot);
118 for (int n = 0; n < nConvectiveFields; ++n)
119 {
120 fields[0]->PhysDeriv(inarray[n], grad0, grad1);
121 Vmath::Vmul(nPointsTot, grad0, 1, AdvVel[0], 1, outarray[n], 1);
122 Vmath::Vvtvp(nPointsTot, grad1, 1, AdvVel[1], 1, outarray[n], 1,
123 outarray[n], 1);
124 }
125 Vmath::Zero(nqtot, outarray[ndim + 1], 1);
126 Vmath::Zero(nqtot, outarray[ndim + 2], 1);
127 break;
128 }
129 case 3:
130 {
131 grad0 = Array<OneD, NekDouble>(nqtot);
132 grad1 = Array<OneD, NekDouble>(nqtot);
133 grad2 = Array<OneD, NekDouble>(nqtot);
134 Array<OneD, NekDouble> tmp = grad2;
135 for (int n = 0; n < nConvectiveFields; ++n)
136 {
137 fields[0]->PhysDeriv(inarray[n], grad0, grad1, grad2);
138 Vmath::Vmul(nPointsTot, grad0, 1, AdvVel[0], 1, outarray[n], 1);
139 Vmath::Vvtvp(nPointsTot, grad1, 1, AdvVel[1], 1, outarray[n], 1,
140 outarray[n], 1);
141 Vmath::Vvtvp(nPointsTot, grad2, 1, AdvVel[2], 1, outarray[n], 1,
142 outarray[n], 1);
143 }
144 Vmath::Zero(nqtot, outarray[ndim + 1], 1);
145 Vmath::Zero(nqtot, outarray[ndim + 2], 1);
146 break;
147 }
148 default:
149 ASSERTL0(false, "dimension unknown");
150 }
151
152 for (int n = 0; n < nConvectiveFields; ++n)
153 {
154 Vmath::Neg(nqtot, outarray[n], 1);
155 }
156}
157
158} // namespace Nektar
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static SolverUtils::AdvectionSharedPtr create(std::string)
Creates an instance of this class.
void v_Advect(const int nConvectiveFields, 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.
void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields) override
Initialises the advection object.
static std::string className
Name of class.
An abstract base class encapsulating the concept of advection of a vector field.
Definition Advection.h:81
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Definition Advection.cpp:43
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:74
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition Vmath.hpp:294
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:368
void Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:275