36#include <boost/algorithm/string.hpp>
87 m_SmoothAdvection(false)
97 std::string velids[] = {
"u",
"v",
"w"};
104 for (j = 0; j < numfields; ++j)
107 if (boost::iequals(velids[i], var))
113 ASSERTL0(j != numfields,
"Failed to find field: " + var);
133 std::string vConvectiveType;
138 vConvectiveType =
"NoAdvection";
142 vConvectiveType =
"Convective";
145 vConvectiveType =
"Linearised";
152 if (
m_session->DefinesTag(
"AdvectiveType") &&
156 vConvectiveType =
m_session->GetTag(
"AdvectiveType");
161 vConvectiveType, vConvectiveType);
173 "X",
"Y",
"Z",
"Theta_x",
"Theta_y",
"Theta_z",
174 "U",
"V",
"W",
"Omega_x",
"Omega_y",
"Omega_z",
175 "A_x",
"A_y",
"A_z",
"DOmega_x",
"DOmega_y",
"DOmega_z",
191 for (
size_t i = 0; i <
m_fields.size(); ++i)
199 BndConds =
m_fields[i]->GetBndConditions();
200 BndExp =
m_fields[i]->GetBndCondExpansions();
201 for (
size_t n = 0; n < BndConds.size(); ++n)
203 if (boost::iequals(BndConds[n]->GetUserDefined(),
"Radiation"))
206 BndConds[n]->GetBoundaryConditionType() ==
208 "Radiation boundary condition must be of type Robin <R>");
216 radpts += BndExp[n]->GetTotPoints();
218 if (boost::iequals(BndConds[n]->GetUserDefined(),
219 "ZeroNormalComponent"))
221 ASSERTL0(BndConds[n]->GetBoundaryConditionType() ==
223 "Zero Normal Component boundary condition option must "
224 "be of type Dirichlet <D>");
239 for (
size_t n = 0; n < BndConds.size(); ++n)
241 if (boost::iequals(BndConds[n]->GetUserDefined(),
"Radiation"))
244 int npoints = BndExp[n]->GetNpoints();
250 BndExp[n]->GetCoords(x0, x1, x2);
253 std::static_pointer_cast<
255 ->m_robinPrimitiveCoeff;
267 for (
size_t i = 0; i <
m_fields.size(); ++i)
269 for (
size_t n = 0; n <
m_fields[i]->GetBndConditions().size(); ++n)
271 if (boost::istarts_with(
272 m_fields[i]->GetBndConditions()[n]->GetUserDefined(),
283 i, n,
m_fields[i]->GetBndConditions()[n]->GetUserDefined());
314 size_t npoints =
m_fields[0]->GetNpoints();
315 for (
size_t i = 0; i < VelDim; ++i)
322 x->PreApply(
m_fields, velocity, velocity, time);
336 size_t nvariables =
m_fields.size();
338 for (i = 0; i < nvariables; ++i)
340 for (n = 0; n <
m_fields[i]->GetBndConditions().size(); ++n)
342 if (
m_fields[i]->GetBndConditions()[n]->IsTimeDependent())
345 m_fields[i]->EvaluateBoundaryConditions(time, varName);
347 else if (boost::istarts_with(
348 m_fields[i]->GetBndConditions()[n]->GetUserDefined(),
374 BndConds =
m_fields[fieldid]->GetBndConditions();
375 BndExp =
m_fields[fieldid]->GetBndCondExpansions();
381 size_t elmtid, nq, offset, boundary;
385 for (cnt = n = 0; n < BndConds.size(); ++n)
387 std::string type = BndConds[n]->GetUserDefined();
389 if ((BndConds[n]->GetBoundaryConditionType() ==
391 (boost::iequals(type,
"Radiation")))
393 size_t nExp = BndExp[n]->GetExpSize();
394 for (i = 0; i < nExp; ++i, cnt++)
397 elmt =
m_fields[fieldid]->GetExp(elmtid);
398 offset =
m_fields[fieldid]->GetPhys_Offset(elmtid);
400 U =
m_fields[fieldid]->UpdatePhys() + offset;
401 Bc = BndExp[n]->GetExp(i);
406 nq = Bc->GetTotPoints();
408 elmt->GetTracePhysVals(boundary, Bc, U, ubc);
413 1, &ubc[0], 1, &ubc[0], 1);
416 BndExp[n]->UpdateCoeffs() + BndExp[n]->GetCoeff_Offset(i);
418 Bc->IProductWRTBase(ubc, Bvals);
420 cnt1 += BndExp[n]->GetTotPoints();
424 cnt += BndExp[n]->GetExpSize();
433 static bool Setup =
false;
456 size_t elmtid, nq, boundary;
463 for (cnt = n = 0; n < BndConds[0].size(); ++n)
465 if ((BndConds[0][n]->GetBoundaryConditionType() ==
467 (boost::iequals(BndConds[0][n]->GetUserDefined(),
468 "ZeroNormalComponent")))
470 size_t nExp = BndExp[0][n]->GetExpSize();
471 for (i = 0; i < nExp; ++i, cnt++)
477 normals = elmt->GetTraceNormal(boundary);
479 nq = BndExp[0][n]->GetExp(i)->GetTotPoints();
484 Bphys = BndExp[k][n]->UpdatePhys() +
485 BndExp[k][n]->GetPhys_Offset(i);
486 Bc = BndExp[k][n]->GetExp(i);
496 Bphys = BndExp[k][n]->UpdatePhys() +
497 BndExp[k][n]->GetPhys_Offset(i);
498 Bcoeffs = BndExp[k][n]->UpdateCoeffs() +
499 BndExp[k][n]->GetCoeff_Offset(i);
500 Bc = BndExp[k][n]->GetExp(i);
501 Vmath::Vvtvp(nq, normvel, 1, normals[k], 1, Bphys, 1, Bphys,
503 Bc->FwdTransBndConstrained(Bphys, Bcoeffs);
509 cnt += BndExp[0][n]->GetExpSize();
520 "Womersley parameters for this boundary have not been set up");
526 size_t M_coeffs = WomParam->m_wom_vel.size();
529 NekDouble axis_normal = WomParam->m_axisnormal[fldid];
539 BndCondExp =
m_fields[fldid]->GetBndCondExpansions()[bndid];
545 size_t exp_npts = BndCondExp->GetExpSize();
551 for (k = 1; k < M_coeffs; k++)
554 zt[k] = std::exp(zi * omega_c * k_c * m_time_c);
558 for (i = 0; i < exp_npts; ++i, cnt++)
561 bc = BndCondExp->GetExp(i);
562 nfq = bc->GetTotPoints();
566 for (j = 0; j < nfq; j++)
568 wbc[j] = WomParam->m_poiseuille[i][j];
569 for (k = 1; k < M_coeffs; k++)
571 zvel = WomParam->m_zvel[i][j][k] * zt[k];
572 wbc[j] = wbc[j] + zvel.real();
579 Bvals = BndCondExp->UpdateCoeffs() + BndCondExp->GetCoeff_Offset(i);
582 bc->FwdTrans(wbc, Bvals);
589 std::string::size_type indxBeg = womStr.find_first_of(
':') + 1;
590 string filename = womStr.substr(indxBeg, string::npos);
592 TiXmlDocument doc(filename);
594 bool loadOkay = doc.LoadFile();
596 (std::string(
"Failed to load file: ") + filename).c_str());
598 TiXmlHandle docHandle(&doc);
602 TiXmlElement *nektar = doc.FirstChildElement(
"NEKTAR");
603 ASSERTL0(nektar,
"Unable to find NEKTAR tag in file.");
605 TiXmlElement *wombc = nektar->FirstChildElement(
"WOMERSLEYBC");
606 ASSERTL0(wombc,
"Unable to find WOMERSLEYBC tag in file.");
609 TiXmlElement *womparam = wombc->FirstChildElement(
"WOMPARAMS");
610 ASSERTL0(womparam,
"Unable to find WOMPARAMS tag in file.");
613 TiXmlElement *params = womparam->FirstChildElement(
"W");
614 map<std::string, std::string> Wparams;
621 propstr = params->Attribute(
"PROPERTY");
624 "Failed to read PROPERTY value Womersley BC Parameter");
627 valstr = params->Attribute(
"VALUE");
630 "Failed to read VALUE value Womersley BC Parameter");
632 std::transform(propstr.begin(), propstr.end(), propstr.begin(),
634 Wparams[propstr] = valstr;
636 params = params->NextSiblingElement(
"W");
643 Wparams.count(
"RADIUS") == 1,
644 "Failed to find Radius parameter in Womersley boundary conditions");
645 std::vector<NekDouble>
rad;
650 Wparams.count(
"PERIOD") == 1,
651 "Failed to find period parameter in Womersley boundary conditions");
652 std::vector<NekDouble> period;
657 Wparams.count(
"AXISNORMAL") == 1,
658 "Failed to find axisnormal parameter in Womersley boundary conditions");
659 std::vector<NekDouble> anorm;
666 Wparams.count(
"AXISPOINT") == 1,
667 "Failed to find axispoint parameter in Womersley boundary conditions");
668 std::vector<NekDouble> apt;
677 TiXmlElement *coeff = wombc->FirstChildElement(
"FOURIERCOEFFS");
680 TiXmlElement *fval = coeff->FirstChildElement(
"F");
686 TiXmlAttribute *fvalAttr = fval->FirstAttribute();
687 std::string attrName(fvalAttr->Name());
690 (std::string(
"Unknown attribute name: ") + attrName).c_str());
692 err = fvalAttr->QueryIntValue(&indx);
693 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
695 std::string coeffStr = fval->FirstChild()->ToText()->ValueStr();
696 vector<NekDouble> coeffvals;
701 (std::string(
"Problem reading value of fourier coefficient, ID=") +
702 boost::lexical_cast<string>(indx))
705 coeffvals.size() == 2,
707 "Have not read two entries of Fourier coefficicent from ID=" +
708 boost::lexical_cast<string>(indx))
714 fval = fval->NextSiblingElement(
"F");
733 BndCondExp =
m_fields[fldid]->GetBndCondExpansions()[bndid];
740 size_t exp_npts = BndCondExp->GetExpSize();
754 for (k = 1; k < M_coeffs; k++)
757 lamda_n[k] = i_pow_3q2 * alpha_c *
sqrt(k_c[k]);
762 for (i = 0; i < exp_npts; ++i, cnt++)
765 bc = BndCondExp->GetExp(i);
766 nfq = bc->GetTotPoints();
771 bc->GetCoords(x, y,
z);
779 for (j = 0; j < nfq; j++)
782 (y[j] - x0[1]) * (y[j] - x0[1]) +
783 (
z[j] - x0[2]) * (
z[j] - x0[2])) /
790 (1. - rqR.real() * rqR.real());
796 for (k = 1; k < M_coeffs; k++)
801 (z1 - (zJ0r / zJ0[k]));
819 [[maybe_unused]]
const NekDouble SpeedSoundFactor)
822 size_t nelmt =
m_fields[0]->GetExpSize();
831 for (
size_t i = 0; i < 2; ++i)
840 for (
size_t i = 0; i < nvel; ++i)
858 if (physfield.size())
860 pressure = physfield[physfield.size() - 1];
871 int nPts = physfield[0].size();
884 velocity[i] = physfield[i];
900 "Arrays have different dimensions, cannot set moving frame "
903 Vmath::Vcopy(vFrameVels.size(), vFrameVels, 1, temp, 1);
913 "Arrays have different dimensions, cannot get moving frame "
935 vFrameDisp.size() == 6,
936 "Arrays have different size, cannot set moving frame displacement");
938 Vmath::Vcopy(vFrameDisp.size(), vFrameDisp, 1, temp, 1);
952 vFrameDisp.size() == 6,
953 "Arrays have different size, cannot get moving frame displacement");
968 "Arrays have different size, cannot set moving frame pivot");
970 Vmath::Vcopy(vFramePivot.size(), vFramePivot, 1, temp, 1);
972 Vmath::Vcopy(vFramePivot.size(), vFramePivot, 1, temp, 1);
996 vector<std::string> vForceList;
997 bool hasForce{
false};
999 if (!
m_session->DefinesElement(
"Nektar/Forcing"))
1004 TiXmlElement *vForcing =
m_session->GetElement(
"Nektar/Forcing");
1007 TiXmlElement *vForce = vForcing->FirstChildElement(
"FORCE");
1010 string vType = vForce->Attribute(
"TYPE");
1012 vForceList.push_back(vType);
1013 vForce = vForce->NextSiblingElement(
"FORCE");
1017 for (
auto &f : vForceList)
1019 if (boost::iequals(f, sForce))
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Array< OneD, Array< OneD, int > > m_fieldsBCToTraceID
Mapping from BCs to Elmt Edge IDs.
Array< OneD, NekDouble > v_GetMaxStdVelocity(const NekDouble SpeedSoundFactor) override
std::map< int, std::map< int, WomersleyParamsSharedPtr > > m_womersleyParams
Womersley parameters if required.
void v_SetAeroForce(Array< OneD, NekDouble > forces) override
bool v_GetMovingFrameVelocities(Array< OneD, NekDouble > &vFrameVels, const int step) override
virtual int v_GetForceDimension()=0
void SetWomersleyBoundary(const int fldid, const int bndid)
Set Womersley Profile if specified.
~IncNavierStokes() override
void v_GetAeroForce(Array< OneD, NekDouble > forces) override
void SetZeroNormalVelocity()
Set Normal Velocity Component to Zero.
void v_SetMovingFrameDisp(const Array< OneD, NekDouble > &vFrameDisp, const int step) override
MultiRegions::ExpListSharedPtr v_GetPressure() override
Array< OneD, NekDouble > m_aeroForces
void SetBoundaryConditions(NekDouble time)
time dependent boundary conditions updating
bool v_GetMovingFrameDisp(Array< OneD, NekDouble > &vFrameDisp, const int step) override
NekDouble m_kinvis
Kinematic viscosity.
void v_GetDensity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &density) override
void SetRadiationBoundaryForcing(int fieldid)
Set Radiation forcing term.
Array< OneD, Array< OneD, NekDouble > > m_fieldsRadiationFactor
RHS Factor for Radiation Condition.
bool DefinedForcing(const std::string &sForce)
bool v_PreIntegrate(int step) override
void v_SetMovingFrameVelocities(const Array< OneD, NekDouble > &vFrameVels, const int step) override
void SetUpWomersley(const int fldid, const int bndid, std::string womstr)
Set Up Womersley details.
void v_InitObject(bool DeclareField=true) override
Initialisation object for EquationSystem.
ExtrapolateSharedPtr m_extrapolation
Array< OneD, int > m_velocity
int which identifies which components of m_fields contains the velocity (u,v,w);
static std::string eqTypeLookupIds[]
void v_SetMovingFramePivot(const Array< OneD, NekDouble > &vFramePivot) override
Array< OneD, Array< OneD, int > > m_fieldsBCToElmtID
Mapping from BCs to Elmt IDs.
void v_GetVelocity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity) override
EquationType m_equationType
equation type;
int m_nConvectiveFields
Number of fields to be convected;.
void AddForcing(const SolverUtils::ForcingSharedPtr &pForce)
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Forcing terms.
void EvaluateAdvectionTerms(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
IncNavierStokes(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Constructor.
NekDouble Evaluate() const
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
A base class for PDEs which include an advection component.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Initialisation object for EquationSystem.
int m_spacedim
Spatial dimension (>= expansion dim).
NekDouble m_timestep
Time step size.
NekDouble m_time
Current time of simulation.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
std::vector< std::string > m_strFrameData
variable name in m_movingFrameData
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
enum HomogeneousType m_HomogeneousType
SOLVER_UTILS_EXPORT int GetPhys_Offset(int n)
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
Pointer to boundary conditions object.
Array< OneD, NekDouble > m_movingFrameData
Moving reference frame status in the inertial frame X, Y, Z, Theta_x, Theta_y, Theta_z,...
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtr > Load(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
Base class for unsteady solvers.
static NekDouble rad(NekDouble x, NekDouble y)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Forcing > ForcingSharedPtr
A shared pointer to an EquationSystem object.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
std::vector< double > z(NPUPPER)
std::complex< double > NekComplexDouble
std::shared_ptr< WomersleyParams > WomersleyParamsSharedPtr
const std::string kEquationTypeStr[]
std::complex< Nektar::NekDouble > ImagBesselComp(int n, std::complex< Nektar::NekDouble > y)
Calcualte the bessel function of the first kind with complex double input y. Taken from Numerical Rec...
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 Neg(int n, T *x, const int incx)
Negate x = -x.
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 Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)