56 const std::shared_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 size_t numBoundaryRegions = pFields[0]->GetBndConditions().size();
150 numBoundaryRegions, 0);
158 for (
auto &it : bregions)
171 if (vComm->GetRank() == 0)
225 size_t n, cnt, elmtid, nq, offset, boundary;
226 size_t nt = pFields[0]->GetNpoints();
227 size_t dim = pFields.size() - 1;
255 size_t 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 (
size_t 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 size_t local_planes = ZIDs.size();
283 for (
size_t 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 size_t nExp = BndExp[n]->GetExpSize();
296 for (
size_t i = 0; i < nExp; ++i, cnt++)
299 elmtid = BoundarytoElmtID[cnt];
300 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
301 nq = elmt->GetTotPoints();
303 pFields[0]->GetPlane(plane)->GetPhys_Offset(elmtid);
308 for (
size_t j = 0; j < dim; ++j)
316 boundary = BoundarytoTraceID[cnt];
319 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
320 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
321 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
324 elmt->PhysDeriv(U, gradU[0], gradU[1]);
325 elmt->PhysDeriv(V, gradV[0], gradV[1]);
336 for (
size_t j = 0; j < dim; ++j)
350 boundary = BoundarytoTraceID[cnt];
354 elmt->GetTracePhysVals(boundary, bc,
P, Pb);
356 for (
size_t j = 0; j < dim; ++j)
358 elmt->GetTracePhysVals(boundary, bc, gradU[j],
360 elmt->GetTracePhysVals(boundary, bc, gradV[j],
366 elmt->GetTraceNormal(boundary);
385 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
386 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
389 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
402 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
403 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
406 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
407 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
415 Vmath::Vvtvp(nbc, Pb, 1, normals[0], 1, drag_p, 1, drag_p,
417 Vmath::Vvtvp(nbc, Pb, 1, normals[1], 1, lift_p, 1, lift_p,
421 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
422 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
424 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
425 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
430 cnt += BndExp[n]->GetExpSize();
435 for (
size_t i = 0; i < pFields.size(); ++i)
437 pFields[i]->SetWaveSpace(
true);
438 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(), pFields[i]->UpdatePhys());
439 pFields[i]->SetPhysState(
false);
448 if (vComm->GetRowComm()->GetSize() > 0)
455 for (
size_t plane = 0; plane < local_planes; plane++)
470 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
472 if (vComm->GetRowComm()->GetRank() == 0)
474 for (
size_t z = 0;
z < Num_z_pos;
z++)
485 if (vComm->GetRowComm()->GetRank() == 0)
487 for (
size_t z = 0;
z < Num_z_pos;
z++)
497 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
500 for (
size_t plane = 0; plane < local_planes; plane++)
502 Aeroforces[plane] = Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
503 Aeroforces[plane + local_planes] =
504 Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
520 pFields[0]->GetHomogeneousBasis()->GetZ();
523 pSession->LoadParameter(
"LZ", LZ);
524 Vmath::Smul(Num_z_pos, LZ / 2.0, pts, 1, z_coords, 1);
525 Vmath::Sadd(Num_z_pos, LZ / 2.0, z_coords, 1, z_coords, 1);
526 if (vComm->GetRank() == 0)
532 for (
size_t i = 0; i < Num_z_pos; i++)
561 for (
size_t plane = 0; plane < local_planes; plane++)
563 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
564 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
565 fces[2] += Fxp[ZIDs[plane]];
566 fces[3] += Fyp[ZIDs[plane]];
567 fces[4] += Fxv[ZIDs[plane]];
568 fces[5] += Fyv[ZIDs[plane]];
571 fces[0] = fces[0] / local_planes;
572 fces[1] = fces[1] / local_planes;
573 fces[2] = fces[2] / local_planes;
574 fces[3] = fces[3] / local_planes;
575 fces[4] = fces[4] / local_planes;
576 fces[5] = fces[5] / local_planes;
586 size_t npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
588 fces[0] = fces[0] / npts;
589 fces[1] = fces[1] / npts;
590 fces[2] = fces[2] / npts;
591 fces[3] = fces[3] / npts;
592 fces[4] = fces[4] / npts;
593 fces[5] = fces[5] / npts;
595 for (
size_t plane = 0; plane < local_planes; plane++)
597 Aeroforces[plane] = fces[0];
598 Aeroforces[plane + local_planes] = fces[1];
607 size_t colrank = vColComm->GetRank();
612 pSession->LoadParameter(
"Strip_Z", nstrips);
613 pSession->LoadParameter(
"DistStrip", DistStrip);
616 for (
size_t i = 0; i < nstrips; i++)
618 z_coords[i] = i * DistStrip;
644 for (
size_t i = 1; i < nstrips; i++)
646 vColComm->Recv(i, fces);
672 for (
size_t i = 1; i < nstrips; i++)
676 vColComm->Send(0, fces);
702 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
704 pSession->LoadParameter(
"LZ", Length);
705 npts =
m_session->GetParameter(
"HomModesZ");
709 pSession->LoadParameter(
"LC", Length);
710 npts =
m_session->GetParameter(
"HomStructModesZ");
714 for (
size_t n = 0; n < npts; n++)
716 z_coords = Length / npts * n;
744 if (pFields[0]->GetComm()->GetRank() == 0)
#define ASSERTL0(condition, msg)
std::string m_outputFile_fce
std::string m_outputFile_mot
void v_Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time) override
FilterMovingBody(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< SolverUtils::EquationSystem > &pEquation, const ParamMap &pParams)
static std::string className
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)
bool v_IsTimeDependent() override
std::vector< unsigned int > m_boundaryRegionsIdList
ID's of boundary regions where we want the forces.
~FilterMovingBody() override
static SolverUtils::FilterSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const std::shared_ptr< SolverUtils::EquationSystem > &pEquation, const ParamMap &pParams)
Creates an instance of this class.
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.
@ P
Monomial polynomials .
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
std::vector< double > z(NPUPPER)
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.