Nektar++
DriverStandard.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File DriverStandard.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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Incompressible Navier Stokes solver
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include <iomanip>
37 
39 
40 namespace Nektar
41 {
42  namespace SolverUtils
43  {
46 
47  /**
48  *
49  */
51  : Driver(pSession)
52  {
53  }
54 
55 
56  /**
57  *
58  */
60  {
61  }
62 
63 
64  /**
65  *
66  */
67  void DriverStandard::v_InitObject(ostream &out)
68  {
70  }
71 
72 
73  void DriverStandard::v_Execute(ostream &out)
74 
75  {
76  time_t starttime, endtime;
77  NekDouble CPUtime;
78 
79  m_equ[0]->PrintSummary(out);
80 
81  time(&starttime);
82 
83  m_equ[0]->DoInitialise();
84  m_equ[0]->DoSolve();
85 
86  time(&endtime);
87 
88  m_equ[0]->Output();
89 
90  if (m_comm->GetRank() == 0)
91  {
92  CPUtime = difftime(endtime, starttime);
93  cout << "-------------------------------------------" << endl;
94  cout << "Total Computation Time = " << CPUtime << "s" << endl;
95  cout << "-------------------------------------------" << endl;
96  }
97 
98  // Evaluate and output computation time and solution accuracy.
99  // The specific format of the error output is essential for the
100  // regression tests to work.
101  // Evaluate L2 Error
102  for(int i = 0; i < m_equ[0]->GetNvariables(); ++i)
103  {
104  Array<OneD, NekDouble> exactsoln(m_equ[0]->GetTotPoints(), 0.0);
105 
106  // Evaluate "ExactSolution" function, or zero array
107  m_equ[0]->EvaluateExactSolution(i, exactsoln,
108  m_equ[0]->GetFinalTime());
109 
110  NekDouble vL2Error = m_equ[0]->L2Error (i, exactsoln);
111  NekDouble vLinfError = m_equ[0]->LinfError(i, exactsoln);
112 
113  if (m_comm->GetRank() == 0)
114  {
115  out << "L 2 error (variable " << m_equ[0]->GetVariable(i)
116  << ") : " << vL2Error << endl;
117  out << "L inf error (variable " << m_equ[0]->GetVariable(i)
118  << ") : " << vLinfError << endl;
119  }
120  }
121  }
122  }
123 }
124 
static std::string className
Name of the class.
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
virtual SOLVER_UTILS_EXPORT void v_InitObject(ostream &out=cout)
Definition: Driver.cpp:90
virtual SOLVER_UTILS_EXPORT void v_Execute(ostream &out=cout)
Virtual function for solve implementation.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:50
virtual SOLVER_UTILS_EXPORT void v_InitObject(ostream &out=cout)
Second-stage initialisation.
SOLVER_UTILS_EXPORT DriverStandard(const LibUtilities::SessionReaderSharedPtr pSession)
Constructor.
double NekDouble
virtual SOLVER_UTILS_EXPORT ~DriverStandard()
Destructor.
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:94
DriverFactory & GetDriverFactory()
Definition: Driver.cpp:64
LibUtilities::CommSharedPtr m_comm
Communication object.
Definition: Driver.h:85
Base class for the development of solvers.
Definition: Driver.h:65
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession)
Creates an instance of this class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215