41using namespace LibUtilities;
46 "Unsteady Advection-Diffusion equation");
65 m_session->MatchSolverInfo(
"SpectralVanishingViscosity",
"True",
74 m_session->MatchSolverInfo(
"Extrapolation",
"SubStepping",
89 m_session->LoadSolverInfo(
"DiffusionType", diffName,
"LDG");
98 "SubSteppingScheme is not set up for DG projection");
107 m_session->LoadSolverInfo(
"AdvectionType", advName,
109 if (advName.compare(
"WeakDG") == 0)
117 std::string riemName;
118 m_session->LoadSolverInfo(
"UpwindType", riemName,
"Upwind");
131 ASSERTL0(
false,
"Explicit Galerkin diffusion not set up.");
138 ASSERTL0(
false,
"Unsupported projection type.");
150 "Projection must be set to Mixed_CG_Discontinuous for "
169 int nVariables = inarray.size();
176 for (
int i = 0; i < nVariables; ++i)
194 for (
int i = 0; i < nVariables; ++i)
196 Vmath::Vadd(outarray[i].size(), &outarrayDiff[i][0], 1,
197 &outarray[i][0], 1, &outarray[i][0], 1);
214 int nvariables = inarray.size();
238 for (
int n = 0; n < nvariables; ++n)
247 for (
int i = 0; i < nvariables; ++i)
257 for (
int i = 0; i < nvariables; ++i)
275 unsigned int nDim = qfield.size();
276 unsigned int nConvectiveFields = qfield[0].size();
277 unsigned int nPts = qfield[0][0].size();
278 for (
unsigned int j = 0; j < nDim; ++j)
280 for (
unsigned int i = 0; i < nConvectiveFields; ++i)
293 std::stringstream ss;
302 std::vector<std::string> &variables)
305 m_session->MatchSolverInfo(
"OutputExtraFields",
"True", extraFields,
true);
337 static int ncalls = 1;
354 std::cout <<
"Sub-integrating using " << nsubsteps
361 for (
int m = 0; m < nint; ++m)
364 fields = solutionVector[m];
372 for (
int n = 0; n < nsubsteps; ++n)
387 int n_element =
m_fields[0]->GetExpSize();
399 for (
int el = 0; el < n_element; ++el)
403 (ExpOrder[el] - 1) * (ExpOrder[el] - 1));
417 unsigned int order = IntegrationScheme->GetOrder();
421 if ((IntegrationScheme->GetName() ==
"Euler" &&
422 IntegrationScheme->GetVariant() ==
"Backward") ||
423 (IntegrationScheme->GetName() ==
"BDFImplicit" &&
424 (order == 1 || order == 2)))
429 "RungeKutta",
"SSP", order, std::vector<NekDouble>());
434 "Integration method not suitable: "
435 "Options include BackwardEuler or BDFImplicitOrder1");
438 m_intSteps = IntegrationScheme->GetNumIntegrationPhases();
455 int nVariables = inarray.size();
458 int ncoeffs =
m_fields[0]->GetNcoeffs();
463 for (i = 1; i < nVariables; ++i)
465 WeakAdv[i] = WeakAdv[i - 1] + ncoeffs;
474 for (i = 0; i < nVariables; ++i)
476 m_fields[i]->IProductWRTBase(outarray[i], WeakAdv[i]);
484 for (i = 0; i < nVariables; ++i)
490 m_fields[i]->MultiplyByElmtInvMass(WeakAdv[i], WeakAdv[i]);
493 m_fields[i]->BwdTrans(WeakAdv[i], outarray[i]);
505 ASSERTL1(inarray.size() == outarray.size(),
506 "Inarray and outarray of different sizes ");
508 for (
int i = 0; i < inarray.size(); ++i)
510 Vmath::Vcopy(inarray[i].size(), inarray[i], 1, outarray[i], 1);
519 ASSERTL1(physfield.size() == Outarray.size(),
520 "Physfield and outarray are of different dimensions");
525 int nTracePts =
m_fields[0]->GetTrace()->GetNpoints();
539 for (i = 0; i < physfield.size(); ++i)
543 m_fields[i]->GetFwdBwdTracePhys(physfield[i], Fwd, Bwd);
546 m_fields[0]->GetTrace()->Upwind(Vn, Fwd, Bwd, numflux);
549 Vmath::Vsub(nTracePts, numflux, 1, Fwd, 1, Fwd, 1);
550 Vmath::Vsub(nTracePts, numflux, 1, Bwd, 1, Bwd, 1);
557 m_fields[0]->AddFwdBwdTraceIntegral(Fwd, Bwd, Outarray[i]);
565 int n_points_0 =
m_fields[0]->GetExp(0)->GetTotPoints();
566 int n_element =
m_fields[0]->GetExpSize();
567 int nvel = inarray.size();
570 ASSERTL0(nvel >= 2,
"Method not implemented for 1D");
579 for (
int i = 0; i < nvel; ++i)
587 for (
int el = 0; el < n_element; ++el)
589 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
590 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
593 if (n_points != n_points_0)
595 for (
int j = 0; j < nvel; ++j)
599 n_points_0 = n_points;
606 ->GetDerivFactors(ptsKeys);
614 for (
int i = 0; i < n_points; i++)
616 stdVelocity[0][i] = gmat[0][i] * inarray[0][i + cnt] +
617 gmat[2][i] * inarray[1][i + cnt];
619 stdVelocity[1][i] = gmat[1][i] * inarray[0][i + cnt] +
620 gmat[3][i] * inarray[1][i + cnt];
625 for (
int i = 0; i < n_points; i++)
627 stdVelocity[0][i] = gmat[0][0] * inarray[0][i + cnt] +
628 gmat[2][0] * inarray[1][i + cnt];
630 stdVelocity[1][i] = gmat[1][0] * inarray[0][i + cnt] +
631 gmat[3][0] * inarray[1][i + cnt];
637 for (
int i = 0; i < n_points; i++)
639 pntVelocity = stdVelocity[0][i] * stdVelocity[0][i] +
640 stdVelocity[1][i] * stdVelocity[1][i];
642 if (pntVelocity > maxV[el])
644 maxV[el] = pntVelocity;
647 maxV[el] =
sqrt(maxV[el]);
653 for (
int el = 0; el < n_element; ++el)
656 int n_points =
m_fields[0]->GetExp(el)->GetTotPoints();
657 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
660 if (n_points != n_points_0)
662 for (
int j = 0; j < nvel; ++j)
666 n_points_0 = n_points;
673 ->GetDerivFactors(ptsKeys);
681 for (
int i = 0; i < n_points; i++)
683 stdVelocity[0][i] = gmat[0][i] * inarray[0][i + cnt] +
684 gmat[3][i] * inarray[1][i + cnt] +
685 gmat[6][i] * inarray[2][i + cnt];
687 stdVelocity[1][i] = gmat[1][i] * inarray[0][i + cnt] +
688 gmat[4][i] * inarray[1][i + cnt] +
689 gmat[7][i] * inarray[2][i + cnt];
691 stdVelocity[2][i] = gmat[2][i] * inarray[0][i + cnt] +
692 gmat[5][i] * inarray[1][i + cnt] +
693 gmat[8][i] * inarray[2][i + cnt];
698 for (
int i = 0; i < n_points; i++)
700 stdVelocity[0][i] = gmat[0][0] * inarray[0][i + cnt] +
701 gmat[3][0] * inarray[1][i + cnt] +
702 gmat[6][0] * inarray[2][i + cnt];
704 stdVelocity[1][i] = gmat[1][0] * inarray[0][i + cnt] +
705 gmat[4][0] * inarray[1][i + cnt] +
706 gmat[7][0] * inarray[2][i + cnt];
708 stdVelocity[2][i] = gmat[2][0] * inarray[0][i + cnt] +
709 gmat[5][0] * inarray[1][i + cnt] +
710 gmat[8][0] * inarray[2][i + cnt];
716 for (
int i = 0; i < n_points; i++)
718 pntVelocity = stdVelocity[0][i] * stdVelocity[0][i] +
719 stdVelocity[1][i] * stdVelocity[1][i] +
720 stdVelocity[2][i] * stdVelocity[2][i];
722 if (pntVelocity > maxV[el])
724 maxV[el] = pntVelocity;
728 maxV[el] =
sqrt(maxV[el]);
746 for (
int i = 0; i < spaceDim; ++i)
#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)
Array< OneD, MultiRegions::ExpListSharedPtr > m_fieldsALE
SOLVER_UTILS_EXPORT void InitObject(int spaceDim, Array< OneD, MultiRegions::ExpListSharedPtr > &fields)
Array< OneD, Array< OneD, NekDouble > > m_gridVelocityTrace
SOLVER_UTILS_EXPORT void ALEDoElmtInvMassBwdTrans(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
SOLVER_UTILS_EXPORT void ExtraFldOutputGridVelocity(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
Array< OneD, Array< OneD, NekDouble > > m_gridVelocity
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
SOLVER_UTILS_EXPORT int GetTraceNpoints()
NekDouble m_timestep
Time step size.
int m_infosteps
Number of time steps between outputting status information.
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.
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 int GetTotPoints()
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).
LibUtilities::TimeIntegrationSchemeSharedPtr m_intScheme
Wrapper to the time integration scheme.
bool m_explicitDiffusion
Indicates if explicit or implicit treatment of diffusion is used.
UnsteadyAdvectionDiffusion(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Session reader.
SolverUtils::DiffusionSharedPtr m_diffusion
void v_ALEInitObject(int spaceDim, Array< OneD, MultiRegions::ExpListSharedPtr > &fields) override
bool v_PreIntegrate(int step) override
PreIntegration step for substepping.
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.
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
void AddAdvectionPenaltyFlux(const Array< OneD, const Array< OneD, NekDouble > > &velfield, const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &Outarray)
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)
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.
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
void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables) override
NekDouble GetSubstepTimeStep()
LibUtilities::TimeIntegrationSchemeOperators m_subStepIntegrationOps
Array< OneD, NekDouble > m_traceVn
Array< OneD, NekDouble > & GetNormalVel(const Array< OneD, const Array< OneD, NekDouble > > &velfield)
Get the normal velocity based on input velfield.
Array< OneD, NekDouble > & GetNormalVelocity()
Get the normal velocity.
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print Summary.
Array< OneD, Array< OneD, NekDouble > > m_velocity
Advection velocity.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
Compute the RHS.
void v_InitObject(bool DeclareFields=true) override
Initialise the object.
bool m_useGJPStabilisation
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
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
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
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 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 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)