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
71{
72}
73
76{
77 if (m_BndExp.empty())
78 {
79 return;
80 }
82 if (pSession->DefinesParameter("TimeStep"))
83 {
84 m_dt = pSession->GetParameter("TimeStep");
85 }
86 else
87 {
88 m_dt = 2.E-4;
89 }
90 NekDouble invdt = 1. / m_dt;
91 Fourth_Coeffs[0] = 1. / 12. * invdt;
92 Fourth_Coeffs[1] = -2. / 3. * invdt;
93 Fourth_Coeffs[2] = 2. / 3. * invdt;
94 Fourth_Coeffs[3] = -1. / 12. * invdt;
95}
96
98 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &fields,
99 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &Adv,
100 std::map<std::string, NekDouble> &params)
101{
102 if (m_BndExp.empty() || fields.size() == 0)
103 {
104 return;
105 }
106 ++m_numCalls;
107 int nptsPlane0 = 0;
108 SetNumPointsOnPlane0(nptsPlane0);
110 for (int i = 0; i < m_bnddim; ++i)
111 {
112 rhs[i] = Array<OneD, NekDouble>(m_npoints, 0.);
113 }
114 // add viscous term
115 AddVisPressureBCs(fields, rhs, params);
116 // Add DuDt
117 std::map<std::string, NekDouble> transParams;
118 std::vector<std::string> accStr = {"A_x", "A_y", "A_z"};
119 NekDouble time = 0., dt2 = 2. * m_dt;
120 if (params.find("Time") != params.end())
121 {
122 time = params["Time"];
123 }
124 std::vector<NekDouble> times = {time - dt2, time - m_dt, time + m_dt,
125 time + dt2};
126 for (int i = 0; i < m_bnddim; ++i)
127 {
128 if (m_BndConds.find(i) != m_BndConds.end() && nptsPlane0)
129 {
130 NekDouble dudt = 0.;
132 std::static_pointer_cast<
134 ->m_dirichletCondition;
135 for (int j = 0; j < times.size(); ++j)
136 {
137 dudt += Fourth_Coeffs[j] * equ.Evaluate(0, 0., 0., times[j]);
138 }
139 transParams[accStr[i]] = dudt;
140 }
141 }
142 AddRigidBodyAcc(rhs, transParams, nptsPlane0);
143 m_BndExp[m_pressure]->NormVectorIProductWRTBase(
144 rhs, m_BndExp[m_pressure]->UpdateCoeffs());
145}
146
147} // 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:65
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