44 RegisterCreatorFunction(
"MovingBody",
45 ForcingMovingBody::create,
46 "Moving Body Forcing");
48 ForcingMovingBody::ForcingMovingBody(
50 const std::weak_ptr<SolverUtils::EquationSystem> &pEquation)
57 const unsigned int& pNumForcingFields,
58 const TiXmlElement* pForce)
62 "Moving body implemented just for 3D Homogenous 1D expansions.");
94 int phystot = pFields[0]->GetTotPoints();
95 for(
int i = 0; i <
m_zta.size(); i++)
124 int physTot = pFields[0]->GetTotPoints();
127 for(
int i =0; i<3; i++)
133 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
143 m_mapping->UpdateMapping(time, coords, coordsVel);
153 ASSERTL0(
false,
"Motion loading from file needs specific "
154 "implementation: Work in Progress!");
168 int physTot = pFields[0]->GetTotPoints();
171 for(
int i =0; i<3; i++)
177 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
190 for(
int var = 0; var < 3; var++)
192 for(
int plane = 0; plane <
m_np; plane++)
194 int n = pFields[0]->GetPlane(plane)->GetTotPoints();
195 int offset = plane * n;
196 int Offset = var *
m_np+plane;
206 "Unrecogized vibration type for cable's dynamic model");
210 int colrank = vcomm->GetColumnComm()->GetRank();
233 int colrank = vcomm->GetColumnComm()->GetRank();
234 int nproc = vcomm->GetColumnComm()->GetSize();
237 m_session->MatchSolverInfo(
"HomoStrip",
"True",homostrip,
false);
243 npts =
m_session->GetParameter(
"HomModesZ");
247 m_session->LoadParameter(
"HomStructModesZ", npts);
248 m_session->LoadParameter(
"Strip_Z", nstrips);
271 fces[0][0] = Hydroforces[0];
272 fces[1][0] = Hydroforces[
m_np];
278 for (
int i = 1; i < nproc; ++i)
280 vcomm->GetColumnComm()->Recv(i, tmp);
281 for(
int n = 0; n <
m_np; n++)
283 for(
int j = 0; j < 2; ++j)
285 fces[j][i*
m_np + n] = tmp[j*
m_np + n];
295 for(
int i = 1; i < nstrips; ++i)
297 vcomm->GetColumnComm()->Recv(i, tmp);
299 for(
int j = 0 ; j < 2; ++j)
310 vcomm->GetColumnComm()->Send(0, Hydroforces);
314 for(
int i = 1; i < nstrips; ++i)
319 tmp[0] = Hydroforces[0];
320 tmp[1] = Hydroforces[
m_np];
321 vcomm->GetColumnComm()->Send(0, tmp);
332 m_session->MatchSolverInfo(
"FictitiousMassMethod",
"True",
337 m_session->LoadParameter(
"FictMass", fictrho);
338 m_session->LoadParameter(
"FictDamp", fictdamp);
341 {{1.0, 0.0},{2.0, -1.0}};
346 int nlevels =
m_fV[0].size();
348 for(
int i = 0; i <
m_motion.size(); ++i)
354 int Aoffset = 2*npts;
361 Betaq_Coeffs[nint-1][nint-1],
363 m_fV[i][nlevels-1], 1);
365 Betaq_Coeffs[nint-1][nint-1],
367 m_fA[i][nlevels-1], 1);
369 for(
int n = 0; n < nint-1; ++n)
372 Betaq_Coeffs[nint-1][n],
374 m_fV[i][nlevels-1],1);
376 Betaq_Coeffs[nint-1][n],
378 m_fA[i][nlevels-1],1);
383 fces[i],1,fces[i],1);
385 fces[i],1,fces[i],1);
393 for(
int n = 0, cn = 1; n <
m_vdim; n++, cn--)
407 vcomm->GetColumnComm()->Recv(0, tmp);
412 for (
int i = 1; i < nproc; ++i)
414 for(
int j = 0; j < 2; j++)
416 for(
int k = 0; k < 2; k++)
418 for (
int n = 0; n <
m_np; n++)
424 vcomm->GetColumnComm()->Send(i, tmp);
427 for(
int j = 0; j < 2; j++)
429 for(
int k = 0; k < 2; k++)
431 for(
int n = 0; n <
m_np; n++)
446 for (
int j = 1; j < nproc/nstrips; j++)
448 if(colrank == j*nstrips)
450 vcomm->GetColumnComm()->Recv(0, tmp);
452 for(
int plane = 0; plane <
m_np; plane++)
454 for(
int var = 0; var < 2; var++)
456 for(
int k = 0; k < 2; k++)
458 Motvars[var*2*
m_np+k*
m_np+plane]= tmp[var*2+k];
465 for(
int i = 1; i < nstrips; i++)
467 for (
int j = 0; j < nproc/nstrips; j++)
469 if(colrank == i+j*nstrips)
471 vcomm->GetColumnComm()->Recv(0, tmp);
473 for(
int plane = 0; plane <
m_np; plane++)
475 for(
int var = 0; var < 2; var++)
477 for(
int k = 0; k < 2; k++)
479 Motvars[var*2*
m_np+k*
m_np+plane] = tmp[var*2+k];
489 for(
int j = 0; j < 2; ++j)
491 for(
int k = 0; k < 2; ++k)
497 for (
int j = 1; j < nproc/nstrips; j++)
499 vcomm->GetColumnComm()->Send(j*nstrips, tmp);
502 for(
int plane = 0; plane <
m_np; plane++)
504 for(
int j = 0; j < 2; j++)
506 for(
int k = 0; k < 2; ++k)
513 for(
int i = 1; i < nstrips; ++i)
515 for(
int j = 0; j < 2; ++j)
517 for(
int k = 0; k < 2; ++k)
523 for (
int j = 0; j < nproc/nstrips; j++)
525 vcomm->GetColumnComm()->Send(i+j*nstrips, tmp);
532 for(
int var = 0; var < 2; var++)
534 for(
int plane = 0; plane <
m_np; plane++)
536 int n = pFields[0]->GetPlane(plane)->GetTotPoints();
540 int offset = plane * n;
541 int xoffset = var *
m_np+plane;
542 int yoffset = 2*
m_np + xoffset;
559 std::string supptype =
m_session->GetSolverInfo(
"SupportType");
561 int npts = HydroForces.size();
566 for(
int i = 0; i < 4; i++)
573 for(
int i = 0; i < 3; i++)
575 Vmath::Vcopy(npts, BodyMotions+i*npts, 1, fft_i[i+1], 1);
579 if(boost::iequals(supptype,
"Free-Free"))
581 for(
int j = 0 ; j < 4; ++j)
583 m_FFT->FFTFwdTrans(fft_i[j], fft_o[j]);
586 else if(boost::iequals(supptype,
"Pinned-Pinned"))
589 int N = fft_i[0].size();
591 for(
int var = 0; var < 4; var++)
593 for(
int i = 0; i < N; i++)
597 for(
int k = 0; k < N; k++)
601 sin(M_PI/(N)*(k+1/2)*(i+1));
609 "Unrecognized support type for cable's motion");
613 for(
int i = 0; i < npts; ++i)
622 for(
int var = 0; var < 3; var++)
624 tmp0[var] = fft_o[var+1][i];
627 tmp2[0] = fft_o[0][i];
638 for(
int var = 0; var < 3; var++)
640 fft_i[var][i] = tmp1[var];
646 if(boost::iequals(supptype,
"Free-Free"))
648 for(
int var = 0; var < 3; var++)
650 m_FFT->FFTBwdTrans(fft_i[var], fft_o[var]);
653 else if(boost::iequals(supptype,
"Pinned-Pinned"))
656 int N = fft_i[0].size();
658 for(
int var = 0; var < 3; var++)
660 for(
int i = 0; i < N; i++)
664 for(
int k = 0; k < N; k++)
668 sin(M_PI/(N)*(k+1)*(i+1/2))*2/N;
676 "Unrecognized support type for cable's motion");
680 for(
int i = 0; i < 3; i++)
683 Vmath::Vcopy(npts, fft_o[i], 1, tmp = BodyMotions+i*npts, 1);
699 int colrank = vcomm->GetColumnComm()->GetRank();
700 int nproc = vcomm->GetColumnComm()->GetSize();
705 m_session->MatchSolverInfo(
"HomoStrip",
"True",homostrip,
false);
709 npts =
m_session->GetParameter(
"HomModesZ");
713 m_session->LoadParameter(
"HomStructModesZ", npts);
721 ZIDs = pFields[0]->GetZIDs();
724 std::string vibtype =
m_session->GetSolverInfo(
"VibrationType");
726 if(boost::iequals(vibtype,
"Constrained"))
730 else if (boost::iequals(vibtype,
"Free"))
734 else if (boost::iequals(vibtype,
"Forced"))
743 int nplanes =
m_session->GetParameter(
"HomModesZ");
753 m_session->LoadParameter(
"DistStrip", DistStrip);
754 m_session->LoadParameter(
"Strip_Z", nstrips);
755 m_lhom = nstrips * DistStrip;
768 m_session->MatchSolverInfo(
"FictitiousMassMethod",
"True",
773 m_session->LoadParameter(
"FictMass", fictrho);
774 m_session->LoadParameter(
"FictDamp", fictdamp);
782 for (
int i = 0; i <
m_motion.size(); ++i)
787 for(
int n = 0; n < 2; ++n)
806 std::ifstream inputStream;
811 m_session->LoadParameter(
"HomStructModesZ", nzpoints);
815 nzpoints = pFields[0]->GetHomogeneousBasis()->GetNumModes();
818 if (vcomm->GetRank() == 0)
820 std::string filename =
m_session->GetFunctionFilename(
824 inputStream.open(filename.c_str());
828 for(
int n = 0; n < tmp.size(); n++)
830 inputStream >> tmp[n];
835 for (
int n = 0; n < nzpoints; n++)
837 inputStream >> setprecision(6) >> time;
838 inputStream >> setprecision(6) >> z_cds;
840 inputStream >> setprecision(8) >>
m_MotionVars[0][n+nzpoints];
841 inputStream >> setprecision(8) >>
m_MotionVars[0][n+2*nzpoints];
843 inputStream >> setprecision(8) >>
m_MotionVars[1][n+nzpoints];
844 inputStream >> setprecision(8) >>
m_MotionVars[1][n+2*nzpoints];
855 int nzpoints = pFields[0]->GetHomogeneousBasis()->GetNumModes();
858 = pFields[0]->GetHomogeneousBasis()->GetZ();
866 for (
int plane = 0; plane <
m_np; plane++)
868 x2[plane] = z_coords[ZIDs[plane]];
878 ffunc0->Evaluate(x0, x1, x2, 0.0, tmp0);
879 ffunc1->Evaluate(x0, x1, x2, 0.0, tmp1);
887 for (
int i = 1; i < nproc; ++i)
889 vcomm->GetColumnComm()->Recv(i, tmp0);
890 vcomm->GetColumnComm()->Recv(i, tmp1);
897 vcomm->GetColumnComm()->Send(0, tmp0);
898 vcomm->GetColumnComm()->Send(0, tmp1);
906 m_session->LoadParameter(
"Strip_Z", nstrips);
909 "Fourier transformation of cable motion is currently "
910 "implemented only for FFTW module.");
913 m_session->LoadParameter(
"DistStrip", DistStrip);
921 for (
int plane = 0; plane < npts; plane++)
923 x2[plane] = plane*DistStrip;
928 ffunc0->Evaluate(x0, x1, x2, 0.0, tmp0);
929 ffunc1->Evaluate(x0, x1, x2, 0.0, tmp1);
952 m_session->MatchSolverInfo(
"HomoStrip",
"True",homostrip,
false);
956 nplanes =
m_session->GetParameter(
"HomModesZ");
960 m_session->LoadParameter(
"Strip_Z", nplanes);
973 m_session->LoadParameter(
"StructStiff", structstiff, 0.0);
974 m_session->LoadParameter(
"CableTension", cabletension, 0.0);
975 m_session->LoadParameter(
"BendingStiff", bendingstiff, 0.0);
986 std::string supptype =
m_session->GetSolverInfo(
"SupportType");
988 for(
int plane = 0; plane < nplanes; plane++)
1000 if (boost::iequals(supptype,
"Free-Free"))
1003 beta = 2.0 * M_PI/
m_lhom;
1005 else if(boost::iequals(supptype,
"Pinned-Pinned"))
1013 "Unrecognized support type for cable's motion");
1019 tmp7 = tmp2 + tmp4 * tmp6 + tmp5 * tmp7;
1055 int nlevels = input.size();
1058 tmp = input[nlevels-1];
1060 for(
int n = nlevels-1; n > 0; --n)
1062 input[n] = input[n-1];
1087 const TiXmlElement* funcNameElmt_D
1088 = pForce->FirstChildElement(
"DISPLACEMENTS");
1090 "MOVINGBODYFORCE tag has to specify a function name which "
1091 "prescribes the body displacement as d(z,t).");
1095 "Function '" +
m_funcName[0] +
"' not defined.");
1098 const TiXmlElement* funcNameElmt_V
1099 = pForce->FirstChildElement(
"VELOCITIES");
1101 "MOVINGBODYFORCE tag has to specify a function name which "
1102 "prescribes the body velocity of movement as v(z,t).");
1106 "Function '" +
m_funcName[1] +
"' not defined.");
1110 const TiXmlElement* funcNameElmt_A
1111 = pForce->FirstChildElement(
"ACCELERATIONS");
1113 "MOVINGBODYFORCE tag has to specify a function name which "
1114 "prescribes the body acceleration as a(z,t).");
1118 "Function '" +
m_funcName[2] +
"' not defined.");
1134 ASSERTL0(
false,
"The displacements in x must be specified via an "
1135 "equation <E> or a file <F>");
1150 ASSERTL0(
false,
"The displacements in y must be specified via an "
1151 "equation <E> or a file <F>");
1166 ASSERTL0(
false,
"The velocities in x must be specified via an equation "
1167 "<E> or a file <F>");
1182 ASSERTL0(
false,
"The velocities in y must be specified via an equation "
1183 "<E> or a file <F>");
1198 ASSERTL0(
false,
"The accelerations in x must be specified via an "
1199 "equation <E> or a file <F>");
1214 ASSERTL0(
false,
"The accelerations in y must be specified via an "
1215 "equation <E> or a file <F>");
1225 const TiXmlElement* pForce)
1229 std::string typeStr = pForce->Attribute(
"TYPE");
1230 std::map<std::string, std::string> vParams;
1232 const TiXmlElement *param = pForce->FirstChildElement(
"PARAM");
1236 "Missing attribute 'NAME' for parameter in filter "
1238 std::string nameStr = param->Attribute(
"NAME");
1240 ASSERTL0(param->GetText(),
"Empty value string for param.");
1241 std::string valueStr = param->GetText();
1243 vParams[nameStr] = valueStr;
1245 param = param->NextSiblingElement(
"PARAM");
#define ASSERTL0(condition, msg)
GlobalMapping::MappingSharedPtr m_mapping
Array< OneD, std::string > m_funcName
[0] is displacements, [1] is velocities, [2] is accelerations
NekDouble m_lhom
length ratio of the cable
NekDouble m_kinvis
fluid viscous
Array< OneD, DNekMatSharedPtr > m_CoeffMat_A
matrices in Newmart-beta method
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)
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)
Array< OneD, Array< OneD, NekDouble > > m_zta
Store the derivatives of motion variables in x-direction.
void RollOver(Array< OneD, Array< OneD, NekDouble > > &input)
void InitialiseCableModel(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
NekDouble m_structrho
mass of the cable per unit length
NekDouble m_timestep
time step
virtual void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
int m_np
number of planes per processors
int m_vdim
vibration dimension
Array< OneD, Array< OneD, NekDouble > > m_eta
Store the derivatives of motion variables in y-direction.
Array< OneD, bool > m_IsFromFile
do determine if the the body motion come from an extern file
FilterMovingBodySharedPtr m_MovBodyfilter
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)
int 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
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.
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
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 vector 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.