55 const std::shared_ptr<SolverUtils::EquationSystem> &pEquation,
57 :
Filter(pSession, pEquation)
70 auto it = pParams.find(
"OutputFrequency");
71 if (it == pParams.end())
83 "Homogeneous 1D discetisations.");
86 it = pParams.find(
"Boundary");
87 ASSERTL0(it != pParams.end(),
"Missing parameter 'Boundary'.");
88 ASSERTL0(it->second.length() > 0,
"Missing parameter 'Boundary'.");
107 (std::string(
"Error reading boundary region definition:") +
111 std::string IndString =
118 (std::string(
"Unable to read boundary regions index "
119 "range for FilterAeroForces: ") +
124 size_t numBoundaryRegions = pFields[0]->GetBndConditions().size();
127 numBoundaryRegions, 0);
135 for (
auto &it : bregions)
148 if (vComm->GetRank() == 0)
202 size_t n, cnt, elmtid, nq, offset, boundary;
203 size_t nt = pFields[0]->GetNpoints();
204 size_t dim = pFields.size() - 1;
232 size_t Num_z_pos = pFields[0]->GetHomogeneousBasis()->GetNumModes();
240 NekDouble rho = (pSession->DefinesParameter(
"rho"))
241 ? (pSession->GetParameter(
"rho"))
243 NekDouble mu = rho * pSession->GetParameter(
"Kinvis");
245 for (
size_t i = 0; i < pFields.size(); ++i)
247 pFields[i]->SetWaveSpace(
false);
248 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(), pFields[i]->UpdatePhys());
249 pFields[i]->SetPhysState(
true);
255 ZIDs = pFields[0]->GetZIDs();
256 size_t local_planes = ZIDs.size();
260 for (
size_t plane = 0; plane < local_planes; plane++)
262 pFields[0]->GetPlane(plane)->GetBoundaryToElmtMap(BoundarytoElmtID,
264 BndExp = pFields[0]->GetPlane(plane)->GetBndCondExpansions();
268 for (cnt = n = 0; n < BndExp.size(); ++n)
272 size_t nExp = BndExp[n]->GetExpSize();
273 for (
size_t i = 0; i < nExp; ++i, cnt++)
276 elmtid = BoundarytoElmtID[cnt];
277 elmt = pFields[0]->GetPlane(plane)->GetExp(elmtid);
278 nq = elmt->GetTotPoints();
280 pFields[0]->GetPlane(plane)->GetPhys_Offset(elmtid);
285 for (
size_t j = 0; j < dim; ++j)
293 boundary = BoundarytoTraceID[cnt];
296 U = pFields[0]->GetPlane(plane)->GetPhys() + offset;
297 V = pFields[1]->GetPlane(plane)->GetPhys() + offset;
298 P = pFields[3]->GetPlane(plane)->GetPhys() + offset;
301 elmt->PhysDeriv(U, gradU[0], gradU[1]);
302 elmt->PhysDeriv(V, gradV[0], gradV[1]);
313 for (
size_t j = 0; j < dim; ++j)
327 boundary = BoundarytoTraceID[cnt];
331 elmt->GetTracePhysVals(boundary, bc,
P, Pb);
333 for (
size_t j = 0; j < dim; ++j)
335 elmt->GetTracePhysVals(boundary, bc, gradU[j],
337 elmt->GetTracePhysVals(boundary, bc, gradV[j],
343 elmt->GetTraceNormal(boundary);
362 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, drag_t, 1);
363 Vmath::Vmul(nbc, drag_t, 1, normals[1], 1, drag_t, 1);
366 Vmath::Vmul(nbc, fgradU[0], 1, normals[0], 1, temp2, 1);
379 Vmath::Vadd(nbc, fgradU[1], 1, fgradV[0], 1, lift_t, 1);
380 Vmath::Vmul(nbc, lift_t, 1, normals[0], 1, lift_t, 1);
383 Vmath::Vmul(nbc, fgradV[1], 1, normals[1], 1, temp2, 1);
384 Vmath::Smul(nbc, -0.5, fgradV[1], 1, fgradV[1], 1);
392 Vmath::Vvtvp(nbc, Pb, 1, normals[0], 1, drag_p, 1, drag_p,
394 Vmath::Vvtvp(nbc, Pb, 1, normals[1], 1, lift_p, 1, lift_p,
398 Fxv[ZIDs[plane]] += bc->Integral(drag_t);
399 Fyv[ZIDs[plane]] += bc->Integral(lift_t);
401 Fxp[ZIDs[plane]] += bc->Integral(drag_p);
402 Fyp[ZIDs[plane]] += bc->Integral(lift_p);
407 cnt += BndExp[n]->GetExpSize();
412 for (
size_t i = 0; i < pFields.size(); ++i)
414 pFields[i]->SetWaveSpace(
true);
415 pFields[i]->BwdTrans(pFields[i]->GetCoeffs(), pFields[i]->UpdatePhys());
416 pFields[i]->SetPhysState(
false);
425 if (vComm->GetRowComm()->GetSize() > 0)
432 for (
size_t plane = 0; plane < local_planes; plane++)
447 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
449 if (vComm->GetRowComm()->GetRank() == 0)
451 for (
size_t z = 0;
z < Num_z_pos;
z++)
462 if (vComm->GetRowComm()->GetRank() == 0)
464 for (
size_t z = 0;
z < Num_z_pos;
z++)
474 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
477 for (
size_t plane = 0; plane < local_planes; plane++)
479 Aeroforces[plane] = Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
480 Aeroforces[plane + local_planes] =
481 Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
497 pFields[0]->GetHomogeneousBasis()->GetZ();
500 pSession->LoadParameter(
"LZ", LZ);
501 Vmath::Smul(Num_z_pos, LZ / 2.0, pts, 1, z_coords, 1);
502 Vmath::Sadd(Num_z_pos, LZ / 2.0, z_coords, 1, z_coords, 1);
503 if (vComm->GetRank() == 0)
509 for (
size_t i = 0; i < Num_z_pos; i++)
538 for (
size_t plane = 0; plane < local_planes; plane++)
540 fces[0] += Fxp[ZIDs[plane]] + Fxv[ZIDs[plane]];
541 fces[1] += Fyp[ZIDs[plane]] + Fyv[ZIDs[plane]];
542 fces[2] += Fxp[ZIDs[plane]];
543 fces[3] += Fyp[ZIDs[plane]];
544 fces[4] += Fxv[ZIDs[plane]];
545 fces[5] += Fyv[ZIDs[plane]];
548 fces[0] = fces[0] / local_planes;
549 fces[1] = fces[1] / local_planes;
550 fces[2] = fces[2] / local_planes;
551 fces[3] = fces[3] / local_planes;
552 fces[4] = fces[4] / local_planes;
553 fces[5] = fces[5] / local_planes;
563 size_t npts = vComm->GetColumnComm()->GetColumnComm()->GetSize();
565 fces[0] = fces[0] / npts;
566 fces[1] = fces[1] / npts;
567 fces[2] = fces[2] / npts;
568 fces[3] = fces[3] / npts;
569 fces[4] = fces[4] / npts;
570 fces[5] = fces[5] / npts;
572 for (
size_t plane = 0; plane < local_planes; plane++)
574 Aeroforces[plane] = fces[0];
575 Aeroforces[plane + local_planes] = fces[1];
584 size_t colrank = vColComm->GetRank();
589 pSession->LoadParameter(
"Strip_Z", nstrips);
590 pSession->LoadParameter(
"DistStrip", DistStrip);
593 for (
size_t i = 0; i < nstrips; i++)
595 z_coords[i] = i * DistStrip;
621 for (
size_t i = 1; i < nstrips; i++)
623 vColComm->Recv(i, fces);
649 for (
size_t i = 1; i < nstrips; i++)
653 vColComm->Send(0, fces);
679 if (!pSession->DefinesSolverInfo(
"HomoStrip"))
681 pSession->LoadParameter(
"LZ", Length);
682 npts =
m_session->GetParameter(
"HomModesZ");
686 pSession->LoadParameter(
"LC", Length);
687 npts =
m_session->GetParameter(
"HomStructModesZ");
691 for (
size_t n = 0; n < npts; n++)
693 z_coords = Length / npts * n;
701 m_outputStream[1] << std::setprecision(8) << MotionVars[npts + n];
703 m_outputStream[1] << std::setprecision(8) << MotionVars[2 * npts + n];
705 m_outputStream[1] << std::setprecision(8) << MotionVars[3 * npts + n];
707 m_outputStream[1] << std::setprecision(8) << MotionVars[4 * npts + n];
709 m_outputStream[1] << std::setprecision(8) << MotionVars[5 * npts + n];
721 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.
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.
SOLVER_UTILS_EXPORT std::string SetupOutput(const std::string ext, const ParamMap &pParams)
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.