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'.");
130 (std::string(
"Error reading boundary region definition:") +
134 std::string IndString =
141 (std::string(
"Unable to read boundary regions index "
142 "range for FilterAeroForces: ") +
147 unsigned int numBoundaryRegions = pFields[0]->GetBndConditions().size();
150 numBoundaryRegions, 0);
158 for (
auto &it : bregions)
171 if (vComm->GetRank() == 0)
225 int n, cnt, elmtid, nq, offset, boundary;
226 int nt = pFields[0]->GetNpoints();
227 int dim = pFields.size() - 1;
255 int Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
263 NekDouble rho = (pSession->DefinesParameter(
"rho"))
264 ? (pSession->GetParameter(
"rho"))
266 NekDouble mu = rho * pSession->GetParameter(
"Kinvis");
268 for (
int i = 0; i < pFields.size(); ++i)
270 pFields[i]->SetWaveSpace(
false);
271 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(), pFields[i]->UpdatePhys());
272 pFields[i]->SetPhysState(
true);
278 ZIDs = pFields[0]->GetZIDs();
279 int local_planes = ZIDs.size();
283 for (
int plane = 0; plane < local_planes; plane++)
285 pFields[0]->GetPlane(plane)->GetBoundaryToElmtMap(BoundarytoElmtID,
287 BndExp = pFields[0]->GetPlane(plane)->GetBndCondExpansions();
291 for (cnt = n = 0; n < BndExp.size(); ++n)
295 for (
int i = 0; i < BndExp[n]->GetExpSize(); ++i, cnt++)
298 elmtid = BoundarytoElmtID[cnt];
299 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
300 nq = elmt->GetTotPoints();
302 pFields[0]->GetPlane(plane)->GetPhys_Offset(elmtid);
307 for (
int j = 0; j < dim; ++j)
315 boundary = BoundarytoTraceID[cnt];
318 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
319 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
320 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
323 elmt->PhysDeriv(U, gradU[0], gradU[1]);
324 elmt->PhysDeriv(V, gradV[0], gradV[1]);
335 for (
int j = 0; j < dim; ++j)
349 boundary = BoundarytoTraceID[cnt];
353 elmt->GetTracePhysVals(boundary, bc,
P, Pb);
355 for (
int j = 0; j < dim; ++j)
357 elmt->GetTracePhysVals(boundary, bc, gradU[j],
359 elmt->GetTracePhysVals(boundary, bc, gradV[j],
365 elmt->GetTraceNormal(boundary);
384 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
385 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
388 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
401 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
402 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
405 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
406 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
414 Vmath::Vvtvp(nbc, Pb, 1, normals[0], 1, drag_p, 1, drag_p,
416 Vmath::Vvtvp(nbc, Pb, 1, normals[1], 1, lift_p, 1, lift_p,
420 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
421 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
423 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
424 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
429 cnt += BndExp[n]->GetExpSize();
434 for (
int i = 0; i < pFields.size(); ++i)
436 pFields[i]->SetWaveSpace(
true);
437 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(), pFields[i]->UpdatePhys());
438 pFields[i]->SetPhysState(
false);
447 if (vComm->GetRowComm()->GetSize() > 0)
454 for (
int plane = 0; plane < local_planes; plane++)
469 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
471 if (vComm->GetRowComm()->GetRank() == 0)
473 for (
int z = 0; z < Num_z_pos; z++)
484 if (vComm->GetRowComm()->GetRank() == 0)
486 for (
int z = 0; z < Num_z_pos; z++)
496 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
499 for (
int plane = 0; plane < local_planes; plane++)
501 Aeroforces[plane] = Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
502 Aeroforces[plane + local_planes] =
503 Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
519 pFields[0]->GetHomogeneousBasis()->GetZ();
522 pSession->LoadParameter(
"LZ", LZ);
523 Vmath::Smul(Num_z_pos, LZ / 2.0, pts, 1, z_coords, 1);
524 Vmath::Sadd(Num_z_pos, LZ / 2.0, z_coords, 1, z_coords, 1);
525 if (vComm->GetRank() == 0)
531 for (
int i = 0; i < Num_z_pos; i++)
560 for (
int plane = 0; plane < local_planes; plane++)
562 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
563 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
564 fces[2] += Fxp[ZIDs[plane]];
565 fces[3] += Fyp[ZIDs[plane]];
566 fces[4] += Fxv[ZIDs[plane]];
567 fces[5] += Fyv[ZIDs[plane]];
570 fces[0] = fces[0] / local_planes;
571 fces[1] = fces[1] / local_planes;
572 fces[2] = fces[2] / local_planes;
573 fces[3] = fces[3] / local_planes;
574 fces[4] = fces[4] / local_planes;
575 fces[5] = fces[5] / local_planes;
585 int npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
587 fces[0] = fces[0] / npts;
588 fces[1] = fces[1] / npts;
589 fces[2] = fces[2] / npts;
590 fces[3] = fces[3] / npts;
591 fces[4] = fces[4] / npts;
592 fces[5] = fces[5] / npts;
594 for (
int plane = 0; plane < local_planes; plane++)
596 Aeroforces[plane] = fces[0];
597 Aeroforces[plane + local_planes] = fces[1];
606 int colrank = vColComm->GetRank();
611 pSession->LoadParameter(
"Strip_Z", nstrips);
612 pSession->LoadParameter(
"DistStrip", DistStrip);
615 for (
int i = 0; i < nstrips; i++)
617 z_coords[i] = i * DistStrip;
643 for (
int i = 1; i < nstrips; i++)
645 vColComm->Recv(i, fces);
671 for (
int i = 1; i < nstrips; i++)
675 vColComm->Send(0, fces);
700 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
702 pSession->LoadParameter(
"LZ", Length);
703 npts =
m_session->GetParameter(
"HomModesZ");
707 pSession->LoadParameter(
"LC", Length);
708 npts =
m_session->GetParameter(
"HomStructModesZ");
712 for (
int n = 0; n < npts; n++)
714 z_coords = Length / npts * n;
742 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
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 vector y = alpha - x.