35 #include <boost/core/ignore_unused.hpp>
45 CompressibleFlowSystem::CompressibleFlowSystem(
59 for (
size_t i = 0; i <
m_fields.size(); i++)
70 "No UPWINDTYPE defined in session.");
102 for (
size_t n = 0; n < (size_t)
m_fields[0]->GetBndConditions().size(); ++n)
104 std::string type =
m_fields[0]->GetBndConditions()[n]->GetUserDefined();
106 if (
m_fields[0]->GetBndConditions()[n]->GetBoundaryConditionType() ==
117 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
146 " is not supported by this solver";
165 "Local time stepping requires CFL parameter.");
176 "Unsupported projection type.");
178 string advName, riemName;
179 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
196 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Average");
220 size_t nvariables = inarray.size();
237 for (
size_t i = 0; i < nvariables; ++i)
241 m_fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
253 for (
size_t i = 0; i < nvariables; ++i)
267 x->Apply(
m_fields, inarray, outarray, time);
272 size_t nElements =
m_fields[0]->GetExpSize();
281 for (
size_t n = 0; n < nElements; ++n)
283 nq =
m_fields[0]->GetExp(n)->GetTotPoints();
284 offset =
m_fields[0]->GetPhys_Offset(n);
286 for (
size_t i = 0; i < nvariables; ++i)
289 tmp = outarray[i] + offset, 1);
303 size_t nvariables = inarray.size();
312 for (
size_t i = 0; i < nvariables; ++i)
329 "compressible Navier-Stokes equations");
347 int nvariables = inarray.size();
370 size_t nvariables = physarray.size();
373 for (
size_t i = 0; i < nvariables; ++i)
376 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
384 x->Apply(Fwd, physarray, time);
414 size_t nVariables = physfield.size();
415 size_t nPts = physfield[0].size();
417 constexpr
unsigned short maxVel = 3;
418 constexpr
unsigned short maxFld = 5;
421 ASSERTL1(nVariables <= maxFld,
"GetFluxVector, hard coded max fields");
423 for (
size_t p = 0;
p < nPts; ++
p)
426 std::array<NekDouble, maxFld> fieldTmp;
427 std::array<NekDouble, maxVel> velocity;
430 for (
size_t f = 0; f < nVariables; ++f)
432 fieldTmp[f] = physfield[f][
p];
441 flux[0][d][
p] = fieldTmp[d + 1];
443 velocity[d] = fieldTmp[d + 1] * oneOrho;
453 flux[f + 1][d][
p] = velocity[d] * fieldTmp[f + 1];
477 size_t nq = physfield[0].size();
478 size_t nVariables =
m_fields.size();
482 nq =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
490 for (
size_t i = 0; i < nVariables; ++i)
494 m_fields[0]->PhysInterp1DScaled(OneDptscale, physfield[i],
495 physfield_interp[i]);
509 m_fields[0]->PhysGalerkinProjection1DScaled(
510 OneDptscale, physfield_interp[i + 1], flux[0][i]);
513 m_varConv->GetVelocityVector(physfield_interp, velocity);
521 Vmath::Vmul(nq, velocity[j], 1, physfield_interp[i + 1], 1,
522 flux_interp[i + 1][j], 1);
527 flux_interp[i + 1][i], 1);
535 m_fields[0]->PhysGalerkinProjection1DScaled(
536 OneDptscale, flux_interp[i + 1][j], flux[i + 1][j]);
550 m_fields[0]->PhysGalerkinProjection1DScaled(
564 boost::ignore_unused(inarray);
566 size_t nElements =
m_fields[0]->GetExpSize();
579 for (
size_t n = 0; n < nElements; ++n)
594 int nElements =
m_fields[0]->GetExpSize();
623 bool dumpInitialConditions,
626 boost::ignore_unused(domain);
632 int phystot =
m_fields[0]->GetTotPoints();
635 m_session->LoadParameter(
"Noise", Noise, 0.0);
636 int m_nConvectiveFields =
m_fields.size();
640 int seed = -
m_comm->GetRank() * m_nConvectiveFields;
641 for (
int i = 0; i < m_nConvectiveFields; i++)
661 if (!fs::is_directory(newdir))
663 fs::create_directory(newdir);
665 if (
m_comm->GetTimeComm()->GetRank() == 0)
681 size_t n_element =
m_fields[0]->GetExpSize();
682 size_t expdim =
m_fields[0]->GetGraph()->GetMeshDimension();
688 for (
size_t i = 0; i < nfields; ++i)
690 physfields[i] =
m_fields[i]->GetPhys();
709 m_varConv->GetVelocityVector(physfields, velocity);
710 m_varConv->GetSoundSpeed(physfields, soundspeed);
712 for (
size_t el = 0; el < n_element; ++el)
714 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
715 offset =
m_fields[0]->GetPhys_Offset(el);
716 int nq =
m_fields[0]->GetExp(el)->GetTotPoints();
719 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
725 ->GetDerivFactors(ptsKeys);
733 for (
size_t i = 0; i < expdim; ++i)
735 Vmath::Vmul(nq, gmat[i], 1, velocity[0] + offset, 1,
736 tmp = stdVelocity[i] + offset, 1);
737 Vmath::Vmul(nq, gmat[i], 1, soundspeed + offset, 1,
738 tmp = stdSoundSpeed[i] + offset, 1);
739 for (
size_t j = 1; j < expdim; ++j)
742 velocity[j] + offset, 1,
743 stdVelocity[i] + offset, 1,
744 tmp = stdVelocity[i] + offset, 1);
746 soundspeed + offset, 1,
747 stdSoundSpeed[i] + offset, 1,
748 tmp = stdSoundSpeed[i] + offset, 1);
754 for (
size_t i = 0; i < expdim; ++i)
756 Vmath::Smul(nq, gmat[i][0], velocity[0] + offset, 1,
757 tmp = stdVelocity[i] + offset, 1);
758 Vmath::Smul(nq, gmat[i][0], soundspeed + offset, 1,
759 tmp = stdSoundSpeed[i] + offset, 1);
760 for (
size_t j = 1; j < expdim; ++j)
763 velocity[j] + offset, 1,
764 stdVelocity[i] + offset, 1,
765 tmp = stdVelocity[i] + offset, 1);
767 soundspeed + offset, 1,
768 stdSoundSpeed[i] + offset, 1,
769 tmp = stdSoundSpeed[i] + offset, 1);
775 for (
size_t i = 0; i < nq; ++i)
778 for (
size_t j = 0; j < expdim; ++j)
781 vel =
std::abs(stdVelocity[j][offset + i]) +
782 SpeedSoundFactor *
std::abs(stdSoundSpeed[j][offset + i]);
783 pntVelocity += vel * vel;
785 pntVelocity =
sqrt(pntVelocity);
786 if (pntVelocity > stdV[el])
788 stdV[el] = pntVelocity;
805 ASSERTL0(n <= 20,
"Illegal modes dimension for CFL calculation "
806 "(P has to be less then 20)");
808 NekDouble CFLDG[21] = {2.0000, 6.0000, 11.8424, 19.1569, 27.8419,
809 37.8247, 49.0518, 61.4815, 75.0797, 89.8181,
810 105.6700, 122.6200, 140.6400, 159.7300, 179.8500,
811 201.0100, 223.1800, 246.3600, 270.5300, 295.6900,
822 "coefficients not introduced yet.");
840 for (i = 0; i <
m_fields[0]->GetExpSize(); i++)
849 std::vector<std::string> &variables)
852 m_session->MatchSolverInfo(
"OutputExtraFields",
"True", extraFields,
true);
855 const int nPhys =
m_fields[0]->GetNpoints();
856 const int nCoeffs =
m_fields[0]->GetNcoeffs();
859 for (
int i = 0; i <
m_fields.size(); ++i)
877 m_varConv->GetVelocityVector(tmp, velocity);
879 m_varConv->GetTemperature(tmp, temperature);
881 m_varConv->GetSoundSpeed(tmp, soundspeed);
882 m_varConv->GetMach(tmp, soundspeed, mach);
885 m_session->LoadParameter(
"SensorOffset", sensorOffset, 1);
894 string velNames[3] = {
"u",
"v",
"w"};
897 m_fields[0]->FwdTransLocalElmt(velocity[i], velFwd[i]);
898 variables.push_back(velNames[i]);
899 fieldcoeffs.push_back(velFwd[i]);
903 m_fields[0]->FwdTransLocalElmt(temperature, TFwd);
904 m_fields[0]->FwdTransLocalElmt(entropy, sFwd);
905 m_fields[0]->FwdTransLocalElmt(soundspeed, aFwd);
906 m_fields[0]->FwdTransLocalElmt(mach, mFwd);
907 m_fields[0]->FwdTransLocalElmt(sensor, sensFwd);
909 variables.push_back(
"p");
910 variables.push_back(
"T");
911 variables.push_back(
"s");
912 variables.push_back(
"a");
913 variables.push_back(
"Mach");
914 variables.push_back(
"Sensor");
915 fieldcoeffs.push_back(pFwd);
916 fieldcoeffs.push_back(TFwd);
917 fieldcoeffs.push_back(sFwd);
918 fieldcoeffs.push_back(aFwd);
919 fieldcoeffs.push_back(mFwd);
920 fieldcoeffs.push_back(sensFwd);
929 variables.push_back(
"ArtificialVisc");
930 fieldcoeffs.push_back(sensorFwd);
952 density = physfield[0];
962 m_varConv->GetVelocityVector(physfield, velocity);
968 boost::ignore_unused(step);
970 const size_t nFields =
m_fields.size();
973 for (
size_t i = 0; i < nFields; ++i)
976 inarray[i] =
m_fields[i]->UpdatePhys();
986 for (
size_t i = 0; i < nFields; ++i)
997 for (
size_t i = 0; i < nFields; ++i)
999 L2[i] =
sqrt(residual[i] * onPoints);
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
virtual void v_DoDiffusion(const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const Array< OneD, Array< OneD, NekDouble >> &pFwd, const Array< OneD, Array< OneD, NekDouble >> &pBwd)=0
virtual MultiRegions::ExpListSharedPtr v_GetPressure() override
virtual NekDouble v_GetTimeStep(const Array< OneD, const Array< OneD, NekDouble >> &inarray) override
Calculate the maximum timestep subject to CFL restrictions.
void DoAdvection(const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time, const Array< OneD, Array< OneD, NekDouble >> &pFwd, const Array< OneD, Array< OneD, NekDouble >> &pBwd)
Compute the advection terms for the right-hand side.
virtual void v_GetVelocity(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, NekDouble >> &velocity) override
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the right-hand side.
NekDouble m_bndEvaluateTime
virtual void v_GetDensity(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &density) override
void DoDiffusion(const Array< OneD, Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const Array< OneD, Array< OneD, NekDouble >> &pFwd, const Array< OneD, Array< OneD, NekDouble >> &pBwd)
Add the diffusions terms to the right-hand side.
virtual bool v_SupportsShockCaptType(const std::string type) const =0
std::string m_shockCaptureType
void GetFluxVector(const Array< OneD, const Array< OneD, NekDouble >> &physfield, TensorOfArray3D< NekDouble > &flux)
Return the flux vector for the compressible Euler equations.
Array< OneD, NekDouble > GetStabilityLimitVector(const Array< OneD, int > &ExpOrder)
Function to calculate the stability limit for DG/CG (a vector of them).
void InitAdvection()
Create advection and diffusion objects for CFS.
virtual ~CompressibleFlowSystem()
Destructor for CompressibleFlowSystem class.
void GetFluxVectorDeAlias(const Array< OneD, const Array< OneD, NekDouble >> &physfield, TensorOfArray3D< NekDouble > &flux)
Return the flux vector for the compressible Euler equations by using the de-aliasing technique.
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble >> &physarray, NekDouble time)
virtual void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0) override
Set up logic for residual calculation.
NekDouble m_filterExponent
virtual void v_InitObject(bool DeclareFields=true) override
Initialization object for CompressibleFlowSystem class.
NekDouble GetStabilityLimit(int n)
Function to calculate the stability limit for DG/CG.
std::vector< CFSBndCondSharedPtr > m_bndConds
void GetElmtTimeStep(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, NekDouble > &tstep)
Calculate the maximum timestep on each element subject to CFL restrictions.
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the projection and call the method for imposing the boundary conditions in case of discontinu...
VariableConverterSharedPtr m_varConv
void SetBoundaryConditionsBwdWeight()
Set up a weight on physical boundaries for boundary condition applications.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
ArtificialDiffusionSharedPtr m_artificialDiffusion
virtual Array< OneD, NekDouble > v_GetMaxStdVelocity(const NekDouble SpeedSoundFactor) override
Compute the advection velocity in the standard space for each element of the expansion.
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
void InitialiseParameters()
Load CFS parameters from the session file.
virtual void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble >> &fieldcoeffs, std::vector< std::string > &variables) override
virtual void v_SteadyStateResidual(int step, Array< OneD, NekDouble > &L2) override
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs()
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
void DefineOdeRhs(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.
A base class for PDEs which include an advection component.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > GetElmtCFLVals(const bool FlagAcousticCFL=true)
virtual SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
int m_spacedim
Spatial dimension (>= expansion dim).
SOLVER_UTILS_EXPORT bool ParallelInTime()
Check if solver use Parallel-in-Time.
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
LibUtilities::CommSharedPtr m_comm
Communicator.
NekDouble m_timestep
Time step size.
NekDouble m_time
Current time of simulation.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
bool m_useInitialCondition
Flag to determine if IC are used.
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
SOLVER_UTILS_EXPORT int GetExpSize()
std::string m_sessionName
Name of the session.
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
enum HomogeneousType m_HomogeneousType
SOLVER_UTILS_EXPORT int GetNpoints()
int m_nchk
Number of checkpoints written so far.
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
int m_checksteps
Number of steps between checkpoints.
SOLVER_UTILS_EXPORT int GetTotPoints()
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.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator()
Get the maximum timestep estimator for cfl control.
NekDouble m_cflNonAcoustic
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< PointsKey > PointsKeyVector
@ eMixed_CG_Discontinuous
std::shared_ptr< RiemannSolver > RiemannSolverSharedPtr
A shared pointer to an EquationSystem object.
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
RiemannSolverFactory & GetRiemannSolverFactory()
std::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
The above copyright notice and this permission notice shall be included.
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
ArtificialDiffusionFactory & GetArtificialDiffusionFactory()
Declaration of the artificial diffusion factory singleton.
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.
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
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
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
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 FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > abs(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)