construction.hh

Go to the documentation of this file.
00001 // $Id: construction.hh 1058 2009-09-04 09:15:34Z mblatt $
00002 #ifndef DUNE_AMGCONSTRUCTION_HH
00003 #define DUNE_AMGCONSTRUCTION_HH
00004 
00005 #include<dune/istl/bvector.hh>
00006 #include<dune/istl/operators.hh>
00007 #include<dune/istl/owneroverlapcopy.hh>
00008 #include"pinfo.hh"
00009 
00010 namespace Dune
00011 {
00012   namespace Amg
00013   {
00014     
00033     template<typename T>
00034     class ConstructionTraits
00035     {
00036     public:
00041       typedef const void* Arguments;
00042       
00049       static inline T* construct(Arguments&  args)
00050       {
00051          return new T();
00052       }
00053 
00058       static inline void deconstruct(T* t)
00059       {
00060         delete t;
00061       }
00062       
00063     };
00064     
00065     template<class T>
00066     class ConstructionTraits<BlockVector<T> >
00067     {
00068     public:
00069       typedef const int Arguments;
00070       static inline BlockVector<T>* construct(Arguments& n)
00071       {
00072         return new BlockVector<T>(n);
00073       }
00074 
00075       static inline void deconstruct(BlockVector<T>* t)
00076       {
00077         delete t;
00078       }
00079     };
00080 
00081     template<class M, class C>
00082     struct OverlappingSchwarzOperatorArgs
00083     {
00084       OverlappingSchwarzOperatorArgs(M& matrix, C& comm)
00085         : matrix_(&matrix), comm_(&comm)
00086       {}
00087       
00088       M* matrix_;
00089       C* comm_;
00090     };
00091     
00092   }// end Amg namspace
00093 
00094   // foward declaration
00095   template<class M, class X, class Y, class C>
00096   class OverlappingSchwarzOperator;
00097 
00098   namespace Amg
00099   {
00100     template<class M, class X, class Y, class C>
00101     class ConstructionTraits<OverlappingSchwarzOperator<M,X,Y,C> >
00102     {
00103     public:
00104       typedef OverlappingSchwarzOperatorArgs<M,C> Arguments;
00105       
00106       static inline OverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args)
00107       {
00108         return new OverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_);
00109       }
00110       
00111       static inline void deconstruct(OverlappingSchwarzOperator<M,X,Y,C>* t)
00112       {
00113         delete t;
00114       }
00115     };
00116 
00117 
00118     template<class M, class X, class Y>
00119     struct MatrixAdapterArgs
00120     {
00121       MatrixAdapterArgs(M& matrix, const SequentialInformation&)
00122         : matrix_(&matrix)
00123       {}
00124       
00125       M* matrix_;
00126     };
00127         
00128     template<class M, class X, class Y>
00129     class ConstructionTraits<MatrixAdapter<M,X,Y> >
00130     {
00131     public:
00132       typedef const MatrixAdapterArgs<M,X,Y> Arguments;
00133       
00134       static inline MatrixAdapter<M,X,Y>* construct(Arguments& args)
00135       {
00136         return new MatrixAdapter<M,X,Y>(*args.matrix_);
00137       }
00138 
00139       static inline void deconstruct(MatrixAdapter<M,X,Y>* m)
00140       {
00141         delete m;
00142       }
00143     };
00144 
00145     template<>
00146     class ConstructionTraits<SequentialInformation>
00147     {
00148     public:
00149       typedef const CollectiveCommunication<void*> Arguments;
00150       
00151       static inline SequentialInformation* construct(Arguments& args)
00152       {
00153         return new SequentialInformation(args);
00154       }
00155       
00156       static inline void deconstruct(SequentialInformation* si)
00157       {
00158         delete si;
00159       }
00160     };
00161     
00162 
00163 #if HAVE_MPI    
00164 
00165     template<class T1, class T2>
00166     class ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> >
00167     {
00168     public:
00169       typedef const MPI_Comm Arguments;
00170       
00171       static inline OwnerOverlapCopyCommunication<T1,T2>* construct(Arguments& args)
00172       {
00173         return new OwnerOverlapCopyCommunication<T1,T2>(args);
00174       }
00175       
00176       static inline void deconstruct(OwnerOverlapCopyCommunication<T1,T2>* com)
00177       {
00178         delete com;
00179       }
00180     };
00181 
00182 #endif
00183     
00185 } // namespace Amg
00186 } // namespace Dune
00187 #endif
Generated on Sat Apr 24 11:13:45 2010 for dune-istl by  doxygen 1.6.3