Nektar++
Loading...
Searching...
No Matches
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: Translational moving wall boundary condition.
32//
33///////////////////////////////////////////////////////////////////////////////
34
37
38namespace Nektar
39{
40
43 "TransMovingWall", TransMovingWall::create,
44 "Translational moving wall boundary condition");
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 params.find("pressure") == params.end())
100 {
101 return;
102 }
103 ++m_numCalls;
104 int nptsPlane0 = 0;
105 SetNumPointsOnPlane0(nptsPlane0);
107 for (int i = 0; i < m_bnddim; ++i)
108 {
109 rhs[i] = Array<OneD, NekDouble>(m_npoints, 0.);
110 }
111 // add viscous term
112 AddExtrapVisPressureBCs(fields, rhs, params);
113 // Add DuDt
114 std::map<std::string, NekDouble> transParams;
115 std::vector<std::string> accStr = {"A_x", "A_y", "A_z"};
116 NekDouble time = 0., dt2 = 2. * m_dt;
117 if (params.find("Time") != params.end())
118 {
119 time = params["Time"];
120 }
121 std::vector<NekDouble> times = {time - dt2, time - m_dt, time + m_dt,
122 time + dt2};
123 for (int i = 0; i < m_bnddim; ++i)
124 {
125 if (m_BndConds.find(i) != m_BndConds.end() && nptsPlane0)
126 {
127 NekDouble dudt = 0.;
129 std::static_pointer_cast<
131 ->m_dirichletCondition;
132 for (int j = 0; j < times.size(); ++j)
133 {
134 dudt += Fourth_Coeffs[j] * equ->Evaluate(0, 0., 0., times[j]);
135 }
136 transParams[accStr[i]] = dudt;
137 }
138 }
139 AddRigidBodyAcc(rhs, transParams, nptsPlane0);
140 m_BndExp[m_pressure]->NormVectorIProductWRTBase(
141 rhs, m_BndExp[m_pressure]->UpdateCoeffs());
142}
143
144} // 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 AddExtrapVisPressureBCs(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
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
std::shared_ptr< Equation > EquationSharedPtr
Definition Equation.h:131
IncBCFactory & GetIncBCFactory()