44#include <boost/algorithm/string.hpp>
49using namespace MultiRegions;
69 m_varCoeffLap(StdRegions::NullVarCoeffMap)
88 ASSERTL0(
false,
"Need to set up pressure field definition");
95 std::string varName =
m_session->GetVariable(n);
96 if (
m_session->DefinesFunction(
"DiffusionCoefficient", varName))
99 m_session->GetFunction(
"DiffusionCoefficient", varName);
114 m_session->MatchSolverInfo(
"GJPStabilisation",
"False",
128 "Can not specify GJPNormalVelocity with"
129 " GJPStabilisation set to SemiImplicit");
159 if (
m_session->DefinesSolverInfo(
"Extrapolation"))
162 m_session->GetSolverInfo(
"Extrapolation"));
234 std::string forces[] = {
"X",
"Y",
"Z"};
241 std::string varName = std::string(
"Force") + forces[i];
242 defined =
m_session->DefinesFunction(
"FlowrateForce", varName);
250 "A 'FlowrateForce' function must defined with components "
251 "[ForceX, ...] to define direction of flowrate forcing");
254 m_session->GetFunction(
"FlowrateForce", varName);
255 flowrateForce[i] = ffunc->Evaluate();
270 flowrateForce[2] = 1.0;
274 for (
size_t i = 0; i < bcs.size(); ++i)
276 if (boost::iequals(bcs[i]->GetUserDefined(),
"Flowrate"))
286 "One boundary region must be marked using the 'Flowrate' "
287 "user-defined type to monitor the volumetric flowrate.");
302 for (
size_t i = 0; i < zIDs.size(); ++i)
311 ASSERTL1(tmpId <= 0,
"Should be either at location 0 or -1 if not "
343 for (
size_t i = 0; i < zIDs.size(); ++i)
366 int nqTot =
m_fields[0]->GetNpoints();
378 m_fields[i]->HomogeneousFwdTrans(nqTot, inTmp[i], inTmp2);
394 for (
size_t n = 0; n < PBndConds.size(); ++n)
396 if (PBndConds[n]->GetBoundaryConditionType() ==
408 m_greenFlux = std::numeric_limits<NekDouble>::max();
420 m_fields[i]->GetBndCondExpansions();
422 for (
int j = 0; j < BndCondExp.size(); ++j)
425 ->GetBndConditions()[j]
429 m_fields[i]->UpdateBndCondExpansion(j)->UpdateCoeffs();
430 SaveDirBCs[std::make_pair(i, j)] =
440 for (
int j = 0; j <
m_fields[i]->GetBndCondExpansions().size(); ++j)
443 ->GetBndConditions()[j]
447 m_fields[i]->UpdateBndCondExpansion(j)->UpdateCoeffs();
448 Vmath::Vcopy(bndcoeffs.size(), SaveDirBCs[std::make_pair(i, j)],
461 std::string filename =
m_session->GetSessionName();
466 <<
"# -------------------------------------------"
550 << std::setw(8) << step
566 AdvectionSystem::v_GenerateSummary(s);
568 "Velocity correction (strong press. form)");
579 dealias += (dealias ==
"" ?
"" :
" + ") + std::string(
"spectral/hp");
592 s,
"Smoothing-SpecHP",
593 "SVV (" + smoothing +
" Exp Kernel(cut-off = " +
603 s,
"Smoothing-SpecHP",
604 "SVV (" + smoothing +
" Power Kernel (Power ratio =" +
613 s,
"Smoothing-SpecHP",
614 "SVV (" + smoothing +
" DG Kernel (diff coeff = " +
624 s,
"Smoothing-Homo1D",
625 "SVV (Homogeneous1D - Exp Kernel(cut-off = " +
634 s,
"GJP Stab. Impl. ",
635 m_session->GetSolverInfo(
"GJPStabilisation"));
638 if (boost::iequals(
m_session->GetSolverInfo(
"GJPStabilisation"),
642 s,
"GJP Normal Velocity",
643 m_session->GetSolverInfo(
"GJPNormalVelocity"));
662 AdvectionSystem::v_DoInitialise(dumpInitialConditions);
673 std::map<std::string, NekDouble> params;
675 params[
"velocity"] = 1.;
682 for (
size_t i = 0; i <
m_fields.size(); ++i)
694 if (
m_fields[0]->GetGJPData() ==
nullptr)
696 std::dynamic_pointer_cast<MultiRegions::ContField>(
m_fields[0])
701 std::dynamic_pointer_cast<MultiRegions::ContField>(
m_fields[i])
702 ->SetGJPData(
m_fields[0]->GetGJPData());
712 size_t nfields =
m_fields.size() - 1;
713 for (
size_t k = 0; k < nfields; ++k)
727 size_t nfields =
m_fields.size() - 1;
728 for (
size_t k = 0; k < nfields; ++k)
741 int vVar =
m_session->GetVariables().size();
743 vChecks[vVar - 1] =
true;
752 return m_session->GetVariables().size() - 1;
780 x->Apply(
m_fields, inarray, outarray, time);
785 std::map<std::string, NekDouble> params;
788 params[
"pressure"] = 1.;
811 size_t physTot =
m_fields[0]->GetTotPoints();
844 m_greenFlux != std::numeric_limits<NekDouble>::max())
854 m_fields[i]->FwdTransLocalElmt(outarray[i],
874 std::map<std::string, NekDouble> params;
875 params[
"Time"] = time;
876 params[
"velocity"] = 1.;
889 size_t physTot =
m_fields[0]->GetTotPoints();
894 for (i = 1; i < nvel; ++i)
912 size_t phystot =
m_fields[0]->GetTotPoints();
988 varCoeffMap, varFactorsMap);
996 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"PowerKernel",
1007 m_session->MatchSolverInfo(
"SpectralVanishingViscositySpectralHP",
1017 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"DGKernel",
1025 m_session->MatchSolverInfo(
"SpectralVanishingViscositySpectralHP",
1040 if (
m_session->DefinesFunction(
"SVVVelocityMagnitude"))
1042 if (
m_comm->GetRank() == 0)
1044 std::cout <<
"Seting up SVV velocity from "
1045 "SVVVelocityMagnitude section in session file"
1049 size_t phystot =
m_fields[0]->GetTotPoints();
1051 std::vector<std::string> vars;
1052 for (
size_t i = 0; i < nvel; ++i)
1059 GetFunction(
"SVVVelocityMagnitude")->Evaluate(vars, SVVVelFields);
1075 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"True",
1079 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
1086 m_session->MatchSolverInfo(
"SpectralVanishingViscositySpectralHP",
1091 "SpectralVanishingViscositySpectralHP",
"ExpKernel",
1098 if (
m_session->DefinesSolverInfo(
"SpectralVanishingViscosityHomo1D"))
1100 m_session->MatchSolverInfo(
"SpectralVanishingViscosityHomo1D",
"True",
1104 m_session->MatchSolverInfo(
"SpectralVanishingViscosityHomo1D",
1120 "Expect to have three velocity fields with homogenous expansion");
1127 size_t num_planes = planes.size();
1130 size_t kmodes =
m_fields[0]->GetHomogeneousBasis()->GetNumModes();
1135 for (
size_t n = 0; n < num_planes; ++n)
1137 if (planes[n] > pstart)
1139 fac = (
NekDouble)((planes[n] - kmodes) *
1140 (planes[n] - kmodes)) /
1142 (planes[n] - pstart)));
1147 for (
size_t i = 0; i <
m_velocity.size(); ++i)
1159 size_t phystot =
m_fields[0]->GetTotPoints();
1160 size_t nel =
m_fields[0]->GetNumElmts();
1172 Vmath::Vmul(phystot, vel[0], 1, vel[0], 1, Velmag, 1);
1173 for (
size_t n = 1; n < nvel; ++n)
1175 Vmath::Vvtvp(phystot, vel[n], 1, vel[n], 1, Velmag, 1, Velmag, 1);
1182 for (
size_t i = 0; i < nel; ++i)
1184 size_t nq =
m_fields[0]->GetExp(i)->GetTotPoints();
1186 diffcoeff[i] =
m_fields[0]->GetExp(i)->Integral(tmp);
1189 diffcoeff[i] = diffcoeff[i] / area;
1198 for (
size_t e = 0; e < nel; e++)
1204 size_t nEdge = exp->GetGeom()->GetNumEdges();
1205 for (
size_t i = 0; i < nEdge; ++i)
1207 h = std::max(h, exp->GetGeom()->GetEdge(i)->GetVertex(0)->dist(
1208 *(exp->GetGeom()->GetEdge(i)->GetVertex(1))));
1214 p = std::max(p, exp->GetBasisNumModes(i) - 1);
1217 diffcoeff[e] *= h / p;
1259 std::dynamic_pointer_cast<MultiRegions::ContField>(
m_fields[0]);
1261 cfield->InitGJPData();
1265 int nTracePts = GJPData->GetNumTracePts();
1269 GJPData->GetTraceNormals();
1271 m_fields[0]->GetFwdBwdTracePhys(inarray[0], Fwd, Bwd,
true,
true);
1272 Vmath::Vmul(nTracePts, Fwd, 1, traceNormals[0], 1, unorm, 1);
1275 for (
int f = 1; f <
m_fields[0]->GetCoordim(0); ++f)
1277 m_fields[0]->GetFwdBwdTracePhys(inarray[f], Fwd, Bwd,
true,
true);
1278 Vmath::Vvtvp(nTracePts, Fwd, 1, traceNormals[f], 1, unorm, 1, unorm,
1287 const std::vector<std::string> &strFrameData,
1289 std::map<std::string, NekDouble> ¶ms)
1291 for (
size_t i = 0; i < strFrameData.size(); ++i)
1293 if (std::fabs(movingFrameData[i]) != 0.0)
1295 params[strFrameData[i]] = movingFrameData[i];
#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
IncBoundaryConditionsSharedPtr m_IncNavierStokesBCs
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);
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.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
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.
std::vector< std::string > m_strFrameData
variable name in m_movingFrameData
SOLVER_UTILS_EXPORT int GetNcoeffs()
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 GetTotPoints()
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
Array< OneD, NekDouble > m_movingFrameData
Moving reference frame status in the body frame X, Y, Z, Theta_x, Theta_y, Theta_z,...
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
Defines a forcing term to be explicitly applied.
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
std::vector< int > m_intVariables
NekDouble m_sVVCutoffRatioHomo1D
NekDouble m_greenFlux
Flux of the Stokes function solution.
virtual std::string v_GetExtrapolateStr(void)
MultiRegions::ExpListSharedPtr m_flowrateBnd
Flowrate reference surface.
Array< OneD, NekDouble > m_svvVarDiffCoeff
Array of coefficient if power kernel is used in SVV.
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.
void v_TransPhysToCoeff(void) override
Virtual function for transformation to coefficient space.
NekDouble m_flowrate
Desired volumetric flowrate.
bool m_IsSVVPowerKernel
Identifier for Power Kernel otherwise DG kernel.
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
static std::string solverTypeLookupId
NekDouble m_sVVDiffCoeff
Diffusion coefficient of SVV modes.
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)
int m_flowrateStepsPrecision
Decimal precision of flow rate (alpha)
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)
void SolveSolid(NekDouble time)
void AddMovingFrameDataToParams(const std::vector< std::string > &strFrameData, const Array< OneD, NekDouble > &movingFrameData, std::map< std::string, NekDouble > ¶ms)
VelocityCorrectionScheme(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Array< OneD, Array< OneD, NekDouble > > m_F
void AppendSVVFactors(StdRegions::ConstFactorMap &factors, StdRegions::VarFactorsMap &varFactorsMap)
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)
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)
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_SolveSolid(NekDouble time)
virtual void v_EvaluateAdvection_SetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
static std::string className
Name of class.
void v_InitObject(bool DeclareField=true) override
Initialisation object for EquationSystem.
NekDouble m_flowrateAiidt
Value of aii_dt used to compute Stokes flowrate solution.
void SolvePressure(const Array< OneD, NekDouble > &Forcing)
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
Array< OneD, bool > v_GetSystemSingularChecks() override
int m_flowrateBndID
Boundary ID of the flowrate reference surface.
void UpdateVelocityBCs(NekDouble time)
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[]
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< StdRegions::ConstFactorType, Array< OneD, NekDouble > > VarFactorsMap
static VarFactorsMap NullVarFactorsMap
std::map< ConstFactorType, NekDouble > ConstFactorMap
static VarCoeffMap NullVarCoeffMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
@ 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.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)