Nektar++
ForcingMovingReferenceFrame.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ForcingMovingReferenceFrame.h
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: Allows for a moving frame of reference, through adding c * du/dx
32// to the body force, where c is the frame velocity vector
33//
34///////////////////////////////////////////////////////////////////////////////
35
36#ifndef NEKTAR_SOLVERUTILS_FORCINGMOVINGREFERENCEFRAME
37#define NEKTAR_SOLVERUTILS_FORCINGMOVINGREFERENCEFRAME
38
39#include <string>
40
49#include <boost/numeric/ublas/io.hpp>
50#include <boost/numeric/ublas/matrix.hpp>
51#include <boost/numeric/ublas/vector.hpp>
52#include <cmath>
53
54namespace Nektar::SolverUtils
55{
56
57namespace bn = boost::numeric;
58
59/***
60 * Solve the body's motion using Newmark-Beta method
61 * M ddx + C dx + K x = F
62 * In discrete form
63 * CoeffMatrix dx = rhs
64 ***/
66{
67public:
72 DNekMatSharedPtr K, std::set<int> DirDoFs);
75 std::map<int, NekDouble> motionPrescribed);
76 int m_rows;
83};
84
86{
87public:
90 void SetAngle(const Array<OneD, NekDouble> theta);
91 void BodyToInerital(const int dim, const Array<OneD, NekDouble> &body,
92 Array<OneD, NekDouble> &inertial);
93 void IneritalToBody(const int dim, Array<OneD, NekDouble> &body,
94 const Array<OneD, NekDouble> &inertial);
95
96private:
98};
99
101{
102
103public:
105
106 /// Creates an instance of this class
109 const std::weak_ptr<EquationSystem> &pEquation,
111 const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
112 {
115 pSession, pEquation);
116 p->InitObject(pFields, pNumForcingFields, pForce);
117 return p;
118 }
119
120 /// Name of the class
121 static std::string classNameBody;
122
123protected:
126 const unsigned int &pNumForcingFields,
127 const TiXmlElement *pForce) override;
128
131 const Array<OneD, Array<OneD, NekDouble>> &inarray,
133 const NekDouble &time) override;
134
137 const Array<OneD, Array<OneD, NekDouble>> &inarray,
139 const NekDouble &time) override;
140
141private:
142 // name of the function for linear and angular velocities in the session
143 // file
144 // pivot point
148
149 // prescribed functions in the session file
150 std::map<int, LibUtilities::EquationSharedPtr> m_frameVelFunction;
151 std::map<int, LibUtilities::EquationSharedPtr> m_extForceFunction;
152 std::ofstream m_outputStream;
154
155 // a boolean switch indicating for which direction the velocities are
156 // available. The available velocites could be different from the
157 // precscribed one because of the rotation which result in change of basis
158 // vector of local frame to the inertial frame.
161
162 // frame linear velocities in inertial frame
164
165 // frame linear velocities in local translating-rotating frame
167
168 // frame angular velocities in inertial frame
170
171 // frame angular velocities in local translating-rotating frame
173 // coordinate vector
175 // externel force
177
178 // rotation angel
180
181 // Projection matrix for transformation of vectors between inertial and
182 // moving reference frames
183 bn::ublas::matrix<NekDouble> m_ProjMatZ;
184
187
195 unsigned int m_index;
196 unsigned int m_outputFrequency;
199 std::set<int> m_DirDoFs;
201
204 const std::weak_ptr<EquationSystem> &pEquation);
205
206 ~ForcingMovingReferenceFrame(void) override;
207
209 const NekDouble &time);
210 void UpdateRotMat();
213 NekDouble &time);
214
215 void addRotation(int npoints,
216 const Array<OneD, Array<OneD, NekDouble>> &inarray0,
217 NekDouble angVelScale,
218 const Array<OneD, Array<OneD, NekDouble>> &inarray1,
219 Array<OneD, Array<OneD, NekDouble>> &outarray);
220 void InitBodySolver(const TiXmlElement *pForce, const int dim,
221 const int rank, const NekDouble time);
223 const Array<OneD, NekDouble> &forcebody,
224 std::map<int, NekDouble> &Dirs);
225 void LoadParameters(const TiXmlElement *pForce, const NekDouble time);
226 NekDouble EvaluateExpression(std::string expression);
227 void InitialiseFilter(
230 const TiXmlElement *pForce);
232};
233
234} // namespace Nektar::SolverUtils
235
236#endif
#define SOLVER_UTILS_EXPORT
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Defines a forcing term to be explicitly applied.
Definition: Forcing.h:71
SOLVER_UTILS_EXPORT void v_PreApply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time) override
void addRotation(int npoints, const Array< OneD, Array< OneD, NekDouble > > &inarray0, NekDouble angVelScale, const Array< OneD, Array< OneD, NekDouble > > &inarray1, Array< OneD, Array< OneD, NekDouble > > &outarray)
outarray = inarray0 + angVelScale Omega x inarray1
std::map< int, LibUtilities::EquationSharedPtr > m_frameVelFunction
void SolveBodyMotion(Array< OneD, Array< OneD, NekDouble > > &bodyVel, const Array< OneD, NekDouble > &forcebody, std::map< int, NekDouble > &Dirs)
void CheckForRestartTime(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, NekDouble &time)
void InitBodySolver(const TiXmlElement *pForce, const int dim, const int rank, const NekDouble time)
ForcingMovingReferenceFrame(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
std::map< int, LibUtilities::EquationSharedPtr > m_extForceFunction
void LoadParameters(const TiXmlElement *pForce, const NekDouble time)
SOLVER_UTILS_EXPORT void v_Apply(const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time) override
Adds the body force, -Omega X u.
SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
Initialise the forcing module.
void Update(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
Updates the forcing array with the current required forcing.
void UpdateBoundaryConditions(NekDouble time)
Set velocity boundary condition at the next time step.
static SOLVER_UTILS_EXPORT ForcingSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Creates an instance of this class.
void InitialiseFilter(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pForce)
void SetAngle(const Array< OneD, NekDouble > theta)
void BodyToInerital(const int dim, const Array< OneD, NekDouble > &body, Array< OneD, NekDouble > &inertial)
void IneritalToBody(const int dim, Array< OneD, NekDouble > &body, const Array< OneD, NekDouble > &inertial)
void SetNewmarkBeta(NekDouble beta, NekDouble gamma, NekDouble dt, DNekMatSharedPtr M, DNekMatSharedPtr C, DNekMatSharedPtr K, std::set< int > DirDoFs)
void Solve(Array< OneD, Array< OneD, NekDouble > > u, Array< OneD, NekDouble > force, std::map< int, NekDouble > motionPrescribed)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:59
std::shared_ptr< FilterAeroForces > FilterAeroForcesSharedPtr
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Forcing > ForcingSharedPtr
A shared pointer to an EquationSystem object.
Definition: Forcing.h:53
std::int32_t NekInt
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75
double NekDouble