35 #include <boost/algorithm/string.hpp>
46 string LinearSWE::className =
48 "LinearSWE", LinearSWE::create,
49 "Linear shallow water equation in primitive variables.");
68 ASSERTL0(
false,
"Implicit SWE not set up.");
91 m_session->LoadSolverInfo(
"AdvectionType", advName,
"WeakDG");
104 m_session->LoadSolverInfo(
"UpwindType", riemName,
"NoSolver");
107 ASSERTL0(
false,
"LinearHLL only valid for constant depth");
123 int nTracePointsTot =
m_fields[0]->GetTrace()->GetTotPoints();
153 ASSERTL0(
false,
"Unsupported projection type.");
181 m_fields[0]->IProductWRTBase(tmp, mod);
182 m_fields[0]->MultiplyByElmtInvMass(mod, mod);
184 Vmath::Vadd(nq, tmp, 1, outarray[1], 1, outarray[1], 1);
189 m_fields[0]->IProductWRTBase(tmp, mod);
190 m_fields[0]->MultiplyByElmtInvMass(mod, mod);
192 Vmath::Vadd(nq, tmp, 1, outarray[2], 1, outarray[2], 1);
200 Vmath::Vadd(nq, tmp, 1, outarray[1], 1, outarray[1], 1);
205 Vmath::Vadd(nq, tmp, 1, outarray[2], 1, outarray[2], 1);
209 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
220 int nvariables = inarray.size();
240 for (i = 0; i < nvariables; ++i)
267 for (i = 0; i < nvariables; ++i)
270 for (j = 0; j < ndim; ++j)
285 for (i = 0; i < nvariables; ++i)
288 fluxvector[i][0], tmp);
290 fluxvector[i][1], tmp1);
308 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
318 int nvariables = inarray.size();
328 for (i = 0; i < nvariables; ++i)
342 for (i = 0; i < nvariables; ++i)
344 m_fields[i]->FwdTrans(inarray[i], coeffs);
345 m_fields[i]->BwdTrans(coeffs, outarray[i]);
350 ASSERTL0(
false,
"Unknown projection scheme");
367 for (
int i = 0; i < nvariables; ++i)
370 m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
374 for (
int n = 0; n <
m_fields[0]->GetBndConditions().size(); ++n)
376 if (
m_fields[0]->GetBndConditions()[n]->GetBoundaryConditionType() ==
383 if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
390 if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
392 for (
int i = 0; i < nvariables; ++i)
395 m_fields[i]->EvaluateBoundaryConditions(time, varName);
398 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
411 int nvariables = physarray.size();
415 int e, id1, id2, npts;
421 ->GetBndCondExpansions()[bcRegion]
424 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
425 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
426 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
435 &tmp[0], 1, &tmp[0], 1);
445 &Fwd[1 + i][id2], 1, &Fwd[1 + i][id2], 1);
449 for (i = 0; i < nvariables; ++i)
453 ->GetBndCondExpansions()[bcRegion]
454 ->UpdatePhys())[id1],
466 int nvariables = physarray.size();
470 int e, id1, id2, npts;
476 ->GetBndCondExpansions()[bcRegion]
479 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
480 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
481 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
499 &tmp_n[0], 1, &tmp_n[0], 1);
504 &tmp_t[0], 1, &tmp_t[0], 1);
513 &Fwd[1][id2], 1, &Fwd[1][id2], 1);
518 &Fwd[2][id2], 1, &Fwd[2][id2], 1);
523 "3D not implemented for Shallow Water Equations");
526 ASSERTL0(
false,
"Illegal expansion dimension");
530 for (i = 0; i < nvariables; ++i)
534 ->GetBndCondExpansions()[bcRegion]
535 ->UpdatePhys())[id1],
547 int nq =
m_fields[0]->GetTotPoints();
572 Vmath::Vadd(nq, flux[i + 1][i], 1, tmp, 1, flux[i + 1][i], 1);
582 if (physin.get() == physout.get())
586 for (
int i = 0; i < 3; ++i)
597 Vmath::Vdiv(nq, tmp[1], 1, tmp[0], 1, physout[1], 1);
600 Vmath::Vdiv(nq, tmp[2], 1, tmp[0], 1, physout[2], 1);
608 Vmath::Vdiv(nq, physin[1], 1, physin[0], 1, physout[1], 1);
611 Vmath::Vdiv(nq, physin[2], 1, physin[0], 1, physout[2], 1);
639 if (physin.get() == physout.get())
643 for (
int i = 0; i < 3; ++i)
654 Vmath::Vmul(nq, physout[0], 1, tmp[1], 1, physout[1], 1);
657 Vmath::Vmul(nq, physout[0], 1, tmp[2], 1, physout[2], 1);
665 Vmath::Vmul(nq, physout[0], 1, physin[1], 1, physout[1], 1);
668 Vmath::Vmul(nq, physout[0], 1, physin[2], 1, physout[2], 1);
700 const int npts = physfield[0].size();
704 Vmath::Vcopy(npts, physfield[1 + i], 1, velocity[i], 1);
711 if (
m_session->DefinesSolverInfo(
"UpwindType"))
#define ASSERTL0(condition, msg)
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 DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
virtual void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print a summary of time stepping parameters.
void GetVelocityVector(const Array< OneD, Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, NekDouble >> &velocity)
Compute the velocity field given the momentum .
void AddCoriolis(const Array< OneD, const Array< OneD, NekDouble >> &physarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
const Array< OneD, NekDouble > & GetDepthFwd()
virtual void v_ConservativeToPrimitive() override
void WallBoundary2D(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble >> &physarray, NekDouble time)
void GetFluxVector(const Array< OneD, const Array< OneD, NekDouble >> &physfield, Array< OneD, Array< OneD, Array< OneD, NekDouble >>> &flux)
virtual void v_InitObject(bool DeclareFields=true) override
Init object for UnsteadySystem class.
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
virtual void v_PrimitiveToConservative() override
Array< OneD, NekDouble > m_dFwd
Still water depth traces.
void WallBoundary(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
Wall boundary condition.
Array< OneD, NekDouble > m_dBwd
const Array< OneD, NekDouble > & GetDepthBwd()
Base class for unsteady solvers.
NekDouble m_g
Acceleration of gravity.
void CopyBoundaryTrace(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
SolverUtils::RiemannSolverSharedPtr m_riemannSolver
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
SolverUtils::AdvectionSharedPtr m_advection
void PrimitiveToConservative()
bool m_constantDepth
Indicates if constant depth case.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print a summary of time stepping parameters.
Array< OneD, NekDouble > m_coriolis
Coriolis force.
Array< OneD, NekDouble > m_depth
Still water depth.
virtual void v_InitObject(bool DeclareFields=true) override
Init object for UnsteadySystem class.
void ConservativeToPrimitive()
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs()
int m_spacedim
Spatial dimension (>= expansion dim).
int m_expdim
Expansion dimension.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
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 GetNpoints()
SOLVER_UTILS_EXPORT int GetNcoeffs()
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()
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
MultiRegions::Direction const DirCartesianMap[]
@ eMixed_CG_Discontinuous
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
std::vector< std::pair< std::string, std::string > > SummaryList
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()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
The above copyright notice and this permission notice shall be included.
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 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 Zero(int n, T *x, const int incx)
Zero vector.
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.