dune-fem  2.6-git
boundaryidprovider.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_MISC_BOUNDARYIDPROVIDER_HH
2 #define DUNE_FEM_MISC_BOUNDARYIDPROVIDER_HH
3 
4 #if not DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
5 #error "Experimental grid extensions required for BoundaryIdProvider. Reconfigure with -DDUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS=TRUE."
6 #endif // #if not DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
7 
8 #if HAVE_DUNE_SPGRID
9 #include <dune/grid/spgrid/declaration.hh>
10 #endif // #if HAVE_DUNE_SPGRID
11 
13 
14 namespace Dune
15 {
16 
17  // External Forward Declarations
18  // -----------------------------
19 
20  template< class Grid >
22 
23 
24 
25  namespace Fem
26  {
27 
28  // Internal Forward Declarations
29  // -----------------------------
30 
31  template< class Grid >
33 
34 
35 
36  // BoundaryIdProvider for AlbertaGrid
37  // ----------------------------------
38 
39 #if HAVE_ALBERTA
40  template< int dim, int dimW >
41  struct BoundaryIdProvider< AlbertaGrid< dim, dimW > >
42  {
43  typedef AlbertaGrid< dim, dimW > GridType;
44 
45  template< class Intersection >
46  static int boundaryId ( const Intersection &intersection )
47  {
48  return intersection.impl().boundaryId();
49  }
50  };
51 #endif // #if HAVE_ALBERTA
52 
53 
54 
55  // BoundaryIdProvider for ALUGrid
56  // ------------------------------
57 
58 #if HAVE_DUNE_ALUGRID
59  template< int dim, int dimw, ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
60  struct BoundaryIdProvider< ALUGrid< dim, dimw, elType, refineType, Comm > >
61  {
62  typedef ALUGrid< dim, dimw, elType, refineType, Comm > GridType;
63 
64  template< class Intersection >
65  static int boundaryId ( const Intersection &intersection )
66  {
67  return intersection.impl().boundaryId();
68  }
69  };
70 #endif // #if HAVE_DUNE_ALUGRID
71 
72 
73 
74  // BoundaryIdProvider for CacheItGrid
75  // ----------------------------------
76 
77 #if HAVE_DUNE_METAGRID
78  template< class HostGrid >
79  struct BoundaryIdProvider< CacheItGrid< HostGrid > >
80  {
81  typedef CacheItGrid< HostGrid > GridType;
82 
83  template< class Intersection >
84  static int boundaryId ( const Intersection &intersection )
85  {
86  return BoundaryIdProvider< HostGrid >
87  ::boundaryId ( HostGridAccess< GridType >::hostIntersection( intersection ) );
88  }
89  };
90 #endif // #if HAVE_DUNE_METAGRID
91 
92 
93 
94  // BoundaryIdProvider for CartesianGrid
95  // ------------------------------------
96 
97 #if HAVE_DUNE_METAGRID
98  template< class HostGrid >
99  struct BoundaryIdProvider< CartesianGrid< HostGrid > >
100  {
101  typedef CartesianGrid< HostGrid > GridType;
102 
103  template< class Intersection >
104  static int boundaryId ( const Intersection &intersection )
105  {
106  return BoundaryIdProvider< HostGrid >
107  ::boundaryId ( HostGridAccess< GridType >::hostIntersection( intersection ) );
108  }
109  };
110 #endif // #if HAVE_DUNE_METAGRID
111 
112 
113 
114  // BoundaryIdProvider for FilteredGrid
115  // -----------------------------------
116 
117 #if HAVE_DUNE_METAGRID
118  template< class HostGrid >
119  struct BoundaryIdProvider< FilteredGrid< HostGrid > >
120  {
121  typedef FilteredGrid< HostGrid > GridType;
122 
123  // todo: FilteredGrid is a filtering grid and, hence, needs a specialized
124  // version of boundaryId.
125  template< class Intersection >
126  static int boundaryId ( const Intersection &intersection )
127  {
128  if( !HostGridAccess< GridType >::hostIntersection( intersection ).boundary() )
129  DUNE_THROW( NotImplemented, "BoundaryIdProvider for artificial boundaries of FilteredGrid not implemented." );
130  return BoundaryIdProvider< HostGrid >
131  ::boundaryId ( HostGridAccess< GridType >::hostIntersection( intersection ) );
132  }
133  };
134 #endif // #if HAVE_DUNE_METAGRID
135 
136 
137 
138  // BoundaryIdProvider for GeometryGrid
139  // -----------------------------------
140 
141  template< class HostGrid, class CoordFunction, class Allocator >
142  struct BoundaryIdProvider< GeometryGrid< HostGrid, CoordFunction, Allocator > >
143  {
144  typedef GeometryGrid< HostGrid, CoordFunction, Allocator > GridType;
145 
146  template< class Intersection >
147  static int boundaryId ( const Intersection &intersection )
148  {
151  }
152  };
153 
154 
155 
156  // BoundaryIdProvider for IdGrid
157  // -----------------------------
158 
159 #if HAVE_DUNE_METAGRID
160  template< class HostGrid >
161  struct BoundaryIdProvider< IdGrid< HostGrid > >
162  {
163  typedef IdGrid< HostGrid > GridType;
164 
165  template< class Intersection >
166  static int boundaryId ( const Intersection &intersection )
167  {
168  return BoundaryIdProvider< HostGrid >
169  ::boundaryId ( HostGridAccess< GridType >::hostIntersection( intersection ) );
170  }
171  };
172 #endif // #if HAVE_DUNE_METAGRID
173 
174 
175 
176  // BoundaryIdProvider for OneDGrid
177  // -------------------------------
178 
179  template<>
180  struct BoundaryIdProvider< OneDGrid >
181  {
182  typedef OneDGrid GridType;
183 
184  template< class Intersection >
185  static int boundaryId ( const Intersection &intersection )
186  {
187  return intersection.boundarySegmentIndex();
188  }
189  };
190 
191 
192 
193  // BoundaryIdProvider for ParallelGrid
194  // -----------------------------------
195 
196 #if HAVE_DUNE_METAGRID
197  template< class HostGrid >
198  struct BoundaryIdProvider< ParallelGrid< HostGrid > >
199  {
200  typedef ParallelGrid< HostGrid > GridType;
201 
202  template< class Intersection >
203  static int boundaryId ( const Intersection &intersection )
204  {
205  return BoundaryIdProvider< HostGrid >
206  ::boundaryId ( HostGridAccess< GridType >::hostIntersection( intersection ) );
207  }
208  };
209 #endif // #if HAVE_DUNE_METAGRID
210 
211 
212 
213  // BoundaryIdProvider for SphereGrid
214  // ---------------------------------
215 
216 #if HAVE_DUNE_METAGRID
217  template< class HostGrid, class MapToSphere >
218  struct BoundaryIdProvider< SphereGrid< HostGrid, MapToSphere > >
219  {
220  typedef SphereGrid< HostGrid, MapToSphere > GridType;
221 
222  template< class Intersection >
223  static int boundaryId ( const Intersection &intersection )
224  {
225  return BoundaryIdProvider< HostGrid >
226  ::boundaryId ( HostGridAccess< GridType >::hostIntersection( intersection ) );
227  }
228  };
229 #endif // #if HAVE_DUNE_METAGRID
230 
231 
232 
233  // BoundaryIdProvider for SPGrid
234  // -----------------------------
235 
236 #if HAVE_DUNE_SPGRID
237  template< class ct, int dim, template< int > class Strategy, class Comm >
238  struct BoundaryIdProvider< SPGrid< ct, dim, Strategy, Comm > >
239  {
240  typedef SPGrid< ct, dim, Strategy, Comm > GridType;
241 
242  template< class Intersection >
243  static int boundaryId ( const Intersection &intersection )
244  {
245  return (intersection.boundary() ? (intersection.indexInInside()+1) : 0);
246  }
247  };
248 #endif // #if HAVE_DUNE_SPGRID
249 
250 
251 
252  // BoundaryIdProvider for UGGrid
253  // -----------------------------
254 
255  template< int dim >
256  struct BoundaryIdProvider< UGGrid< dim > >
257  {
259 
260  template< class Intersection >
261  static int boundaryId ( const Intersection &intersection )
262  {
263  return intersection.boundarySegmentIndex();
264  }
265  };
266 
267 
268 
269  // BoundaryIdProvider for YaspGrid
270  // -------------------------------
271 
272  template< int dim, class CoordCont >
273  struct BoundaryIdProvider< YaspGrid< dim, CoordCont > >
274  {
276 
277  template< class Intersection >
278  static int boundaryId ( const Intersection &intersection )
279  {
280  return (intersection.boundary() ? (intersection.indexInInside()+1) : 0);
281  }
282  };
283 
284  } // namespace Fem
285 
286 } // namespace Dune
287 
288 #endif // #ifndef DUNE_FEM_MISC_BOUNDARYIDPROVIDER_HH
Definition: bindguard.hh:11
Definition: boundaryidprovider.hh:21
Definition: boundaryidprovider.hh:32
static int boundaryId(const Intersection &intersection)
Definition: boundaryidprovider.hh:147
GeometryGrid< HostGrid, CoordFunction, Allocator > GridType
Definition: boundaryidprovider.hh:144
static int boundaryId(const Intersection &intersection)
Definition: boundaryidprovider.hh:185
OneDGrid GridType
Definition: boundaryidprovider.hh:182
UGGrid< dim > GridType
Definition: boundaryidprovider.hh:258
static int boundaryId(const Intersection &intersection)
Definition: boundaryidprovider.hh:261
static int boundaryId(const Intersection &intersection)
Definition: boundaryidprovider.hh:278
YaspGrid< dim, CoordCont > GridType
Definition: boundaryidprovider.hh:275
Definition: griddeclaration.hh:33
Definition: griddeclaration.hh:36
Definition: griddeclaration.hh:39