3#ifndef DUNE_MMESH_GRID_GEOMETRY_HH
4#define DUNE_MMESH_GRID_GEOMETRY_HH
15#include <dune/grid/common/geometry.hh>
25template <
int mydim,
int coorddim,
class Gr
idImp>
30template <
int md,
class Gr
idImp>
34 static constexpr int mydim = md;
35 static constexpr int coorddim = 2;
40 enum { dimension = GridImp::dimension };
41 enum { dimensionworld = GridImp::dimensionworld };
42 enum { coorddimension = coorddim };
43 enum { mydimension = mydim };
47 GeometryTypes::simplex(mydim),
52 MMeshGeometry(
const typename GridImp::template HostGridEntity<0>& hostEntity)
53 :
BaseType(GeometryTypes::simplex(mydim), getVertices(hostEntity)) {}
56 :
BaseType(GeometryTypes::simplex(mydim), points) {}
59 MMeshGeometry(
const typename GridImp::template HostGridEntity<1>& hostEntity)
60 :
BaseType(GeometryTypes::simplex(mydim), getVertices(hostEntity)) {}
64 :
BaseType(GeometryTypes::simplex(mydim), getLocalVertices_(idx)) {}
67 MMeshGeometry(
const typename GridImp::template HostGridEntity<2>& hostEntity)
69 GeometryTypes::simplex(mydim),
77 const typename GridImp::template HostGridEntity<0> hostEntity) {
78 const auto& cgalIdx = hostEntity->info().cgalIndex;
89 const typename GridImp::template HostGridEntity<1>& hostEntity) {
90 const auto& cgalIdx = hostEntity.first->info().cgalIndex;
93 2,
typename GridImp::template HostGridEntity<1>>(hostEntity);
96 for (
int k = 0; k < 2; ++k)
100 cgalIdx[MMeshImpl::ref<2>().subEntity(facetIdx, 1, k, 2)])
108 FVector({0.0, 0.0}), FVector({1.0, 0.0}), FVector({0.0, 1.0})};
110 return {
local[k == 2 ? 1 : 0],
local[k == 0 ? 1 : 2]};
116template <
int md,
class Gr
idImp>
120 static constexpr int mydim = md;
121 static constexpr int coorddim = 3;
123 typedef typename GridImp::ctype
ctype;
127 enum { dimension = GridImp::dimension };
128 enum { dimensionworld = GridImp::dimensionworld };
129 enum { coorddimension = coorddim };
130 enum { mydimension = mydim };
133 :
BaseType(GeometryTypes::simplex(mydim),
139 MMeshGeometry(
const typename GridImp::template HostGridEntity<0>& hostEntity)
140 :
BaseType(GeometryTypes::simplex(mydim), getVertices<0>(hostEntity)) {}
143 :
BaseType(GeometryTypes::simplex(mydim), points) {}
146 MMeshGeometry(
const typename GridImp::template HostGridEntity<1>& hostEntity)
147 :
BaseType(GeometryTypes::simplex(mydim), getVertices<1>(hostEntity)) {}
151 :
BaseType(GeometryTypes::simplex(mydim), getLocalVertices_(idx)) {}
154 MMeshGeometry(
const typename GridImp::template HostGridEntity<2>& hostEntity)
155 :
BaseType(GeometryTypes::simplex(mydim), getVertices<2>(hostEntity)) {}
158 MMeshGeometry(
const typename GridImp::template HostGridEntity<3>& hostEntity)
160 GeometryTypes::simplex(mydim),
167 template <
int codim,
typename Enable = std::enable_if_t<codim == 0>>
169 const typename GridImp::template HostGridEntity<0>& hostEntity) {
170 const auto& cgalIdx = hostEntity->info().cgalIndex;
173 for (
int i = 0; i < 4; ++i)
174 vertices[i] =
makeFieldVector(hostEntity->vertex(cgalIdx[i])->point());
178 template <
int codim,
typename Enable = std::enable_if_t<codim == 1>>
180 const typename GridImp::template HostGridEntity<1>& hostEntity) {
181 const auto& cgalIdx = hostEntity.first->info().cgalIndex;
182 const auto& cell = hostEntity.first;
185 3,
typename GridImp::template HostGridEntity<1>>(hostEntity);
188 for (
int i = 0; i < 3; ++i)
191 cgalIdx[MMeshImpl::ref<3>().subEntity(facetIdx, 1, i, 3)])
196 template <
int codim,
typename Enable = std::enable_if_t<codim == 2>>
198 const typename GridImp::template HostGridEntity<2>& hostEntity) {
199 const auto& cgalIdx = hostEntity.first->info().cgalIndex;
200 const auto& cell = hostEntity.first;
203 3,
typename GridImp::template HostGridEntity<2>>(hostEntity);
207 cell->vertex(cgalIdx[MMeshImpl::ref<3>().subEntity(edgeIdx, 2, 0, 3)])
210 cell->vertex(cgalIdx[MMeshImpl::ref<3>().subEntity(edgeIdx, 2, 1, 3)])
218 FVector({0.0, 0.0, 0.0}), FVector({1.0, 0.0, 0.0}),
219 FVector({0.0, 1.0, 0.0}), FVector({0.0, 0.0, 1.0})};
221 return {
local[k <= 2 ? 0 : 1],
local[k <= 1 ? 1 : 2],
222 local[k == 0 ? 2 : 3]};
Helpers for conversion from CGAL::Point_x to DUNE::FieldVector.
static std::size_t cgalEdgeToDuneEdge(const HostEdge &cgalEdge)
Definition grid/common.hh:99
static std::size_t cgalFacetToDuneFacet(const HostFacet &facet)
Definition grid/common.hh:82
static FieldVector< typename Kernel::RT, 2 > makeFieldVector(const CGAL::Point_2< Kernel > &p)
Helper function to create DUNE::FieldVector from CGAL::Point_2.
Definition pointfieldvector.hh:20
auto computeCircumcenter(const Geometry &geo)
Compute circumcenter.
Definition pointfieldvector.hh:78
IteratorRange<... > vertices(const GV &gv)
Geometry.
Definition grid/geometry.hh:26
GridImp::LeafIntersection Intersection
Definition grid/geometry.hh:38
const FVector circumcenter() const
Obtain the circumcenter.
Definition grid/geometry.hh:73
FieldVector< typename GridImp::ctype, coorddim > FVector
Definition grid/geometry.hh:37
AffineGeometry< typename GridImp::ctype, mydim, coorddim > BaseType
Definition grid/geometry.hh:36
MMeshGeometry()
Definition grid/geometry.hh:45
MMeshGeometry(const typename GridImp::template HostGridEntity< 0 > &hostEntity)
Constructor from host geometry with codim 0.
Definition grid/geometry.hh:52
MMeshGeometry(const std::array< FVector, 3 > points)
Definition grid/geometry.hh:55
MMeshGeometry(const typename GridImp::template HostGridEntity< 1 > &hostEntity)
Constructor from host geometry with codim 1.
Definition grid/geometry.hh:59
MMeshGeometry(const typename GridImp::template HostGridEntity< 2 > &hostEntity)
Constructor from host geometry with codim 2.
Definition grid/geometry.hh:67
MMeshGeometry(int idx)
Constructor of local intersection geometry.
Definition grid/geometry.hh:63
AffineGeometry< typename GridImp::ctype, mydim, coorddim > BaseType
Definition grid/geometry.hh:122
MMeshGeometry(const std::array< FVector, 4 > points)
Definition grid/geometry.hh:142
const FVector circumcenter() const
Obtain the circumcenter.
Definition grid/geometry.hh:164
FieldVector< ctype, coorddim > FVector
Definition grid/geometry.hh:124
MMeshGeometry(const typename GridImp::template HostGridEntity< 1 > &hostEntity)
Constructor from host geometry with codim 1.
Definition grid/geometry.hh:146
MMeshGeometry(const typename GridImp::template HostGridEntity< 2 > &hostEntity)
Constructor from host geometry with codim 1.
Definition grid/geometry.hh:154
MMeshGeometry(const typename GridImp::template HostGridEntity< 0 > &hostEntity)
Constructor from host geometry with codim 0.
Definition grid/geometry.hh:139
MMeshGeometry(const typename GridImp::template HostGridEntity< 3 > &hostEntity)
Constructor from host geometry with codim 3.
Definition grid/geometry.hh:158
MMeshGeometry()
Definition grid/geometry.hh:132
GridImp::LeafIntersection Intersection
Definition grid/geometry.hh:125
GridImp::ctype ctype
Definition grid/geometry.hh:123
MMeshGeometry(int idx)
Constructor of local intersection geometry.
Definition grid/geometry.hh:150