35 #include <boost/core/ignore_unused.hpp>
43 CompressibleFlowSystem::CompressibleFlowSystem(
62 "No UPWINDTYPE defined in session.");
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);
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);
516 Vmath::Vmul(nq, velocity[j], 1, physfield_interp[i+1], 1,
517 flux_interp[i+1][j], 1);
522 flux_interp[i+1][i], 1);
530 m_fields[0]->PhysGalerkinProjection1DScaled(
531 OneDptscale, flux_interp[i+1][j], flux[i+1][j]);
545 m_fields[0]->PhysGalerkinProjection1DScaled(
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);
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);
#define ASSERTL0(condition, msg)
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.
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble > > &physarray, NekDouble time)
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...
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.
std::string m_shockCaptureType
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, 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 void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Set up logic for residual calculation.
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.
NekDouble m_filterExponent
NekDouble GetStabilityLimit(int n)
Function to calculate the stability limit for DG/CG.
virtual void GetDensity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, NekDouble > &density)
Extract array with density from physfield.
std::vector< CFSBndCondSharedPtr > m_bndConds
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)
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.
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
Array< OneD, NekDouble > GetElmtMinHP(void)
Function to get estimate of min h/p factor per element.
VariableConverterSharedPtr m_varConv
virtual void v_InitObject()
Initialization object for CompressibleFlowSystem class.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
ArtificialDiffusionSharedPtr m_artificialDiffusion
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
void InitialiseParameters()
Load CFS parameters from the session file.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the right-hand side.
virtual Array< OneD, NekDouble > v_GetMaxStdVelocity()
Compute the advection velocity in the standard space for each element of the expansion.
virtual void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
virtual void GetVelocity(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity)
Extract array with velocity from physfield.
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)
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(void)
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.
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).
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator()
Get the maximum timestep estimator for cfl control.
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
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
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*y.
void Zero(int n, T *x, const int incx)
Zero vector.
void FillWhiteNoise(int n, const T eps, T *x, const int incx, int outseed)
Fills a vector with white noise.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)