19#ifndef DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
20#define DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
27#include <dune/common/fmatrix.hh>
28#include <dune/common/fvector.hh>
30#include <dune/geometry/referenceelements.hh>
44template<
int dim,
int dimworld,
typename T =
double>
75 void computeIntersections(
const Dune::GeometryType& grid1ElementType,
76 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
77 std::bitset<(1<<dim)>& neighborIntersects1,
78 unsigned int grid1Index,
79 const Dune::GeometryType& grid2ElementType,
80 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
81 std::bitset<(1<<dim)>& neighborIntersects2,
82 unsigned int grid2Index,
100 unsigned int grid1Parent(
unsigned int idx,
unsigned int parId = 0)
const;
107 unsigned int grid2Parent(
unsigned int idx,
unsigned int parId = 0)
const;
118 LocalCoords grid1ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId = 0)
const;
127 LocalCoords grid2ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId = 0)
const;
132template<
int dim,
int dimworld,
typename T>
133void ConformingMerge<dim, dimworld, T>::computeIntersections(
const Dune::GeometryType& grid1ElementType,
134 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
135 std::bitset<(1<<dim)>& neighborIntersects1,
136 unsigned int grid1Index,
137 const Dune::GeometryType& grid2ElementType,
138 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
139 std::bitset<(1<<dim)>& neighborIntersects2,
140 unsigned int grid2Index,
146 assert((
unsigned int)(Dune::ReferenceElements<T,dim>::general(grid1ElementType).size(dim)) == grid1ElementCorners.size());
147 assert((
unsigned int)(Dune::ReferenceElements<T,dim>::general(grid2ElementType).size(dim)) == grid2ElementCorners.size());
149 neighborIntersects1.reset();
150 neighborIntersects2.reset();
153 if (grid1ElementType != grid2ElementType)
159 std::vector<int> other(grid1ElementCorners.size(), -1);
161 for (
unsigned int i=0; i<grid1ElementCorners.size(); i++) {
163 for (
unsigned int j=0; j<grid2ElementCorners.size(); j++) {
165 if ( (grid1ElementCorners[i]-grid2ElementCorners[j]).two_norm() < tolerance_ ) {
184 const Dune::ReferenceElement<T,dim>& refElement = Dune::ReferenceElements<T,dim>::general(grid1ElementType);
187 if (grid1ElementType.isSimplex()) {
189 intersections.push_back(RemoteSimplicialIntersection(grid1Index, grid2Index));
191 for (
int i=0; i<refElement.size(dim); i++) {
192 intersections.back().grid1Local_[0][i] = refElement.position(i,dim);
193 intersections.back().grid2Local_[0][i] = refElement.position(other[i],dim);
196 }
else if (grid1ElementType.isQuadrilateral()) {
199 const unsigned int subVertices[2][3] = {{0,1,3}, {0,3,2}};
201 for (
int i=0; i<2; i++) {
203 RemoteSimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
205 for (
int j=0; j<dim+1; j++) {
206 newSimplicialIntersection.grid1Local_[0][j] = refElement.position(subVertices[i][j],dim);
207 newSimplicialIntersection.grid2Local_[0][j] = refElement.position(subVertices[i][other[j]],dim);
214 }
else if (grid1ElementType.isHexahedron()) {
218 const unsigned int subVertices[5][4] = {{0,1,3,5}, {0,3,2,6}, {4,5,0,6}, {6,7,6,3}, {6,0,5,3}};
220 for (
int i=0; i<5; i++) {
222 RemoteSimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
224 for (
int j=0; j<dim+1; j++) {
225 newSimplicialIntersection.grid1Local_[0][j] = refElement.position(subVertices[i][j],dim);
226 newSimplicialIntersection.grid2Local_[0][j] = refElement.position(subVertices[i][other[j]],dim);
234 DUNE_THROW(Dune::GridError,
"Unsupported element type");
239template<
int dim,
int dimworld,
typename T>
240inline unsigned int ConformingMerge<dim, dimworld, T>::grid1Parent(
unsigned int idx,
unsigned int parId)
const
242 return this->intersections_[idx].grid1Entities_[parId];
246template<
int dim,
int dimworld,
typename T>
247inline unsigned int ConformingMerge<dim, dimworld, T>::grid2Parent(
unsigned int idx,
unsigned int parId)
const
250 return this->intersections_[idx].grid2Entities_[parId];
254template<
int dim,
int dimworld,
typename T>
257 return this->intersections_[idx].grid1Local_[parId][
corner];
261template<
int dim,
int dimworld,
typename T>
264 return this->intersections_[idx].grid2Local_[parId][
corner];
Common base class for many merger implementations: produce pairs of entities that may intersect.
Definition gridglue.hh:30
IteratorRange<... > intersections(const GridGlue<... > &glue, const Reverse<... > &reverse=!reversed)
Iterate over all intersections of a GridGlue.
Coordinate corner(unsigned c)
Definition projection_impl.hh:22
Implementation of the Merger concept for conforming interfaces.
Definition conformingmerge.hh:47
Dune::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition conformingmerge.hh:60
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition conformingmerge.hh:57
ConformingMerge(T tolerance=1E-4)
Definition conformingmerge.hh:87
T ctype
the numeric type used in this interface
Definition conformingmerge.hh:54
Common base class for many merger implementations: produce pairs of entities that may intersect.
Definition standardmerge.hh:55
Definition standardmerge.hh:80