35 #include <boost/core/ignore_unused.hpp>
45 CompressibleFlowSystem::CompressibleFlowSystem(
60 for (
int i = 0; i <
m_fields.size(); i++)
71 "No UPWINDTYPE defined in session.");
95 int nPts =
m_fields[0]->GetTotPoints();
98 int nTracePts =
m_fields[0]->GetTrace()->GetTotPoints();
117 for (
int n = 0; n <
m_fields[0]->GetBndConditions().size(); ++n)
120 m_fields[0]->GetBndConditions()[n]->GetUserDefined();
122 if (
m_fields[0]->GetBndConditions()[n]->GetBoundaryConditionType()
139 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
167 m_session->LoadSolverInfo(
"ShockCaptureType",
171 m_session->MatchSolverInfo(
"ExponentialFiltering",
"True",
181 m_session->MatchSolverInfo(
"LocalTimeStep",
"True",
186 "Local time stepping requires CFL parameter.");
198 "Unsupported projection type.");
200 string advName, riemName;
201 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
218 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Average");
225 riemannSolver->SetParam (
227 riemannSolver->SetAuxVec(
229 riemannSolver->SetVector(
245 int nvariables = inarray.size();
262 for (
int i = 0; i < nvariables; ++i)
266 m_fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
278 for (
int i = 0; i < nvariables; ++i)
292 x->Apply(
m_fields, inarray, outarray, time);
297 int nElements =
m_fields[0]->GetExpSize();
306 for (
int n = 0; n < nElements; ++n)
308 nq =
m_fields[0]->GetExp(n)->GetTotPoints();
309 offset =
m_fields[0]->GetPhys_Offset(n);
311 for (
int i = 0; i < nvariables; ++i)
314 tmp = outarray[i] + offset, 1);
329 int nvariables = inarray.size();
338 for (
int i = 0; i < nvariables; ++i)
343 m_fields[i]->ExponentialFilter(outarray[i],
354 "compressible Navier-Stokes equations");
374 int nvariables = inarray.size();
378 outarray, time, pFwd, pBwd);
404 int nvariables = physarray.size();
407 for (
int i = 0; i < nvariables; ++i)
410 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
418 x->Apply(Fwd, physarray, time);
448 auto nVariables = physfield.size();
449 auto nPts = physfield[0].size();
451 constexpr
unsigned short maxVel = 3;
452 constexpr
unsigned short maxFld = 5;
455 ASSERTL1(nVariables <= maxFld,
"GetFluxVector, hard coded max fields");
457 for (
size_t p = 0;
p < nPts; ++
p)
460 std::array<NekDouble, maxFld> fieldTmp;
461 std::array<NekDouble, maxVel> velocity;
464 for (
size_t f = 0; f < nVariables; ++f)
466 fieldTmp[f] = physfield[f][
p];
475 flux[0][d][
p] = fieldTmp[d+1];
477 velocity[d] = fieldTmp[d+1] * oneOrho;
487 flux[f+1][d][
p] = velocity[d] * fieldTmp[f+1];
512 int nq = physfield[0].size();
517 nq =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
525 for (i = 0; i < nVariables; ++ i)
530 OneDptscale, physfield[i], physfield_interp[i]);
544 m_fields[0]->PhysGalerkinProjection1DScaled(
545 OneDptscale, physfield_interp[i+1], flux[0][i]);
548 m_varConv->GetVelocityVector(physfield_interp, velocity);
556 Vmath::Vmul(nq, velocity[j], 1, physfield_interp[i+1], 1,
557 flux_interp[i+1][j], 1);
562 flux_interp[i+1][i], 1);
570 m_fields[0]->PhysGalerkinProjection1DScaled(
571 OneDptscale, flux_interp[i+1][j], flux[i+1][j]);
585 m_fields[0]->PhysGalerkinProjection1DScaled(
600 boost::ignore_unused(inarray);
602 int nElements =
m_fields[0]->GetExpSize();
615 for (
int n = 0; n < nElements; ++n)
630 int nElements =
m_fields[0]->GetExpSize();
660 bool dumpInitialConditions,
663 boost::ignore_unused(domain);
669 int phystot =
m_fields[0]->GetTotPoints();
672 m_session->LoadParameter(
"Noise", Noise,0.0);
673 int m_nConvectiveFields =
m_fields.size();
677 int seed = -
m_comm->GetRank()*m_nConvectiveFields;
678 for (
int i = 0; i < m_nConvectiveFields; i++)
684 noise, 1,
m_fields[i]->UpdatePhys(), 1);
705 int n_element =
m_fields[0]->GetExpSize();
706 int expdim =
m_fields[0]->GetGraph()->GetMeshDimension();
712 for (
int i = 0; i < nfields; ++i)
714 physfields[i] =
m_fields[i]->GetPhys();
733 m_varConv->GetVelocityVector(physfields, velocity);
734 m_varConv->GetSoundSpeed (physfields, soundspeed);
736 for (
int el = 0; el < n_element; ++el)
738 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
739 offset =
m_fields[0]->GetPhys_Offset(el);
740 int nq =
m_fields[0]->GetExp(el)->GetTotPoints();
743 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
745 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()
746 ->GetDerivFactors(ptsKeys);
754 for (
int i = 0; i < expdim; ++i)
757 velocity[0] + offset, 1,
758 tmp = stdVelocity[i] + offset, 1);
760 soundspeed + offset, 1,
761 tmp = stdSoundSpeed[i] + offset, 1);
762 for (
int j = 1; j < expdim; ++j)
765 velocity[j] + offset, 1,
766 stdVelocity[i] + offset, 1,
767 tmp = stdVelocity[i] + offset, 1);
769 soundspeed + offset, 1,
770 stdSoundSpeed[i] + offset, 1,
771 tmp = stdSoundSpeed[i] + offset, 1);
777 for (
int i = 0; i < expdim; ++i)
780 velocity[0] + offset, 1,
781 tmp = stdVelocity[i] + offset, 1);
783 soundspeed + offset, 1,
784 tmp = stdSoundSpeed[i] + offset, 1);
785 for (
int j = 1; j < expdim; ++j)
788 velocity[j] + offset, 1,
789 stdVelocity[i] + offset, 1,
790 tmp = stdVelocity[i] + offset, 1);
792 soundspeed + offset, 1,
793 stdSoundSpeed[i] + offset, 1,
794 tmp = stdSoundSpeed[i] + offset, 1);
800 for (
int i = 0; i < nq; ++i)
803 for (
int j = 0; j < expdim; ++j)
806 vel =
std::abs(stdVelocity[j][offset + i]) +
808 std::abs(stdSoundSpeed[j][offset + i]);
809 pntVelocity += vel * vel;
811 pntVelocity =
sqrt(pntVelocity);
812 if (pntVelocity > stdV[el])
814 stdV[el] = pntVelocity;
831 ASSERTL0(n <= 20,
"Illegal modes dimension for CFL calculation "
832 "(P has to be less then 20)");
834 NekDouble CFLDG[21] = { 2.0000, 6.0000, 11.8424, 19.1569,
835 27.8419, 37.8247, 49.0518, 61.4815,
836 75.0797, 89.8181, 105.6700, 122.6200,
837 140.6400, 159.7300, 179.8500, 201.0100,
838 223.1800, 246.3600, 270.5300, 295.6900,
849 "coefficients not introduced yet.");
867 for (i =0; i<
m_fields[0]->GetExpSize(); i++)
876 std::vector<std::string> &variables)
879 m_session->MatchSolverInfo(
"OutputExtraFields",
"True",
883 const int nPhys =
m_fields[0]->GetNpoints();
884 const int nCoeffs =
m_fields[0]->GetNcoeffs();
887 for (
int i = 0; i <
m_fields.size(); ++i)
905 m_varConv->GetVelocityVector(tmp, velocity);
907 m_varConv->GetTemperature(tmp, temperature);
909 m_varConv->GetSoundSpeed(tmp, soundspeed);
910 m_varConv->GetMach (tmp, soundspeed, mach);
913 m_session->LoadParameter (
"SensorOffset", sensorOffset, 1);
922 string velNames[3] = {
"u",
"v",
"w"};
925 m_fields[0]->FwdTrans_IterPerExp(velocity[i], velFwd[i]);
926 variables.push_back(velNames[i]);
927 fieldcoeffs.push_back(velFwd[i]);
931 m_fields[0]->FwdTrans_IterPerExp(temperature,TFwd);
932 m_fields[0]->FwdTrans_IterPerExp(entropy, sFwd);
933 m_fields[0]->FwdTrans_IterPerExp(soundspeed, aFwd);
934 m_fields[0]->FwdTrans_IterPerExp(mach, mFwd);
935 m_fields[0]->FwdTrans_IterPerExp(sensor, sensFwd);
937 variables.push_back (
"p");
938 variables.push_back (
"T");
939 variables.push_back (
"s");
940 variables.push_back (
"a");
941 variables.push_back (
"Mach");
942 variables.push_back (
"Sensor");
943 fieldcoeffs.push_back(pFwd);
944 fieldcoeffs.push_back(TFwd);
945 fieldcoeffs.push_back(sFwd);
946 fieldcoeffs.push_back(aFwd);
947 fieldcoeffs.push_back(mFwd);
948 fieldcoeffs.push_back(sensFwd);
959 variables.push_back (
"ArtificialVisc");
960 fieldcoeffs.push_back(sensorFwd);
982 density = physfield[0];
992 m_varConv->GetVelocityVector(physfield, velocity);
999 boost::ignore_unused(step);
1001 const int nFields =
m_fields.size();
1004 for (
int i = 0; i < nFields; ++i)
1007 inarray[i] =
m_fields[i]->UpdatePhys();
1017 for (
int i = 0; i < nFields; ++i)
1028 for (
int i = 0; i < nFields; ++i)
1030 L2[i] =
sqrt(residual[i]*onPoints);
1041 int nElements =
m_fields[0]->GetExpSize();
1046 for (
int e = 0; e < nElements; e++)
1055 for (
int i = 0; i < exp3D->GetNtraces(); ++i)
1057 h = min(h, exp3D->GetGeom3D()->GetEdge(i)->GetVertex(0)->
1058 dist(*(exp3D->GetGeom3D()->GetEdge(i)->GetVertex(1))));
1067 for (
int i = 0; i < exp2D->GetNtraces(); ++i)
1069 h = min(h, exp2D->GetGeom2D()->GetEdge(i)->GetVertex(0)->
1070 dist(*(exp2D->GetGeom2D()->GetEdge(i)->GetVertex(1))));
1079 h = min(h, exp1D->
GetGeom1D()->GetVertex(0)->
1080 dist(*(exp1D->GetGeom1D()->GetVertex(1))));
1091 hOverP[e] = h/max(pOrderElmt[e]-1,1);
#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, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const Array< OneD, const Array< OneD, NekDouble >> &pFwd, const Array< OneD, const Array< OneD, NekDouble >> &pBwd)
Array< OneD, NekDouble > m_muav
virtual void GetVelocity(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, NekDouble >> &velocity)
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
Array< OneD, NekDouble > m_muavTrace
void DoDiffusion(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const Array< OneD, const Array< OneD, NekDouble >> &pFwd, const Array< OneD, const Array< OneD, NekDouble >> &pBwd)
Add the diffusions terms to the right-hand side.
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.
virtual Array< OneD, NekDouble > v_GetMaxStdVelocity(const NekDouble SpeedSoundFactor)
Compute the advection velocity in the standard space for each element of the expansion.
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)
Set up logic for residual calculation.
NekDouble m_filterExponent
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
Array< OneD, NekDouble > GetElmtMinHP(void)
Function to get estimate of min h/p factor per element.
virtual void v_SteadyStateResidual(int step, Array< OneD, NekDouble > &L2)
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.
virtual void v_InitObject()
Initialization object for CompressibleFlowSystem class.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
ArtificialDiffusionSharedPtr m_artificialDiffusion
virtual void GetDensity(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, NekDouble > &density)
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
void InitialiseParameters()
Load CFS parameters from the session file.
void DoAdvection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble >> &pFwd, const Array< OneD, const Array< OneD, NekDouble >> &pBwd)
Compute the advection terms for the right-hand side.
virtual void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs()
virtual NekDouble v_GetTimeStep(const Array< OneD, const Array< OneD, NekDouble > > &inarray)
Calculate the maximum timestep subject to CFL restrictions.
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.
SpatialDomains::Geometry1DSharedPtr GetGeom1D() const
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.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > GetElmtCFLVals(const bool FlagAcousticCFL=true)
int m_spacedim
Spatial dimension (>= expansion dim).
int m_expdim
Expansion dimension.
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
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.
SOLVER_UTILS_EXPORT int GetExpSize()
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.
SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr GetPressure()
Get pressure field if available.
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
std::shared_ptr< Expansion2D > Expansion2DSharedPtr
std::shared_ptr< Expansion1D > Expansion1DSharedPtr
std::shared_ptr< Expansion3D > Expansion3DSharedPtr
@ 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)