3#ifndef DUNE_PYTHON_MMESH_INTERFACEGRID_HH
4#define DUNE_PYTHON_MMESH_INTERFACEGRID_HH
14#include <dune/common/hybridutilities.hh>
15#include <dune/common/iteratorrange.hh>
17#include <dune/geometry/referenceelements.hh>
18#include <dune/geometry/type.hh>
20#include <dune/python/common/mpihelper.hh>
21#include <dune/python/common/typeregistry.hh>
23#include <dune/python/grid/capabilities.hh>
24#include <dune/python/grid/enums.hh>
25#include <dune/python/grid/factory.hh>
26#include <dune/python/grid/gridview.hh>
27#include <dune/python/grid/idset.hh>
29#include <dune/python/pybind11/functional.h>
30#include <dune/python/pybind11/numpy.h>
31#include <dune/python/pybind11/pybind11.h>
32#include <dune/python/pybind11/stl.h>
43 template<
class Grid,
class... options >
44 void registerHierarchicalGrid ( pybind11::module module, pybind11::class_<Grid, options... > cls )
46 Dune::Python::registerHierarchicalGrid( module, cls );
48 cls.def_property_readonly(
"bulkGrid", [] (
const Grid &grid ) {
49 return grid.getMMesh().leafGridView();
52 Obtain bulk grid of the MMesh
63 template<
int d,
class... options >
64 void registerHierarchicalGrid ( pybind11::module module, pybind11::class_<
Dune::MovingMesh<d>, options...> cls )
66 Dune::Python::registerHierarchicalGrid( module, cls );
70 cls.def_property_readonly(
"interfaceHierarchicalGrid", [] (
const Grid &grid ) ->
const auto & {
71 return grid.interfaceGrid();
72 }, pybind11::return_value_policy::reference, pybind11::keep_alive< 0, 1 >(),
74 Obtain interface hierarchical grid of the MMesh
76 Returns: interface hierarchical grid
79 using Element =
typename Grid::template Codim< 0 >::Entity;
80 using Vertex =
typename Grid::template Codim< d >::Entity;
81 using Intersection =
typename Grid::Intersection;
82 using InterfaceEntity =
typename Grid::InterfaceEntity;
83 using InterfaceGrid =
typename Grid::InterfaceGrid;
84 using InterfaceVertex =
typename InterfaceGrid::template Codim< InterfaceGrid::dimension >::Entity;
85 using FieldVector = Dune::FieldVector< double, d >;
87 cls.def(
"preAdapt", [] ( Grid &self ) {
91 Prepare grid for adaption
94 cls.def( "ensureInterfaceMovement", [] ( Grid &self,
const std::vector< FieldVector >& shifts ) {
95 return self.ensureInterfaceMovement( shifts );
98 Ensure the non-degeneration of the mesh after movement of the interface vertices
101 cls.def( "markElements", [] ( Grid &self ) {
102 return self.markElements();
105 Mark all elements in accordance to the default indicator
108 cls.def( "adapt", [] ( Grid &self ) {
115 cls.def( "getConnectedComponent", [] ( Grid &self,
const Element& element ) {
116 return self.getConnectedComponent( element );
119 Return the connected component of an entity
122 cls.def( "moveInterface", [] ( Grid &self,
const std::vector< FieldVector >& shifts ) {
123 self.moveInterface( shifts );
126 Move the interface by the given movement for each interface vertex
129 cls.def( "moveVertices", [] ( Grid &self,
const std::vector< FieldVector >& shifts ) {
130 self.moveVertices( shifts );
133 Move all vertices of the triangulation by the given movement
136 cls.def( "isInterface", [] ( Grid &self,
const Intersection& intersection ) {
137 return self.isInterface( intersection );
140 Return if intersection is part of the interface
143 cls.def( "isInterface", [] ( Grid &self,
const Vertex& vertex ) {
144 return self.isInterface( vertex );
147 Return if vertex is part of the interface
150 cls.def( "asInterfaceEntity", [] ( Grid &self,
const Intersection& intersection ) {
151 return self.asInterfaceEntity( intersection );
154 Return intersection as entity of the interface grid
157 cls.def( "asIntersection", [] ( Grid &self,
const InterfaceEntity& interfaceEntity ) {
158 return self.asIntersection( interfaceEntity );
161 Return entity of the interface grid as (some) intersection of the MMesh
164 cls.def( "addInterface", [] ( Grid &self,
const Intersection& intersection ) {
165 self.addInterface( intersection );
168 Add the intersection to the set of interface edges
171 cls.def( "addInterface", [] ( Grid &self,
const Intersection& intersection,
const std::size_t marker ) {
172 self.addInterface( intersection, marker );
175 Add the intersection to the set of interface edges and mark it with marker
178 cls.def( "postAdapt", [] ( Grid &self ) {
182 Remove adaption markers and connected components
185 cls.def( "isTip", [] ( Grid &self,
const InterfaceVertex& interfaceVertex ) {
186 return interfaceVertex.impl().isTip();
189 Return if interface vertex is a tip
192 cls.def( "refineEdge", [] ( Grid &self,
const Element& element,
const std::size_t edgeIndex,
const double where ) {
193 return self.refineEdge(element, edgeIndex, where);
199 cls.def( "refineEdge", [] ( Grid &self,
const Element& element,
const std::size_t edgeIndex ) {
200 return self.refineEdge(element, edgeIndex, 0.5);
206 cls.def( "removeVertex", [] ( Grid &self,
const Vertex& vertex ) {
207 return self.removeVertex(vertex);
210 Remove vertex manually
213 cls.def( "removeVertex", [] ( Grid &self,
const InterfaceVertex& vertex ) {
214 return self.removeVertex(vertex);
217 Remove interface vertex manually
220 cls.def( "insertVertexInCell", [] ( Grid &self,
const FieldVector& position ) {
221 return self.insertVertexInCell(position);
224 Insert vertex in cell manually
The MMesh class templatized by the CGAL host grid type and the dimension.
Definition: mmesh.hh:140