File: intersection.hh

package info (click to toggle)
dune-grid 2.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,472 kB
  • sloc: cpp: 60,883; python: 1,438; perl: 191; makefile: 12; sh: 3
file content (100 lines) | stat: -rw-r--r-- 3,853 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// -*- tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_PYTHON_GRID_INTERSECTION_HH
#define DUNE_PYTHON_GRID_INTERSECTION_HH

#include <dune/common/visibility.hh>

#include <dune/python/grid/geometry.hh>
#include <dune/python/pybind11/pybind11.h>
#include <dune/python/pybind11/operators.h>
#include <dune/python/pybind11/extensions.h>

namespace Dune
{

  namespace Python
  {

    namespace detail
    {

      // registerGridIntersection
      // ------------------------

      template< class Intersection >
      void registerGridIntersection ( pybind11::handle scope,
          pybind11::class_<Intersection> cls )
      {
        const int mydimension = Intersection::mydimension;
        // information on boundary intersections
        cls.def_property_readonly( "boundary", &Intersection::boundary );
        cls.def_property_readonly( "boundarySegmentIndex", [] ( const Intersection &i ) {
            return (i.boundary() ? pybind11::cast( i.boundarySegmentIndex() ) : pybind11::none());
          } );

        // conformity
        cls.def_property_readonly( "conforming", &Intersection::conforming );

        // geometric information
        cls.def_property_readonly( "geometry", &Intersection::geometry );
        cls.def_property_readonly( "type", &Intersection::type );
        cls.def_property_readonly( "referenceElement", []( const Intersection &self ) {
            return referenceElement< double, mydimension >( self.type() );
          }, pybind11::keep_alive< 0, 1 >(),
          R"doc(
            corresponding reference element, describing the domain of the map
          )doc" );

        // information on inside entity
        cls.def_property_readonly( "inside", &Intersection::inside );
        cls.def_property_readonly( "geometryInInside", &Intersection::geometryInInside );
        cls.def_property_readonly( "indexInInside", &Intersection::indexInInside );

        // information on outside entity
        cls.def_property_readonly( "outside", [] ( const Intersection &i ) {
              return (i.neighbor() ? pybind11::cast( i.outside() ) : pybind11::none());
            } );
        cls.def_property_readonly( "geometryInOutside", [] ( const Intersection &i ) {
              return (i.neighbor() ? pybind11::cast( i.geometryInOutside() ) : pybind11::none());
            } );
        cls.def_property_readonly( "indexInOutside", [] ( const Intersection &i ) {
              return (i.neighbor() ? pybind11::cast( i.indexInOutside() ) : pybind11::none());
            } );

        // outer normals
        cls.def_property_readonly( "centerUnitOuterNormal", &Intersection::centerUnitOuterNormal);
        cls.def( "outerNormal", &Intersection::outerNormal );
        cls.def( "integrationOuterNormal", &Intersection::integrationOuterNormal );
        cls.def( "unitOuterNormal", &Intersection::unitOuterNormal );

        // comparison
        cls.def( pybind11::self == pybind11::self );
        cls.def( pybind11::self != pybind11::self );
      }

    } // namespace detail



    // registerGridIntersection
    // ------------------------

    template< class GridView >
    auto registerGridIntersection ( pybind11::handle scope )
    {
      typedef typename GridView::Intersection Intersection;
      pybind11::class_< Intersection > cls = insertClass<Intersection>(scope, "Intersection",
         GenerateTypeName(scope,"Intersection")).first;
      detail::registerGridIntersection( scope, cls );
      registerGridGeometry<Intersection>( cls );
      return cls;
    }

  } // namespace Python

} // namespace Dune

#endif //#ifndef DUNE_PYTHON_GRID_INTERSECTION_HH