37 #include <boost/core/ignore_unused.hpp>
44 using 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();
319 for (i = 0; i < nvariables; ++i)
330 for (i = 0; i < nvariables; ++i)
332 m_fields[i]->FwdTrans(inarray[i], coeffs);
333 m_fields[i]->BwdTrans(coeffs, outarray[i]);
339 ASSERTL0(
false,
"Unknown projection scheme");
357 int nvariables = inarray.size();
380 for (
int n = 0; n < nvariables; ++n)
389 for (
int i = 0; i < nvariables; ++i)
399 for (
int i = 0; i < nvariables; ++i)
419 "Dimension of flux array and velocity array do not match");
421 const int nq =
m_fields[0]->GetNpoints();
423 for (
int i = 0; i < flux.size(); ++i)
425 for (
int j = 0; j < flux[0].size(); ++j)
446 boost::ignore_unused(inarray);
448 unsigned int nDim = qfield.size();
449 unsigned int nConvectiveFields = qfield[0].size();
450 unsigned int nPts = qfield[0][0].size();
451 for (
unsigned int j = 0; j < nDim; ++j)
453 for (
unsigned int i = 0; i < nConvectiveFields; ++i)
467 s,
"GJP Stab. Impl. ",
468 m_session->GetSolverInfo(
"GJPStabilisation"));
498 static int ncalls = 1;
515 std::cout <<
"Sub-integrating using " << nsubsteps
522 for (
int m = 0; m < nint; ++m)
525 fields = solutionVector[m];
533 for (n = 0; n < nsubsteps; ++n)
549 int n_element =
m_fields[0]->GetExpSize();
561 for (
int el = 0; el < n_element; ++el)
565 (ExpOrder[el] - 1) * (ExpOrder[el] - 1));
579 unsigned int order = IntegrationScheme->GetOrder();
583 if ((IntegrationScheme->GetName() ==
"Euler" &&
584 IntegrationScheme->GetVariant() ==
"Backward") ||
585 (IntegrationScheme->GetName() ==
"BDFImplicit" &&
586 (order == 1 || order == 2)))
591 "RungeKutta",
"SSP", order, std::vector<NekDouble>());
596 "Integration method not suitable: "
597 "Options include BackwardEuler or BDFImplicitOrder1");
600 m_intSteps = IntegrationScheme->GetNumIntegrationPhases();
617 int nVariables = inarray.size();
620 int ncoeffs =
m_fields[0]->GetNcoeffs();
625 for (i = 1; i < nVariables; ++i)
627 WeakAdv[i] = WeakAdv[i - 1] + ncoeffs;
636 for (i = 0; i < nVariables; ++i)
638 m_fields[i]->IProductWRTBase(outarray[i], WeakAdv[i]);
646 for (i = 0; i < nVariables; ++i)
652 m_fields[i]->MultiplyByElmtInvMass(WeakAdv[i], WeakAdv[i]);
655 m_fields[i]->BwdTrans(WeakAdv[i], outarray[i]);
666 boost::ignore_unused(time);
668 ASSERTL1(inarray.size() == outarray.size(),
669 "Inarray and outarray of different sizes ");
671 for (
int i = 0; i < inarray.size(); ++i)
673 Vmath::Vcopy(inarray[i].size(), inarray[i], 1, outarray[i], 1);
682 ASSERTL1(physfield.size() == Outarray.size(),
683 "Physfield and outarray are of different dimensions");
688 int nTracePts =
m_fields[0]->GetTrace()->GetNpoints();
702 for (i = 0; i < physfield.size(); ++i)
706 m_fields[i]->GetFwdBwdTracePhys(physfield[i], Fwd, Bwd);
709 m_fields[0]->GetTrace()->Upwind(Vn, Fwd, Bwd, numflux);
712 Vmath::Vsub(nTracePts, numflux, 1, Fwd, 1, Fwd, 1);
713 Vmath::Vsub(nTracePts, numflux, 1, Bwd, 1, Bwd, 1);
720 m_fields[0]->AddFwdBwdTraceIntegral(Fwd, Bwd, Outarray[i]);
728 int n_points_0 =
m_fields[0]->GetExp(0)->GetTotPoints();
729 int n_element =
m_fields[0]->GetExpSize();
730 int nvel = inarray.size();
733 ASSERTL0(nvel >= 2,
"Method not implemented for 1D");
742 for (
int i = 0; i < nvel; ++i)
750 for (
int el = 0; el < n_element; ++el)
752 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
753 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
756 if (n_points != n_points_0)
758 for (
int j = 0; j < nvel; ++j)
762 n_points_0 = n_points;
769 ->GetDerivFactors(ptsKeys);
777 for (
int i = 0; i < n_points; i++)
779 stdVelocity[0][i] = gmat[0][i] * inarray[0][i + cnt] +
780 gmat[2][i] * inarray[1][i + cnt];
782 stdVelocity[1][i] = gmat[1][i] * inarray[0][i + cnt] +
783 gmat[3][i] * inarray[1][i + cnt];
788 for (
int i = 0; i < n_points; i++)
790 stdVelocity[0][i] = gmat[0][0] * inarray[0][i + cnt] +
791 gmat[2][0] * inarray[1][i + cnt];
793 stdVelocity[1][i] = gmat[1][0] * inarray[0][i + cnt] +
794 gmat[3][0] * inarray[1][i + cnt];
800 for (
int i = 0; i < n_points; i++)
802 pntVelocity = stdVelocity[0][i] * stdVelocity[0][i] +
803 stdVelocity[1][i] * stdVelocity[1][i];
805 if (pntVelocity > maxV[el])
807 maxV[el] = pntVelocity;
810 maxV[el] =
sqrt(maxV[el]);
816 for (
int el = 0; el < n_element; ++el)
819 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
820 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
823 if (n_points != n_points_0)
825 for (
int j = 0; j < nvel; ++j)
829 n_points_0 = n_points;
836 ->GetDerivFactors(ptsKeys);
844 for (
int i = 0; i < n_points; i++)
846 stdVelocity[0][i] = gmat[0][i] * inarray[0][i + cnt] +
847 gmat[3][i] * inarray[1][i + cnt] +
848 gmat[6][i] * inarray[2][i + cnt];
850 stdVelocity[1][i] = gmat[1][i] * inarray[0][i + cnt] +
851 gmat[4][i] * inarray[1][i + cnt] +
852 gmat[7][i] * inarray[2][i + cnt];
854 stdVelocity[2][i] = gmat[2][i] * inarray[0][i + cnt] +
855 gmat[5][i] * inarray[1][i + cnt] +
856 gmat[8][i] * inarray[2][i + cnt];
861 for (
int i = 0; i < n_points; i++)
863 stdVelocity[0][i] = gmat[0][0] * inarray[0][i + cnt] +
864 gmat[3][0] * inarray[1][i + cnt] +
865 gmat[6][0] * inarray[2][i + cnt];
867 stdVelocity[1][i] = gmat[1][0] * inarray[0][i + cnt] +
868 gmat[4][0] * inarray[1][i + cnt] +
869 gmat[7][0] * inarray[2][i + cnt];
871 stdVelocity[2][i] = gmat[2][0] * inarray[0][i + cnt] +
872 gmat[5][0] * inarray[1][i + cnt] +
873 gmat[8][0] * inarray[2][i + cnt];
879 for (
int i = 0; i < n_points; i++)
881 pntVelocity = stdVelocity[0][i] * stdVelocity[0][i] +
882 stdVelocity[1][i] * stdVelocity[1][i] +
883 stdVelocity[2][i] * stdVelocity[2][i];
885 if (pntVelocity > maxV[el])
887 maxV[el] = pntVelocity;
891 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.
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.
UnsteadyAdvectionDiffusion(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
Array< OneD, NekDouble > m_traceVn
virtual ~UnsteadyAdvectionDiffusion()
Destructor.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the RHS.
SolverUtils::DiffusionSharedPtr m_diffusion
Array< OneD, NekDouble > & GetNormalVelocity()
Get the normal velocity based on m_velocity.
void AddAdvectionPenaltyFlux(const Array< OneD, const Array< OneD, NekDouble >> &velfield, const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, NekDouble >> &Outarray)
virtual bool v_PreIntegrate(int step) override
PreIntegration step for substepping.
void SubStepAdvection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
NekDouble m_cflSafetyFactor
virtual void v_InitObject(bool DeclareFields=true) override
Initialise the object.
Array< OneD, Array< OneD, NekDouble > > m_velocity
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.
void SetUpSubSteppingTimeIntegration(const LibUtilities::TimeIntegrationSchemeSharedPtr &IntegrationScheme)
NekDouble m_sVVCutoffRatio
bool m_useGJPStabilisation
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Forcing terms.
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 > GetMaxStdVelocity(const Array< OneD, Array< OneD, NekDouble >> inarray)
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
void SubStepAdvance(int nstep, NekDouble time)
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.
static std::string className
Name of class.
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
virtual void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print Summary.
LibUtilities::TimeIntegrationSchemeSharedPtr m_subStepIntegrationScheme
Array< OneD, NekDouble > & GetNormalVel(const Array< OneD, const Array< OneD, NekDouble >> &velfield)
Get the normal velocity based on input velfield.
NekDouble GetSubstepTimeStep()
void SubStepProjection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
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
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)