Nektar++
ShallowWaterSystem.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ShallowWaterSystem.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Generic timestepping for shallow water solvers
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include <iostream>
36
38
39using namespace std;
40
41namespace Nektar
42{
43/**
44 * @class ShallowWaterSystem
45 *
46 * Provides the underlying timestepping framework for shallow water flow solvers
47 * including the general timestepping routines. This class is not intended
48 * to be directly instantiated, but rather is a base class on which to
49 * define shallow water solvers, e.g. SWE, Boussinesq, linear and nonlinear
50 * versions.
51 *
52 * For details on implementing unsteady solvers see
53 * \ref sectionADRSolverModuleImplementation
54 */
55
56/**
57 * Processes SolverInfo parameters from the session file and sets up
58 * timestepping-specific code.
59 * @param pSession Session object to read parameters from.
60 */
61
64 "ShallowWaterSystem", ShallowWaterSystem::create,
65 "Auxiliary functions for the shallow water system.");
66
70 : UnsteadySystem(pSession, pGraph)
71{
72}
73
74void ShallowWaterSystem::v_InitObject(bool DeclareFields)
75{
76 UnsteadySystem::v_InitObject(DeclareFields);
77
78 // if discontinuous Galerkin determine numerical flux to use
80 {
81 ASSERTL0(m_session->DefinesSolverInfo("UPWINDTYPE"),
82 "No UPWINDTYPE defined in session.");
83 }
84
85 // Set up locations of velocity vector.
88 for (int i = 0; i < m_spacedim; ++i)
89 {
90 m_vecLocs[0][i] = 1 + i;
91 }
92
93 // Load acceleration of gravity
94 m_session->LoadParameter("Gravity", m_g, 9.81);
95
96 // input/output in primitive variables
97 m_primitive = true;
98
100
101 m_constantDepth = true;
102 NekDouble depth = m_depth[0];
103 for (int i = 0; i < GetTotPoints(); ++i)
104 {
105 if (m_depth[i] != depth)
106 {
107 m_constantDepth = false;
108 break;
109 }
110 }
111
112 // Compute the bottom slopes
113 int nq = GetTotPoints();
114 if (m_constantDepth != true)
115 {
117 for (int i = 0; i < m_spacedim; ++i)
118 {
121 m_bottomSlope[i]);
122 Vmath::Neg(nq, m_bottomSlope[i], 1);
123 }
124 }
125
127}
128
129/**
130 *
131 */
133{
134}
135
137{
139 if (m_constantDepth == true)
140 {
141 SolverUtils::AddSummaryItem(s, "Depth", "constant");
142 }
143 else
144 {
145 SolverUtils::AddSummaryItem(s, "Depth", "variable");
146 }
147}
148
150{
151 ASSERTL0(false, "This function is not implemented for this equation.");
152}
153
155{
156 ASSERTL0(false, "This function is not implemented for this equation.");
157}
158
160{
161 GetFunction("WaterDepth")->Evaluate("d", m_depth);
162}
163
165{
166 GetFunction("Coriolis")->Evaluate("f", m_coriolis);
167}
168
171{
172
173 int cnt = 0;
174 // loop over Boundary Regions
175 for (int bcRegion = 0; bcRegion < m_fields[0]->GetBndConditions().size();
176 ++bcRegion)
177 {
178 if (m_fields[0]
179 ->GetBndConditions()[bcRegion]
180 ->GetBoundaryConditionType() == SpatialDomains::ePeriodic)
181 {
182 continue;
183 }
184
185 // Copy the forward trace of the field to the backward trace
186 int e, id2, npts;
187
188 for (e = 0;
189 e < m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
190 ++e)
191 {
192 npts = m_fields[0]
193 ->GetBndCondExpansions()[bcRegion]
194 ->GetExp(e)
195 ->GetTotPoints();
196 id2 = m_fields[0]->GetTrace()->GetPhys_Offset(
197 m_fields[0]->GetTraceMap()->GetBndCondIDToGlobalTraceID(cnt +
198 e));
199
200 Vmath::Vcopy(npts, &Fwd[id2], 1, &Bwd[id2], 1);
201 }
202
203 cnt += m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
204 }
205}
206
207} // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:197
NekDouble m_g
Acceleration of gravity.
void CopyBoundaryTrace(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
Array< OneD, Array< OneD, NekDouble > > m_bottomSlope
bool m_constantDepth
Indicates if constant depth case.
bool m_primitive
Indicates if variables are primitive or conservative.
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.
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.
void v_InitObject(bool DeclareFields=true) override
Init object for UnsteadySystem class.
static std::string className
Name of class.
~ShallowWaterSystem() override
Destructor.
int m_spacedim
Spatial dimension (>= expansion dim).
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
SOLVER_UTILS_EXPORT int GetExpSize()
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
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.
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.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:86
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:47
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
double NekDouble
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.hpp:292
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825