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 
39 using namespace std;
40 
41 namespace 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 versions.
50  *
51  * For details on implementing unsteady solvers see
52  * \ref sectionADRSolverModuleImplementation
53  */
54 
55  /**
56  * Processes SolverInfo parameters from the session file and sets up
57  * timestepping-specific code.
58  * @param pSession Session object to read parameters from.
59  */
60 
61  string ShallowWaterSystem::className =
63  "ShallowWaterSystem",
64  ShallowWaterSystem::create,
65  "Auxiliary functions for the shallow water system.");
66 
67 
68  ShallowWaterSystem::ShallowWaterSystem(
71  : UnsteadySystem(pSession, pGraph)
72  {
73  }
74 
76  {
78 
79  // if discontinuous Galerkin determine numerical flux to use
81  {
82  ASSERTL0(m_session->DefinesSolverInfo("UPWINDTYPE"),
83  "No UPWINDTYPE defined in session.");
84  }
85 
86  // Set up locations of velocity vector.
88  m_vecLocs[0] = Array<OneD, NekDouble>(m_spacedim);
89  for (int i = 0; i < m_spacedim; ++i)
90  {
91  m_vecLocs[0][i] = 1 + i;
92  }
93 
94  // Load generic input parameters
95  m_session->LoadParameter("IO_InfoSteps", m_infosteps, 0);
96 
97  // Load acceleration of gravity
98  m_session->LoadParameter("Gravity", m_g, 9.81);
99 
100  // input/output in primitive variables
101  m_primitive = true;
102 
104 
105  m_constantDepth = true;
106  NekDouble depth = m_depth[0];
107  for (int i = 0; i < GetTotPoints(); ++i)
108  {
109  if (m_depth[i] != depth)
110  {
111  m_constantDepth = false;
112  break;
113  }
114  }
115 
116  // Compute the bottom slopes
117  int nq = GetTotPoints();
118  if (m_constantDepth != true)
119  {
121  for (int i = 0; i < m_spacedim; ++i)
122  {
125  Vmath::Neg(nq,m_bottomSlope[i],1);
126  }
127  }
128 
130 
131  }
132 
133 
134  /**
135  *
136  */
138  {
139  }
140 
141 
143  {
145  if (m_constantDepth == true)
146  {
147  SolverUtils::AddSummaryItem(s, "Depth", "constant");
148  }
149  else
150  {
151  SolverUtils::AddSummaryItem(s, "Depth", "variable");
152  }
153 
154 
155  }
156 
158  {
159  ASSERTL0(false, "This function is not implemented for this equation.");
160  }
161 
163  {
164  ASSERTL0(false, "This function is not implemented for this equation.");
165  }
166 
168  {
169  GetFunction("WaterDepth")->Evaluate("d", m_depth);
170  }
171 
172 
174  {
175  GetFunction("Coriolis")->Evaluate("f", m_coriolis);
176  }
177 
179  {
180 
181  int cnt = 0;
182  // loop over Boundary Regions
183  for(int bcRegion = 0; bcRegion < m_fields[0]->GetBndConditions().num_elements(); ++bcRegion)
184  {
185  if (m_fields[0]->GetBndConditions()[bcRegion]->GetBoundaryConditionType()
187  {
188  continue;
189  }
190 
191  // Copy the forward trace of the field to the backward trace
192  int e, id2, npts;
193 
194  for (e = 0; e < m_fields[0]->GetBndCondExpansions()[bcRegion]
195  ->GetExpSize(); ++e)
196  {
197  npts = m_fields[0]->GetBndCondExpansions()[bcRegion]->
198  GetExp(e)->GetTotPoints();
199  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(
200  m_fields[0]->GetTraceMap()->
201  GetBndCondCoeffsToGlobalCoeffsMap(cnt+e));
202 
203  Vmath::Vcopy(npts, &Fwd[id2], 1, &Bwd[id2], 1);
204  }
205 
206  cnt +=m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
207  }
208  }
209 
210 }
Array< OneD, NekDouble > m_coriolis
Coriolis force.
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:163
bool m_primitive
Indicates if variables are primitive or conservative.
Array< OneD, NekDouble > m_depth
Still water depth.
std::vector< std::pair< std::string, std::string > > SummaryList
Definition: Misc.h:46
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
STL namespace.
SOLVER_UTILS_EXPORT int GetTotPoints()
virtual SOLVER_UTILS_EXPORT void v_GenerateSummary(SummaryList &s)
Print a summary of time stepping parameters.
Array< OneD, Array< OneD, NekDouble > > m_bottomSlope
virtual void v_InitObject()
Init object for UnsteadySystem class.
Base class for unsteady solvers.
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
Definition: Misc.cpp:49
int m_spacedim
Spatial dimension (>= expansion dim).
void CopyBoundaryTrace(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
void Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:399
double NekDouble
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
EquationSystemFactory & GetEquationSystemFactory()
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
MultiRegions::Direction const DirCartesianMap[]
Definition: ExpList.h:88
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
virtual ~ShallowWaterSystem()
Destructor.
bool m_constantDepth
Indicates if constant depth case.
int m_infosteps
Number of time steps between outputting status information.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
NekDouble m_g
Acceleration of gravity.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
std::shared_ptr< SessionReader > SessionReaderSharedPtr