Commit b57b3346 authored by Andrew Comerford's avatar Andrew Comerford
Browse files

Preconditioner Factory

parent eeefef9e
......@@ -40,7 +40,10 @@ GlobalMatrixKey.cpp
GlobalOptimizationParameters.cpp
SubStructuredGraph.cpp
Preconditioner.cpp
PreconditionerDiagonal.cpp
PreconditionerLowEnergy.cpp
)
SET(MULTI_REGIONS_HEADERS
......@@ -80,6 +83,8 @@ MultiRegionsDeclspec.h
GlobalOptimizationParameters.h
SubStructuredGraph.h
Preconditioner.h
PreconditionerDiagonal.h
PreconditionerLowEnergy.h
)
SET(ASSEMBLY_MAP_HEADERS
......
......@@ -347,9 +347,14 @@ namespace Nektar
// Check if preconditioner has been computed and compute if needed.
if (!m_precon)
{
v_UniqueMap();
m_precon = MemoryManager<Preconditioner>::AllocateSharedPtr(
GetSharedThisPtr(),plocToGloMap);
MultiRegions::PreconditionerType pType = plocToGloMap->GetPreconType();
std::string PreconType = MultiRegions::PreconditionerTypeMap[pType];
v_UniqueMap();
m_precon = GetPreconFactory().CreateInstance(PreconType,GetSharedThisPtr(),plocToGloMap);
//m_precon = MemoryManager<Preconditioner>::AllocateSharedPtr(
// GetSharedThisPtr(),plocToGloMap);
}
// Get the communicator for performing data exchanges
......
......@@ -239,7 +239,7 @@ namespace Nektar
}
else
{
DNekScalBlkMat &S1 = *m_S1Blk;
DNekScalBlkMat &S1 = *m_S1Blk;
DNekScalBlkMat &R = *m_RBlk;
DNekScalBlkMat &BinvD = *m_BinvD;
......@@ -280,7 +280,6 @@ namespace Nektar
pLocToGloMap->GlobalToLocalBnd(F_GlobBnd,F_LocBnd);
F_LocBnd=R*F_LocBnd;
pLocToGloMap->AssembleBnd(F_LocBnd,F_HomBnd, nDirBndDofs);
//pLocToGloMap->LocalBndToGlobal(F_LocBnd,F_HomBnd, nDirBndDofs);
}
......@@ -299,7 +298,7 @@ namespace Nektar
//transform back to original basis
if(pLocToGloMap->GetPreconType() == MultiRegions::eLowEnergy)
{
DNekScalBlkMat &RT = *m_RTBlk;
DNekScalBlkMat &RT = *m_RTBlk;
pLocToGloMap->GlobalToLocalBnd(V_GlobHomBnd,V_LocBnd, nDirBndDofs);
......@@ -431,7 +430,7 @@ namespace Nektar
void GlobalLinSysIterativeStaticCond::SetupLowEnergyTopLevel(
const boost::shared_ptr<AssemblyMap>& pLocToGloMap)
{
int n;
int n;
int n_exp = m_expList.lock()->GetNumElmts();
const Array<OneD,const unsigned int>& nbdry_size
......@@ -439,10 +438,12 @@ namespace Nektar
const Array<OneD,const unsigned int>& nint_size
= pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
MultiRegions::PreconditionerType pType = pLocToGloMap->GetPreconType();
std::string PreconType = MultiRegions::PreconditionerTypeMap[pType];
v_UniqueMap();
m_precon = MemoryManager<Preconditioner>::AllocateSharedPtr(
GetSharedThisPtr(),m_locToGloMap);
m_precon = GetPreconFactory().CreateInstance(PreconType,GetSharedThisPtr(),pLocToGloMap);
// Setup Block Matrix systems
MatrixStorage blkmatStorage = eDIAGONAL;
......@@ -501,7 +502,7 @@ namespace Nektar
m_RBlk->SetBlock(n,n, tmp_mat = MemoryManager<DNekScalMat>::AllocateSharedPtr(one,m_R));
m_RTBlk->SetBlock(n,n, tmp_mat = MemoryManager<DNekScalMat>::AllocateSharedPtr(one,m_RT));
}
}
}
/**
* Assemble the schur complement matrix from the block matrices stored
......
......@@ -116,7 +116,7 @@ namespace Nektar
// Workspace array for matrix multiplication
Array<OneD, NekDouble> m_wsp;
PreconditionerSharedPtr m_precon;
PreconditionerSharedPtr m_precon;
/// Solve the linear system for given input and output vectors
/// using a specified local to global map.
......
This diff is collapsed.
......@@ -43,6 +43,14 @@ namespace Nektar
{
namespace MultiRegions
{
class Preconditioner;
typedef boost::shared_ptr<Preconditioner> PreconditionerSharedPtr;
typedef LibUtilities::NekFactory< std::string, Preconditioner,
const boost::shared_ptr<GlobalLinSys>&,
const boost::shared_ptr<AssemblyMap>& > PreconFactory;
PreconFactory& GetPreconFactory();
class Preconditioner
{
public:
......@@ -53,86 +61,81 @@ namespace Nektar
MULTI_REGIONS_EXPORT
virtual ~Preconditioner() {}
void DoPreconditioner(
inline void DoPreconditioner(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput);
const DNekMatSharedPtr& GetTransformationMatrix() const;
inline void InitObject();
const DNekMatSharedPtr& GetTransposedTransformationMatrix() const;
Array<OneD, NekDouble> AssembleStaticCondGlobalDiagonals();
const DNekMatSharedPtr& GetInverseTransformationMatrix() const;
const inline DNekMatSharedPtr &GetTransformationMatrix(void) const;
const inline DNekMatSharedPtr &GetTransposedTransformationMatrix(void) const;
const DNekMatSharedPtr& GetInverseTransposedTransformationMatrix() const;
protected:
const boost::weak_ptr<GlobalLinSys> m_linsys;
PreconditionerType m_preconType;
StdRegions::StdExpansionSharedPtr vExp;
DNekMatSharedPtr m_preconditioner;
DNekScalBlkMatSharedPtr GloBlkMat;
DNekScalMatSharedPtr bnd_mat;
DNekMatSharedPtr m_vertexedgefacetransformmatrix;
DNekMatSharedPtr m_vertexedgefacecoupling;
DNekMatSharedPtr m_edgefacecoupling;
DNekMatSharedPtr m_transformationmatrix;
DNekMatSharedPtr m_inversetransformationmatrix;
DNekMatSharedPtr m_transposedtransformationmatrix;
DNekMatSharedPtr m_inversetransposedtransformationmatrix;
DNekMatSharedPtr m_efedgefacecoupling;
DNekMatSharedPtr m_effacefacecoupling;
DNekMatSharedPtr m_edgefacetransformmatrix;
boost::shared_ptr<AssemblyMap> m_locToGloMap;
Array<OneD, int> vertModeLocation;
Array<OneD, Array<OneD, unsigned int> > edgeModeLocation;
Array<OneD, Array<OneD, unsigned int> > faceModeLocation;
Array<OneD, Array<OneD, unsigned int> > MatEdgeLocation;
Array<OneD, Array<OneD, unsigned int> > MatFaceLocation;
private:
void NullPreconditioner(void);
void DiagonalPreconditionerSum(void);
void StaticCondDiagonalPreconditionerSum(void);
void InverseLinearSpacePreconditioner(void);
void StaticCondInverseLinearSpacePreconditioner(void);
void SetUpLowEnergyBasis(void);
virtual void v_InitObject();
void CreateLinearFiniteElmentSpace(void);
void CreateReferenceGeometryAndMatrix(void);
void SetLowEnergyModes_Rv(void);
void SetLowEnergyModes_Ref(void);
void SetUpInverseTransformationMatrix(void);
void LowEnergyPreconditioner(void);
void BlockPreconditioner(void);
virtual void v_DoPreconditioner(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput);
void VertexEdgeFaceMatrix(void);
virtual const DNekMatSharedPtr& v_GetTransformationMatrix(void) const;
Array<OneD, NekDouble> AssembleStaticCondGlobalDiagonals();
virtual const DNekMatSharedPtr& v_GetTransposedTransformationMatrix(void) const;
static std::string lookupIds[];
static std::string def;
};
typedef boost::shared_ptr<Preconditioner> PreconditionerSharedPtr;
/**
*
*/
inline void Preconditioner::InitObject()
{
v_InitObject();
}
/**
*
*/
inline const DNekMatSharedPtr& Preconditioner::GetTransformationMatrix(void) const
{
return v_GetTransformationMatrix();
}
/**
*
*/
inline const DNekMatSharedPtr& Preconditioner::GetTransposedTransformationMatrix(void) const
{
return v_GetTransposedTransformationMatrix();
}
/**
*
*/
inline void Preconditioner::DoPreconditioner(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput)
{
v_DoPreconditioner(pInput,pOutput);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment