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);
185 for (
size_t i = 0; i <
m_fields.size(); ++i)
193 BndConds =
m_fields[i]->GetBndConditions();
194 BndExp =
m_fields[i]->GetBndCondExpansions();
195 for (
size_t n = 0; n < BndConds.size(); ++n)
197 if (boost::iequals(BndConds[n]->GetUserDefined(),
"Radiation"))
200 BndConds[n]->GetBoundaryConditionType() ==
202 "Radiation boundary condition must be of type Robin <R>");
210 radpts += BndExp[n]->GetTotPoints();
212 if (boost::iequals(BndConds[n]->GetUserDefined(),
213 "ZeroNormalComponent"))
215 ASSERTL0(BndConds[n]->GetBoundaryConditionType() ==
217 "Zero Normal Component boundary condition option must "
218 "be of type Dirichlet <D>");
233 for (
size_t n = 0; n < BndConds.size(); ++n)
235 if (boost::iequals(BndConds[n]->GetUserDefined(),
"Radiation"))
238 int npoints = BndExp[n]->GetNpoints();
244 BndExp[n]->GetCoords(x0, x1, x2);
247 std::static_pointer_cast<
249 ->m_robinPrimitiveCoeff;
261 for (
size_t i = 0; i <
m_fields.size(); ++i)
263 for (
size_t n = 0; n <
m_fields[i]->GetBndConditions().size(); ++n)
265 if (boost::istarts_with(
266 m_fields[i]->GetBndConditions()[n]->GetUserDefined(),
277 i, n,
m_fields[i]->GetBndConditions()[n]->GetUserDefined());
308 size_t npoints =
m_fields[0]->GetNpoints();
309 for (
size_t i = 0; i < VelDim; ++i)
316 x->PreApply(
m_fields, velocity, velocity, time);
330 size_t nvariables =
m_fields.size();
332 for (i = 0; i < nvariables; ++i)
334 for (n = 0; n <
m_fields[i]->GetBndConditions().size(); ++n)
336 if (
m_fields[i]->GetBndConditions()[n]->IsTimeDependent())
339 m_fields[i]->EvaluateBoundaryConditions(time, varName);
341 else if (boost::istarts_with(
342 m_fields[i]->GetBndConditions()[n]->GetUserDefined(),
369 BndConds =
m_fields[fieldid]->GetBndConditions();
370 BndExp =
m_fields[fieldid]->GetBndCondExpansions();
376 size_t elmtid, nq, offset, boundary;
380 for (cnt = n = 0; n < BndConds.size(); ++n)
382 std::string type = BndConds[n]->GetUserDefined();
384 if ((BndConds[n]->GetBoundaryConditionType() ==
386 (boost::iequals(type,
"Radiation")))
388 size_t nExp = BndExp[n]->GetExpSize();
389 for (i = 0; i < nExp; ++i, cnt++)
392 elmt =
m_fields[fieldid]->GetExp(elmtid);
393 offset =
m_fields[fieldid]->GetPhys_Offset(elmtid);
395 U =
m_fields[fieldid]->UpdatePhys() + offset;
396 Bc = BndExp[n]->GetExp(i);
401 nq = Bc->GetTotPoints();
403 elmt->GetTracePhysVals(boundary, Bc, U, ubc);
408 1, &ubc[0], 1, &ubc[0], 1);
411 BndExp[n]->UpdateCoeffs() + BndExp[n]->GetCoeff_Offset(i);
413 Bc->IProductWRTBase(ubc, Bvals);
415 cnt1 += BndExp[n]->GetTotPoints();
419 cnt += BndExp[n]->GetExpSize();
428 static bool Setup =
false;
451 size_t elmtid, nq, boundary;
458 for (cnt = n = 0; n < BndConds[0].size(); ++n)
460 if ((BndConds[0][n]->GetBoundaryConditionType() ==
462 (boost::iequals(BndConds[0][n]->GetUserDefined(),
463 "ZeroNormalComponent")))
465 size_t nExp = BndExp[0][n]->GetExpSize();
466 for (i = 0; i < nExp; ++i, cnt++)
472 normals = elmt->GetTraceNormal(boundary);
474 nq = BndExp[0][n]->GetExp(i)->GetTotPoints();
479 Bphys = BndExp[k][n]->UpdatePhys() +
480 BndExp[k][n]->GetPhys_Offset(i);
481 Bc = BndExp[k][n]->GetExp(i);
491 Bphys = BndExp[k][n]->UpdatePhys() +
492 BndExp[k][n]->GetPhys_Offset(i);
493 Bcoeffs = BndExp[k][n]->UpdateCoeffs() +
494 BndExp[k][n]->GetCoeff_Offset(i);
495 Bc = BndExp[k][n]->GetExp(i);
496 Vmath::Vvtvp(nq, normvel, 1, normals[k], 1, Bphys, 1, Bphys,
498 Bc->FwdTransBndConstrained(Bphys, Bcoeffs);
504 cnt += BndExp[0][n]->GetExpSize();
515 "Womersley parameters for this boundary have not been set up");
521 size_t M_coeffs = WomParam->m_wom_vel.size();
524 NekDouble axis_normal = WomParam->m_axisnormal[fldid];
534 BndCondExp =
m_fields[fldid]->GetBndCondExpansions()[bndid];
540 size_t exp_npts = BndCondExp->GetExpSize();
546 for (k = 1; k < M_coeffs; k++)
549 zt[k] = std::exp(zi * omega_c * k_c * m_time_c);
553 for (i = 0; i < exp_npts; ++i, cnt++)
556 bc = BndCondExp->GetExp(i);
557 nfq = bc->GetTotPoints();
561 for (j = 0; j < nfq; j++)
563 wbc[j] = WomParam->m_poiseuille[i][j];
564 for (k = 1; k < M_coeffs; k++)
566 zvel = WomParam->m_zvel[i][j][k] * zt[k];
567 wbc[j] = wbc[j] + zvel.real();
574 Bvals = BndCondExp->UpdateCoeffs() + BndCondExp->GetCoeff_Offset(i);
577 bc->FwdTrans(wbc, Bvals);
584 std::string::size_type indxBeg = womStr.find_first_of(
':') + 1;
585 string filename = womStr.substr(indxBeg, string::npos);
587 TiXmlDocument doc(filename);
589 bool loadOkay = doc.LoadFile();
591 (std::string(
"Failed to load file: ") + filename).c_str());
593 TiXmlHandle docHandle(&doc);
597 TiXmlElement *nektar = doc.FirstChildElement(
"NEKTAR");
598 ASSERTL0(nektar,
"Unable to find NEKTAR tag in file.");
600 TiXmlElement *wombc = nektar->FirstChildElement(
"WOMERSLEYBC");
601 ASSERTL0(wombc,
"Unable to find WOMERSLEYBC tag in file.");
604 TiXmlElement *womparam = wombc->FirstChildElement(
"WOMPARAMS");
605 ASSERTL0(womparam,
"Unable to find WOMPARAMS tag in file.");
608 TiXmlElement *params = womparam->FirstChildElement(
"W");
609 map<std::string, std::string> Wparams;
616 propstr = params->Attribute(
"PROPERTY");
619 "Failed to read PROPERTY value Womersley BC Parameter");
622 valstr = params->Attribute(
"VALUE");
625 "Failed to read VALUE value Womersley BC Parameter");
627 std::transform(propstr.begin(), propstr.end(), propstr.begin(),
629 Wparams[propstr] = valstr;
631 params = params->NextSiblingElement(
"W");
638 Wparams.count(
"RADIUS") == 1,
639 "Failed to find Radius parameter in Womersley boundary conditions");
640 std::vector<NekDouble>
rad;
645 Wparams.count(
"PERIOD") == 1,
646 "Failed to find period parameter in Womersley boundary conditions");
647 std::vector<NekDouble> period;
652 Wparams.count(
"AXISNORMAL") == 1,
653 "Failed to find axisnormal parameter in Womersley boundary conditions");
654 std::vector<NekDouble> anorm;
661 Wparams.count(
"AXISPOINT") == 1,
662 "Failed to find axispoint parameter in Womersley boundary conditions");
663 std::vector<NekDouble> apt;
672 TiXmlElement *coeff = wombc->FirstChildElement(
"FOURIERCOEFFS");
675 TiXmlElement *fval = coeff->FirstChildElement(
"F");
681 TiXmlAttribute *fvalAttr = fval->FirstAttribute();
682 std::string attrName(fvalAttr->Name());
685 (std::string(
"Unknown attribute name: ") + attrName).c_str());
687 err = fvalAttr->QueryIntValue(&indx);
688 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
690 std::string coeffStr = fval->FirstChild()->ToText()->ValueStr();
691 vector<NekDouble> coeffvals;
696 (std::string(
"Problem reading value of fourier coefficient, ID=") +
697 boost::lexical_cast<string>(indx))
700 coeffvals.size() == 2,
702 "Have not read two entries of Fourier coefficicent from ID=" +
703 boost::lexical_cast<string>(indx))
709 fval = fval->NextSiblingElement(
"F");
728 BndCondExp =
m_fields[fldid]->GetBndCondExpansions()[bndid];
735 size_t exp_npts = BndCondExp->GetExpSize();
749 for (k = 1; k < M_coeffs; k++)
752 lamda_n[k] = i_pow_3q2 * alpha_c *
sqrt(k_c[k]);
757 for (i = 0; i < exp_npts; ++i, cnt++)
760 bc = BndCondExp->GetExp(i);
761 nfq = bc->GetTotPoints();
766 bc->GetCoords(x, y,
z);
774 for (j = 0; j < nfq; j++)
777 (y[j] - x0[1]) * (y[j] - x0[1]) +
778 (
z[j] - x0[2]) * (
z[j] - x0[2])) /
785 (1. - rqR.real() * rqR.real());
791 for (k = 1; k < M_coeffs; k++)
796 (z1 - (zJ0r / zJ0[k]));
838 for (
size_t n = 0; n < BndExp[0].size(); ++n)
840 std::set<int> MRFwall;
841 for (
size_t k = 0; k < BndConds.size(); ++k)
843 if (BndConds[k][n]->GetBoundaryConditionType() ==
845 (boost::iequals(BndConds[k][n]->GetUserDefined(),
855 npoints = BndExp[0][n]->GetNpoints();
862 for (
size_t k = 0; k <
m_velocity.size(); ++k)
868 for (
size_t k = 0; k < 3; ++k)
872 BndExp[0][n]->GetCoords(coords[0], coords[1], coords[2]);
900 velocities[0], 1, velocities[0], 1);
903 velocities[1], 1, velocities[1], 1);
930 1, acceleration[k], 1);
934 for (
auto k : MRFwall)
939 BndExp[k][n]->UpdatePhys(), 1);
942 BndExp[k][n]->SetWaveSpace(
false);
944 BndExp[k][n]->FwdTransBndConstrained(
945 BndExp[k][n]->GetPhys(), BndExp[k][n]->UpdateCoeffs());
949 BndExp[k][n]->NormVectorIProductWRTBase(
950 acceleration, BndExp[k][n]->UpdateCoeffs());
984 for (
size_t n = 0; n < BndExp[0].size(); ++n)
986 std::set<int> MRFBnd;
989 if (BndConds[k][n]->GetBoundaryConditionType() ==
991 (boost::iequals(BndConds[k][n]->GetUserDefined(),
992 "MovingFrameDomainVel")))
997 if (MRFBnd.size() == 0)
1001 npoints = BndExp[0][n]->GetNpoints();
1002 for (
size_t k = 0; k <
m_velocity.size(); ++k)
1008 for (
size_t k = 0; k < 3; ++k)
1012 BndExp[0][n]->GetCoords(coords[0], coords[1], coords[2]);
1016 for (
size_t k = 0; k <
m_velocity.size(); ++k)
1019 std::static_pointer_cast<
1021 ->m_dirichletCondition;
1023 condition.
Evaluate(coords[0], coords[1], coords[2], time,
1034 definedVels[m], 1, velocities[l], 1, velocities[l],
1040 for (
auto k : MRFBnd)
1042 Vmath::Vcopy(npoints, velocities[k], 1, BndExp[k][n]->UpdatePhys(),
1046 BndExp[k][n]->SetWaveSpace(
false);
1048 BndExp[k][n]->FwdTransBndConstrained(BndExp[k][n]->GetPhys(),
1049 BndExp[k][n]->UpdateCoeffs());
1066 [[maybe_unused]]
const NekDouble SpeedSoundFactor)
1069 size_t nelmt =
m_fields[0]->GetExpSize();
1078 for (
size_t i = 0; i < 2; ++i)
1087 for (
size_t i = 0; i < nvel; ++i)
1105 if (physfield.size())
1107 pressure = physfield[physfield.size() - 1];
1118 int nPts = physfield[0].size();
1131 velocity[i] = physfield[i];
1145 "Arrays have different dimensions, cannot set moving frame "
1154 "Arrays have different dimensions, cannot get moving frame "
1167 const bnu::matrix<NekDouble> &vProjMat)
1170 "Matrices have different numbers of rows, cannot Set the "
1171 "moving frame projection matrix");
1173 "Matrices have different numbers of columns, cannot Set the "
1174 "moving frame projection matrix");
1175 for (
size_t i = 0; i < vProjMat.size1(); ++i)
1177 for (
size_t j = 0; j < vProjMat.size2(); ++j)
1185 bnu::matrix<NekDouble> &vProjMat)
1188 "Matrices have different numbers of rows, cannot Get the "
1189 "moving frame projection matrix");
1191 "Matrices have different numbers of columns, cannot Get the "
1192 "moving frame projection matrix");
1194 for (
size_t i = 0; i < vProjMat.size1(); ++i)
1196 for (
size_t j = 0; j < vProjMat.size2(); ++j)
1212 "Arrays have different size, cannot set moving frame displacement");
1213 for (
size_t i = 0; i < vFrameDisp.size(); ++i)
1227 "Arrays have different size, cannot get moving frame displacement");
1249 vector<std::string> vForceList;
1250 bool hasForce{
false};
1252 if (!
m_session->DefinesElement(
"Nektar/Forcing"))
1257 TiXmlElement *vForcing =
m_session->GetElement(
"Nektar/Forcing");
1260 TiXmlElement *vForce = vForcing->FirstChildElement(
"FORCE");
1263 string vType = vForce->Attribute(
"TYPE");
1265 vForceList.push_back(vType);
1266 vForce = vForce->NextSiblingElement(
"FORCE");
1270 for (
auto &f : vForceList)
1272 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 > m_pivotPoint
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
virtual int v_GetForceDimension()=0
void SetWomersleyBoundary(const int fldid, const int bndid)
Set Womersley Profile if specified.
void v_GetMovingFrameVelocities(Array< OneD, NekDouble > &vFrameVels) override
~IncNavierStokes() override
void v_GetAeroForce(Array< OneD, NekDouble > forces) override
void SetZeroNormalVelocity()
Set Normal Velocity Component to Zero.
void v_GetMovingFrameDisp(Array< OneD, NekDouble > &vFrameDisp) override
MultiRegions::ExpListSharedPtr v_GetPressure() override
Array< OneD, NekDouble > m_aeroForces
void SetBoundaryConditions(NekDouble time)
time dependent boundary conditions updating
void SetMRFDomainVelBCs(const NekDouble &time)
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)
void SetMRFWallBCs(const NekDouble &time)
void v_SetMovingFrameVelocities(const Array< OneD, NekDouble > &vFrameVels) override
bool v_PreIntegrate(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_GetMovingFrameProjectionMat(bnu::matrix< NekDouble > &vProjMat) 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;
void v_SetMovingFrameProjectionMat(const bnu::matrix< NekDouble > &vProjMat) override
int m_nConvectiveFields
Number of fields to be convected;.
void AddForcing(const SolverUtils::ForcingSharedPtr &pForce)
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Forcing terms.
void v_SetMovingFrameDisp(const Array< OneD, NekDouble > &vFrameDisp) override
void EvaluateAdvectionTerms(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
void SetMovingReferenceFrameBCs(const NekDouble &time)
Set the moving reference frame boundary conditions.
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).
boost::numeric::ublas::matrix< NekDouble > m_movingFrameProjMat
Projection matrix for transformation between inertial and moving.
NekDouble m_timestep
Time step size.
NekDouble m_time
Current time of simulation.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
Array< OneD, NekDouble > m_movingFrameVelsxyz
Moving frame of reference velocities (u, v, w, omega_x, omega_y, omega_z, a_x, a_y,...
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 frame of reference angles with respect to the.
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 Svtsvtp(int n, const T alpha, const T *x, int incx, const T beta, const T *y, int incy, T *z, int incz)
Svtsvtp (scalar times vector plus scalar times vector):
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 Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*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 Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)