45 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();
112 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
122 ASSERTL0(
false,
"Implicit CFS not set up.");
145 m_session->LoadParameter (
"GasConstant", gasConstant, 287.058);
155 m_session->LoadParameter(
"uInf", velInf, 0.1);
162 m_session->LoadParameter(
"vInf", velInf, 0.0);
169 m_session->LoadParameter(
"wInf", velInf, 0.0);
179 if(
m_session->DefinesParameter(
"thermalConductivity"))
182 "Cannot define both Pr and thermalConductivity.");
184 m_session->LoadParameter (
"thermalConductivity",
199 m_session->LoadSolverInfo(
"ShockCaptureType",
210 "Unsupported projection type.");
212 string advName, riemName;
213 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
230 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Average");
237 riemannSolver->SetParam (
239 riemannSolver->SetAuxVec(
241 riemannSolver->SetVector(
258 int nvariables = inarray.num_elements();
273 for(i = 0; i < nvariables; ++i)
277 m_fields[i]->GetFwdBwdTracePhys(inarray[i], Fwd[i], Bwd[i]);
285 for (i = 0; i < nvariables; ++i)
294 std::vector<SolverUtils::ForcingSharedPtr>::const_iterator x;
297 (*x)->Apply(
m_fields, inarray, outarray, time);
311 int nvariables = inarray.num_elements();
320 for(i = 0; i < nvariables; ++i)
330 ASSERTL0(
false,
"No Continuous Galerkin for full compressible "
331 "Navier-Stokes equations");
335 ASSERTL0(
false,
"Unknown projection scheme");
350 int nvariables = inarray.num_elements();
354 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]);
394 (*x)->Apply(Fwd, physarray, time);
410 int nq = physfield[0].num_elements();
411 int nVariables =
m_fields.num_elements();
423 m_varConv->GetVelocityVector(physfield, velocity);
424 m_varConv->GetPressure(physfield, velocity, pressure);
436 Vmath::Vadd(nq, flux[i+1][i], 1, pressure, 1, flux[i+1][i], 1);
440 Vmath::Vadd(nq, physfield[m_spacedim+1], 1, pressure, 1,
446 flux[m_spacedim+1][j], 1);
450 if (nVariables == m_spacedim+3)
472 int nq = physfield[0].num_elements();
473 int nVariables =
m_fields.num_elements();
477 nq =
m_fields[0]->Get1DScaledTotPoints(OneDptscale);
486 for (i = 0; i < nVariables; ++ i)
491 OneDptscale, physfield[i], physfield_interp[i]);
505 m_fields[0]->PhysGalerkinProjection1DScaled(
506 OneDptscale, physfield_interp[i+1], flux[0][i]);
509 m_varConv->GetVelocityVector(physfield_interp, velocity);
510 m_varConv->GetPressure (physfield_interp, velocity, pressure);
517 Vmath::Vmul(nq, velocity[j], 1, physfield_interp[i+1], 1,
518 flux_interp[i+1][j], 1);
522 Vmath::Vadd(nq, flux_interp[i+1][i], 1, pressure,1,
523 flux_interp[i+1][i], 1);
531 m_fields[0]->PhysGalerkinProjection1DScaled(
532 OneDptscale, flux_interp[i+1][j], flux[i+1][j]);
537 Vmath::Vadd(nq, physfield_interp[m_spacedim+1], 1, pressure, 1,
543 flux_interp[m_spacedim+1][j], 1);
546 m_fields[0]->PhysGalerkinProjection1DScaled(
548 flux_interp[m_spacedim+1][j],
549 flux[m_spacedim+1][j]);
564 if (
m_comm->GetRank() == 0)
566 cout <<
"Reached Steady State to tolerance "
582 const int nFields =
m_fields.num_elements();
588 for (
int i = 0; i < nFields; ++i)
600 L2[0] = sqrt(residual[0]) /
m_rhoInf;
602 for (
int i = 1; i < nFields-1; ++i)
608 L2[nFields-1] = sqrt(residual[nFields-1]) / Einf;
610 if (
m_comm->GetRank() == 0 && output)
616 for (
int i = 0; i < nFields; ++i)
618 m_errFile << setprecision(11) << setw(22) << scientific
628 if (
m_session->DefinesCmdLineArgument(
"verbose") &&
629 m_comm->GetRank() == 0 && output)
631 cout <<
"-- Maximum L^2 residual: " << maxL2 << endl;
639 for (
int i = 0; i <
m_fields.num_elements(); ++i)
654 int nElements =
m_fields[0]->GetExpSize();
669 for(n = 0; n < nElements; ++n)
671 int npoints =
m_fields[0]->GetExp(n)->GetTotPoints();
675 minLength = sqrt(Area);
676 if (
m_fields[0]->GetExp(n)->as<LocalRegions::TriExp>())
682 / (stdVelocity[n] * cLambda
683 * (ExpOrder[n] - 1) * (ExpOrder[n] - 1));
697 bool dumpInitialConditions,
704 int phystot =
m_fields[0]->GetTotPoints();
707 m_session->LoadParameter(
"Noise", Noise,0.0);
708 int m_nConvectiveFields =
m_fields.num_elements();
712 int seed = -
m_comm->GetRank()*m_nConvectiveFields;
713 for (
int i = 0; i < m_nConvectiveFields; i++)
719 noise, 1,
m_fields[i]->UpdatePhys(), 1);
727 if (dumpInitialConditions)
736 if (
m_session->DefinesParameter(
"SteadyStateTol"))
738 const int nPoints =
m_fields[0]->GetTotPoints();
742 for (
int i = 0; i <
m_fields.num_elements(); ++i)
748 if (
m_comm->GetRank() == 0)
750 std::string fName =
m_session->GetSessionName() +
754 << setw(15) << left <<
"Time"
755 << setw(22) << left <<
"rho";
757 std::string velFields[3] = {
"u",
"v",
"w"};
759 for (
int i = 0; i <
m_fields.num_elements()-2; ++i)
761 m_errFile << setw(22) <<
"rho"+velFields[i];
764 m_errFile << setw(22) << left <<
"E" << endl;
782 int n_element =
m_fields[0]->GetExpSize();
801 m_varConv->GetVelocityVector(inarray, velocity);
802 m_varConv->GetPressure (inarray, velocity, pressure);
803 m_varConv->GetSoundSpeed (inarray, pressure, soundspeed);
805 for(
int el = 0; el < n_element; ++el)
807 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
811 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
813 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo()
814 ->GetDerivFactors(ptsKeys);
816 int nq =
m_fields[0]->GetExp(el)->GetTotPoints();
828 1, stdVelocity[i], 1, stdVelocity[i], 1);
841 1, stdVelocity[i], 1, stdVelocity[i], 1);
846 for (
int i = 0; i < nq; ++i)
851 pntVelocity += stdVelocity[j][i]*stdVelocity[j][i];
853 pntVelocity = sqrt(pntVelocity) + soundspeed[nBCEdgePts];
854 if (pntVelocity > stdV[el])
856 stdV[el] = pntVelocity;
872 ASSERTL0(n <= 20,
"Illegal modes dimension for CFL calculation "
873 "(P has to be less then 20)");
875 NekDouble CFLDG[21] = { 2.0000, 6.0000, 11.8424, 19.1569,
876 27.8419, 37.8247, 49.0518, 61.4815,
877 75.0797, 89.8181, 105.6700, 122.6200,
878 140.6400, 159.7300, 179.8500, 201.0100,
879 223.1800, 246.3600, 270.5300, 295.6900,
889 ASSERTL0(
false,
"Continuous Galerkin stability coefficients "
890 "not introduced yet.");
908 for (i =0; i<
m_fields[0]->GetExpSize(); i++)
917 std::vector<std::string> &variables)
920 m_session->MatchSolverInfo(
"OutputExtraFields",
"True",
924 const int nPhys =
m_fields[0]->GetNpoints();
925 const int nCoeffs =
m_fields[0]->GetNcoeffs();
928 for (
int i = 0; i <
m_fields.num_elements(); ++i)
937 m_varConv->GetSoundSpeed(tmp, pressure, soundspeed);
938 m_varConv->GetMach (tmp, soundspeed, mach);
944 m_fields[0]->FwdTrans_IterPerExp(pressure, pFwd);
945 m_fields[0]->FwdTrans_IterPerExp(soundspeed, sFwd);
946 m_fields[0]->FwdTrans_IterPerExp(mach, mFwd);
947 m_fields[0]->FwdTrans_IterPerExp(sensor, sensFwd);
949 variables.push_back (
"p");
950 variables.push_back (
"a");
951 variables.push_back (
"Mach");
952 variables.push_back (
"Sensor");
953 fieldcoeffs.push_back(pFwd);
954 fieldcoeffs.push_back(sFwd);
955 fieldcoeffs.push_back(mFwd);
956 fieldcoeffs.push_back(sensFwd);
962 m_fields[0]->FwdTrans_IterPerExp(pressure, pFwd);
964 variables.push_back (
"ArtificialVisc");
965 fieldcoeffs.push_back(pFwd);
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)
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.
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
NekDouble m_time
Current time of simulation.
void GetStdVelocity(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &stdV)
Compute the advection velocity in the standard space for each element of the expansion.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
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)
SOLVER_UTILS_EXPORT const Array< OneD, int > GetNumExpModesPerExp()
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.
std::string m_ViscosityType
bool m_specHP_dealiasing
Flag to determine if dealisising is usde for the Spectral/hp element discretisation.
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtr > Load(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
Array< OneD, Array< OneD, NekDouble > > m_un
SOLVER_UTILS_EXPORT NekDouble MaxTimeStepEstimator()
Get the maximum timestep estimator for cfl control.
boost::shared_ptr< RiemannSolver > RiemannSolverSharedPtr
A shared pointer to an EquationSystem object.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
NekDouble m_steadyStateTol
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...
SOLVER_UTILS_EXPORT int GetTotPoints()
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
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...
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).
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 SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
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).
virtual bool v_PostIntegrate(int step)
Perform post-integration checks, presently just to check steady state behaviour.
bool CalcSteadyState(bool output)
Calculate whether the system has reached a steady state by observing residuals to a user-defined tole...
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.
SolverUtils::AdvectionSharedPtr m_advection
void InitAdvection()
Create advection and diffusion objects for CFS.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
std::string m_shockCaptureType
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
NekDouble m_thermalConductivity
SOLVER_UTILS_EXPORT int GetNpoints()
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
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.
int m_infosteps
Number of time steps between outputting status information.
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.
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
void Zero(int n, T *x, const int incx)
Zero vector.
void InitializeSteadyState()
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::vector< CFSBndCondSharedPtr > m_bndConds
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.