43 RegisterCreatorFunction(
"MovingBody",
45 "Moving Body Forcing");
55 const unsigned int& pNumForcingFields,
56 const TiXmlElement* pForce)
60 "Moving body implemented just for 3D Homogenous 1D expansions.");
92 int phystot = pFields[0]->GetTotPoints();
93 for(
int i = 0; i <
m_zta.num_elements(); i++)
122 int physTot = pFields[0]->GetTotPoints();
125 for(
int i =0; i<3; i++)
131 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
141 m_mapping->UpdateMapping(time, coords, coordsVel);
147 for(
int j = 0; j <
m_funcName.num_elements(); j++)
151 ASSERTL0(
false,
"Motion loading from file needs specific "
152 "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].num_elements();
348 for(
int i = 0; i <
m_motion.num_elements(); ++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++)
420 tmp[j*2*m_np+k*m_np+n] =
m_MotionVars[j][k*npts+i*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.num_elements();
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].num_elements();
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];
629 Blas::Dgemv(
'N', nrows, nrows, 1.0,
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].num_elements();
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();
722 m_np = ZIDs.num_elements();
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.num_elements(); ++i)
787 for(
int n = 0; n < 2; ++n)
801 for(
int j = 0; j <
m_funcName.num_elements(); j++)
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.num_elements(); n++)
830 inputStream >> tmp[n];
835 for (
int n = 0; n < nzpoints; n++)
837 inputStream >> setprecision(6) >> time;
838 inputStream >> setprecision(6) >> z_cds;
839 inputStream >> setprecision(8) >> m_MotionVars[0][n];
840 inputStream >> setprecision(8) >> m_MotionVars[0][n+nzpoints];
841 inputStream >> setprecision(8) >> m_MotionVars[0][n+2*nzpoints];
842 inputStream >> setprecision(8) >> m_MotionVars[1][n];
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);
882 Vmath::Vcopy(m_np, tmp0, 1, tmp = m_MotionVars[0]+offset,1);
883 Vmath::Vcopy(m_np, tmp1, 1, tmp = m_MotionVars[1]+offset,1);
887 for (
int i = 1; i < nproc; ++i)
889 vcomm->GetColumnComm()->Recv(i, tmp0);
890 vcomm->GetColumnComm()->Recv(i, tmp1);
891 Vmath::Vcopy(m_np, tmp0, 1, tmp = m_MotionVars[0]+offset+i*m_np,1);
892 Vmath::Vcopy(m_np, tmp1, 1, tmp = m_MotionVars[1]+offset+i*m_np,1);
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);
932 Vmath::Vcopy(npts, tmp0, 1, tmp = m_MotionVars[0]+offset,1);
933 Vmath::Vcopy(npts, tmp1, 1, tmp = m_MotionVars[1]+offset,1);
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;
1030 (*m_CoeffMat_B[plane])(0,0) = 0.0;
1031 (*m_CoeffMat_B[plane])(0,1) = 0.0;
1032 (*m_CoeffMat_B[plane])(0,2) = 0.0;
1033 (*m_CoeffMat_B[plane])(1,0) = 0.0;
1034 (*m_CoeffMat_B[plane])(1,1) = 1.0;
1035 (*m_CoeffMat_B[plane])(1,2) = m_timestep/2.0;
1036 (*m_CoeffMat_B[plane])(2,0) = 1.0;
1038 (*m_CoeffMat_B[plane])(2,2) = tmp1/4.0;
1041 (*m_CoeffMat_B[plane]) =
1055 int nlevels = input.num_elements();
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");
Array< OneD, DNekMatSharedPtr > m_CoeffMat_B
matrices in Newmart-beta method
NekDouble m_structrho
mass of the cable per unit length
#define ASSERTL0(condition, msg)
void CheckIsFromFile(const TiXmlElement *pForce)
NekDouble m_structdamp
damping ratio of the cable
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
Array< OneD, Array< OneD, NekDouble > > m_MotionVars
storage for the cable's motion(x,y) variables
void SetDynEqCoeffMatrix(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Array< OneD, DNekMatSharedPtr > m_CoeffMat_A
matrices in Newmart-beta method
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
ForcingFactory & GetForcingFactory()
Declaration of the forcing factory singleton.
virtual void v_InitObject(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
SOLVER_UTILS_EXPORT void EvaluateFunction(Array< OneD, MultiRegions::ExpListSharedPtr > pFields, LibUtilities::SessionReaderSharedPtr pSession, std::string pFieldName, Array< OneD, NekDouble > &pArray, const std::string &pFunctionName, NekDouble pTime=NekDouble(0))
GlobalMapping::MappingSharedPtr m_mapping
void Newmark_betaSolver(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &FcePhysinArray, Array< OneD, NekDouble > &MotPhysinArray)
NektarFFTFactory & GetNektarFFTFactory()
void InitialiseFilter(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const TiXmlElement *pForce)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
ForcingMovingBody(const LibUtilities::SessionReaderSharedPtr &pSession)
int m_movingBodyCalls
number of times the movbody have been called
NekDouble m_kinvis
fluid viscous
Array< OneD, std::string > m_motion
motion direction: [0] is 'x' and [1] is 'y'
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
int m_vdim
vibration dimension
LibUtilities::NektarFFTSharedPtr m_FFT
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)
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
NekDouble m_timestep
time step
boost::shared_ptr< Equation > EquationSharedPtr
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.
void InitialiseCableModel(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
Array< OneD, bool > m_IsFromFile
do determine if the the body motion come from an extern file
Array< OneD, Array< OneD, NekDouble > > m_eta
Store the derivatives of motion variables in y-direction.
FilterMovingBodySharedPtr m_MovBodyfilter
NekDouble m_lhom
length ratio of the cable
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_fV
fictitious velocity storage
static std::string className
Name of the class.
int m_np
number of planes per processors
Array< OneD, std::string > m_funcName
[0] is displacements, [1] is velocities, [2] is accelerations
void EvaluateStructDynModel(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &Hydroforces, NekDouble time)
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_fA
fictitious acceleration storage
void RollOver(Array< OneD, Array< OneD, NekDouble > > &input)
static SolverUtils::ForcingSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Creates an instance of this class.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Array< OneD, Array< OneD, NekDouble > > m_zta
Store the derivatives of motion variables in x-direction.
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.
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.