dune-grid  2.3beta2
common/intersection.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 
4 #ifndef DUNE_GRID_INTERSECTION_HH
5 #define DUNE_GRID_INTERSECTION_HH
6 
8 
9 namespace Dune
10 {
11 
159  template< class GridImp, class IntersectionImp >
161  {
162 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
163  public:
164 #else
165  protected:
166  // give the GridDefaultImplementation class access to the realImp
167  friend class GridDefaultImplementation<
168  GridImp::dimension, GridImp::dimensionworld,
169  typename GridImp::ctype,
170  typename GridImp::GridFamily> ;
171 #endif
172  // type of underlying implementation, for internal use only
173  typedef IntersectionImp Implementation;
174 
176  Implementation &impl () { return real; }
178  const Implementation &impl () const { return real; }
179 
180  protected:
182 
183  enum { dim=GridImp::dimension };
184  enum { dimworld=GridImp::dimensionworld };
185 
186  public:
188  typedef typename GridImp::template Codim<0>::Entity Entity;
189 
191  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
192 
194  typedef typename GridImp::template Codim<1>::Geometry Geometry;
195 
198 
201 
203  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
204 
206  enum { codimension=1 };
207 
209  enum { dimension=dim };
210 
212  enum { mydimension=dim-1 };
213 
216 
218  typedef typename GridImp::ctype ctype;
219 
221  bool boundary () const
222  {
223  return this->real.boundary();
224  }
225 
226 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
227 
242  int boundaryId () const
243  {
244  return this->real.boundaryId();
245  }
246 #endif
247 
259  size_t boundarySegmentIndex () const
260  {
261  return this->real.boundarySegmentIndex();
262  }
263 
265  bool neighbor () const
266  {
267  return this->real.neighbor();
268  }
269 
274  {
275  return this->real.inside();
276  }
277 
285  {
286  return this->real.outside();
287  }
288 
291  bool conforming () const
292  {
293  return this->real.conforming();
294  }
295 
310  {
311  return this->real.geometryInInside();
312  }
313 
328  {
329  return this->real.geometryInOutside();
330  }
331 
344  {
345  return this->real.geometry();
346  }
347 
350  {
351  return this->real.type();
352  }
353 
363  int indexInInside () const
364  {
365  return this->real.indexInInside();
366  }
367 
377  int indexInOutside () const
378  {
379  return this->real.indexInOutside();
380  }
381 
387  {
388  return this->real.outerNormal(local);
389  }
390 
398  {
399  return this->real.integrationOuterNormal(local);
400  }
401 
408  {
409  return this->real.unitOuterNormal(local);
410  }
411 
419  {
420  return this->real.centerUnitOuterNormal();
421  }
422 
423  //===========================================================
427  //===========================================================
428 
431  : real( impl )
432  {}
434 
435  protected:
438  friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
439 
440  /* hide copy constructor */
442  : real( i.real )
443  {}
444 
445  /* hide assignment operator */
447  {
448  real = i.real;
449  return *this;
450  }
451  };
452 
453  //**********************************************************************
459  template< class GridImp, class IntersectionImp >
461  {
462  enum { dim=GridImp::dimension };
463  enum { dimworld=GridImp::dimensionworld };
464  typedef typename GridImp::ctype ct;
465  public:
466 
470  FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
471  {
472  FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
473  n *= asImp().intersectionGlobal().integrationElement(local);
474  return n;
475  }
476 
478  FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
479  {
480  FieldVector<ct, dimworld> n = asImp().outerNormal(local);
481  n /= n.two_norm();
482  return n;
483  }
484 
486  FieldVector<ct, dimworld> centerUnitOuterNormal () const
487  {
488  // For now, we do this...
489  GeometryType type = asImp().geometry().type();
490  const ReferenceElement<ct, dim-1> & refElement =
491  ReferenceElements<ct, dim-1>::general(type);
492  return asImp().unitOuterNormal(refElement.position(0,0));
493  // But later, if we change the meaning of center(),
494  // we may have to change to this...
495  // return asImp().unitOuterNormal(asImp().local(asImp().center()));
496  }
497 
498  private:
499  // CRTP (curiously recurring template pattern)
500  IntersectionImp &asImp () { return static_cast< IntersectionImp & >( *this ); }
501  const IntersectionImp &asImp () const { return static_cast< const IntersectionImp & >( *this ); }
502  };
503 
504 } // namespace Dune
505 
506 #endif // DUNE_GRID_INTERSECTION_HH