graphcreator.hh

00001 #ifndef DUNE_AMG_GRAPHCREATOR_HH
00002 #define DUNE_AMG_GRAPHCREATOR_HH
00003 
00004 #include"graph.hh"
00005 #include"pmatrix.hh"
00006 #include"dependency.hh"
00007 #include<dune/istl/operators.hh>
00008 #include<dune/istl/bcrsmatrix.hh>
00009 #include<dune/common/tuples.hh>
00010 
00011 namespace Dune
00012 {
00013   namespace Amg
00014   {
00015     template<class M, int cat=M::category>
00016     struct PropertiesGraphCreator
00017     {
00018     };
00019     
00020     template<class M>
00021     struct PropertiesGraphCreator<M,SolverCategory::sequential>
00022     {
00023       typedef typename M::matrix_type Matrix;
00024       
00025       typedef MatrixGraph<const Matrix> MatrixGraph;
00026       
00027       typedef PropertiesGraph<MatrixGraph,
00028                               VertexProperties,
00029                               EdgeProperties,
00030                               IdentityMap,
00031                               IdentityMap> PropertiesGraph;
00032       
00033       typedef Tuple<MatrixGraph*,PropertiesGraph*> GraphTuple;
00034       
00035       template<class OF, class T>
00036       static GraphTuple create(const M& matrix, T& excluded,
00037                                const SequentialInformation& pinfo,
00038                                const OF&)
00039       {
00040         MatrixGraph* mg = new MatrixGraph(matrix.getmat());
00041         PropertiesGraph* pg = new PropertiesGraph(*mg, IdentityMap(), IdentityMap());
00042         return GraphTuple(mg,pg);
00043       }
00044       
00045       static void free(GraphTuple& graphs)
00046       {
00047         delete Element<1>::get(graphs);
00048       }
00049       
00050     };
00051 
00052     template<class M>
00053     struct PropertiesGraphCreator<M,SolverCategory::overlapping>
00054     {
00055       typedef typename M::matrix_type Matrix;
00056       typedef MatrixGraph<const Matrix> MatrixGraph;
00057       typedef SubGraph<MatrixGraph,
00058                        std::vector<bool> > SubGraph;
00059       typedef PropertiesGraph<SubGraph,
00060                               VertexProperties,
00061                               EdgeProperties,
00062                               IdentityMap,
00063                               typename SubGraph::EdgeIndexMap>
00064       PropertiesGraph;
00065     
00066       typedef Tuple<MatrixGraph*,PropertiesGraph*,SubGraph*> GraphTuple;
00067       
00068       template<class OF, class T, class PI>
00069       static GraphTuple create(const M& matrix, T& excluded, 
00070                                PI& pinfo, const OF& of)
00071       {
00072         typedef OF OverlapFlags;
00073         MatrixGraph* mg = new MatrixGraph(matrix.getmat());
00074         typedef typename PI::ParallelIndexSet ParallelIndexSet;
00075         typedef typename ParallelIndexSet::const_iterator IndexIterator;
00076         IndexIterator iend = pinfo.indexSet().end();
00077         
00078         for(IndexIterator index = pinfo.indexSet().begin(); index != iend; ++index)
00079           excluded[index->local()] = of.contains(index->local().attribute());
00080         
00081         SubGraph* sg= new SubGraph(*mg, excluded);
00082         PropertiesGraph* pg = new PropertiesGraph(*sg, IdentityMap(), sg->getEdgeIndexMap());
00083         return GraphTuple(mg,pg,sg);
00084       }
00085 
00086       static void free(GraphTuple& graphs)
00087       {
00088         delete Element<2>::get(graphs);
00089         delete Element<1>::get(graphs);
00090       }
00091     };
00092     
00093   }//namespace Amg
00094 } // namespace Dune
00095 #endif

Generated on 6 Nov 2008 with Doxygen (ver 1.5.6) [logfile].