Nektar++
Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Nektar::SolverUtils::DriverParareal Class Reference

Base class for the development of solvers. More...

#include <DriverParareal.h>

Inheritance diagram for Nektar::SolverUtils::DriverParareal:
[legend]

Static Public Member Functions

static DriverSharedPtr create (const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
 Creates an instance of this class. More...
 

Static Public Attributes

static std::string className
 Name of the class. More...
 

Protected Member Functions

SOLVER_UTILS_EXPORT DriverParareal (const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
 Constructor. More...
 
SOLVER_UTILS_EXPORT ~DriverParareal () override=default
 Destructor. More...
 
SOLVER_UTILS_EXPORT void v_InitObject (std::ostream &out=std::cout) override
 Virtual function for initialisation implementation. More...
 
SOLVER_UTILS_EXPORT void v_Execute (std::ostream &out=std::cout) override
 Virtual function for solve implementation. More...
 
- Protected Member Functions inherited from Nektar::SolverUtils::DriverParallelInTime
SOLVER_UTILS_EXPORT DriverParallelInTime (const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
 Constructor. More...
 
SOLVER_UTILS_EXPORT ~DriverParallelInTime () override=default
 Destructor. More...
 
SOLVER_UTILS_EXPORT void v_InitObject (std::ostream &out=std::cout) override
 Virtual function for initialisation implementation. More...
 
SOLVER_UTILS_EXPORT void v_Execute (std::ostream &out=std::cout) override
 Virtual function for solve implementation. More...
 
void SetParallelInTimeEquationSystem (std::string AdvectiveType)
 
void GetParametersFromSession (void)
 
void InitialiseEqSystem (bool turnoff_output)
 
void InitialiseInterpolationField (void)
 
void PrintSolverInfo (std::ostream &out=std::cout)
 
void PrintHeader (const std::string &title, const char c)
 
void RecvFromPreviousProc (Array< OneD, Array< OneD, NekDouble > > &array, int &convergence)
 
void RecvFromPreviousProc (Array< OneD, NekDouble > &array)
 
void SendToNextProc (Array< OneD, Array< OneD, NekDouble > > &array, int &convergence)
 
void SendToNextProc (Array< OneD, NekDouble > &array)
 
void CopySolutionVector (const Array< OneD, const Array< OneD, NekDouble > > &in, Array< OneD, Array< OneD, NekDouble > > &out)
 
void CopyFromPhysField (const size_t timeLevel, Array< OneD, Array< OneD, NekDouble > > &out)
 
void CopyToPhysField (const size_t timeLevel, const Array< OneD, const Array< OneD, NekDouble > > &in)
 
void UpdateFieldCoeffs (const size_t timeLevel, const Array< OneD, const Array< OneD, NekDouble > > &in=NullNekDoubleArrayOfArray)
 
void EvaluateExactSolution (const size_t timeLevel, const NekDouble &time)
 
void SolutionConvergenceMonitoring (const size_t timeLevel, const size_t iter)
 
void SolutionConvergenceSummary (const size_t timeLevel)
 
void UpdateErrorNorm (const size_t timeLevel, const bool normalized)
 
void PrintErrorNorm (const size_t timeLevel, const bool normalized)
 
NekDouble vL2ErrorMax (void)
 
NekDouble EstimateCommunicationTime (Array< OneD, Array< OneD, NekDouble > > &buffer1, Array< OneD, Array< OneD, NekDouble > > &buffer2)
 
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)
 
- Protected Member Functions inherited from Nektar::SolverUtils::Driver
 Driver (const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
 Initialises EquationSystem class members. More...
 
virtual SOLVER_UTILS_EXPORT void v_InitObject (std::ostream &out=std::cout)
 Virtual function for initialisation implementation. More...
 
virtual SOLVER_UTILS_EXPORT void v_Execute (std::ostream &out=std::cout)=0
 Virtual function for solve implementation. More...
 

Static Protected Attributes

static std::string driverLookupId
 
- Static Protected Attributes inherited from Nektar::SolverUtils::Driver
static std::string evolutionOperatorLookupIds []
 
static std::string evolutionOperatorDef
 
static std::string driverDefault
 

Private Member Functions

void AllocateMemory (void)
 
void AssertParameters (void)
 
void UpdateInitialConditionFromSolver (const size_t timeLevel)
 
void UpdateSolverInitialCondition (const size_t timeLevel)
 
void UpdateSolution (const size_t timeLevel, const NekDouble time, const size_t nstep, const size_t wd, const size_t iter)
 
void CorrectionWithOldCoarseSolution (void)
 
void CorrectionWithNewCoarseSolution (void)
 
void InterpolateCoarseSolution (void)
 
void ApplyWindowing (const size_t w)
 
void CopyConvergedCheckPoints (const size_t w, const size_t k)
 
void WriteTimeChunkOuput (void)
 

Private Attributes

Array< OneD, Array< OneD, NekDouble > > m_initialCondition
 
Array< OneD, Array< OneD, NekDouble > > m_fineSolution
 
Array< OneD, Array< OneD, NekDouble > > m_coarseSolution
 

Static Private Attributes

static constexpr size_t m_fineLevel = 0
 
static constexpr size_t m_coarseLevel = 1
 

Friends

class MemoryManager< DriverParareal >
 

Additional Inherited Members

- Public Member Functions inherited from Nektar::SolverUtils::Driver
virtual ~Driver ()=default
 Destructor. More...
 
SOLVER_UTILS_EXPORT void InitObject (std::ostream &out=std::cout)
 Initialise Object. More...
 
SOLVER_UTILS_EXPORT void Execute (std::ostream &out=std::cout)
 Execute driver. More...
 
SOLVER_UTILS_EXPORT Array< OneD, EquationSystemSharedPtrGetEqu ()
 
- Protected Attributes inherited from Nektar::SolverUtils::DriverParallelInTime
NekDouble m_totalTime
 Total time integration interval. More...
 
NekDouble m_chunkTime
 Time integration interval per chunk. More...
 
NekDouble m_time
 Local time. More...
 
size_t m_numChunks
 Number of time chunks. More...
 
size_t m_chunkRank
 Rank in time. More...
 
size_t m_iterMaxPIT
 Maximum number of parallel-in-time iteration. More...
 
size_t m_numWindowsPIT
 
bool m_exactSolution
 Using exact solution to compute error norms. More...
 
NekDouble m_tolerPIT
 ParallelInTime tolerance. More...
 
size_t m_nVar
 Number of variables. More...
 
size_t m_nTimeLevel
 Number of time levels. More...
 
Array< OneD, size_t > m_nsteps
 Number of time steps for each time level. More...
 
Array< OneD, NekDoublem_timestep
 Time step for each time level. More...
 
Array< OneD, size_t > m_npts
 Number of dof for each time level. More...
 
Array< OneD, std::shared_ptr< UnsteadySystem > > m_EqSys
 Equation system to solve. More...
 
Array< OneD, NekDoublem_vL2Errors
 Storage for parallel-in-time iteration. More...
 
Array< OneD, NekDoublem_vLinfErrors
 
Array< OneD, Array< OneD, NekDouble > > m_exactsoln
 
- Protected Attributes inherited from Nektar::SolverUtils::Driver
LibUtilities::CommSharedPtr m_comm
 Communication object. More...
 
LibUtilities::SessionReaderSharedPtr m_session
 Session reader object. More...
 
LibUtilities::SessionReaderSharedPtr session_LinNS
 Coupling between SFD and arnoldi. More...
 
SpatialDomains::MeshGraphSharedPtr m_graph
 MeshGraph object. More...
 
Array< OneD, EquationSystemSharedPtrm_equ
 Equation system to solve. More...
 
int m_nequ
 number of equations More...
 
enum EvolutionOperatorType m_EvolutionOperator
 Evolution Operator. More...
 

Detailed Description

Base class for the development of solvers.

Definition at line 44 of file DriverParareal.h.

Constructor & Destructor Documentation

◆ DriverParareal()

Nektar::SolverUtils::DriverParareal::DriverParareal ( const LibUtilities::SessionReaderSharedPtr  pSession,
const SpatialDomains::MeshGraphSharedPtr  pGraph 
)
protected

Constructor.

Definition at line 52 of file DriverParareal.cpp.

55 : DriverParallelInTime(pSession, pGraph)
56{
57}
SOLVER_UTILS_EXPORT DriverParallelInTime(const LibUtilities::SessionReaderSharedPtr pSession, const SpatialDomains::MeshGraphSharedPtr pGraph)
Constructor.

◆ ~DriverParareal()

SOLVER_UTILS_EXPORT Nektar::SolverUtils::DriverParareal::~DriverParareal ( )
overrideprotecteddefault

Destructor.

Member Function Documentation

◆ AllocateMemory()

void Nektar::SolverUtils::DriverParareal::AllocateMemory ( void  )
private

Definition at line 278 of file DriverParareal.cpp.

279{
280 // Allocate storage for Parareal solver.
281 m_initialCondition = Array<OneD, Array<OneD, NekDouble>>(m_nVar);
282 m_fineSolution = Array<OneD, Array<OneD, NekDouble>>(m_nVar);
283 m_coarseSolution = Array<OneD, Array<OneD, NekDouble>>(m_nVar);
284 for (size_t i = 0; i < m_nVar; ++i)
285 {
287 Array<OneD, NekDouble>(m_npts[m_fineLevel], 0.0);
288 m_fineSolution[i] = m_EqSys[m_fineLevel]->UpdatePhysField(i);
291 ? m_EqSys[m_coarseLevel]->UpdatePhysField(i)
292 : Array<OneD, NekDouble>(m_npts[m_fineLevel], 0.0);
293 }
294}
Array< OneD, std::shared_ptr< UnsteadySystem > > m_EqSys
Equation system to solve.
Array< OneD, size_t > m_npts
Number of dof for each time level.
static constexpr size_t m_fineLevel
static constexpr size_t m_coarseLevel
Array< OneD, Array< OneD, NekDouble > > m_coarseSolution
Array< OneD, Array< OneD, NekDouble > > m_fineSolution
Array< OneD, Array< OneD, NekDouble > > m_initialCondition

References m_coarseLevel, m_coarseSolution, Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, m_fineSolution, m_initialCondition, Nektar::SolverUtils::DriverParallelInTime::m_npts, and Nektar::SolverUtils::DriverParallelInTime::m_nVar.

Referenced by v_InitObject().

◆ ApplyWindowing()

void Nektar::SolverUtils::DriverParareal::ApplyWindowing ( const size_t  w)
private

Definition at line 474 of file DriverParareal.cpp.

475{
476 if (w == m_numWindowsPIT - 1)
477 {
478 // No windowing required for the last window.
479 return;
480 }
481
482 // Use last chunk solution as initial condition for the next
483 // window.
484 if (m_chunkRank == m_numChunks - 1)
485 {
486 for (size_t i = 0; i < m_nVar; ++i)
487 {
489 m_EqSys[m_fineLevel]->UpdatePhysField(i), 1,
490 m_initialCondition[i], 1);
491 }
492 }
493
494 // Broadcast I.C. for windowing.
495 for (size_t i = 0; i < m_nVar; ++i)
496 {
497 m_comm->GetTimeComm()->Bcast(m_initialCondition[i], m_numChunks - 1);
498 }
499}
LibUtilities::CommSharedPtr m_comm
Communication object.
Definition: Driver.h:80
std::vector< double > w(NPUPPER)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References Nektar::SolverUtils::DriverParallelInTime::m_chunkRank, Nektar::SolverUtils::Driver::m_comm, Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, m_initialCondition, Nektar::SolverUtils::DriverParallelInTime::m_npts, Nektar::SolverUtils::DriverParallelInTime::m_numChunks, Nektar::SolverUtils::DriverParallelInTime::m_numWindowsPIT, Nektar::SolverUtils::DriverParallelInTime::m_nVar, Vmath::Vcopy(), and Nektar::UnitTests::w().

Referenced by v_Execute().

◆ AssertParameters()

void Nektar::SolverUtils::DriverParareal::AssertParameters ( void  )
private

Definition at line 299 of file DriverParareal.cpp.

300{
301 // Assert time-stepping parameters
302 ASSERTL0(
304 "Total number of fine step should be divisible by number of chunks.");
305
306 ASSERTL0(
308 "Total number of coarse step should be divisible by number of chunks.");
309
311 "Total number of fine step should be divisible by number of "
312 "windows times number of chunks.");
313
315 "Total number of coarse step should be divisible by number of "
316 "windows times number of chunks.");
317
320 "Fine and coarse total computational times do not match");
321
323 ->GetTimeIntegrationScheme()
324 ->GetNumIntegrationPhases() == 1,
325 "Only single step time-integration schemes currently supported "
326 "for Parareal");
327
329 ->GetTimeIntegrationScheme()
330 ->GetNumIntegrationPhases() == 1,
331 "Only single step time-integration schemes currently supported "
332 "for Parareal");
333
334 // Assert I/O parameters
335 if (m_EqSys[m_fineLevel]->GetInfoSteps())
336 {
337 ASSERTL0(m_nsteps[m_fineLevel] % (m_EqSys[m_fineLevel]->GetInfoSteps() *
339 0,
340 "number of IO_InfoSteps should divide number of fine steps "
341 "per time chunk");
342 }
343
344 if (m_EqSys[m_coarseLevel]->GetInfoSteps())
345 {
347 (m_EqSys[m_coarseLevel]->GetInfoSteps() * m_numChunks *
349 0,
350 "number of IO_InfoSteps should divide number of coarse steps "
351 "per time chunk");
352 }
353
354 if (m_EqSys[m_fineLevel]->GetCheckpointSteps())
355 {
357 (m_EqSys[m_fineLevel]->GetCheckpointSteps() *
359 0,
360 "number of IO_CheckSteps should divide number of fine steps "
361 "per time chunk");
362 }
363
364 if (m_EqSys[m_coarseLevel]->GetCheckpointSteps())
365 {
367 (m_EqSys[m_coarseLevel]->GetCheckpointSteps() *
369 0,
370 "number of IO_CheckSteps should divide number of coarse steps "
371 "per time chunk");
372 }
373}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
Array< OneD, size_t > m_nsteps
Number of time steps for each time level.
Array< OneD, NekDouble > m_timestep
Time step for each time level.

References ASSERTL0, m_coarseLevel, Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, Nektar::SolverUtils::DriverParallelInTime::m_nsteps, Nektar::SolverUtils::DriverParallelInTime::m_numChunks, Nektar::SolverUtils::DriverParallelInTime::m_numWindowsPIT, and Nektar::SolverUtils::DriverParallelInTime::m_timestep.

Referenced by v_Execute().

◆ CopyConvergedCheckPoints()

void Nektar::SolverUtils::DriverParareal::CopyConvergedCheckPoints ( const size_t  w,
const size_t  k 
)
private

Output directory name.

Definition at line 504 of file DriverParareal.cpp.

505{
506 // Determine max number of iteration.
507 size_t kmax = k;
508 m_comm->GetTimeComm()->AllReduce(kmax, Nektar::LibUtilities::ReduceMax);
509
510 if (m_comm->GetSpaceComm()->GetRank() == 0)
511 {
512 for (size_t j = k; j < kmax; j++)
513 {
514 // Copy converged solution files from directory corresponding to
515 // iteration j - 1 to the directory corresponding to iteration j.
516
517 auto sessionName = m_EqSys[m_fineLevel]->GetSessionName();
518
519 // Input directory name.
520 std::string indir =
521 sessionName + "_" + std::to_string(j - 1) + ".pit";
522
523 /// Output directory name.
524 std::string outdir = sessionName + "_" + std::to_string(j) + ".pit";
525
526 for (size_t timeLevel = 0; timeLevel < m_nTimeLevel; timeLevel++)
527 {
528 // Number of checkpoint by chunk.
529 size_t nChkPts =
530 m_EqSys[timeLevel]->GetCheckpointSteps()
531 ? m_nsteps[timeLevel] /
532 m_EqSys[timeLevel]->GetCheckpointSteps()
533 : 0;
534
535 // Checkpoint index.
536 size_t iChkPts = (m_chunkRank + w * m_numChunks) * nChkPts;
537
538 for (size_t i = 1; i <= nChkPts; i++)
539 {
540 // Filename corresponding to checkpoint iChkPts.
541 std::string filename = sessionName + "_timeLevel" +
542 std::to_string(timeLevel) + "_" +
543 std::to_string(iChkPts + i) + ".chk";
544
545 // Intput full file name.
546 std::string infullname = indir + "/" + filename;
547
548 // Output full file name.
549 std::string outfullname = outdir + "/" + filename;
550
551 // Remove output file if already existing.
552 fs::remove_all(outfullname);
553
554 // Copy converged solution files.
555 fs::copy(infullname, outfullname);
556 }
557 }
558 }
559 }
560}
def copy(self)
Definition: pycml.py:2663

References CellMLToNektar.pycml::copy(), Nektar::SolverUtils::DriverParallelInTime::m_chunkRank, Nektar::SolverUtils::Driver::m_comm, Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, Nektar::SolverUtils::DriverParallelInTime::m_nsteps, Nektar::SolverUtils::DriverParallelInTime::m_nTimeLevel, Nektar::SolverUtils::DriverParallelInTime::m_numChunks, Nektar::LibUtilities::ReduceMax, and Nektar::UnitTests::w().

Referenced by v_Execute().

◆ CorrectionWithNewCoarseSolution()

void Nektar::SolverUtils::DriverParareal::CorrectionWithNewCoarseSolution ( void  )
private

Definition at line 444 of file DriverParareal.cpp.

445{
446 // Interpolate coarse solution.
448
449 // Correct solution F -> F + Gnew.
450 for (size_t i = 0; i < m_nVar; ++i)
451 {
453 m_coarseSolution[i], 1, m_fineSolution[i], 1);
454 }
455}
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.hpp:180

References InterpolateCoarseSolution(), m_coarseSolution, m_fineLevel, m_fineSolution, Nektar::SolverUtils::DriverParallelInTime::m_npts, Nektar::SolverUtils::DriverParallelInTime::m_nVar, and Vmath::Vadd().

Referenced by v_Execute().

◆ CorrectionWithOldCoarseSolution()

void Nektar::SolverUtils::DriverParareal::CorrectionWithOldCoarseSolution ( void  )
private

Definition at line 431 of file DriverParareal.cpp.

432{
433 // Correct solution F -> F - Gold.
434 for (size_t i = 0; i < m_nVar; ++i)
435 {
437 m_coarseSolution[i], 1, m_fineSolution[i], 1);
438 }
439}
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.hpp:220

References m_coarseSolution, m_fineLevel, m_fineSolution, Nektar::SolverUtils::DriverParallelInTime::m_npts, Nektar::SolverUtils::DriverParallelInTime::m_nVar, and Vmath::Vsub().

Referenced by v_Execute().

◆ create()

static DriverSharedPtr Nektar::SolverUtils::DriverParareal::create ( const LibUtilities::SessionReaderSharedPtr pSession,
const SpatialDomains::MeshGraphSharedPtr pGraph 
)
inlinestatic

Creates an instance of this class.

Definition at line 50 of file DriverParareal.h.

53 {
56 p->InitObject();
57 return p;
58 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< Driver > DriverSharedPtr
A shared pointer to a Driver object.
Definition: Driver.h:52

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), and CellMLToNektar.cellml_metadata::p.

◆ InterpolateCoarseSolution()

void Nektar::SolverUtils::DriverParareal::InterpolateCoarseSolution ( void  )
private

Definition at line 460 of file DriverParareal.cpp.

461{
463 {
464 // Interpolate coarse solution to fine field.
465 Interpolate(m_EqSys[m_coarseLevel]->UpdateFields(),
466 m_EqSys[m_fineLevel]->UpdateFields(),
468 }
469}
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)
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray

References Nektar::SolverUtils::DriverParallelInTime::Interpolate(), m_coarseLevel, m_coarseSolution, Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, Nektar::SolverUtils::DriverParallelInTime::m_npts, and Nektar::NullNekDoubleArrayOfArray.

Referenced by CorrectionWithNewCoarseSolution(), and v_Execute().

◆ UpdateInitialConditionFromSolver()

void Nektar::SolverUtils::DriverParareal::UpdateInitialConditionFromSolver ( const size_t  timeLevel)
private

Definition at line 378 of file DriverParareal.cpp.

379{
380 // Interpolate solution to fine field.
381 Interpolate(m_EqSys[timeLevel]->UpdateFields(),
384}

References Nektar::SolverUtils::DriverParallelInTime::Interpolate(), Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, m_initialCondition, and Nektar::NullNekDoubleArrayOfArray.

Referenced by v_Execute().

◆ UpdateSolution()

void Nektar::SolverUtils::DriverParareal::UpdateSolution ( const size_t  timeLevel,
const NekDouble  time,
const size_t  nstep,
const size_t  wd,
const size_t  iter 
)
private

Definition at line 400 of file DriverParareal.cpp.

403{
404 // Number of checkpoint by chunk.
405 size_t nChkPts =
406 m_EqSys[timeLevel]->GetCheckpointSteps()
407 ? m_nsteps[timeLevel] / m_EqSys[timeLevel]->GetCheckpointSteps()
408 : 1;
409
410 // Checkpoint index.
411 size_t iChkPts = (m_chunkRank + wd * m_numChunks) * nChkPts + 1;
412
413 // Reinitialize check point number for each parallel-in-time
414 // iteration.
415 m_EqSys[timeLevel]->SetCheckpointNumber(iChkPts);
416
417 // Update parallel-in-time iteration number.
418 m_EqSys[timeLevel]->SetIterationNumberPIT(iter);
419
420 // Update parallel-in-time window number.
421 m_EqSys[timeLevel]->SetWindowNumberPIT(wd);
422
423 m_EqSys[timeLevel]->SetTime(time);
424 m_EqSys[timeLevel]->SetSteps(nstep);
425 m_EqSys[timeLevel]->DoSolve();
426}

References Nektar::SolverUtils::DriverParallelInTime::m_chunkRank, Nektar::SolverUtils::DriverParallelInTime::m_EqSys, Nektar::SolverUtils::DriverParallelInTime::m_nsteps, and Nektar::SolverUtils::DriverParallelInTime::m_numChunks.

Referenced by v_Execute().

◆ UpdateSolverInitialCondition()

void Nektar::SolverUtils::DriverParareal::UpdateSolverInitialCondition ( const size_t  timeLevel)
private

Definition at line 389 of file DriverParareal.cpp.

390{
391 // Restrict fine field to coarse solution.
392 Interpolate(m_EqSys[m_fineLevel]->UpdateFields(),
393 m_EqSys[timeLevel]->UpdateFields(), m_initialCondition,
395}

References Nektar::SolverUtils::DriverParallelInTime::Interpolate(), Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, m_initialCondition, and Nektar::NullNekDoubleArrayOfArray.

Referenced by v_Execute().

◆ v_Execute()

void Nektar::SolverUtils::DriverParareal::v_Execute ( std::ostream &  out = std::cout)
overrideprotectedvirtual

Virtual function for solve implementation.

Reimplemented from Nektar::SolverUtils::DriverParallelInTime.

Definition at line 74 of file DriverParareal.cpp.

75{
76 // Timing.
78 NekDouble totalTime = 0.0, predictorTime = 0.0, coarseSolveTime = 0.0,
79 fineSolveTime = 0.0, correctionTime = 0.0;
80
81 // Get and assert parameters from session file.
83
84 // Initialie time step parameters.
89
90 // Pre-solve for one time-step to initialize preconditioner.
92
93 // Start iteration windows.
94 m_comm->GetTimeComm()->Block();
96 for (size_t w = 0; w < m_numWindowsPIT; w++)
97 {
98 timer.Start();
99 // Initialize time for the current window.
101
102 // Print window number.
103 PrintHeader((boost::format("WINDOWS #%1%") % (w + 1)).str(), '*');
104
105 // Update coarse initial condition.
107
108 // Run predictor.
109 for (size_t i = 0; i < m_nVar; ++i)
110 {
111 RecvFromPreviousProc(m_EqSys[m_coarseLevel]->UpdatePhysField(i));
112 }
113 if (m_chunkRank > 0)
114 {
116 }
118 for (size_t i = 0; i < m_nVar; ++i)
119 {
120 SendToNextProc(m_EqSys[m_coarseLevel]->UpdatePhysField(i));
121 }
122
123 // Interpolate coarse solution.
125
126 // Compute exact solution, if necessary.
127 if (m_exactSolution)
128 {
130 }
131 timer.Stop();
132 predictorTime += timer.Elapsed().count();
133 totalTime += timer.Elapsed().count();
134
135 // Solution convergence monitoring.
136 timer.Start();
139 timer.Stop();
140 totalTime += timer.Elapsed().count();
141 if (m_chunkRank == m_numChunks - 1 &&
142 m_comm->GetSpaceComm()->GetRank() == 0)
143 {
144 std::cout << "Total Computation Time : " << totalTime << "s"
145 << std::endl
146 << std::flush;
147 }
148
149 // Start Parareal iteration.
150 size_t iter = 1;
151 int convergenceCurr = false;
152 int convergencePrev = (m_chunkRank == 0);
153 while (iter <= m_iterMaxPIT && !convergenceCurr)
154 {
155 // Use previous parareal solution as "exact solution", if necessary.
156 timer.Start();
157 if (!m_exactSolution)
158 {
160 }
161 timer.Stop();
162 totalTime += timer.Elapsed().count();
163
164 // Calculate fine solution (parallel-in-time).
165 timer.Start();
168 timer.Stop();
169 fineSolveTime += timer.Elapsed().count();
170 totalTime += timer.Elapsed().count();
171
172 // Compute F -> F - Gold
173 timer.Start();
175 timer.Stop();
176 correctionTime += timer.Elapsed().count();
177 totalTime += timer.Elapsed().count();
178
179 // Receive coarse solution from previous processor.
180 timer.Start();
182 timer.Stop();
183 totalTime += timer.Elapsed().count();
184
185 // Calculate coarse solution (serial-in-time).
186 timer.Start();
189 iter);
190 timer.Stop();
191 coarseSolveTime += timer.Elapsed().count();
192 totalTime += timer.Elapsed().count();
193
194 // Compute F -> F + Gnew
195 timer.Start();
197 timer.Stop();
198 correctionTime += timer.Elapsed().count();
199 totalTime += timer.Elapsed().count();
200
201 // Solution convergence monitoring.
204 if (m_chunkRank == m_numChunks - 1 &&
205 m_comm->GetSpaceComm()->GetRank() == 0)
206 {
207 std::cout << "Total Computation Time : " << totalTime << "s"
208 << std::endl
209 << std::flush;
210 std::cout << " - Predictor Time : " << predictorTime << "s"
211 << std::endl
212 << std::flush;
213 std::cout << " - Coarse Solve Time : " << coarseSolveTime << "s"
214 << std::endl
215 << std::flush;
216 std::cout << " - Fine Solve Time : " << fineSolveTime << "s"
217 << std::endl
218 << std::flush;
219 std::cout << " - Correction Time : " << correctionTime << "s"
220 << std::endl
221 << std::flush;
222 }
223
224 // Check convergence of L2 error for each time chunk.
225 convergenceCurr = (vL2ErrorMax() < m_tolerPIT && convergencePrev) ||
226 (m_chunkRank + 1 == iter);
227
228 // Send solution to next processor.
229 timer.Start();
230 SendToNextProc(m_fineSolution, convergenceCurr);
231 timer.Stop();
232 totalTime += timer.Elapsed().count();
233
234 // Increment iteration index.
235 iter++;
236 }
237
238 // Copy converged check points.
240
241 // Write time chunk solution to files.
243
244 // Apply windowing.
245 timer.Start();
247 timer.Stop();
248 totalTime += timer.Elapsed().count();
249 }
250
251 m_comm->GetTimeComm()->Block();
252 PrintHeader("SUMMARY", '*');
255 if (m_chunkRank == m_numChunks - 1 &&
256 m_comm->GetSpaceComm()->GetRank() == 0)
257 {
258 std::cout << "Total Computation Time : " << totalTime << "s"
259 << std::endl
260 << std::flush;
261 std::cout << " - Predictor Time : " << predictorTime << "s" << std::endl
262 << std::flush;
263 std::cout << " - Coarse Solve Time : " << coarseSolveTime << "s"
264 << std::endl
265 << std::flush;
266 std::cout << " - Fine Solve Time : " << fineSolveTime << "s"
267 << std::endl
268 << std::flush;
269 std::cout << " - Correction Time : " << correctionTime << "s"
270 << std::endl
271 << std::flush;
272 }
273}
NekDouble m_totalTime
Total time integration interval.
NekDouble m_chunkTime
Time integration interval per chunk.
void SendToNextProc(Array< OneD, Array< OneD, NekDouble > > &array, int &convergence)
size_t m_iterMaxPIT
Maximum number of parallel-in-time iteration.
void EvaluateExactSolution(const size_t timeLevel, const NekDouble &time)
void RecvFromPreviousProc(Array< OneD, Array< OneD, NekDouble > > &array, int &convergence)
void PrintHeader(const std::string &title, const char c)
NekDouble m_tolerPIT
ParallelInTime tolerance.
bool m_exactSolution
Using exact solution to compute error norms.
void CopyFromPhysField(const size_t timeLevel, Array< OneD, Array< OneD, NekDouble > > &out)
void CopyToPhysField(const size_t timeLevel, const Array< OneD, const Array< OneD, NekDouble > > &in)
Array< OneD, Array< OneD, NekDouble > > m_exactsoln
void SolutionConvergenceSummary(const size_t timeLevel)
void SolutionConvergenceMonitoring(const size_t timeLevel, const size_t iter)
void UpdateInitialConditionFromSolver(const size_t timeLevel)
void CopyConvergedCheckPoints(const size_t w, const size_t k)
void UpdateSolution(const size_t timeLevel, const NekDouble time, const size_t nstep, const size_t wd, const size_t iter)
void UpdateSolverInitialCondition(const size_t timeLevel)
double NekDouble

References ApplyWindowing(), AssertParameters(), CopyConvergedCheckPoints(), Nektar::SolverUtils::DriverParallelInTime::CopyFromPhysField(), Nektar::SolverUtils::DriverParallelInTime::CopyToPhysField(), CorrectionWithNewCoarseSolution(), CorrectionWithOldCoarseSolution(), Nektar::LibUtilities::Timer::Elapsed(), Nektar::SolverUtils::DriverParallelInTime::EvaluateExactSolution(), CellMLToNektar.pycml::format, InterpolateCoarseSolution(), Nektar::SolverUtils::DriverParallelInTime::m_chunkRank, Nektar::SolverUtils::DriverParallelInTime::m_chunkTime, m_coarseLevel, m_coarseSolution, Nektar::SolverUtils::Driver::m_comm, Nektar::SolverUtils::DriverParallelInTime::m_EqSys, Nektar::SolverUtils::DriverParallelInTime::m_exactsoln, Nektar::SolverUtils::DriverParallelInTime::m_exactSolution, m_fineLevel, m_fineSolution, m_initialCondition, Nektar::SolverUtils::DriverParallelInTime::m_iterMaxPIT, Nektar::SolverUtils::DriverParallelInTime::m_nsteps, Nektar::SolverUtils::DriverParallelInTime::m_numChunks, Nektar::SolverUtils::DriverParallelInTime::m_numWindowsPIT, Nektar::SolverUtils::DriverParallelInTime::m_nVar, Nektar::SolverUtils::DriverParallelInTime::m_time, Nektar::SolverUtils::DriverParallelInTime::m_timestep, Nektar::SolverUtils::DriverParallelInTime::m_tolerPIT, Nektar::SolverUtils::DriverParallelInTime::m_totalTime, Nektar::SolverUtils::DriverParallelInTime::PrintHeader(), Nektar::SolverUtils::DriverParallelInTime::RecvFromPreviousProc(), Nektar::SolverUtils::DriverParallelInTime::SendToNextProc(), Nektar::SolverUtils::DriverParallelInTime::SolutionConvergenceMonitoring(), Nektar::SolverUtils::DriverParallelInTime::SolutionConvergenceSummary(), Nektar::LibUtilities::Timer::Start(), Nektar::LibUtilities::Timer::Stop(), UpdateInitialConditionFromSolver(), UpdateSolution(), UpdateSolverInitialCondition(), Nektar::SolverUtils::DriverParallelInTime::vL2ErrorMax(), Nektar::UnitTests::w(), and WriteTimeChunkOuput().

◆ v_InitObject()

void Nektar::SolverUtils::DriverParareal::v_InitObject ( std::ostream &  out = std::cout)
overrideprotectedvirtual

◆ WriteTimeChunkOuput()

void Nektar::SolverUtils::DriverParareal::WriteTimeChunkOuput ( void  )
private

Definition at line 565 of file DriverParareal.cpp.

566{
567 PrintHeader("PRINT SOLUTION FILES", '-');
568
569 // Update field coefficients.
571
572 // Output solution files.
573 m_EqSys[m_fineLevel]->Output();
574}
void UpdateFieldCoeffs(const size_t timeLevel, const Array< OneD, const Array< OneD, NekDouble > > &in=NullNekDoubleArrayOfArray)

References Nektar::SolverUtils::DriverParallelInTime::m_EqSys, m_fineLevel, Nektar::SolverUtils::DriverParallelInTime::PrintHeader(), and Nektar::SolverUtils::DriverParallelInTime::UpdateFieldCoeffs().

Referenced by v_Execute().

Friends And Related Function Documentation

◆ MemoryManager< DriverParareal >

friend class MemoryManager< DriverParareal >
friend

Definition at line 1 of file DriverParareal.h.

Member Data Documentation

◆ className

std::string Nektar::SolverUtils::DriverParareal::className
static
Initial value:
=
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
DriverFactory & GetDriverFactory()
Definition: Driver.cpp:66

Name of the class.

Definition at line 61 of file DriverParareal.h.

◆ driverLookupId

std::string Nektar::SolverUtils::DriverParareal::driverLookupId
staticprotected
Initial value:
=
static std::string RegisterEnumValue(std::string pEnum, std::string pString, int pEnumValue)
Registers an enumeration value.

Definition at line 79 of file DriverParareal.h.

◆ m_coarseLevel

constexpr size_t Nektar::SolverUtils::DriverParareal::m_coarseLevel = 1
staticconstexprprivate

◆ m_coarseSolution

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::DriverParareal::m_coarseSolution
private

◆ m_fineLevel

constexpr size_t Nektar::SolverUtils::DriverParareal::m_fineLevel = 0
staticconstexprprivate

◆ m_fineSolution

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::DriverParareal::m_fineSolution
private

◆ m_initialCondition

Array<OneD, Array<OneD, NekDouble> > Nektar::SolverUtils::DriverParareal::m_initialCondition
private