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'.");
134 (std::string(
"Error reading boundary region definition:") +
138 LastInd - FirstInd + 1);
144 (std::string(
"Unable to read boundary regions index "
145 "range for FilterAeroForces: ") + IndString).c_str());
150 unsigned int numBoundaryRegions
151 = pFields[0]->GetBndConditions().num_elements();
154 numBoundaryRegions, 0);
161 SpatialDomains::BoundaryRegionCollection::const_iterator it;
163 for (cnt = 0, it = bregions.begin(); it != bregions.end();
176 if (vComm->GetRank() == 0)
232 int n, cnt, elmtid, nq, offset, boundary;
233 int nt = pFields[0]->GetNpoints();
234 int dim = pFields.num_elements()-1;
262 int Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
271 NekDouble rho = (pSession->DefinesParameter(
"rho"))
272 ? (pSession->GetParameter(
"rho"))
274 NekDouble mu = rho*pSession->GetParameter(
"Kinvis");
276 for(
int i = 0; i < pFields.num_elements(); ++i)
278 pFields[i]->SetWaveSpace(
false);
279 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
280 pFields[i]->UpdatePhys());
281 pFields[i]->SetPhysState(
true);
287 ZIDs = pFields[0]->GetZIDs();
288 int local_planes = ZIDs.num_elements();
292 for(
int plane = 0 ; plane < local_planes; plane++)
294 pFields[0]->GetPlane(plane)->GetBoundaryToElmtMap(BoundarytoElmtID,
296 BndExp = pFields[0]->GetPlane(plane)->GetBndCondExpansions();
300 for(cnt = n = 0; n < BndExp.num_elements(); ++n)
304 for(
int i = 0; i < BndExp[n]->GetExpSize(); ++i, cnt++)
307 elmtid = BoundarytoElmtID[cnt];
308 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
309 nq = elmt->GetTotPoints();
310 offset = pFields[0]->GetPlane(plane)
311 ->GetPhys_Offset(elmtid);
316 for(
int j = 0; j < dim; ++j)
324 boundary = BoundarytoTraceID[cnt];
327 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
328 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
329 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
332 elmt->PhysDeriv(U,gradU[0],gradU[1]);
333 elmt->PhysDeriv(V,gradV[0],gradV[1]);
344 for(
int j = 0; j < dim; ++j)
358 boundary = BoundarytoTraceID[cnt];
362 elmt->GetEdgePhysVals(boundary,bc,P,Pb);
364 for(
int j = 0; j < dim; ++j)
366 elmt->GetEdgePhysVals(boundary,bc,gradU[j],fgradU[j]);
367 elmt->GetEdgePhysVals(boundary,bc,gradV[j],fgradV[j]);
372 = elmt->GetEdgeNormal(boundary);
391 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
392 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
395 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
409 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
410 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
413 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
414 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
429 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
430 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
432 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
433 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
438 cnt += BndExp[n]->GetExpSize();
443 for(
int i = 0; i < pFields.num_elements(); ++i)
445 pFields[i]->SetWaveSpace(
true);
446 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
447 pFields[i]->UpdatePhys());
448 pFields[i]->SetPhysState(
false);
457 if(vComm->GetRowComm()->GetSize() > 0)
464 for(
int plane = 0 ; plane < local_planes; plane++)
479 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
481 if(vComm->GetRowComm()->GetRank() == 0)
483 for(
int z = 0 ; z < Num_z_pos; z++)
494 if(vComm->GetRowComm()->GetRank() == 0)
496 for(
int z = 0 ; z < Num_z_pos; z++)
506 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
509 for(
int plane = 0 ; plane < local_planes; plane++)
511 Aeroforces[plane] = Fxp[ZIDs[plane]]
513 Aeroforces[plane + local_planes] = Fyp[ZIDs[plane]]
530 = pFields[0]->GetHomogeneousBasis()->GetZ();
533 pSession->LoadParameter(
"LZ", LZ);
535 Vmath::Sadd(Num_z_pos,LZ/2.0,z_coords,1,z_coords,1);
536 if (vComm->GetRank() == 0)
542 for(
int i = 0 ; i < Num_z_pos; i++)
571 for(
int plane = 0 ; plane < local_planes; plane++)
573 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
574 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
575 fces[2] += Fxp[ZIDs[plane]] ;
576 fces[3] += Fyp[ZIDs[plane]] ;
577 fces[4] += Fxv[ZIDs[plane]] ;
578 fces[5] += Fyv[ZIDs[plane]] ;
581 fces[0] = fces[0]/local_planes;
582 fces[1] = fces[1]/local_planes;
583 fces[2] = fces[2]/local_planes;
584 fces[3] = fces[3]/local_planes;
585 fces[4] = fces[4]/local_planes;
586 fces[5] = fces[5]/local_planes;
596 int npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
598 fces[0] = fces[0]/
npts;
599 fces[1] = fces[1]/
npts;
600 fces[2] = fces[2]/
npts;
601 fces[3] = fces[3]/
npts;
602 fces[4] = fces[4]/
npts;
603 fces[5] = fces[5]/
npts;
605 for(
int plane = 0 ; plane < local_planes; plane++)
607 Aeroforces[plane] = fces[0];
608 Aeroforces[plane+local_planes] = fces[1];
617 int colrank = vColComm->GetRank();
622 pSession->LoadParameter(
"Strip_Z", nstrips);
623 pSession->LoadParameter(
"DistStrip", DistStrip);
626 for(
int i = 0; i < nstrips; i++)
628 z_coords[i] = i * DistStrip;
654 for(
int i = 1; i < nstrips; i++)
656 vColComm->Recv(i, fces);
682 for(
int i = 1; i < nstrips; i++)
686 vColComm->Send(0, fces);
713 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
715 pSession->LoadParameter(
"LZ", Length);
716 npts =
m_session->GetParameter(
"HomModesZ");
720 pSession->LoadParameter(
"LC", Length);
721 npts =
m_session->GetParameter(
"HomStructModesZ");
725 for(
int n = 0; n <
npts; n++)
727 z_coords = Length/npts*n;
756 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 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.