Nektar++
ShallowWaterSolver.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ShallowWaterSolver.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: Shallow Water Equations framework solver
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
38 
39 using namespace std;
40 using namespace Nektar;
41 using namespace Nektar::SolverUtils;
42 
43 int main(int argc, char *argv[])
44 {
45  // Create session reader and MeshGraph.
47  session = LibUtilities::SessionReader::CreateInstance(argc, argv);
48 
50  graph = SpatialDomains::MeshGraph::Read(session);
51 
53  NekDouble CPUtime;
55 
56  // Record start time.
57  timer.Start();
58 
59  // Create instance of module to solve the equation specified in the session.
60  try
61  {
63  session->GetSolverInfo("EQTYPE"), session, graph);
64  }
65  catch (int e)
66  {
67  ASSERTL0(e == -1, "No such solver class defined.");
68  }
69 
70  // Print a summary of solver and problem parameters and initialise the
71  // solver.
72  equ->PrintSummary(cout);
73  equ->DoInitialise();
74 
75  // Solve the problem.
76  equ->DoSolve();
77 
78  // Record end time.
79  timer.Stop();
80  CPUtime = (1.0 / 60.0 / 60.0) * timer.Elapsed().count();
81 
82  // Write output to .fld file
83  equ->Output();
84 
85  // Evaluate and output computation time and solution accuracy.
86  // The specific format of the error output is essential for the
87  // regression tests to work.
88  cout << "-------------------------------------------" << endl;
89  cout << "Total Computation Time = " << CPUtime << " hr." << endl;
90 
91  for (int i = 0; i < equ->GetNvariables(); ++i)
92  {
93  cout << "L 2 error (variable " << equ->GetVariable(i)
94  << "): " << equ->L2Error(i, true) << endl;
95  cout << "L inf error (variable " << equ->GetVariable(i)
96  << "): " << equ->LinfError(i) << endl;
97  }
98 
99  session->Finalise();
100 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
int main(int argc, char *argv[])
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< EquationSystem > EquationSystemSharedPtr
A shared pointer to an EquationSystem object.
EquationSystemFactory & GetEquationSystemFactory()
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:172
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble