dune-grid  2.2.1
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 
162 template<class GridImp, template<class> class IntersectionImp>
163 class Intersection
164 {
165 #if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
166 public:
167 #else
168 protected:
169  // give the GridDefaultImplementation class access to the realImp
170  friend class GridDefaultImplementation<
171  GridImp::dimension, GridImp::dimensionworld,
172  typename GridImp::ctype,
173  typename GridImp::GridFamily> ;
174 #endif
175  // type of underlying implementation, for internal use only
176  typedef IntersectionImp< const GridImp > Implementation;
177 
179  Implementation &impl () { return real; }
181  const Implementation &impl () const { return real; }
182 
183 protected:
185 
186  enum { dim=GridImp::dimension };
187  enum { dimworld=GridImp::dimensionworld };
188 
189 public:
191  typedef typename GridImp::template Codim<0>::Entity Entity;
192 
194  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
195 
197  typedef typename GridImp::template Codim<1>::Geometry Geometry;
198 
201 
204 
206  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
207 
209  enum { codimension=1 };
210 
212  enum { dimension=dim };
213 
215  enum { mydimension=dim-1 };
216 
219 
221  typedef typename GridImp::ctype ctype;
222 
224  bool boundary () const
225  {
226  return this->real.boundary();
227  }
228 
244  int boundaryId () const
245  // allow to use boundary id without warning when experimental is enabled
246 #if ! DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
247  DUNE_DEPRECATED
248 #endif
249  {
250  return this->real.boundaryId();
251  }
252 
264  size_t boundarySegmentIndex () const
265  {
266  return this->real.boundarySegmentIndex();
267  }
268 
270  bool neighbor () const
271  {
272  return this->real.neighbor();
273  }
274 
279  {
280  return this->real.inside();
281  }
282 
290  {
291  return this->real.outside();
292  }
293 
304  bool conforming () const
305  {
306  return this->real.conforming();
307  }
308 
323  {
324  return this->real.geometryInInside();
325  }
326 
341  {
342  return this->real.geometryInOutside();
343  }
344 
357  {
358  return this->real.geometry();
359  }
360 
363  {
364  return this->real.type();
365  }
366 
376  int indexInInside () const
377  {
378  return this->real.indexInInside();
379  }
380 
390  int indexInOutside () const
391  {
392  return this->real.indexInOutside();
393  }
394 
400  {
401  return this->real.outerNormal(local);
402  }
403 
411  {
412  return this->real.integrationOuterNormal(local);
413  }
414 
421  {
422  return this->real.unitOuterNormal(local);
423  }
424 
432  {
433  return this->real.centerUnitOuterNormal();
434  }
435 
436  //===========================================================
440  //===========================================================
441 
443  Intersection(const IntersectionImp<const GridImp> & i) :
444  real(i) {}
446 
447  typedef typename remove_const<GridImp>::type mutableGridImp;
448 protected:
451  friend class IntersectionIterator<GridImp, IntersectionImp, IntersectionImp>;
452 
453  /* hide copy constructor */
455  : real( i.real )
456  {}
457 
458  /* hide assignment operator */
460  {
461  real = i.real;
462  return *this;
463  }
464 };
465 
466 //**********************************************************************
472 template<class GridImp, template<class> class IntersectionImp>
474 {
475  enum { dim=GridImp::dimension };
476  enum { dimworld=GridImp::dimensionworld };
477  typedef typename GridImp::ctype ct;
478 public:
479 
483  FieldVector<ct, dimworld> integrationOuterNormal (const FieldVector<ct, dim-1>& local) const
484  {
485  FieldVector<ct, dimworld> n = asImp().unitOuterNormal(local);
486  n *= asImp().intersectionGlobal().integrationElement(local);
487  return n;
488  }
489 
491  FieldVector<ct, dimworld> unitOuterNormal (const FieldVector<ct, dim-1>& local) const
492  {
493  FieldVector<ct, dimworld> n = asImp().outerNormal(local);
494  n /= n.two_norm();
495  return n;
496  }
497 
499  FieldVector<ct, dimworld> centerUnitOuterNormal () const
500  {
501  // For now, we do this...
502  GeometryType type = asImp().geometry().type();
503  const GenericReferenceElement<ct, dim-1> & refElement =
504  GenericReferenceElements<ct, dim-1>::general(type);
505  return asImp().unitOuterNormal(refElement.position(0,0));
506  // But later, if we change the meaning of center(),
507  // we may have to change to this...
508  // return asImp().unitOuterNormal(asImp().local(asImp().center()));
509  }
510 
511 private:
513  IntersectionImp<GridImp>& asImp ()
514  {return static_cast<IntersectionImp<GridImp>&>(*this);}
515  const IntersectionImp<GridImp>& asImp () const
516  {return static_cast<const IntersectionImp<GridImp>&>(*this);}
517 };
518 
519 } // namespace Dune
520 
521 #endif // DUNE_GRID_INTERSECTION_HH