Skip to content
Snippets Groups Projects
Commit a76a33fa authored by Markus Blatt's avatar Markus Blatt
Browse files

Fully support ILU0 and ILUn as smoothers for AMG

[[Imported from SVN: r715]]
parent 6d0e6941
Branches
Tags
No related merge requests found
......@@ -67,13 +67,14 @@ namespace Dune
typedef DefaultSmootherArgs<typename T::matrix_type::field_type> Arguments;
};
template<class T>
class ConstructionTraits;
/**
* @brief Construction Arguments for the default smoothers
*/
template<class T, class C=SequentialInformation>
template<class T>
class DefaultConstructionArgs
{
typedef T Matrix;
......@@ -96,11 +97,30 @@ namespace Dune
args_=&args;
}
template<class T1>
void setComm(T1& comm)
{}
const SmootherArgs getArgs() const
{
return *args_;
}
private:
const Matrix* matrix_;
const SmootherArgs* args_;
};
template<class T>
struct ConstructionArgs
: public DefaultConstructionArgs<typename T::matrix_type>
{};
template<class T, class C=SequentialInformation>
class DefaultParallelConstructionArgs
: public ConstructionArgs<T>
{
public:
void setComm(const C& comm)
{
comm_ = &comm;
......@@ -110,14 +130,11 @@ namespace Dune
{
return *comm_;
}
private:
const Matrix* matrix_;
const SmootherArgs* args_;
const C* comm_;
};
/**
* @brief Policy for the construction of the SeqSSOR smoother
*/
......@@ -181,13 +198,80 @@ namespace Dune
};
/**
* @brief Policy for the construction of the SeqILUn smoother
*/
template<class M, class X, class Y>
struct ConstructionTraits<SeqILU0<M,X,Y> >
{
typedef DefaultConstructionArgs<M> Arguments;
static inline SeqILU0<M,X,Y>* construct(Arguments& args)
{
return new SeqILU0<M,X,Y>(args.getMatrix(),
args.getArgs().relaxationFactor);
}
static void deconstruct(SeqILU0<M,X,Y>* ilu)
{
delete ilu;
}
};
template<class M, class X, class Y>
class ConstructionArgs<SeqILUn<M,X,Y> >
: public DefaultConstructionArgs<M>
{
public:
ConstructionArgs(int n=1)
: n_(n)
{}
void setN(int n)
{
n_ = n;
}
int getN()
{
return n_;
}
private:
int n_;
};
/**
* @brief Policy for the construction of the SeqJac smoother
*/
template<class M, class X, class Y>
struct ConstructionTraits<SeqILUn<M,X,Y> >
{
typedef ConstructionArgs<SeqILUn<M,X,Y> > Arguments;
static inline SeqILUn<M,X,Y>* construct(Arguments& args)
{
return new SeqILUn<M,X,Y>(args.getMatrix(), args.getN(),
args.getArgs().relaxationFactor);
}
static void deconstruct(SeqILUn<M,X,Y>* ilu)
{
delete ilu;
}
};
/**
* @brief Policy for the construction of the ParSSOR smoother
*/
template<class M, class X, class Y, class C>
struct ConstructionTraits<ParSSOR<M,X,Y,C> >
{
typedef DefaultConstructionArgs<M,C> Arguments;
typedef DefaultParallelConstructionArgs<M,C> Arguments;
static inline ParSSOR<M,X,Y,C>* construct(Arguments& args)
{
......@@ -204,18 +288,17 @@ namespace Dune
template<class X, class Y, class C, class T>
struct ConstructionTraits<BlockPreconditioner<X,Y,C,T> >
{
typedef DefaultConstructionArgs<typename T::matrix_type,C> Arguments;
typedef DefaultParallelConstructionArgs<T,C> Arguments;
typedef ConstructionTraits<T> SeqConstructionTraits;
static inline BlockPreconditioner<X,Y,C,T>* construct(Arguments& args)
{
return new BlockPreconditioner<X,Y,C,T>(*(new T(args.getMatrix(), args.getArgs().iterations,
args.getArgs().relaxationFactor)),
return new BlockPreconditioner<X,Y,C,T>(*SeqConstructionTraits::construct(args),
args.getComm());
}
static inline void deconstruct(BlockPreconditioner<X,Y,C,T>* bp)
{
delete &bp->preconditioner;
SeqConstructionTraits::deconstruct(static_cast<T*>(&bp->preconditioner));
delete bp;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment