39 #include <boost/algorithm/string.hpp>
50 "Nonlinear Peregrine equations in conservative variables.");
66 if (
m_session->DefinesSolverInfo(
"PROBLEMTYPE"))
69 std::string ProblemTypeStr =
m_session->GetSolverInfo(
"PROBLEMTYPE");
91 ASSERTL0(
false,
"Implicit Peregrine not set up.");
96 if (
m_session->DefinesParameter(
"ConstDepth"))
102 ASSERTL0(
false,
"Constant Depth not specified");
112 "Continuous projection type not supported for Peregrine.");
126 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
135 m_session->LoadSolverInfo(
"UpwindType", riemName,
"NoSolver");
158 ASSERTL0(
false,
"Unsupported projection type.");
188 m_fields[0]->IProductWRTBase(tmp, mod);
189 m_fields[0]->MultiplyByElmtInvMass(mod, mod);
191 Vmath::Vadd(nq, tmp, 1, outarray[1], 1, outarray[1], 1);
196 m_fields[0]->IProductWRTBase(tmp, mod);
197 m_fields[0]->MultiplyByElmtInvMass(mod, mod);
199 Vmath::Vadd(nq, tmp, 1, outarray[2], 1, outarray[2], 1);
207 Vmath::Vadd(nq, tmp, 1, outarray[1], 1, outarray[1], 1);
212 Vmath::Vadd(nq, tmp, 1, outarray[2], 1, outarray[2], 1);
216 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
242 m_fields[0]->IProductWRTBase(tmp, mod);
243 m_fields[0]->MultiplyByElmtInvMass(mod, mod);
245 Vmath::Vadd(nq, tmp, 1, outarray[i + 1], 1, outarray[i + 1], 1);
256 Vmath::Vadd(nq, tmp, 1, outarray[i + 1], 1, outarray[i + 1], 1);
261 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
272 int nvariables = inarray.num_elements();
285 for (i = 0; i < nvariables; ++i)
303 for (i = 0; i < nvariables - 1; ++i)
323 "Variable depth not supported for the Peregrine "
337 m_fields[0]->IProductWRTBase(outarray[1], modarray[1]);
338 m_fields[0]->IProductWRTBase(outarray[2], modarray[2]);
348 m_fields[0]->MultiplyByElmtInvMass(modarray[1], modarray[1]);
349 m_fields[0]->MultiplyByElmtInvMass(modarray[2], modarray[2]);
361 for (i = 0; i < 2; ++i)
401 m_fields[0]->IProductWRTDerivBase(0, physfield[0], coeffsfield[0]);
402 m_fields[0]->IProductWRTDerivBase(1, physfield[1], coeffsfield[1]);
403 Vmath::Vadd(ncoeffs, coeffsfield[0], 1, coeffsfield[1], 1,
410 m_fields[0]->AddTraceIntegral(upwindX[0], upwindY[0],
412 m_fields[0]->MultiplyByElmtInvMass(coeffsfield[0], coeffsfield[0]);
413 m_fields[0]->BwdTrans(coeffsfield[0], physfield[0]);
415 Vmath::Smul(nq, -invgamma, physfield[0], 1, physfield[0], 1);
443 Vmath::Smul(nq, gamma, physfield[0], 1, physfield[0], 1);
448 m_fields[0]->IProductWRTDerivBase(0, physfield[0], coeffsfield[0]);
449 m_fields[1]->IProductWRTDerivBase(1, physfield[0], coeffsfield[1]);
460 m_fields[0]->AddTraceIntegral(upwindX[0], uptemp,
462 m_fields[0]->AddTraceIntegral(uptemp, upwindY[0],
466 Vmath::Vadd(ncoeffs, f1, 1, coeffsfield[0], 1, modarray[1], 1);
467 Vmath::Vadd(ncoeffs, f2, 1, coeffsfield[1], 1, modarray[2], 1);
469 m_fields[1]->MultiplyByElmtInvMass(modarray[1], modarray[1]);
470 m_fields[2]->MultiplyByElmtInvMass(modarray[2], modarray[2]);
472 m_fields[1]->BwdTrans(modarray[1], outarray[1]);
473 m_fields[2]->BwdTrans(modarray[2], outarray[2]);
482 ASSERTL0(
false,
"Unknown projection scheme for the Peregrine");
485 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
496 int nvariables = inarray.num_elements();
506 for (i = 0; i < nvariables; ++i)
518 EquationSystem::SetBoundaryConditions(time);
521 for (i = 0; i < nvariables; ++i)
523 m_fields[i]->FwdTrans(inarray[i], coeffs);
524 m_fields[i]->BwdTrans_IterPerExp(coeffs, outarray[i]);
529 ASSERTL0(
false,
"Unknown projection scheme");
540 int nvariables =
m_fields.num_elements();
547 for (
int i = 0; i < nvariables; ++i)
550 m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
554 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
558 if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
"Wall"))
564 if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
566 for (
int i = 0; i < nvariables; ++i)
568 m_fields[i]->EvaluateBoundaryConditions(time);
571 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
584 int nvariables = physarray.num_elements();
588 int e, id1, id2,
npts;
590 m_fields[0]->GetBndCondExpansions()[bcRegion];
591 for (e = 0; e < bcexp->GetExpSize(); ++e)
593 npts = bcexp->GetExp(e)->GetTotPoints();
594 id1 = bcexp->GetPhys_Offset(e);
595 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
596 m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
606 &tmp[0], 1, &tmp[0], 1);
616 &Fwd[1 + i][id2], 1, &Fwd[1 + i][id2], 1);
620 for (i = 0; i < nvariables; ++i)
622 bcexp =
m_fields[i]->GetBndCondExpansions()[bcRegion];
623 Vmath::Vcopy(npts, &Fwd[i][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
640 int e, id1, id2,
npts;
642 m_fields[0]->GetBndCondExpansions()[bcRegion];
644 for (e = 0; e < bcexp->GetExpSize();
647 npts = bcexp->GetExp(e)->GetNumPoints(0);
648 id1 = bcexp->GetPhys_Offset(e);
649 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
650 m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
669 &tmp_n[0], 1, &tmp_n[0], 1);
674 &tmp_t[0], 1, &tmp_t[0], 1);
683 &Fwd[1][id2], 1, &Fwd[1][id2], 1);
688 &Fwd[2][id2], 1, &Fwd[2][id2], 1);
693 "3D not implemented for Shallow Water Equations");
696 ASSERTL0(
false,
"Illegal expansion dimension");
700 for (i = 0; i < nvariables; ++i)
702 bcexp =
m_fields[i]->GetBndCondExpansions()[bcRegion];
703 Vmath::Vcopy(npts, &Fwd[i][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
714 int nq =
m_fields[0]->GetTotPoints();
730 Vmath::Vmul(nq, physfield[0], 1, physfield[0], 1, tmp, 1);
738 Vmath::Vmul(nq, velocity[j], 1, physfield[i + 1], 1,
743 Vmath::Vadd(nq, flux[i + 1][i], 1, tmp, 1, flux[i + 1][i], 1);
754 if (physin.get() == physout.get())
758 for (
int i = 0; i < 3; ++i)
769 Vmath::Vdiv(nq, tmp[1], 1, tmp[0], 1, physout[1], 1);
772 Vmath::Vdiv(nq, tmp[2], 1, tmp[0], 1, physout[2], 1);
780 Vmath::Vdiv(nq, physin[1], 1, physin[0], 1, physout[1], 1);
783 Vmath::Vdiv(nq, physin[2], 1, physin[0], 1, physout[2], 1);
811 if (physin.get() == physout.get())
815 for (
int i = 0; i < 3; ++i)
826 Vmath::Vmul(nq, physout[0], 1, tmp[1], 1, physout[1], 1);
829 Vmath::Vmul(nq, physout[0], 1, tmp[2], 1, physout[2], 1);
838 Vmath::Vmul(nq, physout[0], 1, physin[1], 1, physout[1], 1);
841 Vmath::Vmul(nq, physout[0], 1, physin[2], 1, physout[2], 1);
875 const int npts = physfield[0].num_elements();
879 Vmath::Vdiv(npts, physfield[1 + i], 1, physfield[0], 1, velocity[i], 1);
900 for (
int j = 0; j < nq; j++)
902 (
m_fields[3]->UpdatePhys())[j] = fce[j];
932 for (i = 0; i < 2; ++i)
943 m_fields[1]->GetFwdBwdTracePhys(inarray[0], Fwd[0], Bwd[0]);
944 m_fields[2]->GetFwdBwdTracePhys(inarray[1], Fwd[1], Bwd[1]);
949 for (i = 0; i < nTraceNumPoints; ++i)
951 numfluxX[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
952 numfluxY[i] = 0.5 * (Fwd[1][i] + Bwd[1][i]);
964 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
968 if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
"Wall"))
974 if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
976 ASSERTL0(
false,
"time-dependent BC not implemented for Boussinesq");
978 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
996 for (
int i = 0; i < nvariables; ++i)
999 m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
1004 int e, id1, id2,
npts;
1006 m_fields[0]->GetBndCondExpansions()[bcRegion];
1007 for (e = 0; e < bcexp->GetExpSize(); ++e)
1009 npts = bcexp->GetExp(e)->GetTotPoints();
1010 id1 = bcexp->GetPhys_Offset(e);
1011 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
1012 m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
1019 ASSERTL0(
false,
"1D not yet implemented for Boussinesq");
1030 &tmp_n[0], 1, &tmp_n[0], 1);
1035 &tmp_t[0], 1, &tmp_t[0], 1);
1044 &Fwd[0][id2], 1, &Fwd[0][id2], 1);
1049 &Fwd[1][id2], 1, &Fwd[1][id2], 1);
1053 ASSERTL0(
false,
"3D not implemented for Boussinesq equations");
1056 ASSERTL0(
false,
"Illegal expansion dimension");
1060 bcexp =
m_fields[1]->GetBndCondExpansions()[bcRegion];
1061 Vmath::Vcopy(npts, &Fwd[0][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
1063 bcexp =
m_fields[2]->GetBndCondExpansions()[bcRegion];
1064 Vmath::Vcopy(npts, &Fwd[1][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
1075 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
1079 if(boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
"Wall"))
1084 if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
1089 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize() - 1;
1102 m_fields[0]->ExtractTracePhys(inarray, z);
1106 int e, id1, id2,
npts;
1108 m_fields[0]->GetBndCondExpansions()[bcRegion];
1110 for (e = 0; e < bcexp->GetExpSize(); ++e)
1112 npts = bcexp->GetExp(e)->GetTotPoints();
1113 id1 = bcexp->GetPhys_Offset(e);
1114 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
1115 m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
1119 bcexp =
m_fields[1]->GetBndCondExpansions()[bcRegion];
1120 Vmath::Vcopy(npts, &z[id2], 1, &(bcexp->UpdatePhys())[id1], 1);
1145 m_fields[1]->GetFwdBwdTracePhys(physfield, Fwd[0], Bwd[0]);
1150 for (i = 0; i < nTraceNumPoints; ++i)
1152 outX[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
1153 outY[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
1178 for (
int i = 0; i < nq; i++)
1180 (
m_fields[0]->UpdatePhys())[i] = amp * pow((1.0 / cosh(
1181 sqrt(0.75 * (amp / (d * d * d))) *
1182 (A * (x0[i] + x_offset) - C * time))), 2.0);
1183 (
m_fields[1]->UpdatePhys())[i] = (amp / d) * pow((1.0 / cosh(
1184 sqrt(0.75 * (amp / (d * d * d))) *
1185 (A * (x0[i] + x_offset) - C * time)
1186 )), 2.0) * sqrt(
m_g * d);
1196 for (
int i = 0; i < 4; ++i)
1210 bool dumpInitialConditions,
1223 EquationSystem::v_SetInitialConditions(initialtime,
false);
1228 if (dumpInitialConditions)
Array< OneD, NekDouble > m_coriolis
Coriolis force.
void SetBoundaryConditionsContVariables(Array< OneD, NekDouble > &inarray, NekDouble time)
#define ASSERTL0(condition, msg)
void NumericalFluxForcing(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &numfluxX, Array< OneD, NekDouble > &numfluxY)
void PrimitiveToConservative()
Base class for unsteady solvers.
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Array< OneD, NekDouble > m_depth
Still water depth.
void GetFluxVector(const Array< OneD, const Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &flux)
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
void WallBoundaryForcing(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &inarray)
std::vector< std::pair< std::string, std::string > > SummaryList
int m_expdim
Expansion dimension.
ProblemType m_problemType
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
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
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs()
SolverUtils::AdvectionSharedPtr m_advection
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
NonlinearPeregrine(const LibUtilities::SessionReaderSharedPtr &pSession)
void Vdiv(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 SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble > > &physarray, NekDouble time)
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
const Array< OneD, NekDouble > & GetDepth()
SOLVER_UTILS_EXPORT int GetTotPoints()
StdRegions::ConstFactorMap m_factors
virtual void v_SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Set the initial conditions.
void ConservativeToPrimitive()
void NumericalFluxConsVariables(Array< OneD, NekDouble > &physfield, Array< OneD, NekDouble > &outX, Array< OneD, NekDouble > &outY)
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
void DefineProjection(FuncPointerT func, ObjectPointerT obj)
Array< OneD, Array< OneD, NekDouble > > m_bottomSlope
virtual ~NonlinearPeregrine()
problem type selector
virtual void v_InitObject()
Init object for UnsteadySystem class.
void WallBoundary(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray)
Wall boundary condition.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
virtual void v_ConservativeToPrimitive()
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
virtual void v_InitObject()
Init object for UnsteadySystem class.
static std::string className
Name of class.
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
RiemannSolverFactory & GetRiemannSolverFactory()
void WCESolve(Array< OneD, NekDouble > &fce, NekDouble lambda)
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
int m_spacedim
Spatial dimension (>= expansion dim).
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
void Neg(int n, T *x, const int incx)
Negate x = -x.
void SetBoundaryConditionsForcing(Array< OneD, Array< OneD, NekDouble > > &inarray, NekDouble time)
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
Creates an instance of this class.
EquationSystemFactory & GetEquationSystemFactory()
void AddVariableDepth(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
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.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
void WallBoundary2D(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray)
SOLVER_UTILS_EXPORT int GetNpoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
void GetVelocityVector(const Array< OneD, Array< OneD, NekDouble > > &physfield, Array< OneD, Array< OneD, NekDouble > > &velocity)
Compute the velocity field given the momentum .
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 plus vector): z = w*x - y
virtual void v_PrimitiveToConservative()
SOLVER_UTILS_EXPORT int GetNcoeffs()
First order Laitone solitary wave.
bool m_constantDepth
Indicates if constant depth case.
void WallBoundaryContVariables(int bcRegion, int cnt, Array< OneD, NekDouble > &inarray)
void AddCoriolis(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
NekDouble m_g
Acceleration of gravity.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
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 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.
static FlagList NullFlagList
An empty flag list.
void LaitoneSolitaryWave(NekDouble amp, NekDouble d, NekDouble time, NekDouble x_offset)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
const char *const ProblemTypeMap[]