Nektar++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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// 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: Driver class for the standard solver
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include <iomanip>
36
39
40namespace Nektar::SolverUtils
41{
42std::string DriverStandard::className =
47
48/**
49 *
50 */
54 : Driver(pSession, pGraph)
55{
56}
57
58/**
59 *
60 */
61void DriverStandard::v_InitObject(std::ostream &out)
62{
64}
65
66/**
67 *
68 */
69void DriverStandard::v_Execute(std::ostream &out)
70
71{
73 NekDouble CPUtime;
74
75 m_equ[0]->PrintSummary(out);
76
77 timer.Start();
78
79 m_equ[0]->DoInitialise();
80 m_equ[0]->DoSolve();
81
82 timer.Stop();
83
84 m_equ[0]->Output();
85
86 if (m_comm->GetRank() == 0)
87 {
88 CPUtime = timer.Elapsed().count();
89 std::cout << "-------------------------------------------" << std::endl;
90 std::cout << "Total Computation Time = " << CPUtime << "s" << std::endl;
91 std::cout << "-------------------------------------------" << std::endl;
92 }
93
94 // Evaluate and output computation time and solution accuracy.
95 // The specific format of the error output is essential for the
96 // regression tests to work.
97
98 // Evaluate L2 Error
99 for (int i = 0; i < m_equ[0]->GetNvariables(); ++i)
100 {
101 Array<OneD, NekDouble> exactsoln(m_equ[0]->GetTotPoints(), 0.0);
102
103 // Evaluate "ExactSolution" function, or zero array
104 m_equ[0]->EvaluateExactSolution(i, exactsoln, m_equ[0]->GetTime());
105
106 NekDouble vL2Error = m_equ[0]->L2Error(i, exactsoln);
107 NekDouble vLinfError = m_equ[0]->LinfError(i, exactsoln);
108
109 if (m_comm->GetRank() == 0)
110 {
111 out << "L 2 error (variable " << m_equ[0]->GetVariable(i)
112 << ") : " << vL2Error << std::endl;
113 out << "L inf error (variable " << m_equ[0]->GetVariable(i)
114 << ") : " << vLinfError << std::endl;
115 }
116 }
117}
118} // namespace Nektar::SolverUtils
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.
Base class for the development of solvers.
Definition: Driver.h:65
virtual SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout)
Virtual function for initialisation implementation.
Definition: Driver.cpp:82
LibUtilities::CommSharedPtr m_comm
Communication object.
Definition: Driver.h:80
Array< OneD, EquationSystemSharedPtr > m_equ
Equation system to solve.
Definition: Driver.h:92
SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout) override
Virtual function for initialisation implementation.
SOLVER_UTILS_EXPORT void v_Execute(std::ostream &out=std::cout) override
Virtual function for solve implementation.
SOLVER_UTILS_EXPORT DriverStandard(const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
Constructor.
static std::string className
Name of the class.
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
DriverFactory & GetDriverFactory()
Definition: Driver.cpp:64
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
double NekDouble