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)
130 !
m_comm->IsParallelInTime())
134 else if (dumpInitialConditions &&
m_nchk == 0 &&
m_comm->IsParallelInTime())
137 if (!fs::is_directory(newdir))
139 fs::create_directory(newdir);
141 if (
m_comm->GetTimeComm()->GetRank() == 0)
153 int nvariables = inarray.size() - 1;
166 inarray, outarray, time);
171 for (
int i = 0; i < nvariables; ++i)
191 "Variable depth not supported for the Peregrine "
215 for (
int i = 0; i < 2; ++i)
244 m_fields[0]->IProductWRTDerivBase(0, physfield[0], coeffsfield[0]);
245 m_fields[0]->IProductWRTDerivBase(1, physfield[1], coeffsfield[1]);
246 Vmath::Vadd(ncoeffs, coeffsfield[0], 1, coeffsfield[1], 1,
255 m_fields[0]->AddTraceIntegral(normflux, coeffsfield[0]);
256 m_fields[0]->MultiplyByElmtInvMass(coeffsfield[0], coeffsfield[0]);
257 m_fields[0]->BwdTrans(coeffsfield[0], physfield[0]);
259 Vmath::Smul(nq, -invgamma, physfield[0], 1, physfield[0], 1);
277 Vmath::Smul(nq, gamma, physfield[0], 1, physfield[0], 1);
279 m_fields[0]->IProductWRTDerivBase(0, physfield[0], coeffsfield[0]);
280 m_fields[0]->IProductWRTDerivBase(1, physfield[0], coeffsfield[1]);
293 m_fields[0]->AddTraceIntegral(normflux, coeffsfield[0]);
296 m_fields[0]->AddTraceIntegral(normflux, coeffsfield[1]);
300 for (
int i = 0; i < 2; ++i)
304 m_fields[0]->IProductWRTBase(outarray[1], modarray[0]);
305 m_fields[0]->IProductWRTBase(outarray[2], modarray[1]);
307 Vmath::Vadd(ncoeffs, modarray[0], 1, coeffsfield[0], 1, modarray[0],
309 Vmath::Vadd(ncoeffs, modarray[1], 1, coeffsfield[1], 1, modarray[1],
312 m_fields[0]->MultiplyByElmtInvMass(modarray[0], modarray[0]);
313 m_fields[0]->MultiplyByElmtInvMass(modarray[1], modarray[1]);
315 m_fields[0]->BwdTrans(modarray[0], outarray[1]);
316 m_fields[0]->BwdTrans(modarray[1], outarray[2]);
323 ASSERTL0(
false,
"Unknown projection scheme for the Peregrine");
326 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
353 for (
int i = 0; i < nq; i++)
356 amp * pow((1.0 / cosh(
sqrt(0.75 * (amp / (d * d * d))) *
357 (
A * (x0[i] + x_offset) - C * time))),
361 pow((1.0 / cosh(
sqrt(0.75 * (amp / (d * d * d))) *
362 (
A * (x0[i] + x_offset) - C * time))),
374 for (
int i = 0; i < 4; ++i)
405 for (
int n = 0; n <
m_fields[0]->GetBndConditions().size(); ++n)
408 if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
415 if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
417 ASSERTL0(
false,
"time-dependent BC not implemented for Boussinesq");
419 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
430 for (
int i = 0; i < 2; ++i)
433 m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
440 m_fields[0]->GetBndCondExpansions()[bcRegion];
442 for (
int e = 0; e < bcexp->GetExpSize(); ++e)
444 npts = bcexp->GetExp(e)->GetTotPoints();
445 id1 = bcexp->GetPhys_Offset(e);
446 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
447 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
453 ASSERTL0(
false,
"1D not yet implemented for Boussinesq");
464 &tmp_n[0], 1, &tmp_n[0], 1);
469 &tmp_t[0], 1, &tmp_t[0], 1);
478 &Fwd[0][id2], 1, &Fwd[0][id2], 1);
483 &Fwd[1][id2], 1, &Fwd[1][id2], 1);
487 ASSERTL0(
false,
"3D not implemented for Boussinesq equations");
490 ASSERTL0(
false,
"Illegal expansion dimension");
494 bcexp =
m_fields[1]->GetBndCondExpansions()[bcRegion];
495 Vmath::Vcopy(npts, &Fwd[0][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
497 bcexp =
m_fields[2]->GetBndCondExpansions()[bcRegion];
498 Vmath::Vcopy(npts, &Fwd[1][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
513 for (
int i = 0; i < 2; ++i)
524 m_fields[1]->GetFwdBwdTracePhys(inarray[0], Fwd[0], Bwd[0]);
525 m_fields[2]->GetFwdBwdTracePhys(inarray[1], Fwd[1], Bwd[1]);
530 for (
int i = 0; i < nTraceNumPoints; ++i)
532 numfluxX[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
533 numfluxY[i] = 0.5 * (Fwd[1][i] + Bwd[1][i]);
545 for (
int n = 0; n <
m_fields[3]->GetBndConditions().size(); ++n)
548 if (boost::iequals(
m_fields[3]->GetBndConditions()[n]->GetUserDefined(),
550 m_fields[3]->GetBndConditions()[n]->IsTimeDependent())
555 cnt +=
m_fields[3]->GetBndCondExpansions()[n]->GetExpSize();
566 m_fields[3]->ExtractTracePhys(inarray, z);
572 m_fields[3]->GetBndCondExpansions()[bcRegion];
574 for (
int e = 0; e < bcexp->GetExpSize(); ++e)
576 npts = bcexp->GetExp(e)->GetTotPoints();
577 id1 = bcexp->GetPhys_Offset(e);
578 id2 =
m_fields[3]->GetTrace()->GetPhys_Offset(
579 m_fields[3]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
583 bcexp =
m_fields[3]->GetBndCondExpansions()[bcRegion];
584 Vmath::Vcopy(npts, &z[id2], 1, &(bcexp->UpdatePhys())[id1], 1);
604 m_fields[3]->GetFwdBwdTracePhys(physfield, Fwd, Bwd);
609 for (
int i = 0; i < nTraceNumPoints; ++i)
611 outX[i] = 0.5 * (Fwd[i] + Bwd[i]);
612 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
Virtual function for generating summary information.
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
Initialisation object for EquationSystem.
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
Virtual function for generating summary information.
void v_InitObject(bool DeclareFields=true) override
Initialisation object for EquationSystem.
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.
NekDouble m_time
Current time of simulation.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetNcoeffs()
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 GetTotPoints()
int m_nchk
Number of checkpoints written so far.
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
LibUtilities::FieldMetaDataMap m_fieldMetaDataMap
Map to identify relevant solver info to dump in output fields.
int m_checksteps
Number of steps between checkpoints.
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
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)