Nektar++
TransMovingWall.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TransMovingWall.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: Abstract base class for Extrapolate.
32//
33///////////////////////////////////////////////////////////////////////////////
34
37
38namespace Nektar
39{
40
43 "TransMovingWall", TransMovingWall::create,
44 "Far field boundary condition of moving reference frame");
45
47 [[maybe_unused]] const LibUtilities::SessionReaderSharedPtr pSession,
48 [[maybe_unused]] Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
51 [[maybe_unused]] int nbnd, [[maybe_unused]] int spacedim,
52 [[maybe_unused]] int bnddim)
53 : StaticWall(pSession, pFields, cond, exp, nbnd, spacedim, bnddim)
54{
55 classname = "TransMovingWall";
56 m_pressure = cond.size() - 1;
57 for (size_t i = 0; i < m_bnddim; ++i)
58 {
59 if (cond[i]->GetUserDefined() == "TimeDependent")
60 {
61 m_BndConds[i] = cond[i];
62 }
63 }
64 if (cond[m_pressure]->GetUserDefined() == classname)
65 {
67 }
68}
69
72{
73 if (m_BndExp.empty())
74 {
75 return;
76 }
78 if (pSession->DefinesParameter("TimeStep"))
79 {
80 m_dt = pSession->GetParameter("TimeStep");
81 }
82 else
83 {
84 m_dt = 2.E-4;
85 }
86 NekDouble invdt = 1. / m_dt;
87 Fourth_Coeffs[0] = 1. / 12. * invdt;
88 Fourth_Coeffs[1] = -2. / 3. * invdt;
89 Fourth_Coeffs[2] = 2. / 3. * invdt;
90 Fourth_Coeffs[3] = -1. / 12. * invdt;
91}
92
94 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &fields,
95 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &Adv,
96 std::map<std::string, NekDouble> &params)
97{
98 if (m_BndExp.empty() || fields.size() == 0)
99 {
100 return;
101 }
102 ++m_numCalls;
103 int nptsPlane0 = 0;
104 SetNumPointsOnPlane0(nptsPlane0);
106 for (int i = 0; i < m_bnddim; ++i)
107 {
108 rhs[i] = Array<OneD, NekDouble>(m_npoints, 0.);
109 }
110 // add viscous term
111 AddVisPressureBCs(fields, rhs, params);
112 // Add DuDt
113 std::map<std::string, NekDouble> transParams;
114 std::vector<std::string> accStr = {"A_x", "A_y", "A_z"};
115 NekDouble time = 0., dt2 = 2. * m_dt;
116 if (params.find("Time") != params.end())
117 {
118 time = params["Time"];
119 }
120 std::vector<NekDouble> times = {time - dt2, time - m_dt, time + m_dt,
121 time + dt2};
122 for (int i = 0; i < m_bnddim; ++i)
123 {
124 if (m_BndConds.find(i) != m_BndConds.end() && nptsPlane0)
125 {
126 NekDouble dudt = 0.;
128 std::static_pointer_cast<
130 ->m_dirichletCondition;
131 for (int j = 0; j < times.size(); ++j)
132 {
133 dudt += Fourth_Coeffs[j] * equ.Evaluate(0, 0., 0., times[j]);
134 }
135 transParams[accStr[i]] = dudt;
136 }
137 }
138 AddRigidBodyAcc(rhs, transParams, nptsPlane0);
139 m_BndExp[m_pressure]->NormVectorIProductWRTBase(
140 rhs, m_BndExp[m_pressure]->UpdateCoeffs());
141}
142
143} // namespace Nektar
std::map< int, MultiRegions::ExpListSharedPtr > m_BndExp
int m_bnddim
bounday dimensionality
void AddRigidBodyAcc(Array< OneD, Array< OneD, NekDouble > > &N, std::map< std::string, NekDouble > &params, int npts0)
void SetNumPointsOnPlane0(int &npointsPlane0)
std::map< int, SpatialDomains::BoundaryConditionShPtr > m_BndConds
void AddVisPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, Array< OneD, Array< OneD, NekDouble > > &N, std::map< std::string, NekDouble > &params)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void v_Initialise(const LibUtilities::SessionReaderSharedPtr &pSession) override
Definition: StaticWall.cpp:62
static std::string className
TransMovingWall(const LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields, Array< OneD, SpatialDomains::BoundaryConditionShPtr > cond, Array< OneD, MultiRegions::ExpListSharedPtr > exp, int nbnd, int spacedim, int bnddim)
void v_Update(const Array< OneD, const Array< OneD, NekDouble > > &fields, const Array< OneD, const Array< OneD, NekDouble > > &Adv, std::map< std::string, NekDouble > &params) override
static IncBaseConditionSharedPtr create(const LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields, Array< OneD, SpatialDomains::BoundaryConditionShPtr > cond, Array< OneD, MultiRegions::ExpListSharedPtr > exp, int nbnd, int spacedim, int bnddim)
void v_Initialise(const LibUtilities::SessionReaderSharedPtr &pSession) override
std::shared_ptr< SessionReader > SessionReaderSharedPtr
IncBCFactory & GetIncBCFactory()
double NekDouble