48 "Nonlinear Peregrine equations in conservative variables.");
65 if (
m_session->DefinesSolverInfo(
"PROBLEMTYPE"))
67 std::string ProblemTypeStr =
m_session->GetSolverInfo(
"PROBLEMTYPE");
84 if (
m_session->DefinesParameter(
"ConstDepth"))
90 ASSERTL0(
false,
"Constant Depth not specified");
94 "Continuous projection type not supported for Peregrine.");
105 NekDouble initialtime,
bool dumpInitialConditions,
106 [[maybe_unused]]
const int domain)
124 !
m_comm->IsParallelInTime())
128 else if (dumpInitialConditions &&
m_nchk == 0 &&
m_comm->IsParallelInTime())
131 if (!fs::is_directory(newdir))
133 fs::create_directory(newdir);
135 if (
m_comm->GetTimeComm()->GetRank() == 0)
147 int nvariables = inarray.size() - 1;
160 inarray, outarray, time);
165 for (
int i = 0; i < nvariables; ++i)
185 "Variable depth not supported for the Peregrine "
209 for (
int i = 0; i < 2; ++i)
238 m_fields[0]->IProductWRTDerivBase(0, physfield[0], coeffsfield[0]);
239 m_fields[0]->IProductWRTDerivBase(1, physfield[1], coeffsfield[1]);
240 Vmath::Vadd(ncoeffs, coeffsfield[0], 1, coeffsfield[1], 1,
249 m_fields[0]->AddTraceIntegral(normflux, coeffsfield[0]);
250 m_fields[0]->MultiplyByElmtInvMass(coeffsfield[0], coeffsfield[0]);
251 m_fields[0]->BwdTrans(coeffsfield[0], physfield[0]);
253 Vmath::Smul(nq, -invgamma, physfield[0], 1, physfield[0], 1);
271 Vmath::Smul(nq, gamma, physfield[0], 1, physfield[0], 1);
273 m_fields[0]->IProductWRTDerivBase(0, physfield[0], coeffsfield[0]);
274 m_fields[0]->IProductWRTDerivBase(1, physfield[0], coeffsfield[1]);
287 m_fields[0]->AddTraceIntegral(normflux, coeffsfield[0]);
290 m_fields[0]->AddTraceIntegral(normflux, coeffsfield[1]);
294 for (
int i = 0; i < 2; ++i)
298 m_fields[0]->IProductWRTBase(outarray[1], modarray[0]);
299 m_fields[0]->IProductWRTBase(outarray[2], modarray[1]);
301 Vmath::Vadd(ncoeffs, modarray[0], 1, coeffsfield[0], 1, modarray[0],
303 Vmath::Vadd(ncoeffs, modarray[1], 1, coeffsfield[1], 1, modarray[1],
306 m_fields[0]->MultiplyByElmtInvMass(modarray[0], modarray[0]);
307 m_fields[0]->MultiplyByElmtInvMass(modarray[1], modarray[1]);
309 m_fields[0]->BwdTrans(modarray[0], outarray[1]);
310 m_fields[0]->BwdTrans(modarray[1], outarray[2]);
317 ASSERTL0(
false,
"Unknown projection scheme for the Peregrine");
320 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
347 for (
int i = 0; i < nq; i++)
350 amp * pow((1.0 / cosh(
sqrt(0.75 * (amp / (
d *
d *
d))) *
351 (
A * (x0[i] + x_offset) - C * time))),
355 pow((1.0 / cosh(
sqrt(0.75 * (amp / (
d *
d *
d))) *
356 (
A * (x0[i] + x_offset) - C * time))),
368 for (
int i = 0; i < 4; ++i)
399 for (
int n = 0; n <
m_fields[0]->GetBndConditions().size(); ++n)
402 if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
409 if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
411 ASSERTL0(
false,
"time-dependent BC not implemented for Boussinesq");
413 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
424 for (
int i = 0; i < 2; ++i)
427 m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
434 m_fields[0]->GetBndCondExpansions()[bcRegion];
436 for (
int e = 0; e < bcexp->GetExpSize(); ++e)
438 npts = bcexp->GetExp(e)->GetTotPoints();
439 id1 = bcexp->GetPhys_Offset(e);
440 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
441 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
447 ASSERTL0(
false,
"1D not yet implemented for Boussinesq");
458 &tmp_n[0], 1, &tmp_n[0], 1);
463 &tmp_t[0], 1, &tmp_t[0], 1);
472 &Fwd[0][id2], 1, &Fwd[0][id2], 1);
477 &Fwd[1][id2], 1, &Fwd[1][id2], 1);
481 ASSERTL0(
false,
"3D not implemented for Boussinesq equations");
484 ASSERTL0(
false,
"Illegal expansion dimension");
488 bcexp =
m_fields[1]->GetBndCondExpansions()[bcRegion];
489 Vmath::Vcopy(npts, &Fwd[0][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
491 bcexp =
m_fields[2]->GetBndCondExpansions()[bcRegion];
492 Vmath::Vcopy(npts, &Fwd[1][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
507 for (
int i = 0; i < 2; ++i)
518 m_fields[1]->GetFwdBwdTracePhys(inarray[0], Fwd[0], Bwd[0]);
519 m_fields[2]->GetFwdBwdTracePhys(inarray[1], Fwd[1], Bwd[1]);
524 for (
int i = 0; i < nTraceNumPoints; ++i)
526 numfluxX[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
527 numfluxY[i] = 0.5 * (Fwd[1][i] + Bwd[1][i]);
539 for (
int n = 0; n <
m_fields[3]->GetBndConditions().size(); ++n)
542 if (boost::iequals(
m_fields[3]->GetBndConditions()[n]->GetUserDefined(),
544 m_fields[3]->GetBndConditions()[n]->IsTimeDependent())
549 cnt +=
m_fields[3]->GetBndCondExpansions()[n]->GetExpSize();
560 m_fields[3]->ExtractTracePhys(inarray,
z);
566 m_fields[3]->GetBndCondExpansions()[bcRegion];
568 for (
int e = 0; e < bcexp->GetExpSize(); ++e)
570 npts = bcexp->GetExp(e)->GetTotPoints();
571 id1 = bcexp->GetPhys_Offset(e);
572 id2 =
m_fields[3]->GetTrace()->GetPhys_Offset(
573 m_fields[3]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
577 bcexp =
m_fields[3]->GetBndCondExpansions()[bcRegion];
578 Vmath::Vcopy(npts, &
z[id2], 1, &(bcexp->UpdatePhys())[id1], 1);
598 m_fields[3]->GetFwdBwdTracePhys(physfield, Fwd, Bwd);
603 for (
int i = 0; i < nTraceNumPoints; ++i)
605 outX[i] = 0.5 * (Fwd[i] + Bwd[i]);
606 outY[i] = 0.5 * (Fwd[i] + Bwd[i]);
#define ASSERTL0(condition, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0) override
Set the initial conditions.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
void SetBoundaryConditionsContVariables(const Array< OneD, const NekDouble > &inarray, NekDouble time)
void SetBoundaryConditionsForcing(Array< OneD, Array< OneD, NekDouble > > &inarray, NekDouble time)
void WallBoundaryForcing(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &inarray)
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print a summary of time stepping parameters.
ProblemType m_problemType
void LaitoneSolitaryWave(NekDouble amp, NekDouble d, NekDouble time, NekDouble x_offset)
static std::string className
Name of class.
void NumericalFluxForcing(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &numfluxX, Array< OneD, NekDouble > &numfluxY)
StdRegions::ConstFactorMap m_factors
void v_InitObject(bool DeclareFields=true) override
Init object for UnsteadySystem class.
NonlinearPeregrine(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
void WallBoundaryContVariables(int bcRegion, int cnt, const Array< OneD, const NekDouble > &inarray)
void WCESolve(Array< OneD, NekDouble > &fce, NekDouble lambda)
void v_DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time) override
void NumericalFluxConsVariables(const Array< OneD, const NekDouble > &physfield, Array< OneD, NekDouble > &outX, Array< OneD, NekDouble > &outY)
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print a summary of time stepping parameters.
void v_InitObject(bool DeclareFields=true) override
Init object for UnsteadySystem class.
NekDouble m_g
Acceleration of gravity.
void AddCoriolis(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
SolverUtils::AdvectionSharedPtr m_advection
bool m_constantDepth
Indicates if constant depth case.
Array< OneD, NekDouble > m_coriolis
Coriolis force.
void DoImplicitSolve(const Array< OneD, const Array< OneD, NekDouble > > &inpnts, Array< OneD, Array< OneD, NekDouble > > &outpnt, const NekDouble time, const NekDouble lambda)
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.
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 void WriteFld(const std::string &outname)
Write field data to the given filename.
std::string m_sessionName
Name of the session.
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 GetNcoeffs()
int m_nchk
Number of checkpoints written so far.
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
int m_checksteps
Number of steps between checkpoints.
SOLVER_UTILS_EXPORT int GetTotPoints()
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::vector< std::pair< std::string, std::string > > SummaryList
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::vector< double > z(NPUPPER)
std::vector< double > d(NPUPPER *NPUPPER)
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
const char *const ProblemTypeMap[]
@ SIZE_ProblemType
Length of enum list.
@ eSolitaryWave
First order Laitone solitary wave.
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.
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 Vvtvm(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)
vvtvm (vector times vector minus vector): z = w*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 Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
void Vvtvvtp(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtp (vector times vector plus vector times vector):
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)