44#include <boost/core/ignore_unused.hpp>
70 const std::weak_ptr<EquationSystem> &pEquation)
83 const unsigned int &pNumForcingFields,
const TiXmlElement *pForce)
85 boost::ignore_unused(pNumForcingFields);
88 bool singleMode, halfMode;
89 m_session->MatchSolverInfo(
"ModeType",
"SingleMode", singleMode,
false);
90 m_session->MatchSolverInfo(
"ModeType",
"HalfMode", halfMode,
false);
91 if (singleMode || halfMode)
96 int npoints = pFields[0]->GetNpoints();
97 int expdim =
m_isH2d ? 1 : pFields[0]->GetGraph()->GetMeshDimension();
108 const TiXmlElement *funcNameElmt;
110 funcNameElmt = pForce->FirstChildElement(
"LinearVelocity");
111 ASSERTL0(funcNameElmt,
"Requires LinearVelocity tag specifying function "
112 "name which prescribes velocity of the moving "
117 "Function '" +
m_velFuncName +
"' is not defined in the session.");
122 funcNameElmt = pForce->FirstChildElement(
"AngularVelocity");
128 "' is not defined in the session.");
133 for (
int i = 0; i < 3; ++i)
140 for (
int i = 0; i < 3; ++i)
149 for (
int i = 0; i < 3; ++i)
165 auto equ =
m_equ.lock();
166 ASSERTL0(equ,
"Weak pointer to the equation system is expired");
167 auto FluidEq = std::dynamic_pointer_cast<FluidInterface>(equ);
169 FluidEq->SetMovingFrameAngles(
m_theta);
180 m_ProjMatX = bn::ublas::zero_matrix<NekDouble>(3, 3);
181 m_ProjMatY = bn::ublas::zero_matrix<NekDouble>(3, 3);
182 m_ProjMatZ = bn::ublas::zero_matrix<NekDouble>(3, 3);
199 std::string s_FieldStr =
m_session->GetVariable(i);
218 std::vector<std::string> angularVar = {
"Omega_x",
"Omega_y",
"Omega_z"};
219 for (
int i = 0; i < 3; ++i)
221 std::string s_FieldStr = angularVar[i];
234 for (
int i = 0; i < 2; ++i)
240 const TiXmlElement *pivotElmt = pForce->FirstChildElement(
"PivotPoint");
244 std::stringstream pivotPointStream;
245 std::string pivotPointStr = pivotElmt->GetText();
246 pivotPointStream.str(pivotPointStr);
250 pivotPointStream >> pivotPointStr;
251 if (!pivotPointStr.empty())
278 for (
int i = 0; i < 3; ++i)
302 m_velXYZ[it.first] = it.second->Evaluate(0., 0., 0., time);
306 m_omegaXYZ[it.first] = it.second->Evaluate(0., 0., 0., time);
314 bn::ublas::vector<NekDouble> v0 = bn::ublas::zero_vector<NekDouble>(3);
315 bn::ublas::vector<NekDouble> v1 = bn::ublas::zero_vector<NekDouble>(3);
321 for (
int i = 0; i < 3; ++i)
327 v0 = bn::ublas::zero_vector<NekDouble>(3);
328 v1 = bn::ublas::zero_vector<NekDouble>(3);
331 v0(it.first) = it.second;
334 for (
int i = 0; i < 3; ++i)
352 for (
int i = 0; i < 3; ++i)
358 auto equ =
m_equ.lock();
359 ASSERTL0(equ,
"Weak pointer to the equation system is expired");
360 auto FluidEq = std::dynamic_pointer_cast<FluidInterface>(equ);
362 FluidEq->SetMovingFrameVelocities(vel);
364 FluidEq->SetMovingFrameProjectionMat(
m_ProjMatZ);
368 FluidEq->SetMovingFrameAngles(
m_theta);
376 std::map<int, NekDouble>
Omega;
380 for (
int i = 0; i < 3; ++i)
418 boost::ignore_unused(time);
426 int npoints = fields[0]->GetNpoints();
427 boost::ignore_unused(npoints);
428 addRotation(npoints, outarray, -1., inarray, outarray);
440 ASSERTL0(&inarray1 != &outarray,
"inarray1 and outarray "
441 "should not be the same.");
448 if (&inarray0 != &outarray)
450 ASSERTL0(inarray0.size() == outarray.size(),
451 "inarray0 and outarray must have same dimentions");
452 for (
int i = 0; i < inarray0.size(); ++i)
463 Vmath::Svtvp(nPnts, cm, inarray1[1], 1, outarray[0], 1, outarray[0], 1);
464 Vmath::Svtvp(nPnts, cp, inarray1[0], 1, outarray[1], 1, outarray[1], 1);
472 Vmath::Svtvp(nPnts, cp, inarray1[1], 1, outarray[2], 1, outarray[2], 1);
473 Vmath::Svtvp(nPnts, cm, inarray1[2], 1, outarray[1], 1, outarray[1], 1);
481 Vmath::Svtvp(nPnts, cp, inarray1[2], 1, outarray[0], 1, outarray[0], 1);
482 Vmath::Svtvp(nPnts, cm, inarray1[0], 1, outarray[2], 1, outarray[2], 1);
492 int npoints = fields[0]->GetNpoints();
493 if (
m_isH2d && fields[0]->GetWaveSpace())
501 fields[0]->HomogeneousFwdTrans(npoints, tmpphys, tmpcoef);
502 Vmath::Vadd(npoints, tmpcoef, 1, inarray[i], 1, outarray[i], 1);
504 else if (&inarray != &outarray)
512 int npoints0 = npoints;
513 if (
m_isH1d && fields[0]->GetWaveSpace())
515 npoints0 =
m_hasPlane0 ? fields[0]->GetPlane(0)->GetNpoints() : 0;
523 if (&inarray != &outarray && npoints != npoints0)
526 Vmath::Vcopy(npoints - npoints0, inarray[i] + npoints0, 1,
530 else if (&inarray != &outarray)
546 std::map<std::string, std::string> fieldMetaDataMap;
549 for (
auto &t : theta)
554 if (
m_session->DefinesFunction(
"InitialConditions"))
556 for (
int i = 0; i < pFields.size(); ++i)
560 vType =
m_session->GetFunctionType(
"InitialConditions",
565 std::string filename =
m_session->GetFunctionFilename(
566 "InitialConditions",
m_session->GetVariable(i));
568 fs::path pfilename(filename);
571 if (fs::is_directory(pfilename))
573 fs::path metafile(
"Info.xml");
574 fs::path fullpath = pfilename / metafile;
579 fld->ImportFieldMetaData(filename, fieldMetaDataMap);
584 std::vector<std::string> vSuffix = {
"_x",
"_y",
"_z"};
586 for (
int j = 0; j < 3; ++j)
588 std::string sTheta =
"Theta" + vSuffix[j];
589 auto iter = fieldMetaDataMap.find(sTheta);
590 if (iter != fieldMetaDataMap.end())
593 boost::lexical_cast<NekDouble>(iter->second);
#define ASSERTL0(condition, msg)
NekDouble Evaluate() const
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Defines a forcing term to be explicitly applied.
int m_NumVariable
Number of variables.
const std::weak_ptr< EquationSystem > m_equ
Weak pointer to equation system using this forcing.
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
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) override
bn::ublas::matrix< NekDouble > m_ProjMatY
std::map< int, bool > m_hasVel
static std::string classNameBody
Name of the class.
bn::ublas::matrix< NekDouble > m_ProjMatZ
void UpdateTheta(const NekDouble &time)
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_omegaFunction
void CheckForRestartTheta(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &theta)
Array< OneD, NekDouble > m_theta
ForcingMovingReferenceFrame(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation)
std::map< int, NekDouble > m_omegaXYZ
Array< OneD, NekDouble > m_pivotPoint
bn::ublas::matrix< NekDouble > m_ProjMatX
std::string m_velFuncName
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) override
Adds the body force, -Omega X u.
virtual SOLVER_UTILS_EXPORT void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
Initialise the forcing module.
std::string m_omegaFuncName
std::map< int, LibUtilities::EquationSharedPtr > m_velFunction
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 Update(const NekDouble &time)
Updates the forcing array with the current required forcing.
std::map< int, bool > m_hasOmega
std::map< int, NekDouble > m_omegaxyz
Array< OneD, Array< OneD, NekDouble > > m_coords
std::map< int, NekDouble > m_velxyz
std::map< int, NekDouble > m_velXYZ
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::string PortablePath(const boost::filesystem::path &path)
create portable path on different platforms for boost::filesystem path
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static FieldMetaDataMap NullFieldMetaDataMap
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
The above copyright notice and this permission notice shall be included.
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 scalar y = alpha + x.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)