36#include <boost/algorithm/string.hpp>
85 m_SmoothAdvection(false)
95 std::string velids[] = {
"u",
"v",
"w"};
102 for (j = 0; j < numfields; ++j)
105 if (boost::iequals(velids[i], var))
111 ASSERTL0(j != numfields,
"Failed to find field: " + var);
131 std::string vConvectiveType;
136 vConvectiveType =
"NoAdvection";
140 vConvectiveType =
"Convective";
143 vConvectiveType =
"Linearised";
150 if (
m_session->DefinesTag(
"AdvectiveType") &&
154 vConvectiveType =
m_session->GetTag(
"AdvectiveType");
159 vConvectiveType, vConvectiveType);
166 std::string vSolver =
m_session->GetSolverInfo(
"SolverType");
167 const bool isVCS = boost::iequals(vSolver,
"VelocityCorrectionScheme");
170 ASSERTL0(
false,
"The Forcing MovingRefenceFrame is no "
171 "longer supported for use in the "
172 "VelocityCorrectionScheme. Please replace the "
173 "SolverType with VCSFSI or PressDecompVCSFSI.");
178 "X",
"Y",
"Z",
"Theta_x",
"Theta_y",
"Theta_z",
179 "U",
"V",
"W",
"Omega_x",
"Omega_y",
"Omega_z",
180 "A_x",
"A_y",
"A_z",
"DOmega_x",
"DOmega_y",
"DOmega_z",
200 for (
size_t i = 0; i <
m_fields.size(); ++i)
208 BndConds =
m_fields[i]->GetBndConditions();
209 BndExp =
m_fields[i]->GetBndCondExpansions();
210 for (
size_t n = 0; n < BndConds.size(); ++n)
212 if (boost::iequals(BndConds[n]->GetUserDefined(),
"Radiation"))
215 BndConds[n]->GetBoundaryConditionType() ==
217 "Radiation boundary condition must be of type Robin <R>");
225 radpts += BndExp[n]->GetTotPoints();
227 if (boost::iequals(BndConds[n]->GetUserDefined(),
228 "ZeroNormalComponent"))
230 ASSERTL0(BndConds[n]->GetBoundaryConditionType() ==
232 "Zero Normal Component boundary condition option must "
233 "be of type Dirichlet <D>");
248 for (
size_t n = 0; n < BndConds.size(); ++n)
250 if (boost::iequals(BndConds[n]->GetUserDefined(),
"Radiation"))
253 int npoints = BndExp[n]->GetNpoints();
259 BndExp[n]->GetCoords(x0, x1, x2);
262 std::static_pointer_cast<
264 ->m_robinPrimitiveCoeff;
266 coeff->Evaluate(x0, x1, x2,
m_time,
276 for (
size_t i = 0; i <
m_fields.size(); ++i)
278 for (
size_t n = 0; n <
m_fields[i]->GetBndConditions().size(); ++n)
280 if (boost::istarts_with(
281 m_fields[i]->GetBndConditions()[n]->GetUserDefined(),
292 i, n,
m_fields[i]->GetBndConditions()[n]->GetUserDefined());
316 size_t npoints =
m_fields[0]->GetNpoints();
317 for (
size_t i = 0; i < VelDim; ++i)
324 x->PreApply(
m_fields, velocity, velocity, time);
338 size_t nvariables =
m_fields.size();
340 for (i = 0; i < nvariables; ++i)
342 for (n = 0; n <
m_fields[i]->GetBndConditions().size(); ++n)
344 if (
m_fields[i]->GetBndConditions()[n]->IsTimeDependent())
347 m_fields[i]->EvaluateBoundaryConditions(time, varName);
349 else if (boost::istarts_with(
350 m_fields[i]->GetBndConditions()[n]->GetUserDefined(),
376 BndConds =
m_fields[fieldid]->GetBndConditions();
377 BndExp =
m_fields[fieldid]->GetBndCondExpansions();
383 size_t elmtid, nq, offset, boundary;
387 for (cnt = n = 0; n < BndConds.size(); ++n)
389 std::string type = BndConds[n]->GetUserDefined();
391 if ((BndConds[n]->GetBoundaryConditionType() ==
393 (boost::iequals(type,
"Radiation")))
395 size_t nExp = BndExp[n]->GetExpSize();
396 for (i = 0; i < nExp; ++i, cnt++)
399 elmt =
m_fields[fieldid]->GetExp(elmtid);
400 offset =
m_fields[fieldid]->GetPhys_Offset(elmtid);
402 U =
m_fields[fieldid]->UpdatePhys() + offset;
403 Bc = BndExp[n]->GetExp(i);
408 nq = Bc->GetTotPoints();
410 elmt->GetTracePhysVals(boundary, Bc, U, ubc);
415 1, &ubc[0], 1, &ubc[0], 1);
418 BndExp[n]->UpdateCoeffs() + BndExp[n]->GetCoeff_Offset(i);
420 Bc->IProductWRTBase(ubc, Bvals);
422 cnt1 += BndExp[n]->GetTotPoints();
426 cnt += BndExp[n]->GetExpSize();
435 static bool Setup =
false;
458 size_t elmtid, nq, boundary;
465 for (cnt = n = 0; n < BndConds[0].size(); ++n)
467 if ((BndConds[0][n]->GetBoundaryConditionType() ==
469 (boost::iequals(BndConds[0][n]->GetUserDefined(),
470 "ZeroNormalComponent")))
472 size_t nExp = BndExp[0][n]->GetExpSize();
473 for (i = 0; i < nExp; ++i, cnt++)
479 normals = elmt->GetTraceNormal(boundary);
481 nq = BndExp[0][n]->GetExp(i)->GetTotPoints();
486 Bphys = BndExp[k][n]->UpdatePhys() +
487 BndExp[k][n]->GetPhys_Offset(i);
488 Bc = BndExp[k][n]->GetExp(i);
498 Bphys = BndExp[k][n]->UpdatePhys() +
499 BndExp[k][n]->GetPhys_Offset(i);
500 Bcoeffs = BndExp[k][n]->UpdateCoeffs() +
501 BndExp[k][n]->GetCoeff_Offset(i);
502 Bc = BndExp[k][n]->GetExp(i);
503 Vmath::Vvtvp(nq, normvel, 1, normals[k], 1, Bphys, 1, Bphys,
505 Bc->FwdTransBndConstrained(Bphys, Bcoeffs);
511 cnt += BndExp[0][n]->GetExpSize();
522 "Womersley parameters for this boundary have not been set up");
528 size_t M_coeffs = WomParam->m_wom_vel.size();
531 NekDouble axis_normal = WomParam->m_axisnormal[fldid];
541 BndCondExp =
m_fields[fldid]->GetBndCondExpansions()[bndid];
547 size_t exp_npts = BndCondExp->GetExpSize();
553 for (k = 1; k < M_coeffs; k++)
556 zt[k] = std::exp(zi * omega_c * k_c * m_time_c);
560 for (i = 0; i < exp_npts; ++i, cnt++)
563 bc = BndCondExp->GetExp(i);
564 nfq = bc->GetTotPoints();
568 for (j = 0; j < nfq; j++)
570 wbc[j] = WomParam->m_poiseuille[i][j];
571 for (k = 1; k < M_coeffs; k++)
573 zvel = WomParam->m_zvel[i][j][k] * zt[k];
574 wbc[j] = wbc[j] + zvel.real();
581 Bvals = BndCondExp->UpdateCoeffs() + BndCondExp->GetCoeff_Offset(i);
584 bc->FwdTrans(wbc, Bvals);
591 std::string::size_type indxBeg = womStr.find_first_of(
':') + 1;
592 std::string filename = womStr.substr(indxBeg, std::string::npos);
594 TiXmlDocument doc(filename);
596 bool loadOkay = doc.LoadFile();
598 (std::string(
"Failed to load file: ") + filename).c_str());
600 TiXmlHandle docHandle(&doc);
604 TiXmlElement *
nektar = doc.FirstChildElement(
"NEKTAR");
607 TiXmlElement *wombc =
nektar->FirstChildElement(
"WOMERSLEYBC");
608 ASSERTL0(wombc,
"Unable to find WOMERSLEYBC tag in file.");
611 TiXmlElement *womparam = wombc->FirstChildElement(
"WOMPARAMS");
612 ASSERTL0(womparam,
"Unable to find WOMPARAMS tag in file.");
615 TiXmlElement *params = womparam->FirstChildElement(
"W");
616 std::map<std::string, std::string> Wparams;
623 propstr = params->Attribute(
"PROPERTY");
626 "Failed to read PROPERTY value Womersley BC Parameter");
629 valstr = params->Attribute(
"VALUE");
632 "Failed to read VALUE value Womersley BC Parameter");
634 std::transform(propstr.begin(), propstr.end(), propstr.begin(),
636 Wparams[propstr] = valstr;
638 params = params->NextSiblingElement(
"W");
645 Wparams.count(
"RADIUS") == 1,
646 "Failed to find Radius parameter in Womersley boundary conditions");
647 std::vector<NekDouble>
rad;
652 Wparams.count(
"PERIOD") == 1,
653 "Failed to find period parameter in Womersley boundary conditions");
654 std::vector<NekDouble> period;
659 Wparams.count(
"AXISNORMAL") == 1,
660 "Failed to find axisnormal parameter in Womersley boundary conditions");
661 std::vector<NekDouble> anorm;
668 Wparams.count(
"AXISPOINT") == 1,
669 "Failed to find axispoint parameter in Womersley boundary conditions");
670 std::vector<NekDouble> apt;
679 TiXmlElement *coeff = wombc->FirstChildElement(
"FOURIERCOEFFS");
682 TiXmlElement *fval = coeff->FirstChildElement(
"F");
688 TiXmlAttribute *fvalAttr = fval->FirstAttribute();
689 std::string attrName(fvalAttr->Name());
692 (std::string(
"Unknown attribute name: ") + attrName).c_str());
694 err = fvalAttr->QueryIntValue(&indx);
695 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
697 std::string coeffStr = fval->FirstChild()->ToText()->ValueStr();
698 std::vector<NekDouble> coeffvals;
703 (std::string(
"Problem reading value of fourier coefficient, ID=") +
704 std::to_string(indx))
707 coeffvals.size() == 2,
709 "Have not read two entries of Fourier coefficicent from ID=" +
710 std::to_string(indx))
716 fval = fval->NextSiblingElement(
"F");
735 BndCondExp =
m_fields[fldid]->GetBndCondExpansions()[bndid];
742 size_t exp_npts = BndCondExp->GetExpSize();
756 for (k = 1; k < M_coeffs; k++)
759 lamda_n[k] = i_pow_3q2 * alpha_c *
sqrt(k_c[k]);
764 for (i = 0; i < exp_npts; ++i, cnt++)
767 bc = BndCondExp->GetExp(i);
768 nfq = bc->GetTotPoints();
773 bc->GetCoords(x, y, z);
781 for (j = 0; j < nfq; j++)
784 (y[j] - x0[1]) * (y[j] - x0[1]) +
785 (z[j] - x0[2]) * (z[j] - x0[2])) /
792 (1. - rqR.real() * rqR.real());
798 for (k = 1; k < M_coeffs; k++)
803 (z1 - (zJ0r / zJ0[k]));
821 [[maybe_unused]]
const NekDouble SpeedSoundFactor)
824 size_t nelmt =
m_fields[0]->GetExpSize();
833 for (
size_t i = 0; i < 2; ++i)
842 for (
size_t i = 0; i < nvel; ++i)
860 if (physfield.size())
862 pressure = physfield[physfield.size() - 1];
873 int nPts = physfield[0].size();
886 velocity[i] = physfield[i];
902 "Arrays have different dimensions, cannot set moving frame "
905 Vmath::Vcopy(vFrameVels.size(), vFrameVels, 1, temp, 1);
915 "Arrays have different dimensions, cannot get moving frame "
937 vFrameDisp.size() == 6,
938 "Arrays have different size, cannot set moving frame displacement");
940 Vmath::Vcopy(vFrameDisp.size(), vFrameDisp, 1, temp, 1);
953 vFrameDisp.size() == 6,
954 "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);
976 "Arrays have different size, cannot set moving frame pivot");
978 Vmath::Vcopy(vFramePivot.size(), temp, 1, vFramePivot, 1);
1022 std::vector<std::string> vForceList;
1023 bool hasForce{
false};
1025 if (!
m_session->DefinesElement(
"Nektar/Forcing"))
1030 TiXmlElement *vForcing =
m_session->GetElement(
"Nektar/Forcing");
1033 TiXmlElement *vForce = vForcing->FirstChildElement(
"FORCE");
1036 std::string vType = vForce->Attribute(
"TYPE");
1038 vForceList.push_back(vType);
1039 vForce = vForce->NextSiblingElement(
"FORCE");
1043 for (
auto &f : vForceList)
1045 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.
void v_GetMovingFramePivot(Array< OneD, NekDouble > &vFramePivot) override
Array< OneD, NekDouble > v_GetMaxStdVelocity(const NekDouble SpeedSoundFactor) override
std::map< int, std::map< int, WomersleyParamsSharedPtr > > m_womersleyParams
Womersley parameters if required.
bool v_GetMovingFrameDisp(Array< OneD, NekDouble > &vFrameDisp) override
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_GetMovableDoFs(std::set< int > &dirDoFs) override
void v_GetAeroForce(Array< OneD, NekDouble > forces) override
void SetZeroNormalVelocity()
Set Normal Velocity Component to Zero.
MultiRegions::ExpListSharedPtr v_GetPressure() override
Array< OneD, NekDouble > m_aeroForces
void SetBoundaryConditions(NekDouble time)
time dependent boundary conditions updating
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 v_SetMovingFrameVelocities(const Array< OneD, NekDouble > &vFrameVels) override
bool v_GetMovingFrameVelocities(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_SetMovingFramePivot(const Array< OneD, NekDouble > &vFramePivot) override
void v_SetMovableDoFs(const std::set< int > &dirDoFs) 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 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)
IncNavierStokes(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Constructor.
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
SOLVER_UTILS_EXPORT int GetPhys_Offset(int n)
std::vector< bool > m_movableDoFs
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
enum HomogeneousType m_HomogeneousType
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 body 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< Equation > EquationSharedPtr
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::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)