35 #include <boost/core/ignore_unused.hpp> 43 CompressibleFlowSystem::CompressibleFlowSystem(
62 "No UPWINDTYPE defined in session.");
72 m_vecLocs[0][i] = 1 + i;
97 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
100 m_fields[0]->GetBndConditions()[n]->GetUserDefined();
102 if (
m_fields[0]->GetBndConditions()[n]->GetBoundaryConditionType()
119 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
129 ASSERTL0(
false,
"Implicit CFS not set up.");
150 m_session->LoadSolverInfo(
"ShockCaptureType",
154 m_session->MatchSolverInfo(
"ExponentialFiltering",
"True",
164 m_session->MatchSolverInfo(
"LocalTimeStep",
"True",
169 "Local time stepping requires CFL parameter.");
180 "Unsupported projection type.");
182 string advName, riemName;
183 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
200 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Average");
207 riemannSolver->SetParam (
209 riemannSolver->SetAuxVec(
211 riemannSolver->SetVector(
228 int nvariables = inarray.num_elements();
243 for(i = 0; i < nvariables; ++i)
247 m_fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
255 for (i = 0; i < nvariables; ++i)
266 x->Apply(
m_fields, inarray, outarray, time);
271 int nElements =
m_fields[0]->GetExpSize();
280 for(
int n = 0; n < nElements; ++n)
282 nq =
m_fields[0]->GetExp(n)->GetTotPoints();
283 offset =
m_fields[0]->GetPhys_Offset(n);
285 for(i = 0; i < nvariables; ++i)
288 tmp = outarray[i] + offset, 1);
304 int nvariables = inarray.num_elements();
313 for(i = 0; i < nvariables; ++i)
318 m_fields[i]->ExponentialFilter(outarray[i],
328 ASSERTL0(
false,
"No Continuous Galerkin for full compressible " 329 "Navier-Stokes equations");
333 ASSERTL0(
false,
"Unknown projection scheme");
348 int nvariables = inarray.num_elements();
352 outarray, time, pFwd, pBwd);
379 int nvariables = physarray.num_elements();
382 for (
int i = 0; i < nvariables; ++i)
385 m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
393 x->Apply(Fwd, physarray, time);
409 int nq = physfield[0].num_elements();
410 int nVariables =
m_fields.num_elements();
422 m_varConv->GetVelocityVector(physfield, velocity);
423 m_varConv->GetPressure(physfield, pressure);
435 Vmath::Vadd(nq, flux[i+1][i], 1, pressure, 1, flux[i+1][i], 1);
439 Vmath::Vadd(nq, physfield[m_spacedim+1], 1, pressure, 1,
445 flux[m_spacedim+1][j], 1);
449 if (nVariables == m_spacedim+3)
471 int nq = physfield[0].num_elements();
472 int nVariables =
m_fields.num_elements();
476 nq =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
485 for (i = 0; i < nVariables; ++ i)
490 OneDptscale, physfield[i], physfield_interp[i]);
504 m_fields[0]->PhysGalerkinProjection1DScaled(
505 OneDptscale, physfield_interp[i+1], flux[0][i]);
508 m_varConv->GetVelocityVector(physfield_interp, velocity);
509 m_varConv->GetPressure (physfield_interp, pressure);
516 Vmath::Vmul(nq, velocity[j], 1, physfield_interp[i+1], 1,
517 flux_interp[i+1][j], 1);
521 Vmath::Vadd(nq, flux_interp[i+1][i], 1, pressure,1,
522 flux_interp[i+1][i], 1);
530 m_fields[0]->PhysGalerkinProjection1DScaled(
531 OneDptscale, flux_interp[i+1][j], flux[i+1][j]);
536 Vmath::Vadd(nq, physfield_interp[m_spacedim+1], 1, pressure, 1,
542 flux_interp[m_spacedim+1][j], 1);
545 m_fields[0]->PhysGalerkinProjection1DScaled(
547 flux_interp[m_spacedim+1][j],
548 flux[m_spacedim+1][j]);
560 boost::ignore_unused(inarray);
563 int nElements =
m_fields[0]->GetExpSize();
576 for(n = 0; n < nElements; ++n)
591 int nElements =
m_fields[0]->GetExpSize();
607 bool dumpInitialConditions,
610 boost::ignore_unused(domain);
616 int phystot =
m_fields[0]->GetTotPoints();
619 m_session->LoadParameter(
"Noise", Noise,0.0);
620 int m_nConvectiveFields =
m_fields.num_elements();
624 int seed = -
m_comm->GetRank()*m_nConvectiveFields;
625 for (
int i = 0; i < m_nConvectiveFields; i++)
631 noise, 1,
m_fields[i]->UpdatePhys(), 1);
651 int n_element =
m_fields[0]->GetExpSize();
652 int expdim =
m_fields[0]->GetGraph()->GetMeshDimension();
653 int nfields =
m_fields.num_elements();
658 for (
int i = 0; i < nfields; ++i)
660 physfields[i] =
m_fields[i]->GetPhys();
679 m_varConv->GetVelocityVector(physfields, velocity);
680 m_varConv->GetSoundSpeed (physfields, soundspeed);
682 for(
int el = 0; el < n_element; ++el)
684 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
685 offset =
m_fields[0]->GetPhys_Offset(el);
686 int nq =
m_fields[0]->GetExp(el)->GetTotPoints();
689 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
691 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()
692 ->GetDerivFactors(ptsKeys);
700 for (
int i = 0; i < expdim; ++i)
703 velocity[0] + offset, 1,
704 tmp = stdVelocity[i] + offset, 1);
706 soundspeed + offset, 1,
707 tmp = stdSoundSpeed[i] + offset, 1);
708 for (
int j = 1; j < expdim; ++j)
711 velocity[j] + offset, 1,
712 stdVelocity[i] + offset, 1,
713 tmp = stdVelocity[i] + offset, 1);
715 soundspeed + offset, 1,
716 stdSoundSpeed[i] + offset, 1,
717 tmp = stdSoundSpeed[i] + offset, 1);
723 for (
int i = 0; i < expdim; ++i)
726 velocity[0] + offset, 1,
727 tmp = stdVelocity[i] + offset, 1);
729 soundspeed + offset, 1,
730 tmp = stdSoundSpeed[i] + offset, 1);
731 for (
int j = 1; j < expdim; ++j)
734 velocity[j] + offset, 1,
735 stdVelocity[i] + offset, 1,
736 tmp = stdVelocity[i] + offset, 1);
738 soundspeed + offset, 1,
739 stdSoundSpeed[i] + offset, 1,
740 tmp = stdSoundSpeed[i] + offset, 1);
746 for (
int i = 0; i < nq; ++i)
749 for (
int j = 0; j < expdim; ++j)
752 vel = std::abs(stdVelocity[j][offset + i]) +
753 std::abs(stdSoundSpeed[j][offset + i]);
754 pntVelocity += vel * vel;
756 pntVelocity = sqrt(pntVelocity);
757 if (pntVelocity > stdV[el])
759 stdV[el] = pntVelocity;
776 ASSERTL0(n <= 20,
"Illegal modes dimension for CFL calculation " 777 "(P has to be less then 20)");
779 NekDouble CFLDG[21] = { 2.0000, 6.0000, 11.8424, 19.1569,
780 27.8419, 37.8247, 49.0518, 61.4815,
781 75.0797, 89.8181, 105.6700, 122.6200,
782 140.6400, 159.7300, 179.8500, 201.0100,
783 223.1800, 246.3600, 270.5300, 295.6900,
793 ASSERTL0(
false,
"Continuous Galerkin stability coefficients " 794 "not introduced yet.");
812 for (i =0; i<
m_fields[0]->GetExpSize(); i++)
821 std::vector<std::string> &variables)
824 m_session->MatchSolverInfo(
"OutputExtraFields",
"True",
828 const int nPhys =
m_fields[0]->GetNpoints();
829 const int nCoeffs =
m_fields[0]->GetNcoeffs();
832 for (
int i = 0; i <
m_fields.num_elements(); ++i)
850 m_varConv->GetVelocityVector(tmp, velocity);
852 m_varConv->GetTemperature(tmp, temperature);
854 m_varConv->GetSoundSpeed(tmp, soundspeed);
855 m_varConv->GetMach (tmp, soundspeed, mach);
858 m_session->LoadParameter (
"SensorOffset", sensorOffset, 1);
867 string velNames[3] = {
"u",
"v",
"w"};
870 m_fields[0]->FwdTrans_IterPerExp(velocity[i], velFwd[i]);
871 variables.push_back(velNames[i]);
872 fieldcoeffs.push_back(velFwd[i]);
876 m_fields[0]->FwdTrans_IterPerExp(temperature,TFwd);
877 m_fields[0]->FwdTrans_IterPerExp(entropy, sFwd);
878 m_fields[0]->FwdTrans_IterPerExp(soundspeed, aFwd);
879 m_fields[0]->FwdTrans_IterPerExp(mach, mFwd);
880 m_fields[0]->FwdTrans_IterPerExp(sensor, sensFwd);
882 variables.push_back (
"p");
883 variables.push_back (
"T");
884 variables.push_back (
"s");
885 variables.push_back (
"a");
886 variables.push_back (
"Mach");
887 variables.push_back (
"Sensor");
888 fieldcoeffs.push_back(pFwd);
889 fieldcoeffs.push_back(TFwd);
890 fieldcoeffs.push_back(sFwd);
891 fieldcoeffs.push_back(aFwd);
892 fieldcoeffs.push_back(mFwd);
893 fieldcoeffs.push_back(sensFwd);
904 variables.push_back (
"ArtificialVisc");
905 fieldcoeffs.push_back(sensorFwd);
917 m_varConv->GetPressure(physfield, pressure);
927 density = physfield[0];
937 m_varConv->GetVelocityVector(physfield, velocity);
946 int nElements =
m_fields[0]->GetExpSize();
951 for (
int e = 0; e < nElements; e++)
960 for(
int i = 0; i < exp3D->GetNedges(); ++i)
962 h = min(h, exp3D->GetGeom3D()->GetEdge(i)->GetVertex(0)->
963 dist(*(exp3D->GetGeom3D()->GetEdge(i)->GetVertex(1))));
972 for(
int i = 0; i < exp2D->GetNedges(); ++i)
974 h = min(h, exp2D->GetGeom2D()->GetEdge(i)->GetVertex(0)->
975 dist(*(exp2D->GetGeom2D()->GetEdge(i)->GetVertex(1))));
984 h = min(h, exp1D->
GetGeom1D()->GetVertex(0)->
985 dist(*(exp1D->GetGeom1D()->GetVertex(1))));
991 ASSERTL0(
false,
"Dimension out of bound.")
996 hOverP[e] = h/max(pOrderElmt[e]-1,1);
SOLVER_UTILS_EXPORT Array< OneD, NekDouble > GetElmtCFLVals(void)
void DoDiffusion(const Array< OneD, const 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.
#define ASSERTL0(condition, msg)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
virtual void v_InitObject()
Initialization object for CompressibleFlowSystem class.
std::vector< PointsKey > PointsKeyVector
virtual ~CompressibleFlowSystem()
Destructor for CompressibleFlowSystem class.
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
std::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
NekDouble m_timestep
Time step size.
VariableConverterSharedPtr m_varConv
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
virtual void v_DoDiffusion(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const Array< OneD, Array< OneD, NekDouble > > &pFwd, const Array< OneD, Array< OneD, NekDouble > > &pBwd)
int m_expdim
Expansion dimension.
NekDouble GetStabilityLimit(int n)
Function to calculate the stability limit for DG/CG.
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
virtual void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
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 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
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator()
Get the maximum timestep estimator for cfl control.
int m_nchk
Number of checkpoints written so far.
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.
int m_checksteps
Number of steps between checkpoints.
virtual NekDouble v_GetTimeStep(const Array< OneD, const Array< OneD, NekDouble > > &inarray)
Calculate the maximum timestep subject to CFL restrictions.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the right-hand side.
LibUtilities::CommSharedPtr m_comm
Communicator.
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...
virtual void GetDensity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &density)
Extract array with density from physfield.
SOLVER_UTILS_EXPORT int GetTotPoints()
virtual void GetVelocity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity)
Extract array with velocity from physfield.
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
std::shared_ptr< RiemannSolver > RiemannSolverSharedPtr
A shared pointer to an EquationSystem object.
std::shared_ptr< Expansion3D > Expansion3DSharedPtr
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs()
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void GetFluxVectorDeAlias(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &flux)
Return the flux vector for the compressible Euler equations by using the de-aliasing technique...
virtual Array< OneD, NekDouble > v_GetMaxStdVelocity()
Compute the advection velocity in the standard space for each element of the expansion.
SpatialDomains::Geometry1DSharedPtr GetGeom1D() const
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.
RiemannSolverFactory & GetRiemannSolverFactory()
Array< OneD, NekDouble > GetStabilityLimitVector(const Array< OneD, int > &ExpOrder)
Function to calculate the stability limit for DG/CG (a vector of them).
int m_spacedim
Spatial dimension (>= expansion dim).
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble > > &physarray, NekDouble time)
void InitialiseParameters()
Load CFS parameters from the session file.
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
ArtificialDiffusionFactory & GetArtificialDiffusionFactory()
Declaration of the artificial diffusion factory singleton.
void Neg(int n, T *x, const int incx)
Negate x = -x.
virtual SOLVER_UTILS_EXPORT void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
virtual void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Set up logic for residual calculation.
NekDouble m_cflSafetyFactor
CFL safety factor (comprise between 0 to 1).
void DoAdvection(const Array< OneD, const 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.
void InitAdvection()
Create advection and diffusion objects for CFS.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
std::string m_shockCaptureType
NekDouble m_filterExponent
SOLVER_UTILS_EXPORT int GetNpoints()
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
std::shared_ptr< Expansion2D > Expansion2DSharedPtr
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
ArtificialDiffusionSharedPtr m_artificialDiffusion
void FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
SOLVER_UTILS_EXPORT MultiRegions::ExpListSharedPtr GetPressure()
Get pressure field if available.
Array< OneD, NekDouble > GetElmtMinHP(void)
Function to get estimate of min h/p factor per element.
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
void GetFluxVector(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &flux)
Return the flux vector for the compressible Euler equations.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
void Zero(int n, T *x, const int incx)
Zero vector.
A base class for PDEs which include an advection component.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Geometry is curved or has non-constant factors.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
std::shared_ptr< Expansion1D > Expansion1DSharedPtr
std::vector< CFSBndCondSharedPtr > m_bndConds
std::shared_ptr< SessionReader > SessionReaderSharedPtr
enum HomogeneousType m_HomogeneousType
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 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.