Nektar++
MovingFrameFar.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: MovingFrameFar.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
41std::string MovingFrameFar::className =
43 "MovingFrameFar", MovingFrameFar::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 : IncBaseCondition(pSession, pFields, cond, exp, nbnd, spacedim, bnddim)
54{
55 classname = "MovingFrameFar";
56 for (size_t i = 0; i < m_spacedim; ++i)
57 {
58 m_BndConds[i] = cond[i];
59 if (cond[i]->GetUserDefined() == classname)
60 {
61 m_BndExp[i] = exp[i];
62 }
63 }
64}
65
67 [[maybe_unused]] const LibUtilities::SessionReaderSharedPtr &pSession)
68{
70 m_definedVels.clear();
71 for (int k = 0; k < m_spacedim; ++k)
72 {
73 m_definedVels.push_back(
74 std::static_pointer_cast<
76 ->m_dirichletCondition);
77 }
78}
79
81 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &fields,
82 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &Adv,
83 std::map<std::string, NekDouble> &params)
84{
85 int nptsPlane0 = 0;
86 SetNumPointsOnPlane0(nptsPlane0);
87 if (0 == nptsPlane0)
88 {
89 return;
90 }
91 NekDouble time = 0.;
92 if (params.find("Time") != params.end())
93 {
94 time = params["Time"];
95 }
97 for (int i = 0; i < m_spacedim; ++i)
98 {
99 vels[i] = m_definedVels[i].Evaluate(0., 0., 0., time);
100 }
101 if (params.find("Theta_z") != params.end())
102 {
103 NekDouble v0 = vels[0], v1 = vels[1];
104 NekDouble c = cos(params["Theta_z"]), s = sin(params["Theta_z"]);
105 vels[0] = v0 * c + v1 * s;
106 vels[1] = -v0 * s + v1 * c;
107 }
108 for (auto &it : m_BndExp)
109 {
110 int k = it.first;
111 if (it.second->GetExpType() == MultiRegions::e2DH1D)
112 {
114 it.second->GetPlane(0)->UpdatePhys();
115 Vmath::Fill(nptsPlane0, vels[k], tmpvel, 1);
116 it.second->GetPlane(0)->FwdTransBndConstrained(
117 tmpvel, it.second->GetPlane(0)->UpdateCoeffs());
118 }
119 else
120 {
121 Array<OneD, NekDouble> tmpvel = it.second->UpdatePhys();
122 Vmath::Fill(nptsPlane0, vels[k], tmpvel, 1);
123 it.second->FwdTransBndConstrained(tmpvel,
124 it.second->UpdateCoeffs());
125 }
126 }
127}
128
129} // namespace Nektar
std::map< int, MultiRegions::ExpListSharedPtr > m_BndExp
virtual void v_Initialise(const LibUtilities::SessionReaderSharedPtr &pSession)
void SetNumPointsOnPlane0(int &npointsPlane0)
std::map< int, SpatialDomains::BoundaryConditionShPtr > m_BndConds
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::vector< LibUtilities::Equation > m_definedVels
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)
static std::string className
MovingFrameFar(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
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.hpp:54