Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Private Member Functions | Static Private Attributes | List of all members
Nektar::MultiRegions::PreconditionerDiagonal Class Reference

#include <PreconditionerDiagonal.h>

Inheritance diagram for Nektar::MultiRegions::PreconditionerDiagonal:
Inheritance graph
[legend]
Collaboration diagram for Nektar::MultiRegions::PreconditionerDiagonal:
Collaboration graph
[legend]

Public Member Functions

 PreconditionerDiagonal (const boost::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
 
virtual ~PreconditionerDiagonal ()
 
- Public Member Functions inherited from Nektar::MultiRegions::Preconditioner
 Preconditioner (const boost::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
 
virtual ~Preconditioner ()
 
void DoPreconditioner (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
 
void DoPreconditionerWithNonVertOutput (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const Array< OneD, NekDouble > &pNonVertOutput, Array< OneD, NekDouble > &pVertForce=NullNekDouble1DArray)
 
void DoTransformToLowEnergy (Array< OneD, NekDouble > &pInOut, int offset)
 
void DoTransformToLowEnergy (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
 
void DoTransformFromLowEnergy (Array< OneD, NekDouble > &pInOut)
 
void DoMultiplybyInverseTransformationMatrix (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
 
void DoMultiplybyInverseTransposedTransformationMatrix (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
 
void BuildPreconditioner ()
 
void InitObject ()
 
Array< OneD, NekDoubleAssembleStaticCondGlobalDiagonals ()
 Performs global assembly of diagonal entries to global Schur complement matrix. More...
 
const DNekScalBlkMatSharedPtrGetBlockTransformedSchurCompl () const
 
const DNekScalBlkMatSharedPtrGetBlockCMatrix () const
 
const DNekScalBlkMatSharedPtrGetBlockInvDMatrix () const
 
const DNekScalBlkMatSharedPtrGetBlockSchurCompl () const
 
const DNekScalBlkMatSharedPtrGetBlockTransformationMatrix () const
 
const DNekScalBlkMatSharedPtrGetBlockTransposedTransformationMatrix () const
 
DNekScalMatSharedPtr TransformedSchurCompl (int offset, const boost::shared_ptr< DNekScalMat > &loc_mat)
 

Static Public Member Functions

static PreconditionerSharedPtr create (const boost::shared_ptr< GlobalLinSys > &plinsys, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Creates an instance of this class. More...
 

Static Public Attributes

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

Protected Attributes

Array< OneD, NekDoublem_diagonals
 
PreconditionerType m_preconType
 
- Protected Attributes inherited from Nektar::MultiRegions::Preconditioner
const boost::weak_ptr< GlobalLinSysm_linsys
 
PreconditionerType m_preconType
 
DNekMatSharedPtr m_preconditioner
 
boost::shared_ptr< AssemblyMapm_locToGloMap
 
LibUtilities::CommSharedPtr m_comm
 

Private Member Functions

void DiagonalPreconditionerSum (void)
 
void StaticCondDiagonalPreconditionerSum (void)
 
virtual void v_InitObject ()
 
virtual void v_DoPreconditioner (const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
 Apply a preconditioner to the conjugate gradient method. More...
 
virtual void v_BuildPreconditioner ()
 

Static Private Attributes

static std::string lookupIds []
 
static std::string def
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::MultiRegions::Preconditioner
virtual DNekScalMatSharedPtr v_TransformedSchurCompl (int offset, const boost::shared_ptr< DNekScalMat > &loc_mat)
 Get block elemental transposed transformation matrix $\mathbf{R}^{T}$. More...
 

Detailed Description

Definition at line 50 of file PreconditionerDiagonal.h.

Constructor & Destructor Documentation

Nektar::MultiRegions::PreconditionerDiagonal::PreconditionerDiagonal ( const boost::shared_ptr< GlobalLinSys > &  plinsys,
const AssemblyMapSharedPtr pLocToGloMap 
)

Definition at line 61 of file PreconditionerDiagonal.cpp.

64  : Preconditioner(plinsys, pLocToGloMap),
65  m_preconType(pLocToGloMap->GetPreconType())
66  {
67  }
Preconditioner(const boost::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
virtual Nektar::MultiRegions::PreconditionerDiagonal::~PreconditionerDiagonal ( )
inlinevirtual

Definition at line 73 of file PreconditionerDiagonal.h.

73 {}

Member Function Documentation

static PreconditionerSharedPtr Nektar::MultiRegions::PreconditionerDiagonal::create ( const boost::shared_ptr< GlobalLinSys > &  plinsys,
const boost::shared_ptr< AssemblyMap > &  pLocToGloMap 
)
inlinestatic

Creates an instance of this class.

Definition at line 54 of file PreconditionerDiagonal.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

58  {
60  p->InitObject();
61  return p;
62  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< Preconditioner > PreconditionerSharedPtr
void Nektar::MultiRegions::PreconditionerDiagonal::DiagonalPreconditionerSum ( void  )
private

Diagonal preconditioner computed by summing the relevant elements of the local matrix system.

Definition at line 96 of file PreconditionerDiagonal.cpp.

References m_diagonals, Nektar::MultiRegions::Preconditioner::m_linsys, Nektar::MultiRegions::Preconditioner::m_locToGloMap, and Vmath::Sdiv().

Referenced by v_BuildPreconditioner().

97  {
98  boost::shared_ptr<MultiRegions::ExpList> expList =
99  ((m_linsys.lock())->GetLocMat()).lock();
100 
102 
103  int i,j,n,cnt,gid1,gid2;
104  NekDouble sign1,sign2,value;
105  int nGlobal = m_locToGloMap->GetNumGlobalCoeffs();
106  int nDir = m_locToGloMap->GetNumGlobalDirBndCoeffs();
107  int nInt = nGlobal - nDir;
108 
109  // fill global matrix
110  DNekScalMatSharedPtr loc_mat;
111  Array<OneD, NekDouble> vOutput(nGlobal,0.0);
112 
113  int loc_row;
114  int nElmt = expList->GetNumElmts();
115  for(n = cnt = 0; n < nElmt; ++n)
116  {
117  loc_mat = (m_linsys.lock())->GetBlock(expList->GetOffset_Elmt_Id(n));
118  loc_row = loc_mat->GetRows();
119 
120  for(i = 0; i < loc_row; ++i)
121  {
122  gid1 = m_locToGloMap->GetLocalToGlobalMap(cnt + i) - nDir;
123  sign1 = m_locToGloMap->GetLocalToGlobalSign(cnt + i);
124  if(gid1 >= 0)
125  {
126  for(j = 0; j < loc_row; ++j)
127  {
128  gid2 = m_locToGloMap->GetLocalToGlobalMap(cnt + j)
129  - nDir;
130  sign2 = m_locToGloMap->GetLocalToGlobalSign(cnt + j);
131  if(gid2 == gid1)
132  {
133  // When global matrix is symmetric,
134  // only add the value for the upper
135  // triangular part in order to avoid
136  // entries to be entered twice
137  value = vOutput[gid1 + nDir]
138  + sign1*sign2*(*loc_mat)(i,j);
139  vOutput[gid1 + nDir] = value;
140  }
141  }
142  }
143  }
144  cnt += loc_row;
145  }
146 
147  // Assemble diagonal contributions across processes
148  m_locToGloMap->UniversalAssemble(vOutput);
149 
151  Vmath::Sdiv(nInt, 1.0, &vOutput[nDir], 1, &m_diagonals[0], 1);
152  }
boost::shared_ptr< AssemblyMap > m_locToGloMap
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/y.
Definition: Vmath.cpp:257
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
const boost::weak_ptr< GlobalLinSys > m_linsys
double NekDouble
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
void Nektar::MultiRegions::PreconditionerDiagonal::StaticCondDiagonalPreconditionerSum ( void  )
private

Diagonal preconditioner defined as the inverse of the main diagonal of the Schur complement

Definition at line 159 of file PreconditionerDiagonal.cpp.

References Nektar::MultiRegions::Preconditioner::AssembleStaticCondGlobalDiagonals(), m_diagonals, Nektar::MultiRegions::Preconditioner::m_locToGloMap, and Vmath::Sdiv().

Referenced by v_BuildPreconditioner().

160  {
161  int nGlobalBnd = m_locToGloMap->GetNumGlobalBndCoeffs();
162  int nDirBnd = m_locToGloMap->GetNumGlobalDirBndCoeffs();
163  int rows = nGlobalBnd - nDirBnd;
164 
165  Array<OneD, NekDouble> vOutput(nGlobalBnd,0.0);
166 
167  // Extract diagonal contributions
169  for (unsigned int i = 0; i < rows; ++i)
170  {
171  vOutput[nDirBnd + i] = diagonals[i];
172  }
173 
174  // Assemble diagonal contributions across processes
175  m_locToGloMap->UniversalAssembleBnd(vOutput);
176 
178  Vmath::Sdiv(rows, 1.0, &vOutput[nDirBnd], 1, &m_diagonals[0], 1);
179  }
boost::shared_ptr< AssemblyMap > m_locToGloMap
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/y.
Definition: Vmath.cpp:257
Array< OneD, NekDouble > AssembleStaticCondGlobalDiagonals()
Performs global assembly of diagonal entries to global Schur complement matrix.
void Nektar::MultiRegions::PreconditionerDiagonal::v_BuildPreconditioner ( )
privatevirtual

Reimplemented from Nektar::MultiRegions::Preconditioner.

Definition at line 73 of file PreconditionerDiagonal.cpp.

References ASSERTL0, DiagonalPreconditionerSum(), Nektar::MultiRegions::eIterativeFull, Nektar::MultiRegions::eIterativeMultiLevelStaticCond, Nektar::MultiRegions::eIterativeStaticCond, Nektar::MultiRegions::Preconditioner::m_locToGloMap, and StaticCondDiagonalPreconditionerSum().

74  {
75  GlobalSysSolnType solvertype =
76  m_locToGloMap->GetGlobalSysSolnType();
77  if (solvertype == eIterativeFull)
78  {
80  }
81  else if(solvertype == eIterativeStaticCond ||
82  solvertype == eIterativeMultiLevelStaticCond)
83  {
85  }
86  else
87  {
88  ASSERTL0(0,"Unsupported solver type");
89  }
90  }
boost::shared_ptr< AssemblyMap > m_locToGloMap
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
void Nektar::MultiRegions::PreconditionerDiagonal::v_DoPreconditioner ( const Array< OneD, NekDouble > &  pInput,
Array< OneD, NekDouble > &  pOutput 
)
privatevirtual

Apply a preconditioner to the conjugate gradient method.

Reimplemented from Nektar::MultiRegions::Preconditioner.

Definition at line 184 of file PreconditionerDiagonal.cpp.

References Nektar::MultiRegions::eIterativeFull, m_diagonals, Nektar::MultiRegions::Preconditioner::m_locToGloMap, and Vmath::Vmul().

187  {
188  GlobalSysSolnType solvertype =
189  m_locToGloMap->GetGlobalSysSolnType();
190 
191  int nGlobal = solvertype == eIterativeFull ?
192  m_locToGloMap->GetNumGlobalCoeffs() :
193  m_locToGloMap->GetNumGlobalBndCoeffs();
194  int nDir = m_locToGloMap->GetNumGlobalDirBndCoeffs();
195  int nNonDir = nGlobal-nDir;
196  Vmath::Vmul(nNonDir, &pInput[0], 1, &m_diagonals[0], 1, &pOutput[0], 1);
197  }
boost::shared_ptr< AssemblyMap > m_locToGloMap
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:169
void Nektar::MultiRegions::PreconditionerDiagonal::v_InitObject ( )
privatevirtual

Reimplemented from Nektar::MultiRegions::Preconditioner.

Definition at line 69 of file PreconditionerDiagonal.cpp.

70  {
71  }

Member Data Documentation

string Nektar::MultiRegions::PreconditionerDiagonal::className
static
Initial value:
"Diagonal",
"Diagonal Preconditioning")

Name of class.

Registers the class with the Factory.

Definition at line 65 of file PreconditionerDiagonal.h.

std::string Nektar::MultiRegions::PreconditionerDiagonal::def
staticprivate

Definition at line 96 of file PreconditionerDiagonal.h.

std::string Nektar::MultiRegions::PreconditionerDiagonal::lookupIds[]
staticprivate

Definition at line 95 of file PreconditionerDiagonal.h.

Array<OneD, NekDouble> Nektar::MultiRegions::PreconditionerDiagonal::m_diagonals
protected
PreconditionerType Nektar::MultiRegions::PreconditionerDiagonal::m_preconType
protected

Definition at line 79 of file PreconditionerDiagonal.h.