Nektar++
Functions
ShallowWaterSolver.cpp File Reference
#include <SolverUtils/EquationSystem.h>
#include <LibUtilities/BasicUtils/SessionReader.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 42 of file ShallowWaterSolver.cpp.

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

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