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