8 #ifndef DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
9 #define DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
22 #include <dune/common/fvector.hh>
23 #include <dune/common/bitsetvector.hh>
24 #include <dune/common/stdstreams.hh>
25 #include <dune/common/timer.hh>
26 #include <dune/common/version.hh>
28 #include <dune/geometry/referenceelements.hh>
29 #include <dune/grid/common/grid.hh>
53 template<
class T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
55 :
public Merger<T,grid1Dim,grid2Dim,dimworld>
127 const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
128 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
129 unsigned int grid1Index,
130 const Dune::GeometryType& grid2ElementType,
131 const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
132 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
133 unsigned int grid2Index,
134 std::vector<RemoteSimplicialIntersection>&
intersections) = 0;
140 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
141 const std::vector<Dune::GeometryType>& grid1_element_types,
142 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
143 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
144 const std::vector<Dune::GeometryType>& grid2_element_types,
145 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
167 virtual void build(
const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
168 const std::vector<unsigned int>& grid1_elements,
169 const std::vector<Dune::GeometryType>& grid1_element_types,
170 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
171 const std::vector<unsigned int>& grid2_elements,
172 const std::vector<Dune::GeometryType>& grid2_element_types
185 purge(intersections_);
186 purge(grid1ElementCorners_);
187 purge(grid2ElementCorners_);
194 m_enableFallback = fallback;
199 m_enableBruteForce = bruteForce;
206 bool m_enableFallback =
false;
211 bool m_enableBruteForce =
false;
215 static void purge(V & v)
229 unsigned int grid1Parents(
unsigned int idx)
const;
236 unsigned int grid2Parents(
unsigned int idx)
const;
243 unsigned int grid1Parent(
unsigned int idx,
unsigned int parId = 0)
const;
250 unsigned int grid2Parent(
unsigned int idx,
unsigned int parId = 0)
const;
262 Grid1Coords grid1ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId = 0)
const;
271 Grid2Coords grid2ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId = 0)
const;
277 void generateSeed(std::vector<int>& seeds,
278 Dune::BitSetVector<1>& isHandled2,
279 std::stack<unsigned>& candidates2,
280 const std::vector<Dune::FieldVector<T, dimworld> >& grid1Coords,
281 const std::vector<Dune::GeometryType>& grid1_element_types,
282 const std::vector<Dune::FieldVector<T, dimworld> >& grid2Coords,
283 const std::vector<Dune::GeometryType>& grid2_element_types);
288 int insertIntersections(
unsigned int candidate1,
unsigned int candidate2,std::vector<RemoteSimplicialIntersection>&
intersections);
293 int bruteForceSearch(
int candidate1,
294 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
295 const std::vector<Dune::GeometryType>& grid1_element_types,
296 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
297 const std::vector<Dune::GeometryType>& grid2_element_types);
302 std::pair<bool, unsigned int>
303 intersectionIndex(
unsigned int grid1Index,
unsigned int grid2Index,
309 template <
int gr
idDim>
310 void computeNeighborsPerElement(
const std::vector<Dune::GeometryType>& gridElementTypes,
311 const std::vector<std::vector<unsigned int> >& gridElementCorners,
312 std::vector<std::vector<int> >& elementNeighbors);
314 void buildAdvancingFront(
315 const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
316 const std::vector<unsigned int>& grid1_elements,
317 const std::vector<Dune::GeometryType>& grid1_element_types,
318 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
319 const std::vector<unsigned int>& grid2_elements,
320 const std::vector<Dune::GeometryType>& grid2_element_types
323 void buildBruteForce(
324 const std::vector<Dune::FieldVector<T,dimworld> >& grid1_Coords,
325 const std::vector<unsigned int>& grid1_elements,
326 const std::vector<Dune::GeometryType>& grid1_element_types,
327 const std::vector<Dune::FieldVector<T,dimworld> >& grid2_coords,
328 const std::vector<unsigned int>& grid2_elements,
329 const std::vector<Dune::GeometryType>& grid2_element_types
336 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
338 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
339 const std::vector<Dune::GeometryType>& grid1_element_types,
340 std::bitset<(1<<grid1Dim)>& neighborIntersects1,
341 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
342 const std::vector<Dune::GeometryType>& grid2_element_types,
343 std::bitset<(1<<grid2Dim)>& neighborIntersects2,
347 int grid1NumVertices = grid1ElementCorners_[candidate0].size();
348 std::vector<Dune::FieldVector<T,dimworld> > grid1ElementCorners(grid1NumVertices);
349 for (
int i=0; i<grid1NumVertices; i++)
350 grid1ElementCorners[i] = grid1Coords[grid1ElementCorners_[candidate0][i]];
353 int grid2NumVertices = grid2ElementCorners_[candidate1].size();
354 std::vector<Dune::FieldVector<T,dimworld> > grid2ElementCorners(grid2NumVertices);
355 for (
int i=0; i<grid2NumVertices; i++)
356 grid2ElementCorners[i] = grid2Coords[grid2ElementCorners_[candidate1][i]];
366 neighborIntersects1, candidate0,
367 grid2_element_types[candidate1], grid2ElementCorners,
368 neighborIntersects2, candidate1,
372 if(insert && intersections.size() > 0)
373 insertIntersections(candidate0,candidate1,intersections);
376 return (intersections.size() > 0 || neighborIntersects1.any() || neighborIntersects2.any());
380 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
382 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
383 const std::vector<Dune::GeometryType>& grid1_element_types,
384 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
385 const std::vector<Dune::GeometryType>& grid2_element_types)
387 std::bitset<(1<<grid1Dim)> neighborIntersects1;
388 std::bitset<(1<<grid2Dim)> neighborIntersects2;
389 for (std::size_t i=0; i<grid1_element_types.size(); i++) {
392 grid1Coords, grid1_element_types, neighborIntersects1,
393 grid2Coords, grid2_element_types, neighborIntersects2,
397 if (intersectionFound)
406 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
407 template<
int gr
idDim>
408 void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::
409 computeNeighborsPerElement(
const std::vector<Dune::GeometryType>& gridElementTypes,
410 const std::vector<std::vector<unsigned int> >& gridElementCorners,
411 std::vector<std::vector<int> >& elementNeighbors)
413 typedef std::vector<unsigned int> FaceType;
414 typedef std::map<FaceType, std::pair<unsigned int, unsigned int> > FaceSetType;
420 elementNeighbors.resize(gridElementTypes.size());
422 for (
size_t i=0; i<gridElementTypes.size(); i++)
423 #
if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
424 elementNeighbors[i].resize(Dune::ReferenceElements<T,gridDim>::general(gridElementTypes[i]).size(1), -1);
426 elementNeighbors[i].resize(Dune::GenericReferenceElements<T,gridDim>::general(gridElementTypes[i]).size(1), -1);
429 for (
size_t i=0; i<gridElementTypes.size(); i++) {
431 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
432 const Dune::ReferenceElement<T,gridDim>& refElement = Dune::ReferenceElements<T,gridDim>::general(gridElementTypes[i]);
434 const Dune::GenericReferenceElement<T,gridDim>& refElement = Dune::GenericReferenceElements<T,gridDim>::general(gridElementTypes[i]);
437 for (
size_t j=0; j<(size_t)refElement.size(1); j++) {
441 for (
size_t k=0; k<(size_t)refElement.size(j,1,gridDim); k++)
442 face.push_back(gridElementCorners[i][refElement.subEntity(j,1,k,gridDim)]);
445 std::sort(face.begin(), face.end());
447 typename FaceSetType::iterator faceHandle = faces.find(face);
449 if (faceHandle == faces.end()) {
452 faces.insert(std::make_pair(face, std::make_pair(i,j)));
457 elementNeighbors[i][j] = faceHandle->second.first;
458 elementNeighbors[faceHandle->second.first][faceHandle->second.second] = i;
460 faces.erase(faceHandle);
474 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
476 const std::vector<unsigned int>& grid1_elements,
477 const std::vector<Dune::GeometryType>& grid1_element_types,
478 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
479 const std::vector<unsigned int>& grid2_elements,
480 const std::vector<Dune::GeometryType>& grid2_element_types
484 std::cout <<
"StandardMerge building merged grid..." << std::endl;
489 intersections_.clear();
499 grid1ElementCorners_.resize(grid1_element_types.size());
501 unsigned int grid1CornerCounter = 0;
503 for (std::size_t i=0; i<grid1_element_types.size(); i++) {
506 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
507 int numVertices = Dune::ReferenceElements<T,grid1Dim>::general(grid1_element_types[i]).size(grid1Dim);
509 int numVertices = Dune::GenericReferenceElements<T,grid1Dim>::general(grid1_element_types[i]).size(grid1Dim);
511 grid1ElementCorners_[i].resize(numVertices);
512 for (
int j=0; j<numVertices; j++)
513 grid1ElementCorners_[i][j] = grid1_elements[grid1CornerCounter++];
518 grid2ElementCorners_.resize(grid2_element_types.size());
520 unsigned int grid2CornerCounter = 0;
522 for (std::size_t i=0; i<grid2_element_types.size(); i++) {
525 #if DUNE_VERSION_NEWER(DUNE_GEOMETRY,2,3)
526 int numVertices = Dune::ReferenceElements<T,grid2Dim>::general(grid2_element_types[i]).size(grid2Dim);
528 int numVertices = Dune::GenericReferenceElements<T,grid2Dim>::general(grid2_element_types[i]).size(grid2Dim);
530 grid2ElementCorners_[i].resize(numVertices);
531 for (
int j=0; j<numVertices; j++)
532 grid2ElementCorners_[i][j] = grid2_elements[grid2CornerCounter++];
543 std::cout <<
"setup took " << watch.elapsed() <<
" seconds." << std::endl;
545 if (m_enableBruteForce)
546 buildBruteForce(grid1Coords, grid1_elements, grid1_element_types, grid2Coords, grid2_elements, grid2_element_types);
548 buildAdvancingFront(grid1Coords, grid1_elements, grid1_element_types, grid2Coords, grid2_elements, grid2_element_types);
551 std::cout <<
"intersection construction took " << watch.elapsed() <<
" seconds." << std::endl;
554 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
556 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
557 const std::vector<unsigned int>& grid1_elements,
558 const std::vector<Dune::GeometryType>& grid1_element_types,
559 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
560 const std::vector<unsigned int>& grid2_elements,
561 const std::vector<Dune::GeometryType>& grid2_element_types
568 std::stack<unsigned int> candidates1;
569 std::stack<unsigned int> candidates2;
571 std::vector<int> seeds(grid2_element_types.size(), -1);
579 Dune::BitSetVector<1> isHandled2(grid2_element_types.size());
582 Dune::BitSetVector<1> isCandidate2(grid2_element_types.size());
584 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_types, grid2Coords, grid2_element_types);
590 std::set<unsigned int> isHandled1;
592 std::set<unsigned int> isCandidate1;
594 while (!candidates2.empty()) {
597 unsigned int currentCandidate2 = candidates2.top();
598 int seed = seeds[currentCandidate2];
602 isHandled2[currentCandidate2] =
true;
606 candidates1.push(seed);
609 isCandidate1.clear();
611 while (!candidates1.empty()) {
613 unsigned int currentCandidate1 = candidates1.top();
615 isHandled1.insert(currentCandidate1);
618 std::bitset<(1<<grid1Dim)> neighborIntersects1;
619 std::bitset<(1<<grid2Dim)> neighborIntersects2;
621 grid1Coords,grid1_element_types, neighborIntersects1,
622 grid2Coords,grid2_element_types, neighborIntersects2);
624 for (
size_t i=0; i<neighborIntersects2.size(); i++)
625 if (neighborIntersects2[i] && elementNeighbors2_[currentCandidate2][i] != -1)
626 seeds[elementNeighbors2_[currentCandidate2][i]] = currentCandidate1;
629 if (intersectionFound) {
631 for (
size_t i=0; i<elementNeighbors1_[currentCandidate1].size(); i++) {
633 int neighbor = elementNeighbors1_[currentCandidate1][i];
638 if (isHandled1.find(neighbor) == isHandled1.end()
639 && isCandidate1.find(neighbor) == isCandidate1.end()) {
640 candidates1.push(neighbor);
641 isCandidate1.insert(neighbor);
655 bool seedFound = !candidates2.empty();
656 for (
size_t i=0; i<elementNeighbors2_[currentCandidate2].size(); i++) {
658 int neighbor = elementNeighbors2_[currentCandidate2][i];
664 if (!isHandled2[neighbor][0] && !isCandidate2[neighbor][0] && seeds[neighbor]>-1) {
666 isCandidate2[neighbor][0] =
true;
667 candidates2.push(neighbor);
672 if (seedFound || !m_enableFallback)
677 for (
size_t i=0; i<elementNeighbors2_[currentCandidate2].size(); i++) {
679 int neighbor = elementNeighbors2_[currentCandidate2][i];
684 if (!isHandled2[neighbor][0] && !isCandidate2[neighbor][0]) {
691 for (
typename std::set<unsigned int>::iterator seedIt = isHandled1.begin();
692 seedIt != isHandled1.end(); ++seedIt) {
694 std::bitset<(1<<grid1Dim)> neighborIntersects1;
695 std::bitset<(1<<grid2Dim)> neighborIntersects2;
697 grid1Coords, grid1_element_types, neighborIntersects1,
698 grid2Coords, grid2_element_types, neighborIntersects2,
702 if (intersectionFound) {
704 Dune::dwarn <<
"Algorithm entered first fallback method and found a new seed in the build algorithm." <<
705 "Probably, the neighborIntersects bitsets computed in computeIntersection specialization is wrong." << std::endl;
714 seed = bruteForceSearch(neighbor,
715 grid1Coords,grid1_element_types,
716 grid2Coords,grid2_element_types);
717 Dune::dwarn <<
"Algorithm entered second fallback method. This probably should not happen." << std::endl;
722 isCandidate2[neighbor] =
true;
729 candidates2.push(neighbor);
730 seeds[neighbor] = seed;
740 if (!seedFound && candidates2.empty()) {
741 generateSeed(seeds, isHandled2, candidates2, grid1Coords, grid1_element_types, grid2Coords, grid2_element_types);
746 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
747 void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::buildBruteForce(
748 const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
749 const std::vector<unsigned int>& grid1_elements,
750 const std::vector<Dune::GeometryType>& grid1_element_types,
751 const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
752 const std::vector<unsigned int>& grid2_elements,
753 const std::vector<Dune::GeometryType>& grid2_element_types
756 std::bitset<(1<<grid1Dim)> neighborIntersects1;
757 std::bitset<(1<<grid2Dim)> neighborIntersects2;
759 for (
unsigned i = 0; i < grid1_element_types.size(); ++i) {
760 for (
unsigned j = 0; j < grid2_element_types.size(); ++j) {
762 grid1Coords, grid1_element_types, neighborIntersects1,
763 grid2Coords, grid2_element_types, neighborIntersects2);
768 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
772 return intersections_.size();
775 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
779 return (intersections_[idx].grid1Entities_).size();
782 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
783 inline unsigned int StandardMerge<T,grid1Dim,grid2Dim,dimworld>::grid2Parents(
unsigned int idx)
const
786 return (intersections_[idx].grid2Entities_).size();
790 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
791 inline unsigned int StandardMerge<T,grid1Dim,grid2Dim,dimworld>::grid1Parent(
unsigned int idx,
unsigned int parId)
const
794 return intersections_[idx].grid1Entities_[parId];
798 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
799 inline unsigned int StandardMerge<T,grid1Dim,grid2Dim,dimworld>::grid2Parent(
unsigned int idx,
unsigned int parId)
const
802 return intersections_[idx].grid2Entities_[parId];
806 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
807 typename StandardMerge<T,grid1Dim,grid2Dim,dimworld>::Grid1Coords StandardMerge<T,grid1Dim,grid2Dim,dimworld>::grid1ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId)
const
810 return intersections_[idx].grid1Local_[parId][
corner];
814 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
815 typename StandardMerge<T,grid1Dim,grid2Dim,dimworld>::Grid2Coords StandardMerge<T,grid1Dim,grid2Dim,dimworld>::grid2ParentLocal(
unsigned int idx,
unsigned int corner,
unsigned int parId)
const
818 return intersections_[idx].grid2Local_[parId][
corner];
821 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
822 void StandardMerge<T,grid1Dim,grid2Dim,dimworld>::generateSeed(std::vector<int>& seeds, Dune::BitSetVector<1>& isHandled2, std::stack<unsigned>& candidates2,
const std::vector<Dune::FieldVector<T, dimworld> >& grid1Coords,
const std::vector<Dune::GeometryType>& grid1_element_types,
const std::vector<Dune::FieldVector<T, dimworld> >& grid2Coords,
const std::vector<Dune::GeometryType>& grid2_element_types)
824 for (std::size_t j=0; j<grid2_element_types.size(); j++) {
826 if (seeds[j] > 0 || isHandled2[j][0])
829 int seed = bruteForceSearch(j,grid1Coords,grid1_element_types,grid2Coords,grid2_element_types);
836 isHandled2[j] =
true;
840 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
841 int StandardMerge<T,grid1Dim,grid2Dim,dimworld>::insertIntersections(
unsigned int candidate1,
unsigned int candidate2,
844 typedef typename std::vector<RemoteSimplicialIntersection>::size_type size_t;
847 for (
size_t i = 0; i < intersections.size(); ++i) {
851 std::tie(found, index) = intersectionIndex(candidate1,candidate2,intersections[i]);
853 if (found && index >= this->intersections_.size()) {
854 this->intersections_.push_back(intersections[i]);
859 for (
size_t j = 0; j < intersections[i].grid1Entities_.size(); ++j) {
860 this->intersections_[index].grid1Entities_.push_back(candidate1);
861 this->intersections_[index].grid1Local_.push_back(intersections[i].grid1Local_[j]);
865 for (
size_t j = 0; j < intersections[i].grid2Entities_.size(); ++j) {
866 this->intersections_[index].grid2Entities_.push_back(candidate2);
867 this->intersections_[index].grid2Local_.push_back(intersections[i].grid2Local_[j]);
872 Dune::dwarn <<
"Computed the same intersection twice!" << std::endl;
878 template<
typename T,
int gr
id1Dim,
int gr
id2Dim,
int dimworld>
879 std::pair<bool, unsigned int>
880 StandardMerge<T,grid1Dim,grid2Dim,dimworld>::intersectionIndex(
unsigned int grid1Index,
unsigned int grid2Index,
881 RemoteSimplicialIntersection& intersection) {
887 std::size_t n_intersections = this->intersections_.size();
888 if (grid1Dim == grid2Dim)
889 return {
true, n_intersections};
893 for (std::size_t i = 0; i < n_intersections; ++i) {
896 for (std::size_t ei = 0; ei < this->intersections_[i].grid1Entities_.size(); ++ei)
898 if (this->intersections_[i].grid1Entities_[ei] == grid1Index)
900 for (std::size_t er = 0; er < intersection.grid1Entities_.size(); ++er)
902 bool found_all =
true;
904 for (std::size_t ci = 0; ci < this->intersections_[i].grid1Local_[ei].size(); ++ci)
906 Dune::FieldVector<T,grid1Dim> ni = this->intersections_[i].grid1Local_[ei][ci];
907 bool found_ni =
false;
908 for (std::size_t cr = 0; cr < intersection.grid1Local_[er].size(); ++cr)
910 Dune::FieldVector<T,grid1Dim> nr = intersection.grid1Local_[er][cr];
912 found_ni = found_ni || ((ni-nr).infinity_norm() < eps);
916 found_all = found_all && found_ni;
922 if (found_all && (this->intersections_[i].grid2Entities_[ei] != grid2Index))
931 for (std::size_t ei = 0; ei < this->intersections_[i].grid2Entities_.size(); ++ei)
933 if (this->intersections_[i].grid2Entities_[ei] == grid2Index)
935 for (std::size_t er = 0; er < intersection.grid2Entities_.size(); ++er)
937 bool found_all =
true;
939 for (std::size_t ci = 0; ci < this->intersections_[i].grid2Local_[ei].size(); ++ci)
941 Dune::FieldVector<T,grid2Dim> ni = this->intersections_[i].grid2Local_[ei][ci];
942 bool found_ni =
false;
943 for (std::size_t cr = 0; cr < intersection.grid2Local_[er].size(); ++cr)
945 Dune::FieldVector<T,grid2Dim> nr = intersection.grid2Local_[er][cr];
946 found_ni = found_ni || ((ni-nr).infinity_norm() < eps);
951 found_all = found_all && found_ni;
957 if (found_all && (this->intersections_[i].grid1Entities_[ei] != grid1Index))
966 return {
true, n_intersections};
970 #define STANDARD_MERGE_INSTANTIATE(T,A,B,C) \
972 void StandardMerge<T,A,B,C>::build(const std::vector<Dune::FieldVector<T,C> >& grid1Coords, \
973 const std::vector<unsigned int>& grid1_elements, \
974 const std::vector<Dune::GeometryType>& grid1_element_types, \
975 const std::vector<Dune::FieldVector<T,C> >& grid2Coords, \
976 const std::vector<unsigned int>& grid2_elements, \
977 const std::vector<Dune::GeometryType>& grid2_element_types \
983 #undef STANDARD_MERGE_INSTANTIATE
989 #endif // DUNE_GRIDGLUE_MERGING_STANDARDMERGE_HH
void enableFallback(bool fallback)
Definition: standardmerge.hh:192
bool valid
Definition: standardmerge.hh:76
Definition: gridglue.hh:33
virtual void build(const std::vector< Dune::FieldVector< T, dimworld > > &grid1_Coords, const std::vector< unsigned int > &grid1_elements, const std::vector< Dune::GeometryType > &grid1_element_types, const std::vector< Dune::FieldVector< T, dimworld > > &grid2_coords, const std::vector< unsigned int > &grid2_elements, const std::vector< Dune::GeometryType > &grid2_element_types)
builds the merged grid
Definition: standardmerge.hh:475
Coordinate corner(unsigned c)
Definition: projection_impl.hh:22
bool computeIntersection(unsigned int candidate0, unsigned int candidate1, const std::vector< Dune::FieldVector< T, dimworld > > &grid1Coords, const std::vector< Dune::GeometryType > &grid1_element_types, std::bitset<(1<< grid1Dim)> &neighborIntersects1, const std::vector< Dune::FieldVector< T, dimworld > > &grid2Coords, const std::vector< Dune::GeometryType > &grid2_element_types, std::bitset<(1<< grid2Dim)> &neighborIntersects2, bool insert=true)
Compute the intersection between two overlapping elements.
Definition: standardmerge.hh:337
unsigned int nSimplices() const
get the number of simplices in the merged grid The indices are then in 0..nSimplices()-1 ...
Definition: standardmerge.hh:769
std::vector< unsigned int > grid2Entities_
Definition: standardmerge.hh:118
T ctype
the numeric type used in this interface
Definition: standardmerge.hh:63
Common base class for many merger implementations: produce pairs of entities that may intersect...
Definition: standardmerge.hh:54
void clear()
Definition: standardmerge.hh:182
STANDARD_MERGE_INSTANTIATE(double, 1, 1, 1)
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition: standardmerge.hh:72
unsigned int counter
Counts the number of times the computeIntersection method has been called.
Definition: merger.hh:195
std::vector< unsigned int > grid1Entities_
Definition: standardmerge.hh:116
Definition: standardmerge.hh:80
std::vector< std::vector< unsigned int > > grid1ElementCorners_
Temporary internal data.
Definition: standardmerge.hh:154
IteratorRange<...> intersections(const GridGlue<...> &glue, const Reverse<...> &reverse=!reversed)
Iterate over all intersections of a GridGlue.
Definition: standardmerge.hh:86
std::vector< std::vector< int > > elementNeighbors1_
Definition: standardmerge.hh:157
std::vector< std::vector< unsigned int > > grid2ElementCorners_
Definition: standardmerge.hh:155
std::vector< std::vector< int > > elementNeighbors2_
Definition: standardmerge.hh:158
void enableBruteForce(bool bruteForce)
Definition: standardmerge.hh:197
std::vector< std::array< Dune::FieldVector< T, grid2Dim >, nVertices > > grid2Local_
Definition: standardmerge.hh:113
std::vector< std::array< Dune::FieldVector< T, grid1Dim >, nVertices > > grid1Local_
Definition: standardmerge.hh:110
Merger< T, grid1Dim, grid2Dim, dimworld >::Grid1Coords Grid1Coords
Type used for local coordinates on the grid1 side.
Definition: standardmerge.hh:66
std::vector< RemoteSimplicialIntersection > intersections_
The computed intersections.
Definition: standardmerge.hh:151
Merger< T, grid1Dim, grid2Dim, dimworld >::Grid2Coords Grid2Coords
Type used for local coordinates on the grid2 side.
Definition: standardmerge.hh:69
virtual void computeIntersections(const Dune::GeometryType &grid1ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid1ElementCorners, std::bitset<(1<< grid1Dim)> &neighborIntersects1, unsigned int grid1Index, const Dune::GeometryType &grid2ElementType, const std::vector< Dune::FieldVector< T, dimworld > > &grid2ElementCorners, std::bitset<(1<< grid2Dim)> &neighborIntersects2, unsigned int grid2Index, std::vector< RemoteSimplicialIntersection > &intersections)=0
Compute the intersection between two overlapping elements.
StandardMerge()
Definition: standardmerge.hh:78
Definition: standardmerge.hh:83
RemoteSimplicialIntersection()
Default constructor.
Definition: standardmerge.hh:89
RemoteSimplicialIntersection(int grid1Entity, int grid2Entity)
Constructor for two given entity indices.
Definition: standardmerge.hh:98
Abstract base for all classes that take extracted grids and build sets of intersections.
Definition: merger.hh:16