- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 // $Id$ 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<dune/istl/solvercategory.hh> 00009 #include"pinfo.hh" 00010 00011 namespace Dune 00012 { 00013 namespace Amg 00014 { 00015 00034 template<typename T> 00035 class ConstructionTraits 00036 { 00037 public: 00042 typedef const void* Arguments; 00043 00050 static inline T* construct(Arguments& args) 00051 { 00052 return new T(); 00053 } 00054 00059 static inline void deconstruct(T* t) 00060 { 00061 delete t; 00062 } 00063 00064 }; 00065 00066 template<class T> 00067 class ConstructionTraits<BlockVector<T> > 00068 { 00069 public: 00070 typedef const int Arguments; 00071 static inline BlockVector<T>* construct(Arguments& n) 00072 { 00073 return new BlockVector<T>(n); 00074 } 00075 00076 static inline void deconstruct(BlockVector<T>* t) 00077 { 00078 delete t; 00079 } 00080 }; 00081 00082 template<class M, class C> 00083 struct OverlappingSchwarzOperatorArgs 00084 { 00085 OverlappingSchwarzOperatorArgs(M& matrix, C& comm) 00086 : matrix_(&matrix), comm_(&comm) 00087 {} 00088 00089 M* matrix_; 00090 C* comm_; 00091 }; 00092 00093 template<class M, class C> 00094 struct NonoverlappingOperatorArgs 00095 { 00096 NonoverlappingOperatorArgs(M& matrix, C& comm) 00097 : matrix_(&matrix), comm_(&comm) 00098 {} 00099 00100 M* matrix_; 00101 C* comm_; 00102 }; 00103 00104 #if HAVE_MPI 00105 struct OwnerOverlapCopyCommunicationArgs 00106 { 00107 OwnerOverlapCopyCommunicationArgs(MPI_Comm comm, SolverCategory::Category cat) 00108 : comm_(comm), cat_(cat) 00109 {} 00110 00111 MPI_Comm comm_; 00112 SolverCategory::Category cat_; 00113 }; 00114 #endif 00115 00116 struct SequentialCommunicationArgs 00117 { 00118 SequentialCommunicationArgs(CollectiveCommunication<void*> comm, int cat) 00119 : comm_(comm) 00120 {} 00121 00122 CollectiveCommunication<void*> comm_; 00123 }; 00124 00125 }// end Amg namspace 00126 00127 // foward declaration 00128 template<class M, class X, class Y, class C> 00129 class OverlappingSchwarzOperator; 00130 00131 template<class M, class X, class Y, class C> 00132 class NonoverlappingSchwarzOperator; 00133 00134 namespace Amg 00135 { 00136 template<class M, class X, class Y, class C> 00137 class ConstructionTraits<OverlappingSchwarzOperator<M,X,Y,C> > 00138 { 00139 public: 00140 typedef OverlappingSchwarzOperatorArgs<M,C> Arguments; 00141 00142 static inline OverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args) 00143 { 00144 return new OverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_); 00145 } 00146 00147 static inline void deconstruct(OverlappingSchwarzOperator<M,X,Y,C>* t) 00148 { 00149 delete t; 00150 } 00151 }; 00152 00153 template<class M, class X, class Y, class C> 00154 class ConstructionTraits<NonoverlappingSchwarzOperator<M,X,Y,C> > 00155 { 00156 public: 00157 typedef NonoverlappingOperatorArgs<M,C> Arguments; 00158 00159 static inline NonoverlappingSchwarzOperator<M,X,Y,C>* construct(const Arguments& args) 00160 { 00161 return new NonoverlappingSchwarzOperator<M,X,Y,C>(*args.matrix_, *args.comm_); 00162 } 00163 00164 static inline void deconstruct(NonoverlappingSchwarzOperator<M,X,Y,C>* t) 00165 { 00166 delete t; 00167 } 00168 }; 00169 00170 template<class M, class X, class Y> 00171 struct MatrixAdapterArgs 00172 { 00173 MatrixAdapterArgs(M& matrix, const SequentialInformation&) 00174 : matrix_(&matrix) 00175 {} 00176 00177 M* matrix_; 00178 }; 00179 00180 template<class M, class X, class Y> 00181 class ConstructionTraits<MatrixAdapter<M,X,Y> > 00182 { 00183 public: 00184 typedef const MatrixAdapterArgs<M,X,Y> Arguments; 00185 00186 static inline MatrixAdapter<M,X,Y>* construct(Arguments& args) 00187 { 00188 return new MatrixAdapter<M,X,Y>(*args.matrix_); 00189 } 00190 00191 static inline void deconstruct(MatrixAdapter<M,X,Y>* m) 00192 { 00193 delete m; 00194 } 00195 }; 00196 00197 template<> 00198 class ConstructionTraits<SequentialInformation> 00199 { 00200 public: 00201 typedef const SequentialCommunicationArgs Arguments; 00202 static inline SequentialInformation* construct(Arguments& args) 00203 { 00204 return new SequentialInformation(args.comm_); 00205 } 00206 00207 static inline void deconstruct(SequentialInformation* si) 00208 { 00209 delete si; 00210 } 00211 }; 00212 00213 00214 #if HAVE_MPI 00215 00216 template<class T1, class T2> 00217 class ConstructionTraits<OwnerOverlapCopyCommunication<T1,T2> > 00218 { 00219 public: 00220 typedef const OwnerOverlapCopyCommunicationArgs Arguments; 00221 00222 static inline OwnerOverlapCopyCommunication<T1,T2>* construct(Arguments& args) 00223 { 00224 return new OwnerOverlapCopyCommunication<T1,T2>(args.comm_, args.cat_); 00225 } 00226 00227 static inline void deconstruct(OwnerOverlapCopyCommunication<T1,T2>* com) 00228 { 00229 delete com; 00230 } 00231 }; 00232 00233 #endif 00234 00236 } // namespace Amg 00237 } // namespace Dune 00238 #endif
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].