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 ()
 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 274 of file DriverParareal.cpp.

275{
276 // Allocate storage for Parareal solver.
277 m_initialCondition = Array<OneD, Array<OneD, NekDouble>>(m_nVar);
278 m_fineSolution = Array<OneD, Array<OneD, NekDouble>>(m_nVar);
279 m_coarseSolution = Array<OneD, Array<OneD, NekDouble>>(m_nVar);
280 for (size_t i = 0; i < m_nVar; ++i)
281 {
283 Array<OneD, NekDouble>(m_npts[m_fineLevel], 0.0);
284 m_fineSolution[i] = m_EqSys[m_fineLevel]->UpdatePhysField(i);
287 ? m_EqSys[m_coarseLevel]->UpdatePhysField(i)
288 : Array<OneD, NekDouble>(m_npts[m_fineLevel], 0.0);
289 }
290}
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 470 of file DriverParareal.cpp.

471{
472 if (w == m_numWindowsPIT - 1)
473 {
474 // No windowing required for the last window.
475 return;
476 }
477
478 // Use last chunk solution as initial condition for the next
479 // window.
480 if (m_chunkRank == m_numChunks - 1)
481 {
482 for (size_t i = 0; i < m_nVar; ++i)
483 {
485 m_EqSys[m_fineLevel]->UpdatePhysField(i), 1,
486 m_initialCondition[i], 1);
487 }
488 }
489
490 // Broadcast I.C. for windowing.
491 for (size_t i = 0; i < m_nVar; ++i)
492 {
493 m_comm->GetTimeComm()->Bcast(m_initialCondition[i], m_numChunks - 1);
494 }
495}
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 295 of file DriverParareal.cpp.

296{
297 // Assert time-stepping parameters
298 ASSERTL0(
300 "Total number of fine step should be divisible by number of chunks.");
301
302 ASSERTL0(
304 "Total number of coarse step should be divisible by number of chunks.");
305
307 "Total number of fine step should be divisible by number of "
308 "windows times number of chunks.");
309
311 "Total number of coarse step should be divisible by number of "
312 "windows times number of chunks.");
313
316 "Fine and coarse total computational times do not match");
317
319 ->GetTimeIntegrationScheme()
320 ->GetNumIntegrationPhases() == 1,
321 "Only single step time-integration schemes currently supported "
322 "for Parareal");
323
325 ->GetTimeIntegrationScheme()
326 ->GetNumIntegrationPhases() == 1,
327 "Only single step time-integration schemes currently supported "
328 "for Parareal");
329
330 // Assert I/O parameters
331 if (m_EqSys[m_fineLevel]->GetInfoSteps())
332 {
333 ASSERTL0(m_nsteps[m_fineLevel] % (m_EqSys[m_fineLevel]->GetInfoSteps() *
335 0,
336 "number of IO_InfoSteps should divide number of fine steps "
337 "per time chunk");
338 }
339
340 if (m_EqSys[m_coarseLevel]->GetInfoSteps())
341 {
343 (m_EqSys[m_coarseLevel]->GetInfoSteps() * m_numChunks *
345 0,
346 "number of IO_InfoSteps should divide number of coarse steps "
347 "per time chunk");
348 }
349
350 if (m_EqSys[m_fineLevel]->GetCheckpointSteps())
351 {
353 (m_EqSys[m_fineLevel]->GetCheckpointSteps() *
355 0,
356 "number of IO_CheckSteps should divide number of fine steps "
357 "per time chunk");
358 }
359
360 if (m_EqSys[m_coarseLevel]->GetCheckpointSteps())
361 {
363 (m_EqSys[m_coarseLevel]->GetCheckpointSteps() *
365 0,
366 "number of IO_CheckSteps should divide number of coarse steps "
367 "per time chunk");
368 }
369}
#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 500 of file DriverParareal.cpp.

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

441{
442 // Interpolate coarse solution.
444
445 // Correct solution F -> F + Gnew.
446 for (size_t i = 0; i < m_nVar; ++i)
447 {
449 m_coarseSolution[i], 1, m_fineSolution[i], 1);
450 }
451}
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 427 of file DriverParareal.cpp.

428{
429 // Correct solution F -> F - Gold.
430 for (size_t i = 0; i < m_nVar; ++i)
431 {
433 m_coarseSolution[i], 1, m_fineSolution[i], 1);
434 }
435}
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 456 of file DriverParareal.cpp.

457{
459 {
460 // Interpolate coarse solution to fine field.
461 Interpolate(m_EqSys[m_coarseLevel]->UpdateFields(),
462 m_EqSys[m_fineLevel]->UpdateFields(),
464 }
465}
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 374 of file DriverParareal.cpp.

375{
376 // Interpolate solution to fine field.
377 Interpolate(m_EqSys[timeLevel]->UpdateFields(),
380}

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 396 of file DriverParareal.cpp.

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

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 385 of file DriverParareal.cpp.

386{
387 // Restrict fine field to coarse solution.
388 Interpolate(m_EqSys[m_fineLevel]->UpdateFields(),
389 m_EqSys[timeLevel]->UpdateFields(), m_initialCondition,
391}

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 // Start iteration windows.
91 m_comm->GetTimeComm()->Block();
93 for (size_t w = 0; w < m_numWindowsPIT; w++)
94 {
95 timer.Start();
96 // Initialize time for the current window.
98
99 // Print window number.
100 PrintHeader((boost::format("WINDOWS #%1%") % (w + 1)).str(), '*');
101
102 // Update coarse initial condition.
104
105 // Run predictor.
106 for (size_t i = 0; i < m_nVar; ++i)
107 {
108 RecvFromPreviousProc(m_EqSys[m_coarseLevel]->UpdatePhysField(i));
109 }
110 if (m_chunkRank > 0)
111 {
113 }
115 for (size_t i = 0; i < m_nVar; ++i)
116 {
117 SendToNextProc(m_EqSys[m_coarseLevel]->UpdatePhysField(i));
118 }
119
120 // Interpolate coarse solution.
122
123 // Compute exact solution, if necessary.
124 if (m_exactSolution)
125 {
127 }
128 timer.Stop();
129 predictorTime += timer.Elapsed().count();
130 totalTime += timer.Elapsed().count();
131
132 // Solution convergence monitoring.
133 timer.Start();
136 timer.Stop();
137 totalTime += timer.Elapsed().count();
138 if (m_chunkRank == m_numChunks - 1 &&
139 m_comm->GetSpaceComm()->GetRank() == 0)
140 {
141 std::cout << "Total Computation Time : " << totalTime << "s"
142 << std::endl
143 << std::flush;
144 }
145
146 // Start Parareal iteration.
147 size_t iter = 1;
148 int convergenceCurr = false;
149 int convergencePrev = (m_chunkRank == 0);
150 while (iter <= m_iterMaxPIT && !convergenceCurr)
151 {
152 // Use previous parareal solution as "exact solution", if necessary.
153 timer.Start();
154 if (!m_exactSolution)
155 {
157 }
158 timer.Stop();
159 totalTime += timer.Elapsed().count();
160
161 // Calculate fine solution (parallel-in-time).
162 timer.Start();
165 timer.Stop();
166 fineSolveTime += timer.Elapsed().count();
167 totalTime += timer.Elapsed().count();
168
169 // Compute F -> F - Gold
170 timer.Start();
172 timer.Stop();
173 correctionTime += timer.Elapsed().count();
174 totalTime += timer.Elapsed().count();
175
176 // Receive coarse solution from previous processor.
177 timer.Start();
179 timer.Stop();
180 totalTime += timer.Elapsed().count();
181
182 // Calculate coarse solution (serial-in-time).
183 timer.Start();
186 iter);
187 timer.Stop();
188 coarseSolveTime += timer.Elapsed().count();
189 totalTime += timer.Elapsed().count();
190
191 // Compute F -> F + Gnew
192 timer.Start();
194 timer.Stop();
195 correctionTime += timer.Elapsed().count();
196 totalTime += timer.Elapsed().count();
197
198 // Solution convergence monitoring.
200 if (m_chunkRank == m_numChunks - 1 &&
201 m_comm->GetSpaceComm()->GetRank() == 0)
202 {
203 std::cout << "Total Computation Time : " << totalTime << "s"
204 << std::endl
205 << std::flush;
206 std::cout << " - Predictor Time : " << predictorTime << "s"
207 << std::endl
208 << std::flush;
209 std::cout << " - Coarse Solve Time : " << coarseSolveTime << "s"
210 << std::endl
211 << std::flush;
212 std::cout << " - Fine Solve Time : " << fineSolveTime << "s"
213 << std::endl
214 << std::flush;
215 std::cout << " - Correction Time : " << correctionTime << "s"
216 << std::endl
217 << std::flush;
218 }
219
220 // Check convergence of L2 error for each time chunk.
221 convergenceCurr = (vL2ErrorMax() < m_tolerPIT && convergencePrev) ||
222 (m_chunkRank + 1 == iter);
223
224 // Send solution to next processor.
225 timer.Start();
226 SendToNextProc(m_fineSolution, convergenceCurr);
227 timer.Stop();
228 totalTime += timer.Elapsed().count();
229
230 // Increment iteration index.
231 iter++;
232 }
233
234 // Copy converged check points.
236
237 // Write time chunk solution to files.
239
240 // Apply windowing.
241 timer.Start();
243 timer.Stop();
244 totalTime += timer.Elapsed().count();
245 }
246
247 m_comm->GetTimeComm()->Block();
248 PrintHeader("SUMMARY", '*');
251 if (m_chunkRank == m_numChunks - 1 &&
252 m_comm->GetSpaceComm()->GetRank() == 0)
253 {
254 std::cout << "Total Computation Time : " << totalTime << "s"
255 << std::endl
256 << std::flush;
257 std::cout << " - Predictor Time : " << predictorTime << "s" << std::endl
258 << std::flush;
259 std::cout << " - Coarse Solve Time : " << coarseSolveTime << "s"
260 << std::endl
261 << std::flush;
262 std::cout << " - Fine Solve Time : " << fineSolveTime << "s"
263 << std::endl
264 << std::flush;
265 std::cout << " - Correction Time : " << correctionTime << "s"
266 << std::endl
267 << std::flush;
268 }
269}
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 561 of file DriverParareal.cpp.

562{
563 PrintHeader("PRINT SOLUTION FILES", '-');
564
565 // Update field coefficients.
567
568 // Output solution files.
569 m_EqSys[m_fineLevel]->Output();
570}
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.
Definition: NekFactory.hpp:197
static DriverSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
DriverFactory & GetDriverFactory()
Definition: Driver.cpp:65

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