44#include <boost/algorithm/string.hpp>
50using namespace MultiRegions;
89 ASSERTL0(
false,
"Need to set up pressure field definition");
96 std::string varName =
m_session->GetVariable(n);
97 if (
m_session->DefinesFunction(
"DiffusionCoefficient", varName))
100 m_session->GetFunction(
"DiffusionCoefficient", varName);
115 m_session->MatchSolverInfo(
"GJPStabilisation",
"False",
129 "Can only specify GJPNormalVelocity with"
130 " GJPStabilisation set to Explicit currently");
158 if (
m_session->DefinesSolverInfo(
"Extrapolation"))
161 m_session->GetSolverInfo(
"Extrapolation"));
229 std::string forces[] = {
"X",
"Y",
"Z"};
236 std::string varName = std::string(
"Force") + forces[i];
237 defined =
m_session->DefinesFunction(
"FlowrateForce", varName);
245 "A 'FlowrateForce' function must defined with components "
246 "[ForceX, ...] to define direction of flowrate forcing");
249 m_session->GetFunction(
"FlowrateForce", varName);
250 flowrateForce[i] = ffunc->Evaluate();
265 flowrateForce[2] = 1.0;
269 for (
size_t i = 0; i < bcs.size(); ++i)
271 if (boost::iequals(bcs[i]->GetUserDefined(),
"Flowrate"))
281 "One boundary region must be marked using the 'Flowrate' "
282 "user-defined type to monitor the volumetric flowrate.");
297 for (
size_t i = 0; i < zIDs.size(); ++i)
306 ASSERTL1(tmpId <= 0,
"Should be either at location 0 or -1 if not "
338 for (
size_t i = 0; i < zIDs.size(); ++i)
361 int nqTot =
m_fields[0]->GetNpoints();
373 m_fields[i]->HomogeneousFwdTrans(nqTot, inTmp[i], inTmp2);
389 for (
size_t n = 0; n < PBndConds.size(); ++n)
391 if (PBndConds[n]->GetBoundaryConditionType() ==
418 std::string filename =
m_session->GetSessionName();
423 <<
"# -------------------------------------------"
507 << setw(16) <<
m_alpha << endl;
528 "Velocity correction (strong press. form)");
539 dealias += (dealias ==
"" ?
"" :
" + ") +
string(
"spectral/hp");
552 s,
"Smoothing-SpecHP",
553 "SVV (" + smoothing +
" Exp Kernel(cut-off = " +
563 s,
"Smoothing-SpecHP",
564 "SVV (" + smoothing +
" Power Kernel (Power ratio =" +
573 s,
"Smoothing-SpecHP",
574 "SVV (" + smoothing +
" DG Kernel (diff coeff = " +
584 s,
"Smoothing-Homo1D",
585 "SVV (Homogeneous1D - Exp Kernel(cut-off = " +
594 s,
"GJP Stab. Impl. ",
595 m_session->GetSolverInfo(
"GJPStabilisation"));
598 if (boost::iequals(
m_session->GetSolverInfo(
"GJPStabilisation"),
602 s,
"GJP Normal Velocity",
603 m_session->GetSolverInfo(
"GJPNormalVelocity"));
635 for (
size_t i = 0; i <
m_fields.size(); ++i)
650 size_t nfields =
m_fields.size() - 1;
651 for (
size_t k = 0; k < nfields; ++k)
665 size_t nfields =
m_fields.size() - 1;
666 for (
size_t k = 0; k < nfields; ++k)
679 int vVar =
m_session->GetVariables().size();
681 vChecks[vVar - 1] =
true;
690 return m_session->GetVariables().size() - 1;
718 x->Apply(
m_fields, inarray, outarray, time);
736 boost::ignore_unused(time);
745 size_t physTot =
m_fields[0]->GetTotPoints();
786 m_fields[i]->FwdTransLocalElmt(outarray[i],
804 size_t physTot =
m_fields[0]->GetTotPoints();
809 for (i = 1; i < nvel; ++i)
827 size_t phystot =
m_fields[0]->GetTotPoints();
903 varCoeffMap, varFactorsMap);
911 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"PowerKernel",
920 m_session->MatchSolverInfo(
"SpectralVanishingViscositySpectralHP",
930 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"DGKernel",
938 m_session->MatchSolverInfo(
"SpectralVanishingViscositySpectralHP",
953 if (
m_session->DefinesFunction(
"SVVVelocityMagnitude"))
955 if (
m_comm->GetRank() == 0)
957 cout <<
"Seting up SVV velocity from "
958 "SVVVelocityMagnitude section in session file"
962 size_t phystot =
m_fields[0]->GetTotPoints();
965 for (
size_t i = 0; i < nvel; ++i)
972 GetFunction(
"SVVVelocityMagnitude")->Evaluate(vars, SVVVelFields);
988 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"True",
992 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
999 m_session->MatchSolverInfo(
"SpectralVanishingViscositySpectralHP",
1004 "SpectralVanishingViscositySpectralHP",
"ExpKernel",
1011 if (
m_session->DefinesSolverInfo(
"SpectralVanishingViscosityHomo1D"))
1013 m_session->MatchSolverInfo(
"SpectralVanishingViscosityHomo1D",
"True",
1017 m_session->MatchSolverInfo(
"SpectralVanishingViscosityHomo1D",
1033 "Expect to have three velocity fields with homogenous expansion");
1040 size_t num_planes = planes.size();
1043 size_t kmodes =
m_fields[0]->GetHomogeneousBasis()->GetNumModes();
1048 for (
size_t n = 0; n < num_planes; ++n)
1050 if (planes[n] > pstart)
1052 fac = (
NekDouble)((planes[n] - kmodes) *
1053 (planes[n] - kmodes)) /
1055 (planes[n] - pstart)));
1060 for (
size_t i = 0; i <
m_velocity.size(); ++i)
1072 size_t phystot =
m_fields[0]->GetTotPoints();
1073 size_t nel =
m_fields[0]->GetNumElmts();
1085 Vmath::Vmul(phystot, vel[0], 1, vel[0], 1, Velmag, 1);
1086 for (
size_t n = 1; n < nvel; ++n)
1088 Vmath::Vvtvp(phystot, vel[n], 1, vel[n], 1, Velmag, 1, Velmag, 1);
1095 for (
size_t i = 0; i < nel; ++i)
1097 size_t nq =
m_fields[0]->GetExp(i)->GetTotPoints();
1099 diffcoeff[i] =
m_fields[0]->GetExp(i)->Integral(tmp);
1102 diffcoeff[i] = diffcoeff[i] / area;
1111 for (
size_t e = 0; e < nel; e++)
1117 size_t nEdge = exp->GetGeom()->GetNumEdges();
1118 for (
size_t i = 0; i < nEdge; ++i)
1120 h = max(h, exp->GetGeom()->GetEdge(i)->GetVertex(0)->dist(
1121 *(exp->GetGeom()->GetEdge(i)->GetVertex(1))));
1127 p = max(
p, exp->GetBasisNumModes(i) - 1);
1130 diffcoeff[e] *= h /
p;
1172 std::dynamic_pointer_cast<MultiRegions::ContField>(
m_fields[0]);
1175 cfield->GetGJPForcing();
1177 int nTracePts = GJPData->GetNumTracePts();
1181 GJPData->GetTraceNormals();
1183 m_fields[0]->GetFwdBwdTracePhys(inarray[0], Fwd, Bwd,
true,
true);
1184 Vmath::Vmul(nTracePts, Fwd, 1, traceNormals[0], 1, unorm, 1);
1187 for (
int f = 1; f <
m_fields[0]->GetCoordim(0); ++f)
1189 m_fields[0]->GetFwdBwdTracePhys(inarray[f], Fwd, Bwd,
true,
true);
1190 Vmath::Vvtvp(nTracePts, Fwd, 1, traceNormals[f], 1, unorm, 1, unorm,
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
This class is the base class for Navier Stokes problems.
void SetBoundaryConditions(NekDouble time)
time dependent boundary conditions updating
MultiRegions::ExpListSharedPtr m_pressure
Pointer to field holding pressure field.
NekDouble m_kinvis
Kinematic viscosity.
bool m_SmoothAdvection
bool to identify if advection term smoothing is requested
virtual void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
ExtrapolateSharedPtr m_extrapolation
Array< OneD, int > m_velocity
int which identifies which components of m_fields contains the velocity (u,v,w);
EquationType m_equationType
equation type;
int m_nConvectiveFields
Number of fields to be convected;.
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)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
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.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
void AccumulateRegion(std::string, int iolevel=0)
Accumulate elapsed time for a region.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
virtual SOLVER_UTILS_EXPORT bool v_PostIntegrate(int step) override
int m_spacedim
Spatial dimension (>= expansion dim).
int m_expdim
Expansion dimension.
LibUtilities::CommSharedPtr m_comm
Communicator.
NekDouble m_timestep
Time step size.
NekDouble m_time
Current time of simulation.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
enum HomogeneousType m_HomogeneousType
bool m_homogen_dealiasing
Flag to determine if dealiasing is used for homogeneous simulations.
SOLVER_UTILS_EXPORT int GetNcoeffs()
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
SOLVER_UTILS_EXPORT int GetTotPoints()
Defines a forcing term to be explicitly applied.
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
virtual SOLVER_UTILS_EXPORT void v_DoInitialise(bool dumpInitialConditions=true) override
Sets up initial conditions.
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s) override
Print a summary of time stepping parameters.
std::vector< int > m_intVariables
NekDouble m_sVVCutoffRatioHomo1D
NekDouble m_greenFlux
Flux of the Stokes function solution.
virtual std::string v_GetExtrapolateStr(void)
virtual ~VelocityCorrectionScheme()
MultiRegions::ExpListSharedPtr m_flowrateBnd
Flowrate reference surface.
Array< OneD, NekDouble > m_svvVarDiffCoeff
Array of coefficient if power kernel is used in SVV.
virtual void v_TransCoeffToPhys(void) override
Virtual function for transformation to physical space.
NekDouble MeasureFlowrate(const Array< OneD, Array< OneD, NekDouble > > &inarray)
Measure the volumetric flow rate through the volumetric flow rate reference surface.
NekDouble m_sVVDiffCoeffHomo1D
Diffusion coefficient of SVV modes in homogeneous 1D Direction.
virtual void v_TransPhysToCoeff(void) override
Virtual function for transformation to coefficient space.
static std::string className
Name of class.
NekDouble m_flowrate
Desired volumetric flowrate.
bool m_IsSVVPowerKernel
Identifier for Power Kernel otherwise DG kernel.
virtual bool v_PostIntegrate(int step) override
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
NekDouble m_sVVCutoffRatio
cutt off ratio from which to start decayhing modes
NekDouble m_sVVDiffCoeff
Diffusion coefficient of SVV modes.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print a summary of time stepping parameters.
void EvaluateAdvection_SetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Array< OneD, Array< OneD, NekDouble > > m_flowrateStokes
Stokes solution used to impose flowrate.
void SolveUnsteadyStokesSystem(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time, const NekDouble a_iixDt)
NekDouble m_alpha
Current flowrate correction.
bool m_useGJPStabilisation
bool to identify if GJP semi-implicit is active.
virtual void v_SolvePressure(const Array< OneD, NekDouble > &Forcing)
VelocityCorrectionScheme(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Constructor.
Array< OneD, Array< OneD, NekDouble > > m_F
void SetUpViscousForcing(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
virtual void v_SolveUnsteadyStokesSystem(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time, const NekDouble a_iixDt)
void SetupFlowrate(NekDouble aii_dt)
Set up the Stokes solution used to impose constant flowrate through a boundary.
void SetUpPressureForcing(const Array< OneD, const Array< OneD, NekDouble > > &fields, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
void SolveViscous(const Array< OneD, const Array< OneD, NekDouble > > &Forcing, const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble aii_Dt)
virtual void v_SetUpPressureForcing(const Array< OneD, const Array< OneD, NekDouble > > &fields, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
static std::string solverTypeLookupId
bool m_useSpecVanVisc
bool to identify if spectral vanishing viscosity is active.
void SetUpExtrapolation(void)
Array< OneD, NekDouble > m_diffCoeff
Diffusion coefficients (will be kinvis for velocities)
int m_flowrateSteps
Interval at which to record flowrate data.
void SVVVarDiffCoeff(const NekDouble velmag, Array< OneD, NekDouble > &diffcoeff, const Array< OneD, Array< OneD, NekDouble > > &vel=NullNekDoubleArrayOfArray)
virtual int v_GetForceDimension() override
virtual void v_SolveViscous(const Array< OneD, const Array< OneD, NekDouble > > &Forcing, const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble aii_Dt)
NekDouble m_flowrateArea
Area of the boundary through which we are measuring the flowrate.
std::ofstream m_flowrateStream
Output stream to record flowrate.
virtual void v_SetUpViscousForcing(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &Forcing, const NekDouble aii_Dt)
virtual void v_EvaluateAdvection_SetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
virtual void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
void AppendSVVFactors(StdRegions::ConstFactorMap &factors, MultiRegions::VarFactorsMap &varFactorsMap)
NekDouble m_flowrateAiidt
Value of aii_dt used to compute Stokes flowrate solution.
void SolvePressure(const Array< OneD, NekDouble > &Forcing)
virtual void v_DoInitialise(bool dumpInitialConditions=true) override
Sets up initial conditions.
int m_planeID
Plane ID for cases with homogeneous expansion.
bool m_useHomo1DSpecVanVisc
bool to identify if spectral vanishing viscosity is active.
bool m_useGJPNormalVel
bool to identify if GJP normal Velocity should be applied in explicit approach
virtual Array< OneD, bool > v_GetSystemSingularChecks() override
int m_flowrateBndID
Boundary ID of the flowrate reference surface.
virtual std::string v_GetSubSteppingExtrapolateStr(const std::string &instr)
void ComputeGJPNormalVelocity(const Array< OneD, const Array< OneD, NekDouble > > &inarray, StdRegions::VarCoeffMap &varcoeffs)
static void Dscal(const int &n, const double &alpha, double *x, const int &incx)
BLAS level 1: x = alpha x.
static void Daxpy(const int &n, const double &alpha, const double *x, const int &incx, const double *y, const int &incy)
BLAS level 1: y = alpha x plus y.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
MultiRegions::Direction const DirCartesianMap[]
static VarFactorsMap NullVarFactorsMap
std::map< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
std::shared_ptr< GJPStabilisation > GJPStabilisationSharedPtr
std::shared_ptr< ContField > ContFieldSharedPtr
std::vector< std::pair< std::string, std::string > > SummaryList
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
@ eFactorSVVDGKerDiffCoeff
@ eFactorSVVPowerKerDiffCoeff
std::map< ConstFactorType, NekDouble > ConstFactorMap
static VarCoeffMap NullVarCoeffMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
StdRegions::ConstFactorMap factors
The above copyright notice and this permission notice shall be included.
@ eVelocityCorrectionScheme
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
ExtrapolateFactory & GetExtrapolateFactory()
static Array< OneD, NekDouble > NullNekDouble1DArray
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
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 Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |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 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 Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.