44 std::string ForcingMovingBody::className =
46 "MovingBody", ForcingMovingBody::create,
"Moving Body Forcing");
48 ForcingMovingBody::ForcingMovingBody(
50 const std::weak_ptr<SolverUtils::EquationSystem> &pEquation)
57 const unsigned int &pNumForcingFields,
const TiXmlElement *pForce)
59 boost::ignore_unused(pNumForcingFields);
63 "Moving body implemented just for 3D Homogenous 1D expansions.");
96 size_t phystot = pFields[0]->GetTotPoints();
97 for (
size_t i = 0; i <
m_zta.size(); i++)
109 boost::ignore_unused(inarray, outarray);
127 size_t physTot = pFields[0]->GetTotPoints();
130 for (
size_t i = 0; i < 3; i++)
136 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
146 m_mapping->UpdateMapping(time, coords, coordsVel);
152 for (
size_t j = 0; j <
m_funcName.size(); j++)
156 ASSERTL0(
false,
"Motion loading from file needs specific "
157 "implementation: Work in Progress!");
173 size_t physTot = pFields[0]->GetTotPoints();
176 for (
size_t i = 0; i < 3; i++)
182 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
195 for (
size_t var = 0; var < 3; var++)
197 for (
size_t plane = 0; plane <
m_np; plane++)
199 size_t n = pFields[0]->GetPlane(plane)->GetTotPoints();
200 size_t offset = plane * n;
201 size_t Offset = var *
m_np + plane;
210 ASSERTL0(
false,
"Unrecogized vibration type for cable's dynamic model");
214 size_t colrank = vcomm->GetColumnComm()->GetRank();
233 boost::ignore_unused(time);
236 size_t colrank = vcomm->GetColumnComm()->GetRank();
237 size_t nproc = vcomm->GetColumnComm()->GetSize();
240 m_session->MatchSolverInfo(
"HomoStrip",
"True", homostrip,
false);
243 size_t npts, nstrips;
246 npts =
m_session->GetParameter(
"HomModesZ");
250 m_session->LoadParameter(
"HomStructModesZ", npts);
251 m_session->LoadParameter(
"Strip_Z", nstrips);
275 fces[0][0] = Hydroforces[0];
276 fces[1][0] = Hydroforces[
m_np];
282 for (
size_t i = 1; i < nproc; ++i)
284 vcomm->GetColumnComm()->Recv(i, tmp);
285 for (
size_t n = 0; n <
m_np; n++)
287 for (
size_t j = 0; j < 2; ++j)
289 fces[j][i *
m_np + n] = tmp[j *
m_np + n];
299 for (
size_t i = 1; i < nstrips; ++i)
301 vcomm->GetColumnComm()->Recv(i, tmp);
303 for (
size_t j = 0; j < 2; ++j)
314 vcomm->GetColumnComm()->Send(0, Hydroforces);
318 for (
size_t i = 1; i < nstrips; ++i)
323 tmp[0] = Hydroforces[0];
324 tmp[1] = Hydroforces[
m_np];
325 vcomm->GetColumnComm()->Send(0, tmp);
336 m_session->MatchSolverInfo(
"FictitiousMassMethod",
"True", fictmass,
341 m_session->LoadParameter(
"FictMass", fictrho);
342 m_session->LoadParameter(
"FictDamp", fictdamp);
344 static NekDouble Betaq_Coeffs[2][2] = {{1.0, 0.0}, {2.0, -1.0}};
349 size_t nlevels =
m_fV[0].size();
351 for (
size_t i = 0; i <
m_motion.size(); ++i)
356 size_t Voffset = npts;
357 size_t Aoffset = 2 * npts;
363 Vmath::Smul(npts, Betaq_Coeffs[nint - 1][nint - 1],
364 m_fV[i][nint - 1], 1,
m_fV[i][nlevels - 1], 1);
365 Vmath::Smul(npts, Betaq_Coeffs[nint - 1][nint - 1],
366 m_fA[i][nint - 1], 1,
m_fA[i][nlevels - 1], 1);
368 for (
size_t n = 0; n < nint - 1; ++n)
371 m_fV[i][nlevels - 1], 1,
m_fV[i][nlevels - 1],
374 m_fA[i][nlevels - 1], 1,
m_fA[i][nlevels - 1],
390 for (
size_t n = 0, cn = 1; n <
m_vdim; n++, cn--)
404 vcomm->GetColumnComm()->Recv(0, tmp);
409 for (
size_t i = 1; i < nproc; ++i)
411 for (
size_t j = 0; j < 2; j++)
413 for (
size_t k = 0; k < 2; k++)
415 for (
size_t n = 0; n <
m_np; n++)
422 vcomm->GetColumnComm()->Send(i, tmp);
425 for (
size_t j = 0; j < 2; j++)
427 for (
size_t k = 0; k < 2; k++)
429 for (
size_t n = 0; n <
m_np; n++)
445 for (
size_t j = 1; j < nproc / nstrips; j++)
447 if (colrank == j * nstrips)
449 vcomm->GetColumnComm()->Recv(0, tmp);
451 for (
size_t plane = 0; plane <
m_np; plane++)
453 for (
size_t var = 0; var < 2; var++)
455 for (
size_t k = 0; k < 2; k++)
457 Motvars[var * 2 *
m_np + k *
m_np + plane] =
465 for (
size_t i = 1; i < nstrips; i++)
467 for (
size_t j = 0; j < nproc / nstrips; j++)
469 if (colrank == i + j * nstrips)
471 vcomm->GetColumnComm()->Recv(0, tmp);
473 for (
size_t plane = 0; plane <
m_np; plane++)
475 for (
size_t var = 0; var < 2; var++)
477 for (
size_t k = 0; k < 2; k++)
479 Motvars[var * 2 *
m_np + k *
m_np + plane] =
490 for (
size_t j = 0; j < 2; ++j)
492 for (
size_t k = 0; k < 2; ++k)
498 for (
size_t j = 1; j < nproc / nstrips; j++)
500 vcomm->GetColumnComm()->Send(j * nstrips, tmp);
503 for (
size_t plane = 0; plane <
m_np; plane++)
505 for (
size_t j = 0; j < 2; j++)
507 for (
size_t k = 0; k < 2; ++k)
509 Motvars[j * 2 *
m_np + k *
m_np + plane] =
515 for (
size_t i = 1; i < nstrips; ++i)
517 for (
size_t j = 0; j < 2; ++j)
519 for (
size_t k = 0; k < 2; ++k)
525 for (
size_t j = 0; j < nproc / nstrips; j++)
527 vcomm->GetColumnComm()->Send(i + j * nstrips, tmp);
534 for (
size_t var = 0; var < 2; var++)
536 for (
size_t plane = 0; plane <
m_np; plane++)
538 size_t n = pFields[0]->GetPlane(plane)->GetTotPoints();
542 size_t offset = plane * n;
543 size_t xoffset = var *
m_np + plane;
544 size_t yoffset = 2 *
m_np + xoffset;
559 boost::ignore_unused(pFields);
561 std::string supptype =
m_session->GetSolverInfo(
"SupportType");
563 size_t npts = HydroForces.size();
568 for (
size_t i = 0; i < 4; i++)
575 for (
size_t i = 0; i < 3; i++)
577 Vmath::Vcopy(npts, BodyMotions + i * npts, 1, fft_i[i + 1], 1);
581 if (boost::iequals(supptype,
"Free-Free"))
583 for (
size_t j = 0; j < 4; ++j)
585 m_FFT->FFTFwdTrans(fft_i[j], fft_o[j]);
588 else if (boost::iequals(supptype,
"Pinned-Pinned"))
591 size_t N = fft_i[0].size();
593 for (
size_t var = 0; var < 4; var++)
595 for (
size_t i = 0; i < N; i++)
599 for (
size_t k = 0; k < N; k++)
602 fft_i[var][k] * sin(M_PI / (N) * (k + 1 / 2) * (i + 1));
609 ASSERTL0(
false,
"Unrecognized support type for cable's motion");
613 for (
size_t i = 0; i < npts; ++i)
622 for (
size_t var = 0; var < 3; var++)
624 tmp0[var] = fft_o[var + 1][i];
627 tmp2[0] = fft_o[0][i];
630 nrows, &tmp0[0], 1, 0.0, &tmp1[0], 1);
632 &(
m_CoeffMat_A[i]->GetPtr())[0], nrows, &tmp2[0], 1, 1.0,
635 for (
size_t var = 0; var < 3; var++)
637 fft_i[var][i] = tmp1[var];
643 if (boost::iequals(supptype,
"Free-Free"))
645 for (
size_t var = 0; var < 3; var++)
647 m_FFT->FFTBwdTrans(fft_i[var], fft_o[var]);
650 else if (boost::iequals(supptype,
"Pinned-Pinned"))
653 size_t N = fft_i[0].size();
655 for (
size_t var = 0; var < 3; var++)
657 for (
size_t i = 0; i < N; i++)
661 for (
size_t k = 0; k < N; k++)
663 fft_o[var][i] += fft_i[var][k] *
664 sin(M_PI / (N) * (k + 1) * (i + 1 / 2)) *
672 ASSERTL0(
false,
"Unrecognized support type for cable's motion");
675 for (
size_t i = 0; i < 3; i++)
678 Vmath::Vcopy(npts, fft_o[i], 1, tmp = BodyMotions + i * npts, 1);
689 boost::ignore_unused(pSession, pFields);
696 size_t colrank = vcomm->GetColumnComm()->GetRank();
697 size_t nproc = vcomm->GetColumnComm()->GetSize();
702 m_session->MatchSolverInfo(
"HomoStrip",
"True", homostrip,
false);
706 npts =
m_session->GetParameter(
"HomModesZ");
710 m_session->LoadParameter(
"HomStructModesZ", npts);
718 ZIDs = pFields[0]->GetZIDs();
721 std::string vibtype =
m_session->GetSolverInfo(
"VibrationType");
723 if (boost::iequals(vibtype,
"Constrained"))
727 else if (boost::iequals(vibtype,
"Free"))
731 else if (boost::iequals(vibtype,
"Forced"))
740 int nplanes =
m_session->GetParameter(
"HomModesZ");
749 m_session->LoadParameter(
"DistStrip", DistStrip);
750 m_session->LoadParameter(
"Strip_Z", nstrips);
751 m_lhom = nstrips * DistStrip;
763 m_session->MatchSolverInfo(
"FictitiousMassMethod",
"True", fictmass,
false);
767 m_session->LoadParameter(
"FictMass", fictrho);
768 m_session->LoadParameter(
"FictDamp", fictdamp);
776 for (
size_t i = 0; i <
m_motion.size(); ++i)
781 for (
size_t n = 0; n < 2; ++n)
795 for (
size_t j = 0; j <
m_funcName.size(); j++)
800 std::ifstream inputStream;
805 m_session->LoadParameter(
"HomStructModesZ", nzpoints);
809 nzpoints = pFields[0]->GetHomogeneousBasis()->GetNumModes();
812 if (vcomm->GetRank() == 0)
814 std::string filename =
818 inputStream.open(filename.c_str());
822 for (
size_t n = 0; n < tmp.size(); n++)
824 inputStream >> tmp[n];
829 for (
size_t n = 0; n < nzpoints; n++)
831 inputStream >> setprecision(6) >> time;
832 inputStream >> setprecision(6) >> z_cds;
834 inputStream >> setprecision(8) >>
836 inputStream >> setprecision(8) >>
839 inputStream >> setprecision(8) >>
841 inputStream >> setprecision(8) >>
854 pFields[0]->GetHomogeneousBasis()->GetNumModes();
857 pFields[0]->GetHomogeneousBasis()->GetZ();
865 for (
size_t plane = 0; plane <
m_np; plane++)
867 x2[plane] = z_coords[ZIDs[plane]];
877 ffunc0->Evaluate(x0, x1, x2, 0.0, tmp0);
878 ffunc1->Evaluate(x0, x1, x2, 0.0, tmp1);
880 size_t offset = j * npts;
886 for (
size_t i = 1; i < nproc; ++i)
888 vcomm->GetColumnComm()->Recv(i, tmp0);
889 vcomm->GetColumnComm()->Recv(i, tmp1);
900 vcomm->GetColumnComm()->Send(0, tmp0);
901 vcomm->GetColumnComm()->Send(0, tmp1);
909 m_session->LoadParameter(
"Strip_Z", nstrips);
913 "Fourier transformation of cable motion is currently "
914 "implemented only for FFTW module.");
917 m_session->LoadParameter(
"DistStrip", DistStrip);
925 for (
size_t plane = 0; plane < npts; plane++)
927 x2[plane] = plane * DistStrip;
932 ffunc0->Evaluate(x0, x1, x2, 0.0, tmp0);
933 ffunc1->Evaluate(x0, x1, x2, 0.0, tmp1);
935 size_t offset = j * npts;
954 boost::ignore_unused(pFields);
959 m_session->MatchSolverInfo(
"HomoStrip",
"True", homostrip,
false);
963 nplanes =
m_session->GetParameter(
"HomModesZ");
967 m_session->LoadParameter(
"Strip_Z", nplanes);
980 m_session->LoadParameter(
"StructStiff", structstiff, 0.0);
981 m_session->LoadParameter(
"CableTension", cabletension, 0.0);
982 m_session->LoadParameter(
"BendingStiff", bendingstiff, 0.0);
993 std::string supptype =
m_session->GetSolverInfo(
"SupportType");
995 for (
size_t plane = 0; plane < nplanes; plane++)
1007 if (boost::iequals(supptype,
"Free-Free"))
1012 else if (boost::iequals(supptype,
"Pinned-Pinned"))
1019 ASSERTL0(
false,
"Unrecognized support type for cable's motion");
1025 tmp7 = tmp2 + tmp4 * tmp6 + tmp5 * tmp7;
1060 size_t nlevels = input.size();
1063 tmp = input[nlevels - 1];
1065 for (
size_t n = nlevels - 1; n > 0; --n)
1067 input[n] = input[n - 1];
1092 const TiXmlElement *funcNameElmt_D =
1093 pForce->FirstChildElement(
"DISPLACEMENTS");
1095 "MOVINGBODYFORCE tag has to specify a function name which "
1096 "prescribes the body displacement as d(z,t).");
1100 "Function '" +
m_funcName[0] +
"' not defined.");
1103 const TiXmlElement *funcNameElmt_V =
1104 pForce->FirstChildElement(
"VELOCITIES");
1106 "MOVINGBODYFORCE tag has to specify a function name which "
1107 "prescribes the body velocity of movement as v(z,t).");
1111 "Function '" +
m_funcName[1] +
"' not defined.");
1114 const TiXmlElement *funcNameElmt_A =
1115 pForce->FirstChildElement(
"ACCELERATIONS");
1117 "MOVINGBODYFORCE tag has to specify a function name which "
1118 "prescribes the body acceleration as a(z,t).");
1122 "Function '" +
m_funcName[2] +
"' not defined.");
1138 ASSERTL0(
false,
"The displacements in x must be specified via an "
1139 "equation <E> or a file <F>");
1154 ASSERTL0(
false,
"The displacements in y must be specified via an "
1155 "equation <E> or a file <F>");
1170 ASSERTL0(
false,
"The velocities in x must be specified via an equation "
1171 "<E> or a file <F>");
1186 ASSERTL0(
false,
"The velocities in y must be specified via an equation "
1187 "<E> or a file <F>");
1202 ASSERTL0(
false,
"The accelerations in x must be specified via an "
1203 "equation <E> or a file <F>");
1218 ASSERTL0(
false,
"The accelerations in y must be specified via an "
1219 "equation <E> or a file <F>");
1229 const TiXmlElement *pForce)
1233 std::string typeStr = pForce->Attribute(
"TYPE");
1234 std::map<std::string, std::string> vParams;
1236 const TiXmlElement *param = pForce->FirstChildElement(
"PARAM");
1240 "Missing attribute 'NAME' for parameter in filter " + typeStr +
1242 std::string nameStr = param->Attribute(
"NAME");
1244 ASSERTL0(param->GetText(),
"Empty value string for param.");
1245 std::string valueStr = param->GetText();
1247 vParams[nameStr] = valueStr;
1249 param = param->NextSiblingElement(
"PARAM");
1256 pSession,
m_equ, vParams);
#define ASSERTL0(condition, msg)
GlobalMapping::MappingSharedPtr m_mapping
Array< OneD, std::string > m_funcName
[0] is displacements, [1] is velocities, [2] is accelerations
Array< OneD, Array< OneD, NekDouble > > m_zta
Store the derivatives of motion variables in x-direction.
NekDouble m_lhom
length ratio of the cable
NekDouble m_kinvis
fluid viscous
size_t m_np
number of planes per processors
Array< OneD, DNekMatSharedPtr > m_CoeffMat_A
matrices in Newmart-beta method
Array< OneD, Array< OneD, NekDouble > > m_eta
Store the derivatives of motion variables in y-direction.
void CheckIsFromFile(const TiXmlElement *pForce)
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_fV
fictitious velocity storage
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_fA
fictitious acceleration storage
void SetDynEqCoeffMatrix(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
void InitialiseCableModel(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
NekDouble m_structrho
mass of the cable per unit length
size_t m_vdim
vibration dimension
NekDouble m_timestep
time step
Array< OneD, bool > m_IsFromFile
do determine if the the body motion come from an extern file
FilterMovingBodySharedPtr m_MovBodyfilter
virtual 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
Array< OneD, Array< OneD, NekDouble > > m_MotionVars
storage for the cable's motion(x,y) variables
Array< OneD, DNekMatSharedPtr > m_CoeffMat_B
matrices in Newmart-beta method
void EvaluateStructDynModel(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &Hydroforces, NekDouble time)
void RollOver(Array< OneD, Array< OneD, NekDouble >> &input)
size_t m_movingBodyCalls
number of times the movbody have been called
void Newmark_betaSolver(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &FcePhysinArray, Array< OneD, NekDouble > &MotPhysinArray)
void InitialiseFilter(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pForce)
Array< OneD, std::string > m_motion
motion direction: [0] is 'x' and [1] is 'y'
LibUtilities::NektarFFTSharedPtr m_FFT
virtual void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce) override
NekDouble m_structdamp
damping ratio of the cable
static GLOBAL_MAPPING_EXPORT MappingSharedPtr Load(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Return a pointer to the mapping, creating it on first call.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
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.
const std::weak_ptr< EquationSystem > m_equ
Weak pointer to equation system using this forcing.
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.
static void Dgemv(const char &trans, const int &m, const int &n, const double &alpha, const double *a, const int &lda, const double *x, const int &incx, const double &beta, double *y, const int &incy)
BLAS level 2: Matrix vector multiply y = A x where A[m x n].
NektarFFTFactory & GetNektarFFTFactory()
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
@ eFunctionTypeExpression
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 Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
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)
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.