Nektar++
DriverPFASST.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File DriverPFASST.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 PFASST solver
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_SOLVERUTILS_DRIVERPFASST_H
36#define NEKTAR_SOLVERUTILS_DRIVERPFASST_H
37
41
42namespace Nektar
43{
44namespace SolverUtils
45{
46
47/// Base class for the development of solvers.
49{
50public:
51 friend class MemoryManager<DriverPFASST>;
52
53 /// Creates an instance of this class
57 {
60 p->InitObject();
61 return p;
62 }
63
64 /// Name of the class
65 static std::string className;
66
67protected:
68 /// Constructor
72
73 /// Destructor
75
76 /// Virtual function for initialisation implementation.
78 std::ostream &out = std::cout) override;
79
80 /// Virtual function for solve implementation.
81 SOLVER_UTILS_EXPORT virtual void v_Execute(
82 std::ostream &out = std::cout) override;
83
84 virtual NekDouble v_EstimateCommunicationTime(void) override;
85
86 virtual NekDouble v_EstimateRestrictionTime(void) override;
87
88 virtual NekDouble v_EstimateInterpolationTime(void) override;
89
90 virtual NekDouble v_EstimateCoarseSolverTime(void) override;
91
92 virtual NekDouble v_EstimateFineSolverTime(void) override;
93
94 virtual NekDouble v_EstimatePredictorTime(void) override;
95
96 virtual NekDouble v_EstimateOverheadTime(void) override;
97
99 const size_t iter, NekDouble fineSolveTime, NekDouble coarseSolveTime,
100 NekDouble restTime, NekDouble interTime, NekDouble commTime,
101 NekDouble predictorOverheadTime, NekDouble overheadTime) override;
102
103 static std::string driverLookupId;
104
105private:
106 void AssertParameters(void);
107
108 void InitialiseSDCScheme(bool pfasst);
109
110 void SetTimeInterpolator(void);
111
112 bool IsNotInitialCondition(const size_t n);
113
114 void SetTime(const NekDouble &time);
115
117 std::shared_ptr<LibUtilities::TimeIntegrationSchemeSDC> SDCsolver,
118 const int index);
119
121
122 void UpdateFineFirstQuadrature(void);
123
124 void ComputeCoarseInitialGuess(void);
125
126 void ComputeFineInitialGuess(void);
127
128 void RunCoarseSweep(void);
129
130 void RunFineSweep(void);
131
132 void CoarseResidualEval(const size_t n);
133
134 void CoarseResidualEval(void);
135
136 void FineResidualEval(const size_t n);
137
138 void FineResidualEval(void);
139
141
143
144 void Interpolate(
145 const Array<OneD, Array<OneD, Array<OneD, NekDouble>>> &coarse,
146 Array<OneD, Array<OneD, Array<OneD, NekDouble>>> &fine, bool forced);
147
148 void InterpolateCoarseSolution(void);
149
150 void InterpolateCoarseResidual(void);
151
152 void Restrict(const Array<OneD, Array<OneD, Array<OneD, NekDouble>>> &fine,
154
155 void RestrictFineSolution(void);
156
157 void RestrictFineResidual(void);
158
159 void SaveCoarseSolution(void);
160
161 void SaveCoarseResidual(void);
162
163 void ComputeFASCorrection(void);
164
165 void Correct(const Array<OneD, Array<OneD, NekDouble>> &coarse,
166 Array<OneD, Array<OneD, NekDouble>> &fine, bool forced);
167
169
171
172 void Correct(const Array<OneD, Array<OneD, Array<OneD, NekDouble>>> &rest,
173 const Array<OneD, Array<OneD, Array<OneD, NekDouble>>> &coarse,
175 bool forced);
176
177 void CorrectFineSolution(void);
178
179 void CorrectFineResidual(void);
180
181 void ApplyWindowing(void);
182
183 void EvaluateSDCResidualNorm(void);
184
185 void WriteOutput(size_t chkPts);
186
187 // Storage of PFASST
194 std::shared_ptr<LibUtilities::TimeIntegrationSchemeSDC> m_fineSDCSolver;
195 std::shared_ptr<LibUtilities::TimeIntegrationSchemeSDC> m_coarseSDCSolver;
196
198};
199
200} // namespace SolverUtils
201} // namespace Nektar
202
203#endif // NEKTAR_SOLVERUTILS_DRIVERPFASST_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 solvers.
Definition: DriverPFASST.h:49
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_solutionRest
Definition: DriverPFASST.h:190
std::shared_ptr< LibUtilities::TimeIntegrationSchemeSDC > m_coarseSDCSolver
Definition: DriverPFASST.h:195
virtual NekDouble v_EstimateFineSolverTime(void) override
static std::string className
Name of the class.
Definition: DriverPFASST.h:65
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_EstimateRestrictionTime(void) override
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_residualRest
Definition: DriverPFASST.h:191
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
Definition: DriverPFASST.h:54
void Correct(const Array< OneD, Array< OneD, NekDouble > > &coarse, Array< OneD, Array< OneD, NekDouble > > &fine, bool forced)
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmpcoarse_arr
Definition: DriverPFASST.h:193
void SetTime(const NekDouble &time)
Array< OneD, NekDouble > m_ImatFtoC
Definition: DriverPFASST.h:188
virtual NekDouble v_EstimatePredictorTime(void) override
void Interpolate(const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &coarse, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &fine, bool forced)
virtual SOLVER_UTILS_EXPORT void v_Execute(std::ostream &out=std::cout) override
Virtual function for solve implementation.
virtual SOLVER_UTILS_EXPORT ~DriverPFASST()=default
Destructor.
virtual SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout) override
Virtual function for initialisation implementation.
Array< OneD, NekDouble > m_ImatCtoF
Definition: DriverPFASST.h:189
void CopyQuadratureSolutionAndResidual(std::shared_ptr< LibUtilities::TimeIntegrationSchemeSDC > SDCsolver, const int index)
virtual NekDouble v_EstimateCommunicationTime(void) override
virtual NekDouble v_EstimateCoarseSolverTime(void) override
virtual NekDouble v_EstimateInterpolationTime(void) override
virtual NekDouble v_EstimateOverheadTime(void) override
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_tmpfine_arr
Definition: DriverPFASST.h:192
SOLVER_UTILS_EXPORT DriverPFASST(const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
Constructor.
void Restrict(const Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &fine, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > &coarse)
static std::string driverLookupId
Definition: DriverPFASST.h:103
bool IsNotInitialCondition(const size_t n)
std::shared_ptr< LibUtilities::TimeIntegrationSchemeSDC > m_fineSDCSolver
Definition: DriverPFASST.h:194
Base class for the development of parallel-in-time solvers.
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
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble