3#ifndef DUNE_ALUGRIDOBJECTFACTORY_HH
4#define DUNE_ALUGRIDOBJECTFACTORY_HH
6#include <dune/grid/alugrid/common/memory.hh>
8#if defined USE_PTHREADS || defined _OPENMP
9#define USE_SMP_PARALLEL
17#include <dune/fem/misc/threads/threadmanager.hh>
22 template <
class InterfaceType>
23 struct MakeableInterfaceObject ;
25 template <
class Gr
idImp>
26 class ALUGridObjectFactory
28 template <
class OF,
int codim>
29 class ALUGridEntityFactory;
36 template <
class Gr
idObjectFactory>
37 class ALUGridEntityFactory<GridObjectFactory,0>
41 typedef typename GridImp :: template Codim<codim> :: Entity Entity;
42 typedef MakeableInterfaceObject<Entity> EntityObject;
43 typedef typename EntityObject :: ImplementationType EntityImp;
45 inline static EntityObject *
46 getNewEntity (
const GridObjectFactory& factory,
int level)
48 return factory.entityProvider_.getEntityObject( factory, level, (EntityImp *) 0);
51 inline static void freeEntity(
const GridObjectFactory& factory, EntityObject * e )
53 factory.entityProvider_.freeObject( e );
57 template <
class Gr
idObjectFactory>
58 class ALUGridEntityFactory<GridObjectFactory,1>
62 typedef typename GridImp :: template Codim<codim> :: Entity Entity;
63 typedef MakeableInterfaceObject<Entity> EntityObject;
64 typedef typename EntityObject :: ImplementationType EntityImp;
66 inline static EntityObject *
67 getNewEntity (
const GridObjectFactory& factory,
int level)
69 return factory.faceProvider_.getEntityObject( factory, level, (EntityImp *) 0);
72 inline static void freeEntity(
const GridObjectFactory& factory, EntityObject * e )
74 factory.faceProvider_.freeObject( e );
78 template <
class Gr
idObjectFactory>
79 class ALUGridEntityFactory<GridObjectFactory,2>
83 typedef typename GridImp :: template Codim<codim> :: Entity Entity;
84 typedef MakeableInterfaceObject<Entity> EntityObject;
85 typedef typename EntityObject :: ImplementationType EntityImp;
87 inline static EntityObject *
88 getNewEntity (
const GridObjectFactory& factory,
int level)
90 return factory.edgeProvider_.getEntityObject( factory, level, (EntityImp *) 0);
93 inline static void freeEntity(
const GridObjectFactory& factory, EntityObject * e )
95 factory.edgeProvider_.freeObject( e );
99 template <
class Gr
idObjectFactory>
100 class ALUGridEntityFactory<GridObjectFactory,3>
104 typedef typename GridImp :: template Codim<codim> :: Entity Entity;
105 typedef MakeableInterfaceObject<Entity> EntityObject;
106 typedef typename EntityObject :: ImplementationType EntityImp;
108 inline static EntityObject *
109 getNewEntity (
const GridObjectFactory& factory,
int level)
111 return factory.vertexProvider_.getEntityObject( factory, level, (EntityImp *) 0);
114 inline static void freeEntity(
const GridObjectFactory& factory, EntityObject * e )
116 factory.vertexProvider_.freeObject( e );
120 enum { vxCodim = GridImp :: dimension };
122 typedef GridImp GridType;
123 typedef ALUGridObjectFactory FactoryType;
125 typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim<0>::Entity> EntityObject;
126 typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim<1>::Entity> FaceObject;
127 typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim<2>::Entity> EdgeObject;
128 typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim< vxCodim >::Entity> VertexObject;
130 typedef typename GridType :: LeafIntersectionIteratorImp LeafIntersectionIteratorImp ;
131 typedef typename GridType :: LevelIntersectionIteratorImp LevelIntersectionIteratorImp ;
134 friend class ALUGridEntityFactory<FactoryType,0>;
135 friend class ALUGridEntityFactory<FactoryType,1>;
136 friend class ALUGridEntityFactory<FactoryType,2>;
137 friend class ALUGridEntityFactory<FactoryType,3>;
145 mutable EntityProvider entityProvider_;
146 mutable FaceProvider faceProvider_;
147 mutable EdgeProvider edgeProvider_;
148 mutable VertexProvider vertexProvider_;
153 mutable LeafIntersectionIteratorProviderType leafInterItProvider_;
154 mutable LevelIntersectionIteratorProviderType levelInterItProvider_;
156 const GridType& grid_ ;
158#ifdef USE_SMP_PARALLEL
161 ALUGridObjectFactory(
const ALUGridObjectFactory& other ) : grid_( other.grid_ ) {}
164 const GridType& grid()
const {
return grid_; }
166 ALUGridObjectFactory(
const GridType& grid ) : grid_( grid ) {}
169 inline MakeableInterfaceObject<typename GridType :: Traits::template Codim<codim>::Entity> *
170 getNewEntity (
int level = -1 )
const
172 return ALUGridEntityFactory<FactoryType,codim>::getNewEntity( *
this, level);
176 inline void freeEntity (MakeableInterfaceObject<
typename GridType :: Traits::template Codim<codim>::Entity> * en)
const
178 ALUGridEntityFactory<FactoryType,codim>::freeEntity(*
this, en);
181 LeafIntersectionIteratorImp& getIntersection(
const int wLevel,
const LeafIntersectionIteratorImp* )
const
183 return * (leafInterItProvider_.getObject( *
this, wLevel ));
186 LevelIntersectionIteratorImp& getIntersection(
const int wLevel,
const LevelIntersectionIteratorImp* )
const
188 return * (levelInterItProvider_.getObject( *
this, wLevel ));
192 void freeIntersection(LeafIntersectionIteratorImp & it)
const { leafInterItProvider_.freeObject( &it ); }
193 void freeIntersection(LevelIntersectionIteratorImp & it)
const { levelInterItProvider_.freeObject( &it ); }
196 static inline int threadNumber()
199 return omp_get_thread_num();
201 return Fem :: ThreadManager :: thread() ;
208 static inline int maxThreads() {
210 return omp_get_max_threads();
212 return Fem :: ThreadManager :: maxThreads() ;
Dune namespace.
Definition: alignment.hh:14