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>
44 template<
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,
83 std::vector<RemoteSimplicialIntersection>& intersections);
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;
132 template<
int dim,
int dimworld,
typename T>
133 void 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,
141 std::vector<RemoteSimplicialIntersection>& intersections)
146 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
147 assert((
unsigned int)(Dune::ReferenceElements<T,dim>::general(grid1ElementType).size(dim)) == grid1ElementCorners.size());
148 assert((
unsigned int)(Dune::ReferenceElements<T,dim>::general(grid2ElementType).size(dim)) == grid2ElementCorners.size());
150 assert((
unsigned int)(Dune::GenericReferenceElements<T,dim>::general(grid1ElementType).size(dim)) == grid1ElementCorners.size());
151 assert((
unsigned int)(Dune::GenericReferenceElements<T,dim>::general(grid2ElementType).size(dim)) == grid2ElementCorners.size());
154 neighborIntersects1.reset();
155 neighborIntersects2.reset();
158 if (grid1ElementType != grid2ElementType)
164 std::vector<int> other(grid1ElementCorners.size(), -1);
166 for (
unsigned int i=0; i<grid1ElementCorners.size(); i++) {
168 for (
unsigned int j=0; j<grid2ElementCorners.size(); j++) {
170 if ( (grid1ElementCorners[i]-grid2ElementCorners[j]).two_norm() < tolerance_ ) {
189 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
190 const Dune::ReferenceElement<T,dim>& refElement = Dune::ReferenceElements<T,dim>::general(grid1ElementType);
192 const Dune::GenericReferenceElement<T,dim>& refElement = Dune::GenericReferenceElements<T,dim>::general(grid1ElementType);
196 if (grid1ElementType.isSimplex()) {
198 intersections.push_back(RemoteSimplicialIntersection(grid1Index, grid2Index));
200 for (
int i=0; i<refElement.size(dim); i++) {
201 intersections.back().grid1Local_[0][i] = refElement.position(i,dim);
202 intersections.back().grid2Local_[0][i] = refElement.position(other[i],dim);
205 }
else if (grid1ElementType.isQuadrilateral()) {
208 const unsigned int subVertices[2][3] = {{0,1,3}, {0,3,2}};
210 for (
int i=0; i<2; i++) {
212 RemoteSimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
214 for (
int j=0; j<dim+1; j++) {
215 newSimplicialIntersection.grid1Local_[0][j] = refElement.position(subVertices[i][j],dim);
216 newSimplicialIntersection.grid2Local_[0][j] = refElement.position(subVertices[i][other[j]],dim);
219 intersections.push_back(newSimplicialIntersection);
223 }
else if (grid1ElementType.isHexahedron()) {
227 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}};
229 for (
int i=0; i<5; i++) {
231 RemoteSimplicialIntersection newSimplicialIntersection(grid1Index, grid2Index);
233 for (
int j=0; j<dim+1; j++) {
234 newSimplicialIntersection.grid1Local_[0][j] = refElement.position(subVertices[i][j],dim);
235 newSimplicialIntersection.grid2Local_[0][j] = refElement.position(subVertices[i][other[j]],dim);
238 intersections.push_back(newSimplicialIntersection);
243 DUNE_THROW(Dune::GridError,
"Unsupported element type");
248 template<
int dim,
int dimworld,
typename T>
249 inline unsigned int ConformingMerge<dim, dimworld, T>::grid1Parent(
unsigned int idx,
unsigned int parId)
const
251 return this->intersections_[idx].grid1Entities_[parId];
255 template<
int dim,
int dimworld,
typename T>
256 inline unsigned int ConformingMerge<dim, dimworld, T>::grid2Parent(
unsigned int idx,
unsigned int parId)
const
259 return this->intersections_[idx].grid2Entities_[parId];
263 template<
int dim,
int dimworld,
typename T>
264 typename ConformingMerge<dim, dimworld, T>::LocalCoords ConformingMerge<dim, dimworld, T>::grid1ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId)
const
266 return this->intersections_[idx].grid1Local_[parId][corner];
270 template<
int dim,
int dimworld,
typename T>
271 typename ConformingMerge<dim, dimworld, T>::LocalCoords ConformingMerge<dim, dimworld, T>::grid2ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId)
const
273 return this->intersections_[idx].grid2Local_[parId][corner];
280 #endif // DUNE_GRIDGLUE_MERGING_CONFORMINGMERGE_HH
T ctype
the numeric type used in this interface
Definition: conformingmerge.hh:54
Definition: gridglue.hh:34
ConformingMerge(T tolerance=1E-4)
Definition: conformingmerge.hh:87
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition: conformingmerge.hh:57
Implementation of the Merger concept for conforming interfaces.
Definition: conformingmerge.hh:45
Common base class for many merger implementations: produce pairs of entities that may intersect...
Definition: standardmerge.hh:50
Dune::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition: conformingmerge.hh:60
Common base class for many merger implementations: produce pairs of entities that may intersect...