Nektar++
Functions
ShallowWaterSolver.cpp File Reference
#include <LibUtilities/BasicUtils/SessionReader.h>
#include <LibUtilities/BasicUtils/Timer.h>
#include <SolverUtils/EquationSystem.h>

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 43 of file ShallowWaterSolver.cpp.

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
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
double NekDouble

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::Timer::Elapsed(), Nektar::SolverUtils::GetEquationSystemFactory(), Nektar::LibUtilities::Timer::Start(), and Nektar::LibUtilities::Timer::Stop().