Пример #1
0
    typename viennagrid::result_of::coord< typename PointAccessorT::value_type >::type
    volume_impl(PointAccessorT const accessor, ElementT const & cell, viennagrid::quadrilateral_tag)
    {
      typedef typename PointAccessorT::value_type PointType;

      PointType const & p0 = accessor( vertices(cell)[0] );
      PointType const & p1 = accessor( vertices(cell)[1] );
      PointType const & p2 = accessor( vertices(cell)[2] );
      PointType const & p3 = accessor( vertices(cell)[3] );

      return spanned_volume(p0, p1, p3) + spanned_volume(p1, p2, p3); //sum up the two triangular parts
    }
Пример #2
0
    typename viennagrid::result_of::coord< typename PointAccessorT::value_type >::type
    volume_impl(PointAccessorT const accessor, ElementT const & cell, viennagrid::triangle_tag)
    {
      typedef typename PointAccessorT::value_type PointType;

      PointType const & p0 = accessor( vertices(cell)[0] );
      PointType const & p1 = accessor( vertices(cell)[1] );
      PointType const & p2 = accessor( vertices(cell)[2] );

      return spanned_volume(p0, p1, p2);
    }
Пример #3
0
    bool is_inside_impl( PointAccessorT const accessor,
                         ElementT const & element, viennagrid::tetrahedron_tag,
                         spatial_point<CoordType, CoordinateSystem> const & p,
                         NumericConfigT numeric_config )
    {
      typedef spatial_point<CoordType, CoordinateSystem> PointType;
      typedef typename viennagrid::result_of::coord<PointType>::type NumericType;

      PointType const & a = accessor( viennagrid::vertices(element)[0] );
      PointType const & b = accessor( viennagrid::vertices(element)[1] );
      PointType const & c = accessor( viennagrid::vertices(element)[2] );
      PointType const & d = accessor( viennagrid::vertices(element)[3] );


      NumericType denom = static_cast<NumericType>(1) / spanned_volume(a,b,c,d);

      NumericType A = spanned_volume(p,b,c,d) * denom;
      NumericType B = spanned_volume(a,p,c,d) * denom;
      NumericType C = spanned_volume(a,b,p,d) * denom;
      NumericType D = spanned_volume(a,b,c,p) * denom;

      NumericType abs_eps = absolute_tolerance<NumericType>(numeric_config);
      return (A >= -abs_eps) && (B >= -abs_eps) && (C >= -abs_eps) && (D >= -abs_eps) && (A+B+C+D <= static_cast<NumericType>(1) + NumericType(2.0)*abs_eps);
    }
Пример #4
0
    typename viennagrid::result_of::coord< typename PointAccessorT::value_type >::type
    volume_impl(PointAccessorT const accessor, ElementT const & cell, viennagrid::hexahedron_tag)
    {
      typedef typename PointAccessorT::value_type PointType;

      PointType const & p0 = accessor( vertices(cell)[0] );
      PointType const & p1 = accessor( vertices(cell)[1] );
      PointType const & p2 = accessor( vertices(cell)[2] );
      PointType const & p3 = accessor( vertices(cell)[3] );
      PointType const & p4 = accessor( vertices(cell)[4] );
      PointType const & p5 = accessor( vertices(cell)[5] );
      PointType const & p6 = accessor( vertices(cell)[6] );
      PointType const & p7 = accessor( vertices(cell)[7] );

      //decompose hexahedron into six tetrahedra
      return spanned_volume(p0, p1, p3, p4)
             + spanned_volume(p4, p1, p3, p7)
             + spanned_volume(p4, p1, p7, p5)
             + spanned_volume(p1, p2, p3, p7)
             + spanned_volume(p1, p2, p7, p5)
             + spanned_volume(p5, p2, p7, p6);
    }