44 #include <boost/core/ignore_unused.hpp>
58 RegisterCreatorFunction(
"MovingReferenceFrame",
59 ForcingMovingReferenceFrame::create,
62 RegisterCreatorFunction(
"Field",
63 ForcingMovingReferenceFrame::create,
71 ForcingMovingReferenceFrame::ForcingMovingReferenceFrame(
73 const std::weak_ptr<EquationSystem> &pEquation)
87 const unsigned int &pNumForcingFields,
88 const TiXmlElement *pForce)
90 boost::ignore_unused(pNumForcingFields);
93 bool singleMode, halfMode;
94 m_session->MatchSolverInfo(
"ModeType",
"SingleMode", singleMode,
false);
95 m_session->MatchSolverInfo(
"ModeType",
"HalfMode", halfMode,
false);
96 if (singleMode || halfMode)
101 int npoints = pFields[0]->GetNpoints();
102 int expdim =
m_isH2d ? 1 : pFields[0]->GetGraph()
103 ->GetMeshDimension();
113 const TiXmlElement *funcNameElmt = pForce->FirstChildElement(
115 ASSERTL0(funcNameElmt,
"Requires FRAMEVELOCITY tag specifying function "
116 "name which prescribes velocity of the moving "
121 "Function '" +
m_funcName +
"' not defined.");
123 for (
int i = 0; i < 6; ++i)
132 std::string s_FieldStr =
m_session->GetVariable(i);
146 std::vector<std::string> angularVar = {
"Omega_x",
"Omega_y",
"Omega_z"};
147 for (
int i = (expdim==2 ? 2 : 0); i < 3; ++i)
149 std::string s_FieldStr = angularVar[i];
170 std::vector<std::string> pivotVar = {
"x0",
"y0",
"z0"};
173 std::string s_FieldStr = pivotVar[i];
178 s_FieldStr)->Evaluate();
218 int npoints = fields[0]->GetNpoints();
219 addRotation(npoints, outarray, -1., inarray, outarray);
232 ASSERTL0(&inarray1!=&outarray,
"inarray1 and outarray "
233 "should have different addresses.");
235 if ((
m_spacedim>=2 && &inarray0 != &outarray) ||
250 if ((
m_spacedim==3 && &inarray0 != &outarray) ||
291 int npoints = fields[0]->GetNpoints();
292 if (
m_isH2d && fields[0]->GetWaveSpace())
300 fields[0]->HomogeneousFwdTrans(tmpphys, tmpcoef);
301 Vmath::Vadd(npoints, tmpcoef, 1, inarray[i], 1, outarray[i], 1);
303 else if (&inarray != &outarray)
311 int npoints0 = npoints;
312 if (
m_isH1d && fields[0]->GetWaveSpace())
314 npoints0 =
m_hasPlane0 ? fields[0]->GetPlane(0)->GetNpoints() : 0;
321 if (&inarray != &outarray && npoints != npoints0)
324 Vmath::Vcopy(npoints - npoints0, inarray[i] + npoints0, 1, tmp, 1);
327 else if (&inarray != &outarray)
#define ASSERTL0(condition, msg)
Defines a forcing term to be explicitly applied.
int m_NumVariable
Number of variables.
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const LibUtilities::SessionReaderSharedPtr &pSession, std::string pName, bool pCache=false)
Get a SessionFunction by name.
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
virtual SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Initialise the forcing module.
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
virtual 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)
Adds the body force, -Omega X u.
virtual 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)
std::map< int, LibUtilities::EquationSharedPtr > m_frameFunction
void Update(const NekDouble &time)
Updates the forcing array with the current required forcing.
std::map< int, NekDouble > m_frameVelocity
Array< OneD, Array< OneD, NekDouble > > m_coords
std::shared_ptr< SessionReader > SessionReaderSharedPtr
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
The above copyright notice and this permission notice shall be included.
static Array< OneD, NekDouble > NullNekDouble1DArray
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha - x.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)