48 std::string FilterMovingBody::className =
50 "MovingBody", FilterMovingBody::create,
"Moving Body Filter");
54 FilterMovingBody::FilterMovingBody(
56 const std::weak_ptr<SolverUtils::EquationSystem> &pEquation,
58 :
Filter(pSession, pEquation)
61 auto it = pParams.find(
"OutputFile");
62 if (it == pParams.end())
69 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
86 it = pParams.find(
"OutputFrequency");
87 if (it == pParams.end())
99 "Homogeneous 1D discetisations.");
102 it = pParams.find(
"Boundary");
103 ASSERTL0(it != pParams.end(),
"Missing parameter 'Boundary'.");
104 ASSERTL0(it->second.length() > 0,
"Missing parameter 'Boundary'.");
122 boost::ignore_unused(time);
132 (std::string(
"Error reading boundary region definition:") +
136 std::string IndString =
143 (std::string(
"Unable to read boundary regions index "
144 "range for FilterAeroForces: ") +
149 size_t numBoundaryRegions = pFields[0]->GetBndConditions().size();
152 numBoundaryRegions, 0);
160 for (
auto &it : bregions)
173 if (vComm->GetRank() == 0)
227 size_t n, cnt, elmtid, nq, offset, boundary;
228 size_t nt = pFields[0]->GetNpoints();
229 size_t dim = pFields.size() - 1;
257 size_t Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
265 NekDouble rho = (pSession->DefinesParameter(
"rho"))
266 ? (pSession->GetParameter(
"rho"))
268 NekDouble mu = rho * pSession->GetParameter(
"Kinvis");
270 for (
size_t i = 0; i < pFields.size(); ++i)
272 pFields[i]->SetWaveSpace(
false);
273 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(), pFields[i]->UpdatePhys());
274 pFields[i]->SetPhysState(
true);
280 ZIDs = pFields[0]->GetZIDs();
281 size_t local_planes = ZIDs.size();
285 for (
size_t plane = 0; plane < local_planes; plane++)
287 pFields[0]->GetPlane(plane)->GetBoundaryToElmtMap(BoundarytoElmtID,
289 BndExp = pFields[0]->GetPlane(plane)->GetBndCondExpansions();
293 for (cnt = n = 0; n < BndExp.size(); ++n)
297 size_t nExp = BndExp[n]->GetExpSize();
298 for (
size_t i = 0; i < nExp; ++i, cnt++)
301 elmtid = BoundarytoElmtID[cnt];
302 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
303 nq = elmt->GetTotPoints();
305 pFields[0]->GetPlane(plane)->GetPhys_Offset(elmtid);
310 for (
size_t j = 0; j < dim; ++j)
318 boundary = BoundarytoTraceID[cnt];
321 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
322 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
323 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
326 elmt->PhysDeriv(U, gradU[0], gradU[1]);
327 elmt->PhysDeriv(V, gradV[0], gradV[1]);
338 for (
size_t j = 0; j < dim; ++j)
352 boundary = BoundarytoTraceID[cnt];
356 elmt->GetTracePhysVals(boundary, bc,
P, Pb);
358 for (
size_t j = 0; j < dim; ++j)
360 elmt->GetTracePhysVals(boundary, bc, gradU[j],
362 elmt->GetTracePhysVals(boundary, bc, gradV[j],
368 elmt->GetTraceNormal(boundary);
387 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
388 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
391 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
404 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
405 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
408 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
409 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
417 Vmath::Vvtvp(nbc, Pb, 1, normals[0], 1, drag_p, 1, drag_p,
419 Vmath::Vvtvp(nbc, Pb, 1, normals[1], 1, lift_p, 1, lift_p,
423 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
424 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
426 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
427 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
432 cnt += BndExp[n]->GetExpSize();
437 for (
size_t i = 0; i < pFields.size(); ++i)
439 pFields[i]->SetWaveSpace(
true);
440 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(), pFields[i]->UpdatePhys());
441 pFields[i]->SetPhysState(
false);
450 if (vComm->GetRowComm()->GetSize() > 0)
457 for (
size_t plane = 0; plane < local_planes; plane++)
472 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
474 if (vComm->GetRowComm()->GetRank() == 0)
476 for (
size_t z = 0; z < Num_z_pos; z++)
487 if (vComm->GetRowComm()->GetRank() == 0)
489 for (
size_t z = 0; z < Num_z_pos; z++)
499 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
502 for (
size_t plane = 0; plane < local_planes; plane++)
504 Aeroforces[plane] = Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
505 Aeroforces[plane + local_planes] =
506 Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
522 pFields[0]->GetHomogeneousBasis()->GetZ();
525 pSession->LoadParameter(
"LZ", LZ);
526 Vmath::Smul(Num_z_pos, LZ / 2.0, pts, 1, z_coords, 1);
527 Vmath::Sadd(Num_z_pos, LZ / 2.0, z_coords, 1, z_coords, 1);
528 if (vComm->GetRank() == 0)
534 for (
size_t i = 0; i < Num_z_pos; i++)
563 for (
size_t plane = 0; plane < local_planes; plane++)
565 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
566 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
567 fces[2] += Fxp[ZIDs[plane]];
568 fces[3] += Fyp[ZIDs[plane]];
569 fces[4] += Fxv[ZIDs[plane]];
570 fces[5] += Fyv[ZIDs[plane]];
573 fces[0] = fces[0] / local_planes;
574 fces[1] = fces[1] / local_planes;
575 fces[2] = fces[2] / local_planes;
576 fces[3] = fces[3] / local_planes;
577 fces[4] = fces[4] / local_planes;
578 fces[5] = fces[5] / local_planes;
588 size_t npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
590 fces[0] = fces[0] / npts;
591 fces[1] = fces[1] / npts;
592 fces[2] = fces[2] / npts;
593 fces[3] = fces[3] / npts;
594 fces[4] = fces[4] / npts;
595 fces[5] = fces[5] / npts;
597 for (
size_t plane = 0; plane < local_planes; plane++)
599 Aeroforces[plane] = fces[0];
600 Aeroforces[plane + local_planes] = fces[1];
609 size_t colrank = vColComm->GetRank();
614 pSession->LoadParameter(
"Strip_Z", nstrips);
615 pSession->LoadParameter(
"DistStrip", DistStrip);
618 for (
size_t i = 0; i < nstrips; i++)
620 z_coords[i] = i * DistStrip;
646 for (
size_t i = 1; i < nstrips; i++)
648 vColComm->Recv(i, fces);
674 for (
size_t i = 1; i < nstrips; i++)
678 vColComm->Send(0, fces);
693 boost::ignore_unused(pFields);
705 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
707 pSession->LoadParameter(
"LZ", Length);
708 npts =
m_session->GetParameter(
"HomModesZ");
712 pSession->LoadParameter(
"LC", Length);
713 npts =
m_session->GetParameter(
"HomStructModesZ");
717 for (
size_t n = 0; n < npts; n++)
719 z_coords = Length / npts * n;
747 boost::ignore_unused(time);
749 if (pFields[0]->GetComm()->GetRank() == 0)
#define ASSERTL0(condition, msg)
std::string m_outputFile_fce
std::string m_outputFile_mot
virtual void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
virtual void v_Finalise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
std::string m_BoundaryString
void UpdateMotion(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, NekDouble > &MotionVars, const NekDouble &time)
virtual bool v_IsTimeDependent() override
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)
NekDouble Evaluate() const
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
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 scalar y = alpha + x.