47 RegisterCreatorFunction(
"MovingBody",
49 "Moving Body Filter");
55 const std::map<std::string, std::string> &pParams)
59 if (pParams.find(
"OutputFile") == pParams.end())
66 ASSERTL0(!(pParams.find(
"OutputFile")->second.empty()),
67 "Missing parameter 'OutputFile'.");
83 if (pParams.find(
"OutputFrequency") == pParams.end())
90 pParams.find(
"OutputFrequency")->second.c_str());
96 "Homogeneous 1D discetisations.");
99 if (pParams.find(
"Boundary") == pParams.end())
101 ASSERTL0(
false,
"Missing parameter 'Boundary'.");
105 ASSERTL0(!(pParams.find(
"Boundary")->second.empty()),
106 "Missing parameter 'Boundary'.");
135 (std::string(
"Error reading boundary region definition:") +
139 LastInd - FirstInd + 1);
145 (std::string(
"Unable to read boundary regions index "
146 "range for FilterAeroForces: ") + IndString).c_str());
151 unsigned int numBoundaryRegions
152 = pFields[0]->GetBndConditions().num_elements();
155 numBoundaryRegions, 0);
162 SpatialDomains::BoundaryRegionCollection::const_iterator it;
164 for (cnt = 0, it = bregions.begin(); it != bregions.end();
177 if (vComm->GetRank() == 0)
233 int n, cnt, elmtid, nq, offset, boundary;
234 int nt = pFields[0]->GetNpoints();
235 int dim = pFields.num_elements()-1;
263 int Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
272 NekDouble rho = (pSession->DefinesParameter(
"rho"))
273 ? (pSession->GetParameter(
"rho"))
275 NekDouble mu = rho*pSession->GetParameter(
"Kinvis");
277 for(
int i = 0; i < pFields.num_elements(); ++i)
279 pFields[i]->SetWaveSpace(
false);
280 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
281 pFields[i]->UpdatePhys());
282 pFields[i]->SetPhysState(
true);
288 ZIDs = pFields[0]->GetZIDs();
289 int local_planes = ZIDs.num_elements();
293 for(
int plane = 0 ; plane < local_planes; plane++)
295 pFields[0]->GetPlane(plane)->GetBoundaryToElmtMap(BoundarytoElmtID,
297 BndExp = pFields[0]->GetPlane(plane)->GetBndCondExpansions();
301 for(cnt = n = 0; n < BndExp.num_elements(); ++n)
305 for(
int i = 0; i < BndExp[n]->GetExpSize(); ++i, cnt++)
308 elmtid = BoundarytoElmtID[cnt];
309 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
310 nq = elmt->GetTotPoints();
311 offset = pFields[0]->GetPlane(plane)
312 ->GetPhys_Offset(elmtid);
317 for(
int j = 0; j < dim; ++j)
325 boundary = BoundarytoTraceID[cnt];
328 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
329 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
330 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
333 elmt->PhysDeriv(U,gradU[0],gradU[1]);
334 elmt->PhysDeriv(V,gradV[0],gradV[1]);
345 for(
int j = 0; j < dim; ++j)
359 boundary = BoundarytoTraceID[cnt];
363 elmt->GetEdgePhysVals(boundary,bc,P,Pb);
365 for(
int j = 0; j < dim; ++j)
367 elmt->GetEdgePhysVals(boundary,bc,gradU[j],fgradU[j]);
368 elmt->GetEdgePhysVals(boundary,bc,gradV[j],fgradV[j]);
373 = elmt->GetEdgeNormal(boundary);
392 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
393 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
396 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
410 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
411 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
414 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
415 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
430 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
431 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
433 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
434 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
439 cnt += BndExp[n]->GetExpSize();
444 for(
int i = 0; i < pFields.num_elements(); ++i)
446 pFields[i]->SetWaveSpace(
true);
447 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
448 pFields[i]->UpdatePhys());
449 pFields[i]->SetPhysState(
false);
458 if(vComm->GetRowComm()->GetSize() > 0)
465 for(
int plane = 0 ; plane < local_planes; plane++)
480 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
482 if(vComm->GetRowComm()->GetRank() == 0)
484 for(
int z = 0 ; z < Num_z_pos; z++)
495 if(vComm->GetRowComm()->GetRank() == 0)
497 for(
int z = 0 ; z < Num_z_pos; z++)
507 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
510 for(
int plane = 0 ; plane < local_planes; plane++)
512 Aeroforces[plane] = Fxp[ZIDs[plane]]
514 Aeroforces[plane + local_planes] = Fyp[ZIDs[plane]]
531 = pFields[0]->GetHomogeneousBasis()->GetZ();
534 pSession->LoadParameter(
"LZ", LZ);
536 Vmath::Sadd(Num_z_pos,LZ/2.0,z_coords,1,z_coords,1);
537 if (vComm->GetRank() == 0)
543 for(
int i = 0 ; i < Num_z_pos; i++)
572 for(
int plane = 0 ; plane < local_planes; plane++)
574 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
575 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
576 fces[2] += Fxp[ZIDs[plane]] ;
577 fces[3] += Fyp[ZIDs[plane]] ;
578 fces[4] += Fxv[ZIDs[plane]] ;
579 fces[5] += Fyv[ZIDs[plane]] ;
582 fces[0] = fces[0]/local_planes;
583 fces[1] = fces[1]/local_planes;
584 fces[2] = fces[2]/local_planes;
585 fces[3] = fces[3]/local_planes;
586 fces[4] = fces[4]/local_planes;
587 fces[5] = fces[5]/local_planes;
597 int npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
599 fces[0] = fces[0]/
npts;
600 fces[1] = fces[1]/
npts;
601 fces[2] = fces[2]/
npts;
602 fces[3] = fces[3]/
npts;
603 fces[4] = fces[4]/
npts;
604 fces[5] = fces[5]/
npts;
606 for(
int plane = 0 ; plane < local_planes; plane++)
608 Aeroforces[plane] = fces[0];
609 Aeroforces[plane+local_planes] = fces[1];
618 int colrank = vColComm->GetRank();
623 pSession->LoadParameter(
"Strip_Z", nstrips);
624 pSession->LoadParameter(
"DistStrip", DistStrip);
627 for(
int i = 0; i < nstrips; i++)
629 z_coords[i] = i * DistStrip;
655 for(
int i = 1; i < nstrips; i++)
657 vColComm->Recv(i, fces);
683 for(
int i = 1; i < nstrips; i++)
687 vColComm->Send(0, fces);
713 ZIDs = pFields[0]->GetZIDs();
714 int local_planes = ZIDs.num_elements();
717 = pFields[0]->GetComm()->GetColumnComm();
720 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
722 int Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
725 = pFields[0]->GetHomogeneousBasis()->GetZ();
728 pSession->LoadParameter(
"LZ", LZ);
730 Vmath::Sadd(Num_z_pos,LZ/2.0,z_coords,1,z_coords,1);
737 for(
int i = 0; i < nStrVars; i++)
743 for(
int plane = 0; plane < local_planes; plane++)
745 for (
int var = 0; var < nStrVars; var++)
747 int xoffset = var*local_planes+plane;
748 int yoffset = nStrVars*local_planes+xoffset;
749 Motion_x[var][plane] = MotionVars[xoffset];
750 Motion_y[var][plane] = MotionVars[yoffset];
761 int npoints = Motion_x[0].num_elements();
776 int colrank = vColComm->GetRank();
777 int nproc = vColComm->GetSize();
781 for (
int j = 0; j <Motion_x[0].num_elements(); j++)
802 for (
int i = 1; i < nproc; ++i)
804 vColComm->Recv(i, CableAccelX);
805 vColComm->Recv(i, CableVelocX);
806 vColComm->Recv(i, CableDisplX);
807 vColComm->Recv(i, CableAccelY);
808 vColComm->Recv(i, CableVelocY);
809 vColComm->Recv(i, CableDisplY);
812 for (
int j = 0; j < Motion_x[0].num_elements(); ++j)
814 int n = Num_z_pos/nproc * i + j;
837 vColComm->Send(0, CableAccelX);
838 vColComm->Send(0, CableVelocX);
839 vColComm->Send(0, CableDisplX);
840 vColComm->Send(0, CableAccelY);
841 vColComm->Send(0, CableVelocY);
842 vColComm->Send(0, CableDisplY);
847 int colrank = vColComm->GetRank();
852 pSession->LoadParameter(
"Strip_Z", nstrips);
853 pSession->LoadParameter(
"DistStrip", DistStrip);
856 for(
int i = 0; i < nstrips; i++)
858 z_coords[i] = i * DistStrip;
866 for(
int i = 0; i < nStrVars; i++)
872 for(
int plane = 0; plane < local_planes; plane++)
874 for (
int var = 0; var < nStrVars; var++)
876 int xoffset = plane*nStrVars+var;
877 int yoffset = nStrVars*local_planes+xoffset;
878 Motion_x[var][plane] = MotionVars[xoffset];
879 Motion_y[var][plane] = MotionVars[yoffset];
885 for(
int var = 0; var <nStrVars; var++)
887 CableMotions[var] = Motion_x[var][0];
888 CableMotions[3+var] = Motion_y[var][0];
897 for(
int var = 0; var < 2*nStrVars; var++)
904 for (
int i = 1; i < nstrips; ++i)
906 vColComm->Recv(i, CableMotions);
912 for(
int var = 0; var < 2*nStrVars; var++)
922 for(
int i = 1; i < nstrips; i++)
926 vColComm->Send(0, CableMotions);
941 if (pFields[0]->GetComm()->GetRank() == 0)
#define ASSERTL0(condition, msg)
std::string m_BoundaryString
Array< OneD, std::ofstream > m_outputStream
virtual bool v_IsTimeDependent()
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
std::string m_outputFile_mot
FilterMovingBody(const LibUtilities::SessionReaderSharedPtr &pSession, const std::map< std::string, std::string > &pParams)
LibUtilities::SessionReaderSharedPtr m_session
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
virtual void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
void UpdateMotion(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &MotionVars, const NekDouble &time)
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
static SolverUtils::FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::map< std::string, std::string > &pParams)
Creates an instance of this class.
static std::string className
virtual void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
vector< unsigned int > m_boundaryRegionsIdList
ID's of boundary regions where we want the forces.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
unsigned int m_outputFrequency
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
std::string m_outputFile_fce
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
vector< bool > m_boundaryRegionIsInList
Determines if a given Boundary Region is in m_boundaryRegionsIdList.
void UpdateForce(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &Aeroforces, const NekDouble &time)
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
FilterFactory & GetFilterFactory()
const BoundaryRegionCollection & GetBoundaryRegions(void) const
void Zero(int n, T *x, const int incx)
Zero vector.
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
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 Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.