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 
37 
38 using namespace std;
39 using namespace Nektar;
40 using namespace Nektar::SolverUtils;
41 
42 int main(int argc, char *argv[])
43 {
44  // Create session reader and MeshGraph.
46  session = LibUtilities::SessionReader::CreateInstance(argc, argv);
47 
49  graph = SpatialDomains::MeshGraph::Read(session);
50 
51  time_t starttime, endtime;
52  NekDouble CPUtime;
54 
55  // Record start time.
56  time(&starttime);
57 
58  // Create instance of module to solve the equation specified in the session.
59  try
60  {
62  session->GetSolverInfo("EQTYPE"), session, graph);
63  }
64  catch (int e)
65  {
66  ASSERTL0(e == -1, "No such solver class defined.");
67  }
68 
69  // Print a summary of solver and problem parameters and initialise the
70  // solver.
71  equ->PrintSummary(cout);
72  equ->DoInitialise();
73 
74  // Solve the problem.
75  equ->DoSolve();
76 
77  // Record end time.
78  time(&endtime);
79  CPUtime = (1.0/60.0/60.0)*difftime(endtime,starttime);
80 
81  // Write output to .fld file
82  equ->Output();
83 
84  // Evaluate and output computation time and solution accuracy.
85  // The specific format of the error output is essential for the
86  // regression tests to work.
87  cout << "-------------------------------------------" << endl;
88  cout << "Total Computation Time = " << CPUtime << " hr." << endl;
89 
90 
91  for(int i = 0; i < equ->GetNvariables(); ++i)
92  {
93  cout << "L 2 error (variable " << equ->GetVariable(i) << "): " << equ->L2Error(i,true) << endl;
94  cout << "L inf error (variable " << equ->GetVariable(i) << "): " << equ->LinfError(i) << endl;
95  }
96 
97  session->Finalise();
98 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
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:145
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:174
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble