Nektar++
DriverParareal.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File DriverParareal.h
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 parareal solver
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_SOLVERUTILS_DRIVERPARAREAL_H
36#define NEKTAR_SOLVERUTILS_DRIVERPARAREAL_H
37
39
40namespace Nektar
41{
42namespace SolverUtils
43{
44
45/// Base class for the development of solvers.
47{
48public:
49 friend class MemoryManager<DriverParareal>;
50
51 /// Creates an instance of this class
55 {
58 p->InitObject();
59 return p;
60 }
61
62 /// Name of the class
63 static std::string className;
64
65protected:
66 /// Constructor
70
71 /// Destructor
73
74 /// Virtual function for initialisation implementation.
76 std::ostream &out = std::cout) override;
77
78 /// Virtual function for solve implementation.
79 SOLVER_UTILS_EXPORT virtual void v_Execute(
80 std::ostream &out = std::cout) override;
81
82 virtual NekDouble v_EstimateCommunicationTime(void) override;
83
84 virtual NekDouble v_EstimateRestrictionTime(void) override;
85
86 virtual NekDouble v_EstimateInterpolationTime(void) override;
87
88 virtual NekDouble v_EstimateCoarseSolverTime(void) override;
89
90 virtual NekDouble v_EstimateFineSolverTime(void) override;
91
92 virtual NekDouble v_EstimatePredictorTime(void) override;
93
94 virtual NekDouble v_EstimateOverheadTime(void) override;
95
97 const size_t iter, NekDouble fineSolveTime, NekDouble coarseSolveTime,
98 NekDouble restTime, NekDouble interTime, NekDouble commTime,
99 NekDouble predictorOverheadTime, NekDouble overheadTime) override;
100
101 static std::string driverLookupId;
102
103private:
104 void AssertParameters(void);
105
106 void RunCoarseSolve(const NekDouble time, const size_t nstep,
107 const Array<OneD, const Array<OneD, NekDouble>> &input,
109
110 void RunFineSolve(const NekDouble time, const size_t nstep,
111 const size_t iter, const size_t wd,
112 const Array<OneD, const Array<OneD, NekDouble>> &input,
114
116 const Array<OneD, const Array<OneD, NekDouble>> &coarse_new,
117 const Array<OneD, const Array<OneD, NekDouble>> &coarse_old,
119
120 void PrintSolutionFile(void);
121
122 void ApplyWindowing(const Array<OneD, const Array<OneD, NekDouble>> &in,
124
125 void CopyConvergedCheckPoints(const size_t w, const size_t k, size_t kmax);
126};
127
128} // namespace SolverUtils
129} // namespace Nektar
130
131#endif // NEKTAR_SOLVERUTILS_DRIVERPARAREAL_H
#define SOLVER_UTILS_EXPORT
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Base class for the development of parallel-in-time solvers.
Base class for the development of solvers.
virtual SOLVER_UTILS_EXPORT void v_Execute(std::ostream &out=std::cout) override
Virtual function for solve implementation.
virtual NekDouble v_EstimatePredictorTime(void) override
virtual SOLVER_UTILS_EXPORT ~DriverParareal()=default
Destructor.
void CopyConvergedCheckPoints(const size_t w, const size_t k, size_t kmax)
void ApplyWindowing(const Array< OneD, const Array< OneD, NekDouble > > &in, Array< OneD, Array< OneD, NekDouble > > &out)
static std::string className
Name of the class.
virtual NekDouble v_EstimateInterpolationTime(void) override
virtual NekDouble v_EstimateCommunicationTime(void) override
virtual SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout) override
Virtual function for initialisation implementation.
virtual NekDouble v_EstimateRestrictionTime(void) override
void RunFineSolve(const NekDouble time, const size_t nstep, const size_t iter, const size_t wd, const Array< OneD, const Array< OneD, NekDouble > > &input, Array< OneD, Array< OneD, NekDouble > > &output)
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
void PararealCorrection(const Array< OneD, const Array< OneD, NekDouble > > &coarse_new, const Array< OneD, const Array< OneD, NekDouble > > &coarse_old, Array< OneD, Array< OneD, NekDouble > > &fine)
SOLVER_UTILS_EXPORT DriverParareal(const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
Constructor.
virtual NekDouble v_EstimateFineSolverTime(void) override
virtual NekDouble v_EstimateOverheadTime(void) override
void RunCoarseSolve(const NekDouble time, const size_t nstep, const Array< OneD, const Array< OneD, NekDouble > > &input, Array< OneD, Array< OneD, NekDouble > > &output)
virtual NekDouble v_ComputeSpeedUp(const size_t iter, NekDouble fineSolveTime, NekDouble coarseSolveTime, NekDouble restTime, NekDouble interTime, NekDouble commTime, NekDouble predictorOverheadTime, NekDouble overheadTime) override
virtual NekDouble v_EstimateCoarseSolverTime(void) override
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
Definition: Driver.h:54
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:176
std::vector< double > w(NPUPPER)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble