3 #ifndef DUNE_ALBERTA_DOFADMIN_HH 4 #define DUNE_ALBERTA_DOFADMIN_HH 6 #include <dune/common/hybridutilities.hh> 7 #include <dune/common/std/utility.hh> 31 template<
int dim,
int codim >
51 node_ = dofSpace->admin->mesh->node[ codimtype ];
52 index_ = dofSpace->admin->n0_dof[ codimtype ];
58 assert( node_ != -1 );
59 assert( subEntity < numSubEntities );
60 return element->dof[ node_ + subEntity ][ index_ + i ];
65 return (*
this)( element, subEntity, 0 );
68 int operator() (
const ElementInfo &elementInfo,
int subEntity,
int i )
const 70 return (*
this)( elementInfo.
el(), subEntity, i );
73 int operator() (
const ElementInfo &elementInfo,
int subEntity )
const 75 return (*
this)( elementInfo.
el(), subEntity );
100 static const int nNodeTypes = N_NODE_TYPES;
102 template<
int codim >
103 struct CreateDofSpace;
105 template<
int codim >
106 struct CacheDofSpace;
108 typedef std::pair< int, int > Cache;
116 This &operator= (
const This & );
126 assert( !(*
this) ==
false );
127 assert( (codim >= 0) && (codim <= dimension) );
128 const Cache &cache = cache_[ codim ];
129 return element->dof[ cache.first + subEntity ][ cache.second ];
132 int operator() (
const ElementInfo &element,
int codim,
unsigned int subEntity )
const 134 return (*
this)( element.
el(), codim, subEntity );
137 explicit operator bool ()
const 145 assert( (codim >= 0) && (codim <= dimension) );
146 return dofSpace_[ codim ];
155 const MeshPointer &
mesh ()
const 162 return dofSpace( codim )->admin->size;
165 void create (
const MeshPointer &mesh );
171 for(
int codim = 0; codim <=
dimension; ++codim )
172 freeDofSpace( dofSpace_[ codim ] );
173 freeDofSpace( emptySpace_ );
174 mesh_ = MeshPointer();
179 static const DofSpace *createEmptyDofSpace (
const MeshPointer &mesh );
180 static const DofSpace *createDofSpace (
const MeshPointer &mesh,
181 const std::string &name,
182 const int (&ndof)[ nNodeTypes ],
183 const bool periodic =
false );
184 static void freeDofSpace (
const DofSpace *dofSpace );
188 const DofSpace *dofSpace_[ dimension+1 ];
189 Cache cache_[ dimension+1 ];
205 Hybrid::forEach( Std::make_index_sequence< dimension+1 >{}, [ & ](
auto i ){ CreateDofSpace< i >::apply( mesh_, dofSpace_ ); } );
206 Hybrid::forEach( Std::make_index_sequence< dimension+1 >{}, [ & ](
auto i ){ CacheDofSpace< i >::apply( dofSpace_, cache_ ); } );
208 emptySpace_ = createEmptyDofSpace( mesh_ );
209 for(
int i = 0; i < nNodeTypes; ++i )
210 assert( emptySpace_->admin->n_dof[ i ] == 0 );
219 int ndof[ nNodeTypes ];
220 for(
int i = 0; i < nNodeTypes; ++i )
222 std::string name =
"Empty";
223 return createDofSpace( mesh, name, ndof );
230 const std::string &name,
231 const int (&ndof)[ nNodeTypes ],
232 const bool periodic )
235 = ADM_PRESERVE_COARSE_DOFS | (periodic ? ADM_PERIODIC : 0);
236 return ALBERTA get_dof_space ( mesh, name.c_str(), ndof, flags );
244 ALBERTA free_fe_space( dofSpace );
253 template<
int codim >
258 int ndof[ nNodeTypes ];
259 for(
int i = 0; i < nNodeTypes; ++i )
263 std::string name =
"Codimension ";
264 name += (char)(codim +
'0');
266 dofSpace[ codim ] = createDofSpace( mesh, name, ndof );
267 assert( dofSpace[ codim ] );
277 template<
int codim >
280 static void apply (
const DofSpace *(&dofSpace)[ dim+1 ], Cache (&cache)[ dim+1 ] )
282 assert( dofSpace[ codim ] );
284 cache[ codim ].first = dofSpace[ codim ]->mesh->node[ codimtype ];
285 cache[ codim ].second = dofSpace[ codim ]->admin->n0_dof[ codimtype ];
293 #endif // #if HAVE_ALBERTA 295 #endif // #ifndef DUNE_ALBERTA_DOFADMIN_HH #define ALBERTA
Definition: albertaheader.hh:27
DofAccess()
Definition: dofadmin.hh:44
void release()
Definition: dofadmin.hh:167
ALBERTA FE_SPACE DofSpace
Definition: misc.hh:63
int size(int codim) const
Definition: dofadmin.hh:160
int operator()(const Element *element, int subEntity, int i) const
Definition: dofadmin.hh:55
static const int dimension
Definition: dofadmin.hh:39
Definition: dofadmin.hh:89
provides a wrapper for ALBERTA's el_info structure
Alberta::MeshPointer< dimension > MeshPointer
Definition: dofadmin.hh:96
Alberta::ElementInfo< dimension > ElementInfo
Definition: dofadmin.hh:97
static const int codimension
Definition: dofadmin.hh:40
Element * el() const
Definition: elementinfo.hh:735
const MeshPointer & mesh() const
Definition: dofadmin.hh:155
Definition: dofadmin.hh:32
~HierarchyDofNumbering()
Definition: dofadmin.hh:119
const DofSpace * dofSpace(int codim) const
Definition: dofadmin.hh:142
const DofSpace * emptyDofSpace() const
Definition: dofadmin.hh:149
Definition: dofadmin.hh:24
Alberta::ElementInfo< dimension > ElementInfo
Definition: dofadmin.hh:42
static const int numSubEntities
Definition: dofadmin.hh:37
ALBERTA EL Element
Definition: misc.hh:52
void create(const MeshPointer &mesh)
Definition: dofadmin.hh:196
HierarchyDofNumbering()
Definition: dofadmin.hh:111
DofAccess(const DofSpace *dofSpace)
Definition: dofadmin.hh:48
Include standard header files.
Definition: agrid.hh:58