49 RegisterCreatorFunction(
"MovingBody",
50 FilterMovingBody::create,
51 "Moving Body Filter");
55 FilterMovingBody::FilterMovingBody(
57 const std::weak_ptr<SolverUtils::EquationSystem> &pEquation,
59 :
Filter(pSession, pEquation)
62 auto 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());
148 unsigned int numBoundaryRegions
149 = pFields[0]->GetBndConditions().size();
152 numBoundaryRegions, 0);
160 for (
auto &it : bregions)
173 if (vComm->GetRank() == 0)
229 int n, cnt, elmtid, nq, offset, boundary;
230 int nt = pFields[0]->GetNpoints();
231 int dim = pFields.size()-1;
259 int Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
268 NekDouble rho = (pSession->DefinesParameter(
"rho"))
269 ? (pSession->GetParameter(
"rho"))
271 NekDouble mu = rho*pSession->GetParameter(
"Kinvis");
273 for(
int i = 0; i < pFields.size(); ++i)
275 pFields[i]->SetWaveSpace(
false);
276 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
277 pFields[i]->UpdatePhys());
278 pFields[i]->SetPhysState(
true);
284 ZIDs = pFields[0]->GetZIDs();
285 int local_planes = ZIDs.size();
289 for(
int plane = 0 ; plane < local_planes; plane++)
291 pFields[0]->GetPlane(plane)->GetBoundaryToElmtMap(BoundarytoElmtID,
293 BndExp = pFields[0]->GetPlane(plane)->GetBndCondExpansions();
297 for(cnt = n = 0; n < BndExp.size(); ++n)
301 for(
int i = 0; i < BndExp[n]->GetExpSize(); ++i, cnt++)
304 elmtid = BoundarytoElmtID[cnt];
305 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
306 nq = elmt->GetTotPoints();
307 offset = pFields[0]->GetPlane(plane)
308 ->GetPhys_Offset(elmtid);
313 for(
int j = 0; j < dim; ++j)
321 boundary = BoundarytoTraceID[cnt];
324 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
325 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
326 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
329 elmt->PhysDeriv(U,gradU[0],gradU[1]);
330 elmt->PhysDeriv(V,gradV[0],gradV[1]);
341 for(
int j = 0; j < dim; ++j)
355 boundary = BoundarytoTraceID[cnt];
359 elmt->GetTracePhysVals(boundary,bc,
P,Pb);
361 for(
int j = 0; j < dim; ++j)
363 elmt->GetTracePhysVals(boundary,bc,gradU[j],fgradU[j]);
364 elmt->GetTracePhysVals(boundary,bc,gradV[j],fgradV[j]);
369 = elmt->GetTraceNormal(boundary);
388 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
389 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
392 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
406 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
407 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
410 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
411 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
426 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
427 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
429 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
430 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
435 cnt += BndExp[n]->GetExpSize();
440 for(
int i = 0; i < pFields.size(); ++i)
442 pFields[i]->SetWaveSpace(
true);
443 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(),
444 pFields[i]->UpdatePhys());
445 pFields[i]->SetPhysState(
false);
454 if(vComm->GetRowComm()->GetSize() > 0)
461 for(
int plane = 0 ; plane < local_planes; plane++)
476 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
478 if(vComm->GetRowComm()->GetRank() == 0)
480 for(
int z = 0 ; z < Num_z_pos; z++)
491 if(vComm->GetRowComm()->GetRank() == 0)
493 for(
int z = 0 ; z < Num_z_pos; z++)
503 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
506 for(
int plane = 0 ; plane < local_planes; plane++)
508 Aeroforces[plane] = Fxp[ZIDs[plane]]
510 Aeroforces[plane + local_planes] = Fyp[ZIDs[plane]]
527 = pFields[0]->GetHomogeneousBasis()->GetZ();
530 pSession->LoadParameter(
"LZ", LZ);
532 Vmath::Sadd(Num_z_pos,LZ/2.0,z_coords,1,z_coords,1);
533 if (vComm->GetRank() == 0)
539 for(
int i = 0 ; i < Num_z_pos; i++)
568 for(
int plane = 0 ; plane < local_planes; plane++)
570 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
571 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
572 fces[2] += Fxp[ZIDs[plane]] ;
573 fces[3] += Fyp[ZIDs[plane]] ;
574 fces[4] += Fxv[ZIDs[plane]] ;
575 fces[5] += Fyv[ZIDs[plane]] ;
578 fces[0] = fces[0]/local_planes;
579 fces[1] = fces[1]/local_planes;
580 fces[2] = fces[2]/local_planes;
581 fces[3] = fces[3]/local_planes;
582 fces[4] = fces[4]/local_planes;
583 fces[5] = fces[5]/local_planes;
593 int npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
595 fces[0] = fces[0]/npts;
596 fces[1] = fces[1]/npts;
597 fces[2] = fces[2]/npts;
598 fces[3] = fces[3]/npts;
599 fces[4] = fces[4]/npts;
600 fces[5] = fces[5]/npts;
602 for(
int plane = 0 ; plane < local_planes; plane++)
604 Aeroforces[plane] = fces[0];
605 Aeroforces[plane+local_planes] = fces[1];
614 int colrank = vColComm->GetRank();
619 pSession->LoadParameter(
"Strip_Z", nstrips);
620 pSession->LoadParameter(
"DistStrip", DistStrip);
623 for(
int i = 0; i < nstrips; i++)
625 z_coords[i] = i * DistStrip;
651 for(
int i = 1; i < nstrips; i++)
653 vColComm->Recv(i, fces);
679 for(
int i = 1; i < nstrips; i++)
683 vColComm->Send(0, fces);
710 if(!pSession->DefinesSolverInfo(
"HomoStrip"))
712 pSession->LoadParameter(
"LZ", Length);
713 npts =
m_session->GetParameter(
"HomModesZ");
717 pSession->LoadParameter(
"LC", Length);
718 npts =
m_session->GetParameter(
"HomStructModesZ");
722 for(
int n = 0; n < npts; n++)
724 z_coords = Length/npts*n;
753 if (pFields[0]->GetComm()->GetRank() == 0)
#define ASSERTL0(condition, msg)
virtual void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
std::string m_outputFile_fce
std::string m_outputFile_mot
virtual void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time)
unsigned int m_outputFrequency
std::string m_BoundaryString
void UpdateMotion(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &MotionVars, const NekDouble &time)
std::vector< unsigned int > m_boundaryRegionsIdList
ID's of boundary regions where we want the forces.
Array< OneD, std::ofstream > m_outputStream
std::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)
virtual bool v_IsTimeDependent()
NekDouble Evaluate() const
static bool GenerateSeqVector(const std::string &str, std::vector< unsigned int > &out)
Takes a comma-separated compressed string and converts it to entries in a vector.
LibUtilities::SessionReaderSharedPtr m_session
std::map< std::string, std::string > ParamMap
const BoundaryRegionCollection & GetBoundaryRegions(void) const
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
std::shared_ptr< Expansion > ExpansionSharedPtr
FilterFactory & GetFilterFactory()
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
The above copyright notice and this permission notice shall be included.
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.
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
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 Zero(int n, T *x, const int incx)
Zero vector.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha - x.