50 const std::weak_ptr<SolverUtils::EquationSystem> &pEquation)
57 [[maybe_unused]]
const unsigned int &pNumForcingFields,
58 const TiXmlElement *pForce)
62 "Moving body implemented just for 3D Homogenous 1D expansions.");
95 size_t phystot = pFields[0]->GetTotPoints();
96 for (
size_t i = 0; i <
m_zta.size(); i++)
125 size_t physTot = pFields[0]->GetTotPoints();
128 for (
size_t i = 0; i < 3; i++)
134 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
144 m_mapping->UpdateMapping(time, coords, coordsVel);
150 for (
size_t j = 0; j <
m_funcName.size(); j++)
154 ASSERTL0(
false,
"Motion loading from file needs specific "
155 "implementation: Work in Progress!");
171 size_t physTot = pFields[0]->GetTotPoints();
174 for (
size_t i = 0; i < 3; i++)
180 pFields[0]->GetCoords(coords[0], coords[1], coords[2]);
193 for (
size_t var = 0; var < 3; var++)
195 for (
size_t plane = 0; plane <
m_np; plane++)
197 size_t n = pFields[0]->GetPlane(plane)->GetTotPoints();
198 size_t offset = plane * n;
199 size_t Offset = var *
m_np + plane;
208 ASSERTL0(
false,
"Unrecogized vibration type for cable's dynamic model");
212 size_t colrank = vcomm->GetColumnComm()->GetRank();
232 size_t colrank = vcomm->GetColumnComm()->GetRank();
233 size_t nproc = vcomm->GetColumnComm()->GetSize();
236 m_session->MatchSolverInfo(
"HomoStrip",
"True", homostrip,
false);
239 size_t npts, nstrips;
242 npts =
m_session->GetParameter(
"HomModesZ");
246 m_session->LoadParameter(
"HomStructModesZ", npts);
247 m_session->LoadParameter(
"Strip_Z", nstrips);
271 fces[0][0] = Hydroforces[0];
272 fces[1][0] = Hydroforces[
m_np];
278 for (
size_t i = 1; i < nproc; ++i)
280 vcomm->GetColumnComm()->Recv(i, tmp);
281 for (
size_t n = 0; n <
m_np; n++)
283 for (
size_t j = 0; j < 2; ++j)
285 fces[j][i *
m_np + n] = tmp[j *
m_np + n];
295 for (
size_t i = 1; i < nstrips; ++i)
297 vcomm->GetColumnComm()->Recv(i, tmp);
299 for (
size_t j = 0; j < 2; ++j)
310 vcomm->GetColumnComm()->Send(0, Hydroforces);
314 for (
size_t 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", fictmass,
337 m_session->LoadParameter(
"FictMass", fictrho);
338 m_session->LoadParameter(
"FictDamp", fictdamp);
340 static NekDouble Betaq_Coeffs[2][2] = {{1.0, 0.0}, {2.0, -1.0}};
345 size_t nlevels =
m_fV[0].size();
347 for (
size_t i = 0; i <
m_motion.size(); ++i)
352 size_t Voffset = npts;
353 size_t Aoffset = 2 * npts;
359 Vmath::Smul(npts, Betaq_Coeffs[nint - 1][nint - 1],
360 m_fV[i][nint - 1], 1,
m_fV[i][nlevels - 1], 1);
361 Vmath::Smul(npts, Betaq_Coeffs[nint - 1][nint - 1],
362 m_fA[i][nint - 1], 1,
m_fA[i][nlevels - 1], 1);
364 for (
size_t n = 0; n < nint - 1; ++n)
367 m_fV[i][nlevels - 1], 1,
m_fV[i][nlevels - 1],
370 m_fA[i][nlevels - 1], 1,
m_fA[i][nlevels - 1],
386 for (
size_t n = 0, cn = 1; n <
m_vdim; n++, cn--)
400 vcomm->GetColumnComm()->Recv(0, tmp);
405 for (
size_t i = 1; i < nproc; ++i)
407 for (
size_t j = 0; j < 2; j++)
409 for (
size_t k = 0; k < 2; k++)
411 for (
size_t n = 0; n <
m_np; n++)
418 vcomm->GetColumnComm()->Send(i, tmp);
421 for (
size_t j = 0; j < 2; j++)
423 for (
size_t k = 0; k < 2; k++)
425 for (
size_t n = 0; n <
m_np; n++)
441 for (
size_t j = 1; j < nproc / nstrips; j++)
443 if (colrank == j * nstrips)
445 vcomm->GetColumnComm()->Recv(0, tmp);
447 for (
size_t plane = 0; plane <
m_np; plane++)
449 for (
size_t var = 0; var < 2; var++)
451 for (
size_t k = 0; k < 2; k++)
453 Motvars[var * 2 *
m_np + k *
m_np + plane] =
461 for (
size_t i = 1; i < nstrips; i++)
463 for (
size_t j = 0; j < nproc / nstrips; j++)
465 if (colrank == i + j * nstrips)
467 vcomm->GetColumnComm()->Recv(0, tmp);
469 for (
size_t plane = 0; plane <
m_np; plane++)
471 for (
size_t var = 0; var < 2; var++)
473 for (
size_t k = 0; k < 2; k++)
475 Motvars[var * 2 *
m_np + k *
m_np + plane] =
486 for (
size_t j = 0; j < 2; ++j)
488 for (
size_t k = 0; k < 2; ++k)
494 for (
size_t j = 1; j < nproc / nstrips; j++)
496 vcomm->GetColumnComm()->Send(j * nstrips, tmp);
499 for (
size_t plane = 0; plane <
m_np; plane++)
501 for (
size_t j = 0; j < 2; j++)
503 for (
size_t k = 0; k < 2; ++k)
505 Motvars[j * 2 *
m_np + k *
m_np + plane] =
511 for (
size_t i = 1; i < nstrips; ++i)
513 for (
size_t j = 0; j < 2; ++j)
515 for (
size_t k = 0; k < 2; ++k)
521 for (
size_t j = 0; j < nproc / nstrips; j++)
523 vcomm->GetColumnComm()->Send(i + j * nstrips, tmp);
530 for (
size_t var = 0; var < 2; var++)
532 for (
size_t plane = 0; plane <
m_np; plane++)
534 size_t n = pFields[0]->GetPlane(plane)->GetTotPoints();
538 size_t offset = plane * n;
539 size_t xoffset = var *
m_np + plane;
540 size_t yoffset = 2 *
m_np + xoffset;
555 std::string supptype =
m_session->GetSolverInfo(
"SupportType");
557 size_t npts = HydroForces.size();
562 for (
size_t i = 0; i < 4; i++)
569 for (
size_t i = 0; i < 3; i++)
571 Vmath::Vcopy(npts, BodyMotions + i * npts, 1, fft_i[i + 1], 1);
575 if (boost::iequals(supptype,
"Free-Free"))
577 for (
size_t j = 0; j < 4; ++j)
579 m_FFT->FFTFwdTrans(fft_i[j], fft_o[j]);
582 else if (boost::iequals(supptype,
"Pinned-Pinned"))
585 size_t N = fft_i[0].size();
587 for (
size_t var = 0; var < 4; var++)
589 for (
size_t i = 0; i < N; i++)
593 for (
size_t k = 0; k < N; k++)
596 fft_i[var][k] * sin(M_PI / (N) * (k + 1 / 2) * (i + 1));
603 ASSERTL0(
false,
"Unrecognized support type for cable's motion");
607 for (
size_t i = 0; i < npts; ++i)
616 for (
size_t var = 0; var < 3; var++)
618 tmp0[var] = fft_o[var + 1][i];
621 tmp2[0] = fft_o[0][i];
624 nrows, &tmp0[0], 1, 0.0, &tmp1[0], 1);
626 &(
m_CoeffMat_A[i]->GetPtr())[0], nrows, &tmp2[0], 1, 1.0,
629 for (
size_t var = 0; var < 3; var++)
631 fft_i[var][i] = tmp1[var];
637 if (boost::iequals(supptype,
"Free-Free"))
639 for (
size_t var = 0; var < 3; var++)
641 m_FFT->FFTBwdTrans(fft_i[var], fft_o[var]);
644 else if (boost::iequals(supptype,
"Pinned-Pinned"))
647 size_t N = fft_i[0].size();
649 for (
size_t var = 0; var < 3; var++)
651 for (
size_t i = 0; i < N; i++)
655 for (
size_t k = 0; k < N; k++)
657 fft_o[var][i] += fft_i[var][k] *
658 sin(M_PI / (N) * (k + 1) * (i + 1 / 2)) *
666 ASSERTL0(
false,
"Unrecognized support type for cable's motion");
669 for (
size_t i = 0; i < 3; i++)
672 Vmath::Vcopy(npts, fft_o[i], 1, tmp = BodyMotions + i * npts, 1);
688 size_t colrank = vcomm->GetColumnComm()->GetRank();
689 size_t nproc = vcomm->GetColumnComm()->GetSize();
694 m_session->MatchSolverInfo(
"HomoStrip",
"True", homostrip,
false);
698 npts =
m_session->GetParameter(
"HomModesZ");
702 m_session->LoadParameter(
"HomStructModesZ", npts);
710 ZIDs = pFields[0]->GetZIDs();
713 std::string vibtype =
m_session->GetSolverInfo(
"VibrationType");
715 if (boost::iequals(vibtype,
"Constrained"))
719 else if (boost::iequals(vibtype,
"Free"))
723 else if (boost::iequals(vibtype,
"Forced"))
732 int nplanes =
m_session->GetParameter(
"HomModesZ");
741 m_session->LoadParameter(
"DistStrip", DistStrip);
742 m_session->LoadParameter(
"Strip_Z", nstrips);
743 m_lhom = nstrips * DistStrip;
755 m_session->MatchSolverInfo(
"FictitiousMassMethod",
"True", fictmass,
false);
759 m_session->LoadParameter(
"FictMass", fictrho);
760 m_session->LoadParameter(
"FictDamp", fictdamp);
768 for (
size_t i = 0; i <
m_motion.size(); ++i)
773 for (
size_t n = 0; n < 2; ++n)
787 for (
size_t j = 0; j <
m_funcName.size(); j++)
792 std::ifstream inputStream;
797 m_session->LoadParameter(
"HomStructModesZ", nzpoints);
801 nzpoints = pFields[0]->GetHomogeneousBasis()->GetNumModes();
804 if (vcomm->GetRank() == 0)
806 std::string filename =
810 inputStream.open(filename.c_str());
814 for (
size_t n = 0; n < tmp.size(); n++)
816 inputStream >> tmp[n];
821 for (
size_t n = 0; n < nzpoints; n++)
823 inputStream >> setprecision(6) >> time;
824 inputStream >> setprecision(6) >> z_cds;
826 inputStream >> setprecision(8) >>
828 inputStream >> setprecision(8) >>
831 inputStream >> setprecision(8) >>
833 inputStream >> setprecision(8) >>
846 pFields[0]->GetHomogeneousBasis()->GetNumModes();
849 pFields[0]->GetHomogeneousBasis()->GetZ();
857 for (
size_t plane = 0; plane <
m_np; plane++)
859 x2[plane] = z_coords[ZIDs[plane]];
869 ffunc0->Evaluate(x0, x1, x2, 0.0, tmp0);
870 ffunc1->Evaluate(x0, x1, x2, 0.0, tmp1);
872 size_t offset = j * npts;
878 for (
size_t i = 1; i < nproc; ++i)
880 vcomm->GetColumnComm()->Recv(i, tmp0);
881 vcomm->GetColumnComm()->Recv(i, tmp1);
892 vcomm->GetColumnComm()->Send(0, tmp0);
893 vcomm->GetColumnComm()->Send(0, tmp1);
901 m_session->LoadParameter(
"Strip_Z", nstrips);
905 "Fourier transformation of cable motion is currently "
906 "implemented only for FFTW module.");
909 m_session->LoadParameter(
"DistStrip", DistStrip);
917 for (
size_t plane = 0; plane < npts; plane++)
919 x2[plane] = plane * DistStrip;
924 ffunc0->Evaluate(x0, x1, x2, 0.0, tmp0);
925 ffunc1->Evaluate(x0, x1, x2, 0.0, tmp1);
927 size_t offset = j * npts;
949 m_session->MatchSolverInfo(
"HomoStrip",
"True", homostrip,
false);
953 nplanes =
m_session->GetParameter(
"HomModesZ");
957 m_session->LoadParameter(
"Strip_Z", nplanes);
970 m_session->LoadParameter(
"StructStiff", structstiff, 0.0);
971 m_session->LoadParameter(
"CableTension", cabletension, 0.0);
972 m_session->LoadParameter(
"BendingStiff", bendingstiff, 0.0);
983 std::string supptype =
m_session->GetSolverInfo(
"SupportType");
985 for (
size_t plane = 0; plane < nplanes; plane++)
997 if (boost::iequals(supptype,
"Free-Free"))
1002 else if (boost::iequals(supptype,
"Pinned-Pinned"))
1009 ASSERTL0(
false,
"Unrecognized support type for cable's motion");
1015 tmp7 = tmp2 + tmp4 * tmp6 + tmp5 * tmp7;
1050 size_t nlevels = input.size();
1053 tmp = input[nlevels - 1];
1055 for (
size_t n = nlevels - 1; n > 0; --n)
1057 input[n] = input[n - 1];
1082 const TiXmlElement *funcNameElmt_D =
1083 pForce->FirstChildElement(
"DISPLACEMENTS");
1085 "MOVINGBODYFORCE tag has to specify a function name which "
1086 "prescribes the body displacement as d(z,t).");
1090 "Function '" +
m_funcName[0] +
"' not defined.");
1093 const TiXmlElement *funcNameElmt_V =
1094 pForce->FirstChildElement(
"VELOCITIES");
1096 "MOVINGBODYFORCE tag has to specify a function name which "
1097 "prescribes the body velocity of movement as v(z,t).");
1101 "Function '" +
m_funcName[1] +
"' not defined.");
1104 const TiXmlElement *funcNameElmt_A =
1105 pForce->FirstChildElement(
"ACCELERATIONS");
1107 "MOVINGBODYFORCE tag has to specify a function name which "
1108 "prescribes the body acceleration as a(z,t).");
1112 "Function '" +
m_funcName[2] +
"' not defined.");
1128 ASSERTL0(
false,
"The displacements in x must be specified via an "
1129 "equation <E> or a file <F>");
1144 ASSERTL0(
false,
"The displacements in y must be specified via an "
1145 "equation <E> or a file <F>");
1160 ASSERTL0(
false,
"The velocities in x must be specified via an equation "
1161 "<E> or a file <F>");
1176 ASSERTL0(
false,
"The velocities in y must be specified via an equation "
1177 "<E> or a file <F>");
1192 ASSERTL0(
false,
"The accelerations in x must be specified via an "
1193 "equation <E> or a file <F>");
1208 ASSERTL0(
false,
"The accelerations in y must be specified via an "
1209 "equation <E> or a file <F>");
1219 const TiXmlElement *pForce)
1223 std::string typeStr = pForce->Attribute(
"TYPE");
1224 std::map<std::string, std::string> vParams;
1226 const TiXmlElement *param = pForce->FirstChildElement(
"PARAM");
1230 "Missing attribute 'NAME' for parameter in filter " + typeStr +
1232 std::string nameStr = param->Attribute(
"NAME");
1234 ASSERTL0(param->GetText(),
"Empty value string for param.");
1235 std::string valueStr = param->GetText();
1237 vParams[nameStr] = valueStr;
1239 param = param->NextSiblingElement(
"PARAM");
1246 pSession,
m_equ.lock(), vParams);
#define ASSERTL0(condition, msg)
GlobalMapping::MappingSharedPtr m_mapping
Array< OneD, std::string > m_funcName
[0] is displacements, [1] is velocities, [2] is accelerations
ForcingMovingBody(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< SolverUtils::EquationSystem > &pEquation)
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 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
size_t m_vdim
vibration dimension
NekDouble m_timestep
time step
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, 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
static SolverUtils::ForcingSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< SolverUtils::EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields, const TiXmlElement *pForce)
Creates an instance of this class.
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)
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
static std::string className
Name of the class.
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 = alpha A x plus beta y 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.
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.