Nektar++
Loading...
Searching...
No Matches
MRFFar.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: MRFFar.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: Far field boundary condition of moving reference frame.
32//
33///////////////////////////////////////////////////////////////////////////////
34
37
38namespace Nektar
39{
40
42 "MRFFar", MRFFar::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 = "MRFFar";
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 [[maybe_unused]] const LibUtilities::SessionReaderSharedPtr &pSession)
67{
69 m_definedVels.clear();
70 for (int k = 0; k < m_spacedim; ++k)
71 {
72 m_definedVels.push_back(
73 std::static_pointer_cast<
75 ->m_dirichletCondition);
76 }
77}
78
80 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &fields,
81 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &Adv,
82 std::map<std::string, NekDouble> &params)
83{
84 int nptsPlane0 = 0;
85 SetNumPointsOnPlane0(nptsPlane0);
86 if (0 == nptsPlane0 || params.find("velocity") == params.end())
87 {
88 return;
89 }
90 NekDouble time = 0.;
91 if (params.find("Time") != params.end())
92 {
93 time = params["Time"];
94 }
96 for (int i = 0; i < m_spacedim; ++i)
97 {
98 vels[i] = m_definedVels[i]->Evaluate(0., 0., 0., time);
99 }
100 if (params.find("Theta_z") != params.end())
101 {
102 NekDouble v0 = vels[0], v1 = vels[1];
103 NekDouble c = cos(params["Theta_z"]), s = sin(params["Theta_z"]);
104 vels[0] = v0 * c + v1 * s;
105 vels[1] = -v0 * s + v1 * c;
106 }
107 for (auto &it : m_BndExp)
108 {
109 int k = it.first;
110 if (it.second->GetExpType() == MultiRegions::e2DH1D)
111 {
113 it.second->GetPlane(0)->UpdatePhys();
114 Vmath::Fill(nptsPlane0, vels[k], tmpvel, 1);
115 it.second->GetPlane(0)->FwdTransBndConstrained(
116 tmpvel, it.second->GetPlane(0)->UpdateCoeffs());
117 }
118 else
119 {
120 Array<OneD, NekDouble> tmpvel = it.second->UpdatePhys();
121 Vmath::Fill(nptsPlane0, vels[k], tmpvel, 1);
122 it.second->FwdTransBndConstrained(tmpvel,
123 it.second->UpdateCoeffs());
124 }
125 }
126}
127
128} // 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.
static std::string className
Definition MRFFar.h:66
MRFFar(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)
Definition MRFFar.cpp:45
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
Definition MRFFar.cpp:79
void v_Initialise(const LibUtilities::SessionReaderSharedPtr &pSession) override
Definition MRFFar.cpp:65
std::vector< LibUtilities::EquationSharedPtr > m_definedVels
Definition MRFFar.h:69
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)
Definition MRFFar.h:53
std::shared_ptr< SessionReader > SessionReaderSharedPtr
IncBCFactory & GetIncBCFactory()
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition Vmath.hpp:54