Nektar++
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Nektar::LibUtilities::NekLinSysIter Class Reference

#include <NekLinSysIter.h>

Inheritance diagram for Nektar::LibUtilities::NekLinSysIter:
[legend]

Public Member Functions

 NekLinSysIter (const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey)
 
 ~NekLinSysIter () override=default
 
void SetUniversalUniqueMap (const Array< OneD, const int > &map)
 
void SetNekLinSysTolerance (const NekDouble in)
 
void SetNekLinSysMaxIterations (const unsigned int in)
 
int GetNekLinSysTolerance ()
 
bool IsLocal ()
 
- Public Member Functions inherited from Nektar::LibUtilities::NekSys
 NekSys (const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey)
 
virtual ~NekSys ()=default
 
void InitObject ()
 
int SolveSystem (const int nGlobal, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int nDir=0)
 
const NekSysOperatorsGetSysOperators ()
 
void SetSysOperators (const NekSysOperators &in)
 
void SetFlagWarnings (bool in)
 
void SetRhsMagnitude (const NekDouble mag)
 

Static Public Member Functions

static NekLinSysIterSharedPtr CreateInstance (const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey)
 
- Static Public Member Functions inherited from Nektar::LibUtilities::NekSys
static NekSysSharedPtr CreateInstance (const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey)
 

Protected Member Functions

void v_InitObject () override
 
void SetUniversalUniqueMap ()
 
void Set_Rhs_Magnitude (const Array< OneD, NekDouble > &pIn)
 
void ConvergenceCheck (const Array< OneD, const NekDouble > &Residual)
 
- Protected Member Functions inherited from Nektar::LibUtilities::NekSys
virtual void v_InitObject ()
 
virtual void v_SetSysOperators (const NekSysOperators &in)
 
virtual int v_SolveSystem (const int nGlobal, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const int nDir)
 

Protected Attributes

Array< OneD, int > m_map
 Global to universal unique map. More...
 
NekDouble m_NekLinSysTolerance
 
int m_NekLinSysMaxIterations
 
int m_totalIterations = 0
 
bool m_isLocal
 
- Protected Attributes inherited from Nektar::LibUtilities::NekSys
LibUtilities::CommSharedPtr m_rowComm
 
bool m_converged
 
bool m_root
 
bool m_verbose
 
bool m_FlagWarnings
 
int m_SysDimen
 
NekSysOperators m_operator
 
NekDouble m_rhs_magnitude = NekConstants::kNekUnsetDouble
 

Friends

class MemoryManager< NekLinSysIter >
 Support creation through MemoryManager. More...
 

Detailed Description

Solves a linear system using iterative methods.

Definition at line 55 of file NekLinSysIter.h.

Constructor & Destructor Documentation

◆ NekLinSysIter()

Nektar::LibUtilities::NekLinSysIter::NekLinSysIter ( const LibUtilities::SessionReaderSharedPtr pSession,
const LibUtilities::CommSharedPtr vRowComm,
const int  nDimen,
const NekSysKey pKey 
)

Definition at line 51 of file NekLinSysIter.cpp.

55 : NekSys(pSession, vRowComm, nDimen, pKey)
56{
57 m_NekLinSysTolerance = fmax(pKey.m_NekLinSysTolerance, 1.0E-16);
58 m_NekLinSysMaxIterations = pKey.m_NekLinSysMaxIterations;
59 m_isLocal = false;
60}
NekSys(const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vRowComm, const int nDimen, const NekSysKey &pKey)
Definition: NekSys.cpp:46

References m_isLocal, m_NekLinSysMaxIterations, Nektar::LibUtilities::NekSysKey::m_NekLinSysMaxIterations, m_NekLinSysTolerance, and Nektar::LibUtilities::NekSysKey::m_NekLinSysTolerance.

◆ ~NekLinSysIter()

Nektar::LibUtilities::NekLinSysIter::~NekLinSysIter ( )
overridedefault

Member Function Documentation

◆ ConvergenceCheck()

void Nektar::LibUtilities::NekLinSysIter::ConvergenceCheck ( const Array< OneD, const NekDouble > &  Residual)
protected

◆ CreateInstance()

static NekLinSysIterSharedPtr Nektar::LibUtilities::NekLinSysIter::CreateInstance ( const LibUtilities::SessionReaderSharedPtr pSession,
const LibUtilities::CommSharedPtr vRowComm,
const int  nDimen,
const NekSysKey pKey 
)
inlinestatic

Definition at line 61 of file NekLinSysIter.h.

65 {
68 nDimen, pKey);
69 return p;
70 }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< NekLinSysIter > NekLinSysIterSharedPtr
Definition: NekLinSysIter.h:47

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

◆ GetNekLinSysTolerance()

int Nektar::LibUtilities::NekLinSysIter::GetNekLinSysTolerance ( )
inline

Definition at line 91 of file NekLinSysIter.h.

92 {
94 }

References m_NekLinSysTolerance.

◆ IsLocal()

bool Nektar::LibUtilities::NekLinSysIter::IsLocal ( )
inline

Definition at line 96 of file NekLinSysIter.h.

97 {
98 return m_isLocal;
99 }

References m_isLocal.

◆ Set_Rhs_Magnitude()

void Nektar::LibUtilities::NekLinSysIter::Set_Rhs_Magnitude ( const Array< OneD, NekDouble > &  pIn)
protected

Definition at line 83 of file NekLinSysIter.cpp.

84{
85 NekDouble vExchange(0.0);
86
87 if (m_isLocal)
88 {
89 Array<OneD, NekDouble> wk(pIn.size());
91 vExchange = Vmath::Dot(pIn.size(), wk, pIn);
92 }
93 else
94 {
95 vExchange = Vmath::Dot2(pIn.size(), pIn, pIn, m_map);
96 }
97
98 m_rowComm->AllReduce(vExchange, LibUtilities::ReduceSum);
99 m_rhs_magnitude = (vExchange > 1.0e-6) ? vExchange : 1.0;
100}
Array< OneD, int > m_map
Global to universal unique map.
NekSysOperators m_operator
Definition: NekSys.h:298
void DoAssembleLoc(InArrayType &xn, OutArrayType &xn1, const bool &flag=false) const
Definition: NekSys.h:162
T Dot2(int n, const T *w, const T *x, const int *y)
dot product
Definition: Vmath.hpp:790

References Nektar::LibUtilities::NekSysOperators::DoAssembleLoc(), Vmath::Dot(), Vmath::Dot2(), m_isLocal, m_map, Nektar::LibUtilities::NekSys::m_operator, Nektar::LibUtilities::NekSys::m_rhs_magnitude, Nektar::LibUtilities::NekSys::m_rowComm, and Nektar::LibUtilities::ReduceSum.

Referenced by Nektar::LibUtilities::NekLinSysIterCGLoc::DoConjugateGradient(), Nektar::LibUtilities::NekLinSysIterCG::DoConjugateGradient(), Nektar::LibUtilities::NekLinSysIterGMRESLoc::DoGMRES(), and Nektar::LibUtilities::NekLinSysIterGMRES::DoGMRES().

◆ SetNekLinSysMaxIterations()

void Nektar::LibUtilities::NekLinSysIter::SetNekLinSysMaxIterations ( const unsigned int  in)
inline

Definition at line 86 of file NekLinSysIter.h.

87 {
89 }

References m_NekLinSysMaxIterations.

◆ SetNekLinSysTolerance()

void Nektar::LibUtilities::NekLinSysIter::SetNekLinSysTolerance ( const NekDouble  in)
inline

Definition at line 81 of file NekLinSysIter.h.

82 {
83 m_NekLinSysTolerance = fmax(1.0E-16, in);
84 }

References m_NekLinSysTolerance.

◆ SetUniversalUniqueMap() [1/2]

void Nektar::LibUtilities::NekLinSysIter::SetUniversalUniqueMap ( )
protected

Definition at line 78 of file NekLinSysIter.cpp.

79{
80 m_map = Array<OneD, int>(m_SysDimen, 1);
81}

References m_map, and Nektar::LibUtilities::NekSys::m_SysDimen.

Referenced by v_InitObject().

◆ SetUniversalUniqueMap() [2/2]

void Nektar::LibUtilities::NekLinSysIter::SetUniversalUniqueMap ( const Array< OneD, const int > &  map)

Definition at line 68 of file NekLinSysIter.cpp.

69{
70 int nmap = map.size();
71 if (m_map.size() != nmap)
72 {
73 m_map = Array<OneD, int>(nmap, 0);
74 }
75 Vmath::Vcopy(nmap, map, 1, m_map, 1);
76}
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825

References m_map, and Vmath::Vcopy().

◆ v_InitObject()

void Nektar::LibUtilities::NekLinSysIter::v_InitObject ( )
overrideprotectedvirtual

Friends And Related Function Documentation

◆ MemoryManager< NekLinSysIter >

friend class MemoryManager< NekLinSysIter >
friend

Support creation through MemoryManager.

Definition at line 53 of file NekLinSysIter.h.

Member Data Documentation

◆ m_isLocal

bool Nektar::LibUtilities::NekLinSysIter::m_isLocal
protected

◆ m_map

Array<OneD, int> Nektar::LibUtilities::NekLinSysIter::m_map
protected

◆ m_NekLinSysMaxIterations

int Nektar::LibUtilities::NekLinSysIter::m_NekLinSysMaxIterations
protected

◆ m_NekLinSysTolerance

NekDouble Nektar::LibUtilities::NekLinSysIter::m_NekLinSysTolerance
protected

◆ m_totalIterations

int Nektar::LibUtilities::NekLinSysIter::m_totalIterations = 0
protected