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{
40std::string MovingFrameFar::className =
42 "MovingFrameFar", MovingFrameFar::create,
43 "Far field boundary condition of moving reference frame");
44
46 [[maybe_unused]] const LibUtilities::SessionReaderSharedPtr pSession,
47 [[maybe_unused]] Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
50 [[maybe_unused]] int nbnd, [[maybe_unused]] int spacedim,
51 [[maybe_unused]] int bnddim)
52 : IncBaseCondition(pSession, pFields, cond, exp, nbnd, spacedim, bnddim)
53{
54 classname = "MovingFrameFar";
55 for (size_t i = 0; i < m_spacedim; ++i)
56 {
57 m_BndConds[i] = cond[i];
58 if (cond[i]->GetUserDefined() == classname)
59 {
60 m_BndExp[i] = exp[i];
61 }
62 }
63}
64
66{
67}
68
70 [[maybe_unused]] const LibUtilities::SessionReaderSharedPtr &pSession)
71{
73 m_definedVels.clear();
74 for (int k = 0; k < m_spacedim; ++k)
75 {
76 m_definedVels.push_back(
77 std::static_pointer_cast<
79 ->m_dirichletCondition);
80 }
81}
82
84 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &fields,
85 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &Adv,
86 std::map<std::string, NekDouble> &params)
87{
88 int nptsPlane0 = 0;
89 SetNumPointsOnPlane0(nptsPlane0);
90 if (0 == nptsPlane0)
91 {
92 return;
93 }
94 NekDouble time = 0.;
95 if (params.find("Time") != params.end())
96 {
97 time = params["Time"];
98 }
100 for (int i = 0; i < m_spacedim; ++i)
101 {
102 vels[i] = m_definedVels[i].Evaluate(0., 0., 0., time);
103 }
104 if (params.find("Theta_z") != params.end())
105 {
106 NekDouble v0 = vels[0], v1 = vels[1];
107 NekDouble c = cos(params["Theta_z"]), s = sin(params["Theta_z"]);
108 vels[0] = v0 * c + v1 * s;
109 vels[1] = -v0 * s + v1 * c;
110 }
111 for (auto &it : m_BndExp)
112 {
113 int k = it.first;
114 if (it.second->GetExpType() == MultiRegions::e2DH1D)
115 {
117 it.second->GetPlane(0)->UpdatePhys();
118 Vmath::Fill(nptsPlane0, vels[k], tmpvel, 1);
119 it.second->GetPlane(0)->FwdTransBndConstrained(
120 tmpvel, it.second->GetPlane(0)->UpdateCoeffs());
121 }
122 else
123 {
124 Array<OneD, NekDouble> tmpvel = it.second->UpdatePhys();
125 Vmath::Fill(nptsPlane0, vels[k], tmpvel, 1);
126 it.second->FwdTransBndConstrained(tmpvel,
127 it.second->UpdateCoeffs());
128 }
129 }
130}
131
132} // 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