47 RegisterCreatorFunction(
"MovingBody",
49 "Moving Body Filter");
59 ParamMap::const_iterator it;
62 it = pParams.find(
"OutputFile");
63 if (it == pParams.end())
70 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
87 it = pParams.find(
"OutputFrequency");
88 if (it == pParams.end())
100 "Homogeneous 1D discetisations.");
103 it = pParams.find(
"Boundary");
104 ASSERTL0(it != pParams.end(),
"Missing parameter 'Boundary'.");
105 ASSERTL0(it->second.length() > 0,
"Missing parameter 'Boundary'.");
133 (std::string(
"Error reading boundary region definition:") +
137 LastInd - FirstInd + 1);
143 (std::string(
"Unable to read boundary regions index "
144 "range for FilterAeroForces: ") + IndString).c_str());
149 unsigned int numBoundaryRegions
150 = pFields[0]->GetBndConditions().num_elements();
153 numBoundaryRegions, 0);
160 SpatialDomains::BoundaryRegionCollection::const_iterator it;
162 for (cnt = 0, it = bregions.begin(); it != bregions.end();
175 if (vComm->GetRank() == 0)
231 int n, cnt, elmtid, nq, offset, boundary;
232 int nt = pFields[0]->GetNpoints();
233 int dim = pFields.num_elements()-1;
261 int Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
270 NekDouble rho = (pSession->DefinesParameter(
"rho"))
271 ? (pSession->GetParameter(
"rho"))
273 NekDouble mu = rho*pSession->GetParameter(
"Kinvis");
275 for(
int i = 0; i < pFields.num_elements(); ++i)
277 pFields[i]->SetWaveSpace(
false);
278 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
279 pFields[i]->UpdatePhys());
280 pFields[i]->SetPhysState(
true);
286 ZIDs = pFields[0]->GetZIDs();
287 int local_planes = ZIDs.num_elements();
291 for(
int plane = 0 ; plane < local_planes; plane++)
293 pFields[0]->GetPlane(plane)->GetBoundaryToElmtMap(BoundarytoElmtID,
295 BndExp = pFields[0]->GetPlane(plane)->GetBndCondExpansions();
299 for(cnt = n = 0; n < BndExp.num_elements(); ++n)
303 for(
int i = 0; i < BndExp[n]->GetExpSize(); ++i, cnt++)
306 elmtid = BoundarytoElmtID[cnt];
307 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
308 nq = elmt->GetTotPoints();
309 offset = pFields[0]->GetPlane(plane)
310 ->GetPhys_Offset(elmtid);
315 for(
int j = 0; j < dim; ++j)
323 boundary = BoundarytoTraceID[cnt];
326 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
327 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
328 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
331 elmt->PhysDeriv(U,gradU[0],gradU[1]);
332 elmt->PhysDeriv(V,gradV[0],gradV[1]);
343 for(
int j = 0; j < dim; ++j)
357 boundary = BoundarytoTraceID[cnt];
361 elmt->GetEdgePhysVals(boundary,bc,P,Pb);
363 for(
int j = 0; j < dim; ++j)
365 elmt->GetEdgePhysVals(boundary,bc,gradU[j],fgradU[j]);
366 elmt->GetEdgePhysVals(boundary,bc,gradV[j],fgradV[j]);
371 = elmt->GetEdgeNormal(boundary);
390 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
391 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
394 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
408 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
409 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
412 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
413 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
428 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
429 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
431 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
432 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
437 cnt += BndExp[n]->GetExpSize();
442 for(
int i = 0; i < pFields.num_elements(); ++i)
444 pFields[i]->SetWaveSpace(
true);
445 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
446 pFields[i]->UpdatePhys());
447 pFields[i]->SetPhysState(
false);
456 if(vComm->GetRowComm()->GetSize() > 0)
463 for(
int plane = 0 ; plane < local_planes; plane++)
478 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
480 if(vComm->GetRowComm()->GetRank() == 0)
482 for(
int z = 0 ; z < Num_z_pos; z++)
493 if(vComm->GetRowComm()->GetRank() == 0)
495 for(
int z = 0 ; z < Num_z_pos; z++)
505 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
508 for(
int plane = 0 ; plane < local_planes; plane++)
510 Aeroforces[plane] = Fxp[ZIDs[plane]]
512 Aeroforces[plane + local_planes] = Fyp[ZIDs[plane]]
529 = pFields[0]->GetHomogeneousBasis()->GetZ();
532 pSession->LoadParameter(
"LZ", LZ);
534 Vmath::Sadd(Num_z_pos,LZ/2.0,z_coords,1,z_coords,1);
535 if (vComm->GetRank() == 0)
541 for(
int i = 0 ; i < Num_z_pos; i++)
570 for(
int plane = 0 ; plane < local_planes; plane++)
572 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
573 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
574 fces[2] += Fxp[ZIDs[plane]] ;
575 fces[3] += Fyp[ZIDs[plane]] ;
576 fces[4] += Fxv[ZIDs[plane]] ;
577 fces[5] += Fyv[ZIDs[plane]] ;
580 fces[0] = fces[0]/local_planes;
581 fces[1] = fces[1]/local_planes;
582 fces[2] = fces[2]/local_planes;
583 fces[3] = fces[3]/local_planes;
584 fces[4] = fces[4]/local_planes;
585 fces[5] = fces[5]/local_planes;
595 int npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
597 fces[0] = fces[0]/
npts;
598 fces[1] = fces[1]/
npts;
599 fces[2] = fces[2]/
npts;
600 fces[3] = fces[3]/
npts;
601 fces[4] = fces[4]/
npts;
602 fces[5] = fces[5]/
npts;
604 for(
int plane = 0 ; plane < local_planes; plane++)
606 Aeroforces[plane] = fces[0];
607 Aeroforces[plane+local_planes] = fces[1];
616 int colrank = vColComm->GetRank();
621 pSession->LoadParameter(
"Strip_Z", nstrips);
622 pSession->LoadParameter(
"DistStrip", DistStrip);
625 for(
int i = 0; i < nstrips; i++)
627 z_coords[i] = i * DistStrip;
653 for(
int i = 1; i < nstrips; i++)
655 vColComm->Recv(i, fces);
681 for(
int i = 1; i < nstrips; i++)
685 vColComm->Send(0, fces);
711 ZIDs = pFields[0]->GetZIDs();
712 int local_planes = ZIDs.num_elements();
715 = pFields[0]->GetComm()->GetColumnComm();
718 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
720 int Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
723 = pFields[0]->GetHomogeneousBasis()->GetZ();
726 pSession->LoadParameter(
"LZ", LZ);
728 Vmath::Sadd(Num_z_pos,LZ/2.0,z_coords,1,z_coords,1);
735 for(
int i = 0; i < nStrVars; i++)
741 for(
int plane = 0; plane < local_planes; plane++)
743 for (
int var = 0; var < nStrVars; var++)
745 int xoffset = var*local_planes+plane;
746 int yoffset = nStrVars*local_planes+xoffset;
747 Motion_x[var][plane] = MotionVars[xoffset];
748 Motion_y[var][plane] = MotionVars[yoffset];
759 int npoints = Motion_x[0].num_elements();
774 int colrank = vColComm->GetRank();
775 int nproc = vColComm->GetSize();
779 for (
int j = 0; j <Motion_x[0].num_elements(); j++)
800 for (
int i = 1; i < nproc; ++i)
802 vColComm->Recv(i, CableAccelX);
803 vColComm->Recv(i, CableVelocX);
804 vColComm->Recv(i, CableDisplX);
805 vColComm->Recv(i, CableAccelY);
806 vColComm->Recv(i, CableVelocY);
807 vColComm->Recv(i, CableDisplY);
810 for (
int j = 0; j < Motion_x[0].num_elements(); ++j)
812 int n = Num_z_pos/nproc * i + j;
835 vColComm->Send(0, CableAccelX);
836 vColComm->Send(0, CableVelocX);
837 vColComm->Send(0, CableDisplX);
838 vColComm->Send(0, CableAccelY);
839 vColComm->Send(0, CableVelocY);
840 vColComm->Send(0, CableDisplY);
845 int colrank = vColComm->GetRank();
850 pSession->LoadParameter(
"Strip_Z", nstrips);
851 pSession->LoadParameter(
"DistStrip", DistStrip);
854 for(
int i = 0; i < nstrips; i++)
856 z_coords[i] = i * DistStrip;
864 for(
int i = 0; i < nStrVars; i++)
870 for(
int plane = 0; plane < local_planes; plane++)
872 for (
int var = 0; var < nStrVars; var++)
874 int xoffset = plane*nStrVars+var;
875 int yoffset = nStrVars*local_planes+xoffset;
876 Motion_x[var][plane] = MotionVars[xoffset];
877 Motion_y[var][plane] = MotionVars[yoffset];
883 for(
int var = 0; var <nStrVars; var++)
885 CableMotions[var] = Motion_x[var][0];
886 CableMotions[3+var] = Motion_y[var][0];
895 for(
int var = 0; var < 2*nStrVars; var++)
902 for (
int i = 1; i < nstrips; ++i)
904 vColComm->Recv(i, CableMotions);
910 for(
int var = 0; var < 2*nStrVars; var++)
920 for(
int i = 1; i < nstrips; i++)
924 vColComm->Send(0, CableMotions);
939 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
LibUtilities::SessionReaderSharedPtr m_session
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
static SolverUtils::FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
Creates an instance of this class.
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 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
NekDouble Evaluate() const
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.
std::map< std::string, std::string > ParamMap
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
FilterMovingBody(const LibUtilities::SessionReaderSharedPtr &pSession, const ParamMap &pParams)
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.