37#include <boost/core/ignore_unused.hpp>
44using namespace LibUtilities;
70 m_session->MatchSolverInfo(
"Extrapolation",
"SubStepping",
75 std::vector<std::string> vel;
83 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"True",
87 m_session->MatchSolverInfo(
"GJPStabilisation",
"False",
113 std::string riemName;
114 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
119 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Upwind");
131 std::string diffName;
132 m_session->LoadSolverInfo(
"DiffusionType", diffName,
"LDG");
141 "SubSteppingScheme is not set up for DG projection");
150 m_session->LoadSolverInfo(
"AdvectionType", advName,
157 if (advName.compare(
"WeakDG") == 0)
159 std::string riemName;
160 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Upwind");
173 ASSERTL0(
false,
"Explicit Galerkin diffusion not set up.");
180 ASSERTL0(
false,
"Unsupported projection type.");
197 "Projection must be set to Mixed_CG_Discontinuous for "
233 for (i = 0; i < velfield.size(); ++i)
235 m_fields[0]->ExtractTracePhys(velfield[i], tmp);
257 int nVariables = inarray.size();
267 for (
int i = 0; i < nVariables; ++i)
275 for (
int i = 0; i < nVariables; ++i)
282 for (
int i = 0; i < nVariables; ++i)
284 Vmath::Vadd(nSolutionPts, &outarrayDiff[i][0], 1, &outarray[i][0],
285 1, &outarray[i][0], 1);
293 x->Apply(
m_fields, inarray, outarray, time);
310 int nvariables = inarray.size();
317 if (inarray != outarray)
321 for (i = 0; i < nvariables; ++i)
333 for (i = 0; i < nvariables; ++i)
335 m_fields[i]->FwdTrans(inarray[i], coeffs);
336 m_fields[i]->BwdTrans(coeffs, outarray[i]);
342 ASSERTL0(
false,
"Unknown projection scheme");
360 int nvariables = inarray.size();
383 for (
int n = 0; n < nvariables; ++n)
392 for (
int i = 0; i < nvariables; ++i)
402 for (
int i = 0; i < nvariables; ++i)
422 "Dimension of flux array and velocity array do not match");
424 const int nq =
m_fields[0]->GetNpoints();
426 for (
int i = 0; i < flux.size(); ++i)
428 for (
int j = 0; j < flux[0].size(); ++j)
449 boost::ignore_unused(inarray);
451 unsigned int nDim = qfield.size();
452 unsigned int nConvectiveFields = qfield[0].size();
453 unsigned int nPts = qfield[0][0].size();
454 for (
unsigned int j = 0; j < nDim; ++j)
456 for (
unsigned int i = 0; i < nConvectiveFields; ++i)
470 s,
"GJP Stab. Impl. ",
471 m_session->GetSolverInfo(
"GJPStabilisation"));
501 static int ncalls = 1;
518 std::cout <<
"Sub-integrating using " << nsubsteps
525 for (
int m = 0; m < nint; ++m)
528 fields = solutionVector[m];
536 for (n = 0; n < nsubsteps; ++n)
551 int n_element =
m_fields[0]->GetExpSize();
563 for (
int el = 0; el < n_element; ++el)
567 (ExpOrder[el] - 1) * (ExpOrder[el] - 1));
581 unsigned int order = IntegrationScheme->GetOrder();
585 if ((IntegrationScheme->GetName() ==
"Euler" &&
586 IntegrationScheme->GetVariant() ==
"Backward") ||
587 (IntegrationScheme->GetName() ==
"BDFImplicit" &&
588 (order == 1 || order == 2)))
593 "RungeKutta",
"SSP", order, std::vector<NekDouble>());
598 "Integration method not suitable: "
599 "Options include BackwardEuler or BDFImplicitOrder1");
602 m_intSteps = IntegrationScheme->GetNumIntegrationPhases();
619 int nVariables = inarray.size();
622 int ncoeffs =
m_fields[0]->GetNcoeffs();
627 for (i = 1; i < nVariables; ++i)
629 WeakAdv[i] = WeakAdv[i - 1] + ncoeffs;
638 for (i = 0; i < nVariables; ++i)
640 m_fields[i]->IProductWRTBase(outarray[i], WeakAdv[i]);
648 for (i = 0; i < nVariables; ++i)
654 m_fields[i]->MultiplyByElmtInvMass(WeakAdv[i], WeakAdv[i]);
657 m_fields[i]->BwdTrans(WeakAdv[i], outarray[i]);
668 boost::ignore_unused(time);
670 ASSERTL1(inarray.size() == outarray.size(),
671 "Inarray and outarray of different sizes ");
673 for (
int i = 0; i < inarray.size(); ++i)
675 Vmath::Vcopy(inarray[i].size(), inarray[i], 1, outarray[i], 1);
684 ASSERTL1(physfield.size() == Outarray.size(),
685 "Physfield and outarray are of different dimensions");
690 int nTracePts =
m_fields[0]->GetTrace()->GetNpoints();
704 for (i = 0; i < physfield.size(); ++i)
708 m_fields[i]->GetFwdBwdTracePhys(physfield[i], Fwd, Bwd);
711 m_fields[0]->GetTrace()->Upwind(Vn, Fwd, Bwd, numflux);
714 Vmath::Vsub(nTracePts, numflux, 1, Fwd, 1, Fwd, 1);
715 Vmath::Vsub(nTracePts, numflux, 1, Bwd, 1, Bwd, 1);
722 m_fields[0]->AddFwdBwdTraceIntegral(Fwd, Bwd, Outarray[i]);
730 int n_points_0 =
m_fields[0]->GetExp(0)->GetTotPoints();
731 int n_element =
m_fields[0]->GetExpSize();
732 int nvel = inarray.size();
735 ASSERTL0(nvel >= 2,
"Method not implemented for 1D");
744 for (
int i = 0; i < nvel; ++i)
752 for (
int el = 0; el < n_element; ++el)
754 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
755 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
758 if (n_points != n_points_0)
760 for (
int j = 0; j < nvel; ++j)
764 n_points_0 = n_points;
771 ->GetDerivFactors(ptsKeys);
779 for (
int i = 0; i < n_points; i++)
781 stdVelocity[0][i] = gmat[0][i] * inarray[0][i + cnt] +
782 gmat[2][i] * inarray[1][i + cnt];
784 stdVelocity[1][i] = gmat[1][i] * inarray[0][i + cnt] +
785 gmat[3][i] * inarray[1][i + cnt];
790 for (
int i = 0; i < n_points; i++)
792 stdVelocity[0][i] = gmat[0][0] * inarray[0][i + cnt] +
793 gmat[2][0] * inarray[1][i + cnt];
795 stdVelocity[1][i] = gmat[1][0] * inarray[0][i + cnt] +
796 gmat[3][0] * inarray[1][i + cnt];
802 for (
int i = 0; i < n_points; i++)
804 pntVelocity = stdVelocity[0][i] * stdVelocity[0][i] +
805 stdVelocity[1][i] * stdVelocity[1][i];
807 if (pntVelocity > maxV[el])
809 maxV[el] = pntVelocity;
812 maxV[el] =
sqrt(maxV[el]);
818 for (
int el = 0; el < n_element; ++el)
821 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
822 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
825 if (n_points != n_points_0)
827 for (
int j = 0; j < nvel; ++j)
831 n_points_0 = n_points;
838 ->GetDerivFactors(ptsKeys);
846 for (
int i = 0; i < n_points; i++)
848 stdVelocity[0][i] = gmat[0][i] * inarray[0][i + cnt] +
849 gmat[3][i] * inarray[1][i + cnt] +
850 gmat[6][i] * inarray[2][i + cnt];
852 stdVelocity[1][i] = gmat[1][i] * inarray[0][i + cnt] +
853 gmat[4][i] * inarray[1][i + cnt] +
854 gmat[7][i] * inarray[2][i + cnt];
856 stdVelocity[2][i] = gmat[2][i] * inarray[0][i + cnt] +
857 gmat[5][i] * inarray[1][i + cnt] +
858 gmat[8][i] * inarray[2][i + cnt];
863 for (
int i = 0; i < n_points; i++)
865 stdVelocity[0][i] = gmat[0][0] * inarray[0][i + cnt] +
866 gmat[3][0] * inarray[1][i + cnt] +
867 gmat[6][0] * inarray[2][i + cnt];
869 stdVelocity[1][i] = gmat[1][0] * inarray[0][i + cnt] +
870 gmat[4][0] * inarray[1][i + cnt] +
871 gmat[7][0] * inarray[2][i + cnt];
873 stdVelocity[2][i] = gmat[2][0] * inarray[0][i + cnt] +
874 gmat[5][0] * inarray[1][i + cnt] +
875 gmat[8][0] * inarray[2][i + cnt];
881 for (
int i = 0; i < n_points; i++)
883 pntVelocity = stdVelocity[0][i] * stdVelocity[0][i] +
884 stdVelocity[1][i] * stdVelocity[1][i] +
885 stdVelocity[2][i] * stdVelocity[2][i];
887 if (pntVelocity > maxV[el])
889 maxV[el] = pntVelocity;
893 maxV[el] =
sqrt(maxV[el]);
#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....
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
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 DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
A base class for PDEs which include an advection component.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
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 int GetTraceNpoints()
NekDouble m_timestep
Time step size.
NekDouble m_time
Current time of simulation.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
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.
SOLVER_UTILS_EXPORT int GetNpoints()
SOLVER_UTILS_EXPORT int GetNcoeffs()
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
SOLVER_UTILS_EXPORT void SetBoundaryConditions(NekDouble time)
Evaluates the boundary conditions at the given time.
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
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.
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s) override
Print a summary of time stepping parameters.
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
UnsteadyAdvectionDiffusion(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
Array< OneD, NekDouble > m_traceVn
virtual ~UnsteadyAdvectionDiffusion()
Destructor.
SolverUtils::DiffusionSharedPtr m_diffusion
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Perform the projection.
Array< OneD, NekDouble > & GetNormalVelocity()
Get the normal velocity based on m_velocity.
virtual bool v_PreIntegrate(int step) override
PreIntegration step for substepping.
NekDouble m_cflSafetyFactor
virtual void v_InitObject(bool DeclareFields=true) override
Initialise the object.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the RHS.
Array< OneD, Array< OneD, NekDouble > > m_velocity
void SetUpSubSteppingTimeIntegration(const LibUtilities::TimeIntegrationSchemeSharedPtr &IntegrationScheme)
void DoImplicitSolve(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, NekDouble time, NekDouble lambda)
Solve implicitly the diffusion term.
NekDouble m_sVVCutoffRatio
bool m_useGJPStabilisation
void AddAdvectionPenaltyFlux(const Array< OneD, const Array< OneD, NekDouble > > &velfield, const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &Outarray)
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Forcing terms.
Array< OneD, NekDouble > & GetNormalVel(const Array< OneD, const Array< OneD, NekDouble > > &velfield)
Get the normal velocity based on input velfield.
void GetFluxVectorAdv(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &flux)
Evaluate the flux at each solution point for the advection part.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
void SubStepAdvection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
void SubStepAdvance(int nstep, NekDouble time)
static std::string className
Name of class.
Array< OneD, NekDouble > GetMaxStdVelocity(const Array< OneD, Array< OneD, NekDouble > > inarray)
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
void GetFluxVectorDiff(const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &qfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &viscousTensor)
Evaluate the flux at each solution point for the diffusion part.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print Summary.
void SubStepProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
LibUtilities::TimeIntegrationSchemeSharedPtr m_subStepIntegrationScheme
NekDouble GetSubstepTimeStep()
LibUtilities::TimeIntegrationSchemeOperators m_subStepIntegrationOps
TimeIntegrationSchemeFactory & GetTimeIntegrationSchemeFactory()
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< PointsKey > PointsKeyVector
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
@ eMixed_CG_Discontinuous
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
std::vector< std::pair< std::string, std::string > > SummaryList
DiffusionFactory & GetDiffusionFactory()
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
RiemannSolverFactory & GetRiemannSolverFactory()
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::map< ConstFactorType, NekDouble > ConstFactorMap
StdRegions::ConstFactorMap factors
The above copyright notice and this permission notice shall be included.
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 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*x.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
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.
scalarT< T > sqrt(scalarT< T > in)