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::SolverUtils
43{
44
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
74 SOLVER_UTILS_EXPORT ~DriverPFASST() override = default;
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 void v_Execute(std::ostream &out = std::cout) override;
82
83 static std::string driverLookupId;
84
85private:
86 void AssertParameters(void);
87
88 void InitialiseSDCScheme(void);
89
90 void SetTimeInterpolator(void);
91
92 bool IsNotInitialCondition(const size_t n);
93
94 void PropagateQuadratureSolutionAndResidual(const size_t timeLevel,
95 const size_t index);
96
97 void UpdateFirstQuadrature(const size_t timeLevel);
98
99 void RunSweep(const NekDouble time, const size_t timeLevel,
100 const bool update = false);
101
102 void ResidualEval(const NekDouble time, const size_t timeLevel,
103 const size_t n);
104
105 void ResidualEval(const NekDouble time, const size_t timeLevel);
106
107 void IntegratedResidualEval(const size_t timeLevel);
108
110
111 void Interpolate(const size_t coarseLevel, const SDCarray &in,
112 const size_t fineLevel, SDCarray &out, bool forced);
113
114 void InterpolateSolution(const size_t timeLevel);
115
116 void InterpolateResidual(const size_t timeLevel);
117
118 void Restrict(const size_t fineLevel, const SDCarray &in,
119 const size_t coarseLevel, SDCarray &out);
120
121 void RestrictSolution(const size_t timeLevel);
122
123 void RestrictResidual(const size_t timeLevel);
124
125 void ComputeFASCorrection(const size_t timeLevel);
126
127 void Correct(const size_t coarseLevel,
129 const size_t fineLevel,
130 Array<OneD, Array<OneD, NekDouble>> &out, bool forced);
131
132 void CorrectInitialSolution(const size_t timeLevel);
133
134 void CorrectInitialResidual(const size_t timeLevel);
135
136 void Correct(const size_t coarseLevel, const SDCarray &rest,
137 const SDCarray &in, const size_t fineLevel, SDCarray &out,
138 bool forced);
139
140 void CorrectSolution(const size_t timeLevel);
141
142 void CorrectResidual(const size_t timeLevel);
143
144 void ApplyWindowing(void);
145
146 void EvaluateSDCResidualNorm(const size_t timeLevel);
147
148 void WriteOutput(const size_t step, const NekDouble time);
149
150 // Storage of PFASST
161
162 bool m_updateResidual = false;
163};
164
165} // namespace Nektar::SolverUtils
166
167#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
void RestrictResidual(const size_t timeLevel)
void UpdateFirstQuadrature(const size_t timeLevel)
void RestrictSolution(const size_t timeLevel)
Array< OneD, Array< OneD, NekDouble > > m_ImatFtoC
Definition: DriverPFASST.h:152
Array< OneD, Array< OneD, NekDouble > > m_ImatCtoF
Definition: DriverPFASST.h:153
void Restrict(const size_t fineLevel, const SDCarray &in, const size_t coarseLevel, SDCarray &out)
void ResidualEval(const NekDouble time, const size_t timeLevel, const size_t n)
SOLVER_UTILS_EXPORT ~DriverPFASST() override=default
Destructor.
static std::string className
Name of the class.
Definition: DriverPFASST.h:65
void InterpolateResidual(const size_t timeLevel)
void CorrectSolution(const size_t timeLevel)
void EvaluateSDCResidualNorm(const size_t timeLevel)
void IntegratedResidualEval(const size_t timeLevel)
void RunSweep(const NekDouble time, const size_t timeLevel, const bool update=false)
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
Definition: DriverPFASST.h:54
void Interpolate(const size_t coarseLevel, const SDCarray &in, const size_t fineLevel, SDCarray &out, bool forced)
void ComputeFASCorrection(const size_t timeLevel)
Array< OneD, SDCarray > m_solutionRest
Definition: DriverPFASST.h:154
void CorrectInitialResidual(const size_t timeLevel)
SOLVER_UTILS_EXPORT void v_Execute(std::ostream &out=std::cout) override
Virtual function for solve implementation.
void WriteOutput(const size_t step, const NekDouble time)
void CorrectInitialSolution(const size_t timeLevel)
Array< OneD, std::shared_ptr< LibUtilities::TimeIntegrationSchemeSDC > > m_SDCSolver
Definition: DriverPFASST.h:160
Array< OneD, SDCarray > m_correction
Definition: DriverPFASST.h:157
SOLVER_UTILS_EXPORT void v_InitObject(std::ostream &out=std::cout) override
Virtual function for initialisation implementation.
Array< OneD, SDCarray > m_storage
Definition: DriverPFASST.h:158
Array< OneD, SDCarray > m_integralRest
Definition: DriverPFASST.h:156
void Correct(const size_t coarseLevel, const Array< OneD, Array< OneD, NekDouble > > &in, const size_t fineLevel, Array< OneD, Array< OneD, NekDouble > > &out, bool forced)
Array< OneD, SDCarray > m_residualRest
Definition: DriverPFASST.h:155
void InterpolateSolution(const size_t timeLevel)
void PropagateQuadratureSolutionAndResidual(const size_t timeLevel, const size_t index)
SOLVER_UTILS_EXPORT DriverPFASST(const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
Constructor.
static std::string driverLookupId
Definition: DriverPFASST.h:83
void CorrectResidual(const size_t timeLevel)
Array< OneD, size_t > m_QuadPts
Definition: DriverPFASST.h:151
bool IsNotInitialCondition(const size_t n)
Base class for the development of parallel-in-time solvers.
void Interpolate(const Array< OneD, MultiRegions::ExpListSharedPtr > &infield, const Array< OneD, MultiRegions::ExpListSharedPtr > &outfield, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
Definition: Driver.h:52
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > SDCarray
Definition: DriverPFASST.h:45
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
Definition: MeshGraph.h:174
double NekDouble