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();
 
  544     for (
int n = 0; n < 
m_fields[0]->GetBndConditions().num_elements(); ++n)
 
  548         if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
"Wall"))
 
  554         if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
 
  556             for (
int i = 0; i < nvariables; ++i)
 
  558                 m_fields[i]->EvaluateBoundaryConditions(time);
 
  561         cnt += 
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
 
  574     int nvariables = physarray.num_elements();
 
  578     for (i = 0; i < nvariables; ++i)
 
  581         m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
 
  586     int e, id1, id2, 
npts;
 
  588                                 m_fields[0]->GetBndCondExpansions()[bcRegion];
 
  589     for (e = 0; e < bcexp->GetExpSize(); ++e)
 
  591         npts = bcexp->GetExp(e)->GetTotPoints();
 
  592         id1  = bcexp->GetPhys_Offset(e);
 
  593         id2  = 
m_fields[0]->GetTrace()->GetPhys_Offset(
 
  594                m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
 
  604                                &tmp[0],          1, &tmp[0],                 1);
 
  614                                &Fwd[1 + i][id2], 1, &Fwd[1 + i][id2],        1);
 
  618         for (i = 0; i < nvariables; ++i)
 
  620             bcexp = 
m_fields[i]->GetBndCondExpansions()[bcRegion];
 
  621             Vmath::Vcopy(npts, &Fwd[i][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
 
  638     for (i = 0; i < nvariables; ++i)
 
  641         m_fields[i]->ExtractTracePhys(physarray[i], Fwd[i]);
 
  646     int e, id1, id2, 
npts;
 
  648                                 m_fields[0]->GetBndCondExpansions()[bcRegion];
 
  650     for (e = 0; e < bcexp->GetExpSize();
 
  653         npts = bcexp->GetExp(e)->GetNumPoints(0);
 
  654         id1  = bcexp->GetPhys_Offset(e);
 
  655         id2  = 
m_fields[0]->GetTrace()->GetPhys_Offset(
 
  656                m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
 
  675                                    &tmp_n[0],    1, &tmp_n[0],               1);
 
  680                                    &tmp_t[0],    1, &tmp_t[0],               1);
 
  689                                    &Fwd[1][id2], 1, &Fwd[1][id2],            1);
 
  694                                    &Fwd[2][id2], 1, &Fwd[2][id2],            1);
 
  699                         "3D not implemented for Shallow Water Equations");
 
  702                 ASSERTL0(
false, 
"Illegal expansion dimension");
 
  706         for (i = 0; i < nvariables; ++i)
 
  708             bcexp = 
m_fields[i]->GetBndCondExpansions()[bcRegion];
 
  709             Vmath::Vcopy(npts, &Fwd[i][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
 
  720     int nq = 
m_fields[0]->GetTotPoints();
 
  736     Vmath::Vmul(nq, physfield[0], 1, physfield[0], 1, tmp, 1);
 
  744             Vmath::Vmul(nq, velocity[j],    1, physfield[i + 1], 1,
 
  749         Vmath::Vadd(nq, flux[i + 1][i], 1, tmp, 1, flux[i + 1][i], 1);
 
  760     if (physin.get() == physout.get())
 
  764         for (
int i = 0; i < 3; ++i)
 
  775         Vmath::Vdiv(nq, tmp[1], 1, tmp[0], 1, physout[1], 1);
 
  778         Vmath::Vdiv(nq, tmp[2], 1, tmp[0], 1, physout[2], 1);
 
  786         Vmath::Vdiv(nq, physin[1], 1, physin[0], 1, physout[1], 1);
 
  789         Vmath::Vdiv(nq, physin[2], 1, physin[0], 1, physout[2], 1);
 
  817     if (physin.get() == physout.get())
 
  821         for (
int i = 0; i < 3; ++i)
 
  832         Vmath::Vmul(nq, physout[0], 1, tmp[1],  1, physout[1], 1);
 
  835         Vmath::Vmul(nq, physout[0], 1, tmp[2],  1, physout[2], 1);
 
  844         Vmath::Vmul(nq, physout[0], 1, physin[1], 1, physout[1], 1);
 
  847         Vmath::Vmul(nq, physout[0], 1, physin[2], 1, physout[2], 1);
 
  881     const int npts = physfield[0].num_elements();
 
  885         Vmath::Vdiv(npts, physfield[1 + i], 1, physfield[0], 1, velocity[i], 1);
 
  906     for (
int j = 0; j < nq; j++)
 
  908         (
m_fields[3]->UpdatePhys())[j] = fce[j];
 
  938     for (i = 0; i < 2; ++i)
 
  949     m_fields[1]->GetFwdBwdTracePhys(inarray[0], Fwd[0], Bwd[0]);
 
  950     m_fields[2]->GetFwdBwdTracePhys(inarray[1], Fwd[1], Bwd[1]);
 
  955     for (i = 0; i < nTraceNumPoints; ++i)
 
  957         numfluxX[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
 
  958         numfluxY[i] = 0.5 * (Fwd[1][i] + Bwd[1][i]);
 
  970     for (
int n = 0; n < 
m_fields[0]->GetBndConditions().num_elements(); ++n)
 
  974         if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
"Wall"))
 
  980         if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
 
  982             ASSERTL0(
false, 
"time-dependent BC not implemented for Boussinesq");
 
  984         cnt += 
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
 
 1002     for (
int i = 0; i < nvariables; ++i)
 
 1005         m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
 
 1010     int e, id1, id2, 
npts;
 
 1012                                 m_fields[0]->GetBndCondExpansions()[bcRegion];
 
 1013     for (e = 0; e < bcexp->GetExpSize(); ++e)
 
 1015         npts = bcexp->GetExp(e)->GetTotPoints();
 
 1016         id1  = bcexp->GetPhys_Offset(e);
 
 1017         id2  = 
m_fields[0]->GetTrace()->GetPhys_Offset(
 
 1018                m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
 
 1025                 ASSERTL0(
false, 
"1D not yet implemented for Boussinesq");
 
 1036                                    &tmp_n[0],    1, &tmp_n[0],               1);
 
 1041                                    &tmp_t[0],    1, &tmp_t[0],               1);
 
 1050                                    &Fwd[0][id2], 1, &Fwd[0][id2],            1);
 
 1055                                    &Fwd[1][id2], 1, &Fwd[1][id2],            1);
 
 1059                 ASSERTL0(
false, 
"3D not implemented for Boussinesq equations");
 
 1062                 ASSERTL0(
false, 
"Illegal expansion dimension");
 
 1066         bcexp = 
m_fields[1]->GetBndCondExpansions()[bcRegion];
 
 1067         Vmath::Vcopy(npts, &Fwd[0][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
 
 1069         bcexp = 
m_fields[2]->GetBndCondExpansions()[bcRegion];
 
 1070         Vmath::Vcopy(npts, &Fwd[1][id2], 1, &(bcexp->UpdatePhys())[id1], 1);
 
 1081     for (
int n = 0; n < 
m_fields[0]->GetBndConditions().num_elements(); ++n)
 
 1085         if(boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
"Wall"))
 
 1090         if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
 
 1095         cnt += 
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize() - 1;
 
 1108     m_fields[0]->ExtractTracePhys(inarray, z);
 
 1112     int e, id1, id2, 
npts;
 
 1114                                 m_fields[0]->GetBndCondExpansions()[bcRegion];
 
 1116     for (e = 0; e < bcexp->GetExpSize(); ++e)
 
 1118         npts = bcexp->GetExp(e)->GetTotPoints();
 
 1119         id1  = bcexp->GetPhys_Offset(e);
 
 1120         id2  = 
m_fields[0]->GetTrace()->GetPhys_Offset(
 
 1121                m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
 
 1125         bcexp = 
m_fields[1]->GetBndCondExpansions()[bcRegion];
 
 1126         Vmath::Vcopy(npts, &z[id2], 1, &(bcexp->UpdatePhys())[id1], 1);
 
 1151     m_fields[1]->GetFwdBwdTracePhys(physfield, Fwd[0], Bwd[0]);
 
 1156     for (i = 0; i < nTraceNumPoints; ++i)
 
 1158         outX[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
 
 1159         outY[i] = 0.5 * (Fwd[0][i] + Bwd[0][i]);
 
 1184     for (
int i = 0; i < nq; i++)
 
 1186         (
m_fields[0]->UpdatePhys())[i] = amp * pow((1.0 / cosh(
 
 1187                                 sqrt(0.75 * (amp / (d * d * d))) *
 
 1188                                 (A * (x0[i] + x_offset) - C * time))), 2.0);
 
 1189         (
m_fields[1]->UpdatePhys())[i] = (amp / d) * pow((1.0 / cosh(
 
 1190                                     sqrt(0.75 * (amp / (d * d * d))) *
 
 1191                                     (A * (x0[i] + x_offset) - C * time)
 
 1192                                 )), 2.0) * sqrt(
m_g * d);
 
 1202     for (
int i = 0; i < 4; ++i)
 
 1216         bool dumpInitialConditions,
 
 1229             EquationSystem::v_SetInitialConditions(initialtime, 
false);
 
 1234     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 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. 
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object. 
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
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 WallBoundary(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &physarray)
Wall boundary condition. 
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()
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 WallBoundary2D(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &physarray)
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[]