63 "Auxiliary functions for the shallow water system.");
138 unsigned int nvariables =
m_fields.size();
139 int ntotal = nvariables *
m_fields[0]->GetNpoints();
145 m_session->LoadParameter(
"NekLinSysMaxIterations",
148 m_session->LoadParameter(
"LinSysRelativeTolInNonlin",
155 m_session->LoadParameter(
"NekNonlinSysMaxIterations",
157 m_session->LoadParameter(
"NewtonRelativeIteTol",
160 "Please specify NewtonRelativeIteTol instead of "
161 "NewtonAbsoluteIteTol in XML session file");
162 m_session->LoadParameter(
"NonlinIterTolRelativeL2",
164 m_session->LoadSolverInfo(
"LinSysIterSolverTypeInNonlin",
187 unsigned int npoints =
m_fields[0]->GetNpoints();
188 unsigned int nvariables =
m_fields.size();
194 for (
int i = 0; i < nvariables; ++i)
196 int noffset = i * npoints;
197 Vmath::Vcopy(npoints, inpnts[i], 1, tmp = inarray + noffset, 1);
202 for (
int i = 0; i < nvariables; ++i)
204 int noffset = i * npoints;
205 Vmath::Vcopy(npoints, outarray + noffset, 1, outpnt[i], 1);
226 unsigned int npoints =
m_fields[0]->GetNpoints();
230 for (
int i = 0; i < 3; ++i)
232 int offset = i * npoints;
234 Vmath::Dot(npoints, inarray + offset, inarray + offset);
236 m_comm->GetSpaceComm()->AllReduce(magnitdEstimat,
240 for (
int i = 0; i < 3; ++i)
248 [[maybe_unused]]
const bool &flag)
250 unsigned int npoints =
m_fields[0]->GetNpoints();
251 unsigned int nvariables =
m_fields.size();
254 for (
int i = 0; i < nvariables; ++i)
256 int offset = i * npoints;
257 in2D[i] = inarray + offset;
258 out2D[i] = out + offset;
267 unsigned int npoints =
m_fields[0]->GetNpoints();
268 unsigned int nvariables =
m_fields.size();
270 for (
int i = 0; i < nvariables; ++i)
278 for (
int i = 0; i < nvariables; ++i)
283 m_nonlinsol->GetRefSourceVec() + i * npoints, 1, out[i], 1);
289 [[maybe_unused]]
const bool &flag)
294 unsigned int ntotal = inarray.size();
296 m_comm->GetSpaceComm()->AllReduce(magninarray,
304 Vmath::Svtvp(ntotal, eps, inarray, 1, solref, 1, solplus, 1);
306 Vmath::Vsub(ntotal, resplus, 1, resref, 1, out, 1);
321 int nvariables = inarray.size();
328 if (inarray != outarray)
332 for (
int i = 0; i < nvariables; ++i)
346 for (
int i = 0; i < nvariables; ++i)
348 m_fields[i]->FwdTrans(inarray[i], coeffs);
349 m_fields[i]->BwdTrans(coeffs, outarray[i]);
354 ASSERTL0(
false,
"Unknown projection scheme");
370 for (
int i = 0; i < nvariables; ++i)
373 m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
377 for (
int n = 0; n <
m_fields[0]->GetBndConditions().size(); ++n)
379 if (
m_fields[0]->GetBndConditions()[n]->GetBoundaryConditionType() ==
386 if (boost::iequals(
m_fields[0]->GetBndConditions()[n]->GetUserDefined(),
393 if (
m_fields[0]->GetBndConditions()[n]->IsTimeDependent())
395 for (
int i = 0; i < nvariables; ++i)
398 m_fields[i]->EvaluateBoundaryConditions(time, varName);
401 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
418 ->GetBndCondExpansions()[bcRegion]
421 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
422 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
423 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt + e));
441 &tmp_n[0], 1, &tmp_n[0], 1);
446 &tmp_t[0], 1, &tmp_t[0], 1);
455 &Fwd[1][id2], 1, &Fwd[1][id2], 1);
460 &Fwd[2][id2], 1, &Fwd[2][id2], 1);
465 "3D not implemented for Shallow Water Equations");
468 ASSERTL0(
false,
"Illegal expansion dimension");
472 for (
int i = 0; i < nvariables; ++i)
476 ->GetBndCondExpansions()[bcRegion]
477 ->UpdatePhys())[id1],
500 m_fields[0]->IProductWRTBase(tmp, mod);
501 m_fields[0]->MultiplyByElmtInvMass(mod, mod);
503 Vmath::Vadd(nq, tmp, 1, outarray[1], 1, outarray[1], 1);
508 m_fields[0]->IProductWRTBase(tmp, mod);
509 m_fields[0]->MultiplyByElmtInvMass(mod, mod);
511 Vmath::Vadd(nq, tmp, 1, outarray[2], 1, outarray[2], 1);
518 Vmath::Vadd(nq, tmp, 1, outarray[1], 1, outarray[1], 1);
523 Vmath::Vadd(nq, tmp, 1, outarray[2], 1, outarray[2], 1);
527 ASSERTL0(
false,
"Unknown projection scheme for the NonlinearSWE");
#define ASSERTL0(condition, msg)
#define WARNINGL0(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.
NekDouble m_NekNonLinSysTolerance
NekDouble m_NonlinIterTolRelativeL2
int m_NekNonlinSysMaxIterations
NekDouble m_NekLinSysTolerance
std::string m_LinSysIterSolverTypeInNonlin
int m_KrylovMaxHessMatBand
int m_NekLinSysMaxIterations
void DefineNekSysResEval(FuncPointerT func, ObjectPointerT obj)
void DefineNekSysLhsEval(FuncPointerT func, ObjectPointerT obj)
void DefineNekSysPrecon(FuncPointerT func, ObjectPointerT obj)
NekDouble m_g
Acceleration of gravity.
void MatrixMultiplyMatrixFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out, const bool &flag)
static std::string className
Name of class.
void WallBoundary2D(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble > > &Fwd)
void EvaluateWaterDepth(void)
Array< OneD, Array< OneD, NekDouble > > m_bottomSlope
void InitialiseNonlinSysSolver(void)
void DoImplicitSolve1D(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out)
void SetBoundaryConditions(const Array< OneD, const Array< OneD, NekDouble > > &physarray, NekDouble time)
void EvaluateCoriolis(void)
NekDouble m_bndEvaluateTime
void AddCoriolis(const Array< OneD, const Array< OneD, NekDouble > > &physarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
LibUtilities::NekNonlinSysIterSharedPtr m_nonlinsol
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
void NonlinSysEvaluator(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &out)
void DoNullPrecon(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const bool &flag)
void PrimitiveToConservative()
virtual void v_DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
bool m_constantDepth
Indicates if constant depth case.
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Print a summary of time stepping parameters.
ShallowWaterSystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Initialises UnsteadySystem class members.
Array< OneD, NekDouble > m_coriolis
Coriolis force.
void NonlinSysEvaluator1D(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out, const bool &flag)
NekDouble m_TimeIntegLambda
void DoImplicitSolve(const Array< OneD, const Array< OneD, NekDouble > > &inpnts, Array< OneD, Array< OneD, NekDouble > > &outpnt, const NekDouble time, const NekDouble lambda)
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
Array< OneD, NekDouble > m_depth
Still water depth.
static SolverUtils::EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
NekDouble m_jacobiFreeEps
void v_InitObject(bool DeclareFields=true) override
Init object for UnsteadySystem class.
void ConservativeToPrimitive()
void CalcRefValues(const Array< OneD, const NekDouble > &inarray)
int m_spacedim
Spatial dimension (>= expansion dim).
int m_expdim
Expansion dimension.
LibUtilities::CommSharedPtr m_comm
Communicator.
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 SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
SOLVER_UTILS_EXPORT int GetTotPoints()
Base class for unsteady solvers.
bool m_explicitAdvection
Indicates if explicit or implicit treatment of advection is used.
SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s) override
Print a summary of time stepping parameters.
SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareField=true) override
Init object for UnsteadySystem class.
NekNonlinSysIterFactory & GetNekNonlinSysIterFactory()
std::shared_ptr< SessionReader > SessionReaderSharedPtr
MultiRegions::Direction const DirCartesianMap[]
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.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
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 Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Svtvp (scalar times vector plus vector): z = alpha*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
T Dot(int n, const T *w, const T *x)
dot product
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 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.
scalarT< T > sqrt(scalarT< T > in)