grid.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=2 sw=2 sts=2:
3#ifndef DUNE_POLYHEDRALGRID_GRID_HH
4#define DUNE_POLYHEDRALGRID_GRID_HH
5
6#include <algorithm>
7#include <array>
8#include <iterator>
9#include <set>
10#include <string>
11#include <utility>
12#include <vector>
13
14// Warning suppression for Dune includes.
16
17//- dune-common includes
18#include <dune/common/version.hh>
19#include <dune/common/parallel/mpihelper.hh>
20
21//- dune-grid includes
22#include <dune/grid/common/grid.hh>
23
24#include <dune/common/parallel/communication.hh>
25
26//- polyhedralgrid includes
34
35// Re-enable warnings.
37
39
41#include <opm/grid/cart_grid.h>
45#include <map>
46#include <unordered_map>
49
50#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
51
52namespace Dune
53{
54
55
56 // PolyhedralGridFamily
57 // ------------
58
59 template< int dim, int dimworld, typename coord_t >
61 {
62 struct Traits
63 {
65
66 typedef coord_t ctype;
67
68 // type of data passed to entities, intersections, and iterators
69 // for PolyhedralGrid this is just an empty place holder
70 typedef const Grid* ExtraData;
71
72 typedef int Index ;
73
74 static const int dimension = dim;
75 static const int dimensionworld = dimworld;
76
77 typedef Dune::FieldVector< ctype, dimensionworld > GlobalCoordinate ;
78
83
84 typedef Dune::Intersection< const Grid, LeafIntersectionImpl > LeafIntersection;
85 typedef Dune::Intersection< const Grid, LevelIntersectionImpl > LevelIntersection;
86
87 typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorImpl, LeafIntersectionImpl > LeafIntersectionIterator;
88 typedef Dune::IntersectionIterator< const Grid, LevelIntersectionIteratorImpl, LevelIntersectionImpl > LevelIntersectionIterator;
89
91 typedef Dune::EntityIterator< 0, const Grid, HierarchicIteratorImpl > HierarchicIterator;
92
93 template< int codim >
94 struct Codim
95 {
97 typedef Dune::Geometry< dimension-codim, dimensionworld, const Grid, PolyhedralGridGeometry > Geometry;
98
101
103 typedef Dune::Entity< codim, dimension, const Grid, PolyhedralGridEntity > Entity;
104
107
108 //typedef Dune::EntitySeed< const Grid, PolyhedralGridEntitySeed< codim, const Grid > > EntitySeed;
110
111 template< PartitionIteratorType pitype >
113 {
115 typedef Dune::EntityIterator< codim, const Grid, LeafIteratorImpl > LeafIterator;
116
118 };
119
122 };
123
126
129
130 typedef Dune::MPIHelper::MPICommunicator MPICommunicator;
131 using Communication = Dune::Communication<MPICommunicator>;
132 using CollectiveCommunication = Dune::Communication<MPICommunicator>;
133
134 template< PartitionIteratorType pitype >
136 {
137 typedef Dune::GridView< PolyhedralGridViewTraits< dim, dimworld, ctype, pitype > > LeafGridView;
138 typedef Dune::GridView< PolyhedralGridViewTraits< dim, dimworld, ctype, pitype > > LevelGridView;
139 };
140
143 };
144 };
145
146
147
148 // PolyhedralGrid
149 // --------------
150
159 template < int dim, int dimworld, typename coord_t >
162 : public GridDefaultImplementation
163 < dim, dimworld, coord_t, PolyhedralGridFamily< dim, dimworld, coord_t > >
165 {
167
168 typedef GridDefaultImplementation
169 < dim, dimworld, coord_t, PolyhedralGridFamily< dim, dimworld, coord_t > > Base;
170
171 public:
173
174 protected:
176 {
177 inline void operator () ( UnstructuredGridType* grdPtr )
178 {
179 destroy_grid( grdPtr );
180 }
181 };
182
183 public:
184 typedef std::unique_ptr< UnstructuredGridType, UnstructuredGridDeleter > UnstructuredGridPtr;
185
187 allocateGrid ( std::size_t nCells, std::size_t nFaces, std::size_t nFaceNodes, std::size_t nCellFaces, std::size_t nNodes )
188 {
189 // Note that we here assign a grid of dimension dimworld in order to obtain global coordinates in the correct dimension
190 UnstructuredGridType *grid = allocate_grid( dimworld, nCells, nFaces, nFaceNodes, nCellFaces, nNodes );
191 if( !grid )
192 DUNE_THROW( GridError, "Unable to allocate grid" );
193 return UnstructuredGridPtr( grid );
194 }
195
196 static void
198 {
199 // get C pointer to UnstructuredGrid
200 UnstructuredGrid* ugPtr = ug.operator ->();
201
202 // compute geometric quantities like cell volume and face normals
203 compute_geometry( ugPtr );
204 }
205
214 typedef typename GridFamily::Traits Traits;
215
222 template< int codim >
223 struct Codim;
224
231 typedef typename Traits::HierarchicIterator HierarchicIterator;
233 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
235 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
236
243 template< PartitionIteratorType pitype >
245 {
246 typedef typename GridFamily::Traits::template Partition< pitype >::LevelGridView LevelGridView;
247 typedef typename GridFamily::Traits::template Partition< pitype >::LeafGridView LeafGridView;
248 };
249
253
267 typedef typename Traits::LeafIndexSet LeafIndexSet;
268
277 typedef typename Traits::LevelIndexSet LevelIndexSet;
278
289 typedef typename Traits::GlobalIdSet GlobalIdSet;
290
306 typedef typename Traits::LocalIdSet LocalIdSet;
307
314 typedef typename Traits::ctype ctype;
315
317 using Communication = typename Traits::Communication;
319
320 typedef typename Traits :: GlobalCoordinate GlobalCoordinate;
321
336 explicit PolyhedralGrid (const Opm::EclipseGrid& inputGrid,
337 const std::vector<double>& poreVolumes = std::vector<double>{},
338 const bool edge_conformal = false,
339 const bool mergeMinpvCells = false)
340 : gridPtr_ { createGrid(inputGrid, poreVolumes, static_cast<int>(edge_conformal), mergeMinpvCells) }
341 , grid_ { *gridPtr_ }
342 , comm_ { MPIHelper::getCommunicator() }
343 , leafIndexSet_ { *this }
344 , globalIdSet_ { *this }
345 , localIdSet_ { *this }
346 , nBndSegments_ { 0 }
347 {
348 init();
349 }
350
356 explicit PolyhedralGrid ( const std::vector< int >& n,
357 const std::vector< double >& dx )
358 : gridPtr_( createGrid( n, dx ) ),
359 grid_( *gridPtr_ ),
360 comm_( MPIHelper::getCommunicator()),
361 leafIndexSet_( *this ),
362 globalIdSet_( *this ),
363 localIdSet_( *this ),
364 nBndSegments_( 0 )
365 {
366 init();
367 }
368
375 explicit PolyhedralGrid ( UnstructuredGridPtr &&gridPtr )
376 : gridPtr_( std::move( gridPtr ) ),
377 grid_( *gridPtr_ ),
378 comm_( MPIHelper::getCommunicator() ),
379 leafIndexSet_( *this ),
380 globalIdSet_( *this ),
381 localIdSet_( *this ),
382 nBndSegments_( 0 )
383 {
384 init();
385 }
386
394 explicit PolyhedralGrid ( const UnstructuredGridType& grid )
395 : gridPtr_(),
396 grid_( grid ),
397 comm_( MPIHelper::getCommunicator() ),
398 leafIndexSet_( *this ),
399 globalIdSet_( *this ),
400 localIdSet_( *this ),
401 nBndSegments_( 0 )
402 {
403 init();
404 }
405
410 operator const UnstructuredGridType& () const { return grid_; }
411
424 int maxLevel () const
425 {
426 return 0;
427 }
428
437 int size ( int /* level */, int codim ) const
438 {
439 return size( codim );
440 }
441
448 int size ( int codim ) const
449 {
450 if( codim == 0 )
451 {
452 return grid_.number_of_cells;
453 }
454 else if ( codim == 1 )
455 {
456 return grid_.number_of_faces;
457 }
458 else if ( codim == dim )
459 {
460 return grid_.number_of_nodes;
461 }
462 else
463 {
464 std::cerr << "Warning: codimension " << codim << " not available in PolyhedralGrid" << std::endl;
465 return 0;
466 }
467 }
468
477 int size ( int /* level */, GeometryType type ) const
478 {
479 return size( dim - type.dim() );
480 }
481
486 int size ( GeometryType type ) const
487 {
488 return size( dim - type.dim() );
489 }
490
497 size_t numBoundarySegments () const
498 {
499 return nBndSegments_;
500 }
503 template< int codim >
505 {
506 return leafbegin< codim, All_Partition >();
507 }
508
509 template< int codim >
511 {
512 return leafend< codim, All_Partition >();
513 }
514
515 template< int codim, PartitionIteratorType pitype >
516 typename Codim< codim >::template Partition< pitype >::LeafIterator
517 leafbegin () const
518 {
519 typedef typename Traits::template Codim< codim >::template Partition< pitype >::LeafIteratorImpl Impl;
520 return Impl( extraData(), true );
521 }
522
523 template< int codim, PartitionIteratorType pitype >
524 typename Codim< codim >::template Partition< pitype >::LeafIterator
525 leafend () const
526 {
527 typedef typename Traits::template Codim< codim >::template Partition< pitype >::LeafIteratorImpl Impl;
528 return Impl( extraData(), false );
529 }
530
531 template< int codim >
532 typename Codim< codim >::LevelIterator lbegin ( const int /* level */ ) const
533 {
534 return leafbegin< codim, All_Partition >();
535 }
536
537 template< int codim >
538 typename Codim< codim >::LevelIterator lend ( const int /* level */ ) const
539 {
540 return leafend< codim, All_Partition >();
541 }
542
543 template< int codim, PartitionIteratorType pitype >
544 typename Codim< codim >::template Partition< pitype >::LevelIterator
545 lbegin ( const int /* level */ ) const
546 {
547 return leafbegin< codim, pitype > ();
548 }
549
550 template< int codim, PartitionIteratorType pitype >
551 typename Codim< codim >::template Partition< pitype >::LevelIterator
552 lend ( const int /* level */ ) const
553 {
554 return leafend< codim, pitype > ();
555 }
556
557 const GlobalIdSet &globalIdSet () const
558 {
559 return globalIdSet_;
560 }
561
562 const LocalIdSet &localIdSet () const
563 {
564 return localIdSet_;
565 }
566
567 const LevelIndexSet &levelIndexSet ( int /* level */ ) const
568 {
569 return leafIndexSet();
570 }
571
573 {
574 return leafIndexSet_;
575 }
576
577 void globalRefine ( int /* refCount */ )
578 {
579 }
580
581 bool mark ( int /* refCount */, const typename Codim< 0 >::Entity& /* entity */ )
582 {
583 return false;
584 }
585
586 int getMark ( const typename Codim< 0 >::Entity& /* entity */) const
587 {
588 return false;
589 }
590
592 bool preAdapt ()
593 {
594 return false;
595 }
596
598 bool adapt ()
599 {
600 return false ;
601 }
602
607 template< class DataHandle >
608 bool adapt ( DataHandle & )
609 {
610 return false;
611 }
612
614 void postAdapt ()
615 {
616 }
617
625 int overlapSize ( int /* codim */) const
626 {
627 return 0;
628 }
629
634 int ghostSize( int codim ) const
635 {
636 return (codim == 0 ) ? 1 : 0;
637 }
638
644 int overlapSize ( int /* level */, int /* codim */ ) const
645 {
646 return 0;
647 }
648
654 int ghostSize ( int /* level */, int codim ) const
655 {
656 return ghostSize( codim );
657 }
658
672 template< class DataHandle>
673 void communicate ( DataHandle& /* dataHandle */,
674 InterfaceType /* interface */,
675 CommunicationDirection /* direction */,
676 int /* level */ ) const
677 {
678 OPM_THROW(std::runtime_error, "communicate not implemented for polyhedreal grid!");
679 }
680
693 template< class DataHandle>
694 void communicate ( DataHandle& /* dataHandle */,
695 InterfaceType /* interface */,
696 CommunicationDirection /* direction */ ) const
697 {
698 OPM_THROW(std::runtime_error, "communicate not implemented for polyhedreal grid!");
699 }
700
703 {
704 OPM_THROW(std::runtime_error, "switch to global view not implemented for polyhedreal grid!");
705 }
706
709 {
710 OPM_THROW(std::runtime_error, "switch to distributed view not implemented for polyhedreal grid!");
711 }
712
721 const CommunicationType &comm () const
722 {
723 return comm_;
724 }
725
726 // data handle interface different between geo and interface
727
738 {
739 return false ;
740 }
741
757 template< class DataHandle, class Data >
758 bool loadBalance ( CommDataHandleIF< DataHandle, Data >& /* datahandle */ )
759 {
760 return false;
761 }
762
777 template< class DofManager >
778 bool loadBalance ( DofManager& /* dofManager */ )
779 {
780 return false;
781 }
782
784 template< PartitionIteratorType pitype >
785 typename Partition< pitype >::LevelGridView levelGridView ( int /* level */ ) const
786 {
787 typedef typename Partition< pitype >::LevelGridView View;
788 typedef typename View::GridViewImp ViewImp;
789 return View( ViewImp( *this ) );
790 }
791
793 template< PartitionIteratorType pitype >
795 {
796 typedef typename Traits::template Partition< pitype >::LeafGridView View;
797 typedef typename View::GridViewImp ViewImp;
798 return View( ViewImp( *this ) );
799 }
800
802 LevelGridView levelGridView ( int /* level */ ) const
803 {
804 typedef typename LevelGridView::GridViewImp ViewImp;
805 return LevelGridView( ViewImp( *this ) );
806 }
807
810 {
811 typedef typename LeafGridView::GridViewImp ViewImp;
812 return LeafGridView( ViewImp( *this ) );
813 }
814
816 template< class EntitySeed >
818 entityPointer ( const EntitySeed &seed ) const
819 {
820 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityPointer EntityPointer;
821 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityPointerImpl EntityPointerImpl;
822 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityImpl EntityImpl;
823 return EntityPointer( EntityPointerImpl( EntityImpl( extraData(), seed ) ) );
824 }
825
827 template< class EntitySeed >
828 typename Traits::template Codim< EntitySeed::codimension >::Entity
829 entity ( const EntitySeed &seed ) const
830 {
831 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityImpl EntityImpl;
832 return EntityImpl( extraData(), seed );
833 }
834
848 void update ()
849 {
850 }
851
854 const std::array<int, 3>& logicalCartesianSize() const
855 {
856 return cartDims_;
857 }
858
859 const int* globalCell() const
860 {
861 assert( grid_.global_cell != 0 );
862 return grid_.global_cell;
863 }
864
865 const int* globalCellPtr() const
866 {
867 return grid_.global_cell;
868 }
869
870 void getIJK(const int c, std::array<int,3>& ijk) const
871 {
872 int gc = globalCell()[c];
873 ijk[0] = gc % logicalCartesianSize()[0]; gc /= logicalCartesianSize()[0];
874 ijk[1] = gc % logicalCartesianSize()[1];
875 ijk[2] = gc / logicalCartesianSize()[1];
876 }
877
882
883
892 template<class DataHandle>
893 void scatterData([[maybe_unused]] DataHandle& handle) const
894 {
895 OPM_THROW(std::runtime_error, "ScatterData not implemented for polyhedral grid!");
896 }
897
898 protected:
900 createGrid(const Opm::EclipseGrid& inputGrid,
901 const std::vector<double>& poreVolumes,
902 const bool edge_conformal,
903 const bool mergeMinpvCells) const
904 {
905 grdecl g{};
906
907 g.dims[0] = inputGrid.getNX();
908 g.dims[1] = inputGrid.getNY();
909 g.dims[2] = inputGrid.getNZ();
910
911 std::vector<double> coord = inputGrid.getCOORD( );
912 std::vector<double> zcorn = inputGrid.getZCORN( );
913 std::vector<int> actnum = inputGrid.getACTNUM( );
914
915 g.coord = coord.data();
916 g.zcorn = zcorn.data();
917 g.actnum = actnum.data();
918
919 const double z_tolerance = inputGrid.isPinchActive() ? inputGrid.getPinchThresholdThickness() : 0.0;
920
921 // The keyword PINCH connects the cells across collapsed inactive cells, as it does for the CpGrid. The grid with edge
922 // conformal cells has the cells merged.
923 const bool pinchActive = inputGrid.isPinchActive() || edge_conformal;
924
925 // The cells that MINPV removed, and the cell above and below each of them if they are to be connected
926 std::map<int, int> pinchOuts;
927
928 if (!poreVolumes.empty() && (inputGrid.getMinpvMode() != Opm::MinpvMode::Inactive))
929 {
930 Opm::MinpvProcessor mp(g.dims[0], g.dims[1], g.dims[2]);
931 const std::vector<double>& minpvv = inputGrid.getMinpvVector();
932 // The cells with a pore volume below MINPV are merged into the cell below, or collapsed. The collapsed cells
933 // leave space between the cells above and below, which is connected as the CpGrid does it by default, see below.
934 const bool merge = edge_conformal || mergeMinpvCells;
935 const bool nogap = ! inputGrid.isPinchActive() || inputGrid.getPinchGapMode() == Opm::PinchMode::NOGAP;
936 const size_t cartGridSize = g.dims[0] * g.dims[1] * g.dims[2];
937 std::vector<double> thickness(cartGridSize);
938 for (size_t i = 0; i < cartGridSize; ++i) {
939 thickness[i] = inputGrid.getCellThickness(i);
940 }
941 pinchOuts = mp.process(thickness, z_tolerance, inputGrid.getPinchMaxEmptyGap() , poreVolumes,
942 minpvv, actnum, merge, zcorn.data(), nogap).nnc;
943 }
944
945 /*
946 if (!poreVolumes.empty() && (inputGrid.getMinpvMode() != Opm::MinpvMode::Inactive)) {
947 Opm::MinpvProcessor mp(g.dims[0], g.dims[1], g.dims[2]);
948 const double minpv_value = inputGrid.getMinpvValue();
949 // Currently the pinchProcessor is not used and only opmfil is supported
950 //bool opmfil = inputGrid.getMinpvMode() == Opm::MinpvMode::OpmFIL;
951 bool opmfil = true;
952 mp.process(poreVolumes, minpv_value, actnum, opmfil, zcorn.data());
953 }
954 */
955
957 (&g, z_tolerance, static_cast<int>(edge_conformal), static_cast<int>(pinchActive));
958
959 if (cgrid == nullptr) {
960 OPM_THROW(std::runtime_error, "Failed to construct grid.");
961 }
962
963 if( ! pinchOuts.empty() )
964 {
965 // As the CpGrid does it, the bottom face of the cell above the space is the face between the cells.
966 std::unordered_map< int, int > cellOfCartesianIndex;
967 for( int c = 0; c < cgrid->number_of_cells; ++c )
968 {
969 cellOfCartesianIndex.emplace( cgrid->global_cell[ c ], c );
970 }
971 std::vector< std::pair< int, int > > pairs;
972 for( const auto& [ above, below ] : pinchOuts )
973 {
974 const auto first = cellOfCartesianIndex.find( above );
975 const auto second = cellOfCartesianIndex.find( below );
976 if( first != cellOfCartesianIndex.end() && second != cellOfCartesianIndex.end() )
977 {
978 pairs.emplace_back( first->second, second->second );
979 }
980 }
982 }
983
984 return cgrid;
985 }
986
987 UnstructuredGridType* createGrid( const std::vector< int >& n, const std::vector< double >& dx ) const
988 {
989 UnstructuredGridType* cgrid = nullptr ;
990 assert( int(n.size()) == dim );
991 if( dim == 2 )
992 {
993 cgrid = create_grid_cart2d( n[ 0 ], n[ 1 ], dx[ 0 ], dx[ 1 ] );
994 }
995 else if ( dim == 3 )
996 {
997 cgrid = create_grid_hexa3d( n[ 0 ], n[ 1 ], n[ 2 ], dx[ 0 ], dx[ 1 ], dx[ 2 ] );
998 }
999
1000 //print_grid( cgrid );
1001 if (!cgrid) {
1002 OPM_THROW(std::runtime_error, "Failed to construct grid.");
1003 }
1004 return cgrid;
1005 }
1006
1007 public:
1008 typedef typename Traits :: ExtraData ExtraData;
1009 ExtraData extraData () const { return this; }
1010
1011 template <class EntitySeed>
1012 int corners( const EntitySeed& seed ) const
1013 {
1014 const int codim = EntitySeed :: codimension;
1015 const int index = seed.index();
1016 if (codim==0)
1017 return cellVertices_[ index ].size();
1018 if (codim==1)
1019 return grid_.face_nodepos[ index+1 ] - grid_.face_nodepos[ index ];
1020 if (codim==dim)
1021 return 1;
1022 return 0;
1023 }
1024
1036 GlobalCoordinate faceCenterEcl ( const int cell, const int side ) const
1037 {
1038 if( dim != 3 || cellVertices_[ cell ].size() != 8 )
1039 {
1040 OPM_THROW(std::logic_error, "faceCenterEcl is only available for cells with eight corners.");
1041 }
1042 // The corners of each side of the reference cube
1043 static const int sideCorners[ 6 ][ 4 ] = { {0, 2, 4, 6}, {1, 3, 5, 7},
1044 {0, 1, 4, 5}, {2, 3, 6, 7},
1045 {0, 1, 2, 3}, {4, 5, 6, 7} };
1046 GlobalCoordinate center( 0 );
1047 for( int i=0; i<4; ++i )
1048 {
1049 center += copyToGlobalCoordinate( grid_.node_coordinates + GlobalCoordinate::dimension * cellVertices_[ cell ][ sideCorners[ side ][ i ] ] );
1050 }
1051 center /= 4;
1052 return center;
1053 }
1054
1056 template< class Intersection >
1057 GlobalCoordinate faceCenterEcl ( const int cell, const int side, const Intersection& ) const
1058 {
1059 return faceCenterEcl( cell, side );
1060 }
1061
1070 GlobalCoordinate faceAreaNormalEcl ( const int face ) const
1071 {
1072 const int first = grid_.face_nodepos[ face ];
1073 const int numNodes = grid_.face_nodepos[ face + 1 ] - first;
1074 auto node = [ this, first ]( const int i )
1075 {
1076 return copyToGlobalCoordinate( grid_.node_coordinates + GlobalCoordinate::dimension * grid_.face_nodes[ first + i ] );
1077 };
1078 auto cross = []( const GlobalCoordinate& a, const GlobalCoordinate& b )
1079 {
1080 GlobalCoordinate c( 0 );
1081 if( dimworld == 3 )
1082 {
1083 c[ 0 ] = a[ 1 ] * b[ 2 ] - a[ 2 ] * b[ 1 ];
1084 c[ 1 ] = a[ 2 ] * b[ 0 ] - a[ 0 ] * b[ 2 ];
1085 c[ 2 ] = a[ 0 ] * b[ 1 ] - a[ 1 ] * b[ 0 ];
1086 }
1087 return c;
1088 };
1089
1090 GlobalCoordinate areaNormal( 0 );
1091 if( dimworld != 3 || numNodes < 3 )
1092 {
1093 return areaNormal;
1094 }
1095 if( numNodes == 3 )
1096 {
1097 areaNormal = cross( node( 0 ) - node( 2 ), node( 1 ) - node( 2 ) );
1098 areaNormal *= 0.5;
1099 }
1100 else if( numNodes == 4 )
1101 {
1102 areaNormal = cross( node( 0 ) - node( 2 ), node( 1 ) - node( 3 ) );
1103 areaNormal *= 0.5;
1104 }
1105 else
1106 {
1107 const int h = ( numNodes - 1 ) / 2;
1108 const int k = ( numNodes % 2 ) ? 0 : numNodes - 1;
1109 // first the quadrilaterals
1110 for( int i = 1; i < h; ++i )
1111 {
1112 areaNormal += cross( node( 2*i ) - node( 0 ), node( 2*i + 1 ) - node( 2*i - 1 ) );
1113 }
1114 // and then the last triangle or quadrilateral
1115 areaNormal += cross( node( 2*h ) - node( 0 ), node( k ) - node( 2*h - 1 ) );
1116 areaNormal *= 0.5;
1117 }
1118 return areaNormal;
1119 }
1120
1121 template <class EntitySeed>
1123 corner ( const EntitySeed& seed, const int i ) const
1124 {
1125 const int codim = EntitySeed :: codimension;
1126 if (codim==0)
1127 {
1128 const int coordIndex = GlobalCoordinate :: dimension * cellVertices_[ seed.index() ][ i ];
1129 return copyToGlobalCoordinate( grid_.node_coordinates + coordIndex );
1130 }
1131 if (codim==1)
1132 {
1133 // for faces we need to swap vertices in 3d since in UnstructuredGrid
1134 // those are ordered counter clockwise, for 2d this does not matter
1135 // TODO: Improve this for performance reasons
1136 const int crners = corners( seed );
1137 const int crner = (crners == 4 && EntitySeed :: dimension == 3 && i > 1 ) ? 5 - i : i;
1138 const int faceVertex = grid_.face_nodes[ grid_.face_nodepos[seed.index() ] + crner ];
1139 return copyToGlobalCoordinate( grid_.node_coordinates + GlobalCoordinate :: dimension * faceVertex );
1140 }
1141 if (codim==dim)
1142 {
1143 const int coordIndex = GlobalCoordinate :: dimension * seed.index();
1144 return copyToGlobalCoordinate( grid_.node_coordinates + coordIndex );
1145 }
1146 return GlobalCoordinate( 0 );
1147 }
1148
1149 template <class EntitySeed>
1150 int subEntities( const EntitySeed& seed, const int codim ) const
1151 {
1152 const int index = seed.index();
1153 if( seed.codimension == 0 )
1154 {
1155 if (codim==0)
1156 return 1;
1157 if (codim==1)
1158 return grid_.cell_facepos[ index+1 ] - grid_.cell_facepos[ index ];
1159 if (codim==dim)
1160 return cellVertices_[ index ].size();
1161 }
1162 else if( seed.codimension == 1 )
1163 {
1164 if (codim==1)
1165 return 1;
1166 if (codim==dim)
1167 return grid_.face_nodepos[ index+1 ] - grid_.face_nodepos[ index ];
1168 }
1169 else if ( seed.codimension == dim )
1170 {
1171 return 1 ;
1172 }
1173
1174 return 0;
1175 }
1176
1177 template <int codim, class EntitySeedArg >
1178 typename Codim<codim>::EntitySeed
1179 subEntitySeed( const EntitySeedArg& baseSeed, const int i ) const
1180 {
1181 assert( codim >= EntitySeedArg::codimension );
1182 assert( i>= 0 && i<subEntities( baseSeed, codim ) );
1183 typedef typename Codim<codim>::EntitySeed EntitySeed;
1184
1185 // if codim equals entity seed codim just return same entity seed.
1186 if( codim == EntitySeedArg::codimension )
1187 {
1188 return EntitySeed( baseSeed.index() );
1189 }
1190
1191 if( EntitySeedArg::codimension == 0 )
1192 {
1193 if ( codim == 1 )
1194 {
1195 return EntitySeed( grid_.cell_faces[ grid_.cell_facepos[ baseSeed.index() ] + i ] );
1196 }
1197 else if ( codim == dim )
1198 {
1199 return EntitySeed( cellVertices_[ baseSeed.index() ][ i ] );
1200 }
1201 }
1202 else if ( EntitySeedArg::codimension == 1 && codim == dim )
1203 {
1204 return EntitySeed( grid_.face_nodes[ grid_.face_nodepos[ baseSeed.index() + i ] ]);
1205 }
1206
1207 DUNE_THROW(NotImplemented,"codimension not available");
1208 return EntitySeed();
1209 }
1210
1211 template <int codim>
1212 typename Codim<codim>::EntitySeed
1213 subEntitySeed( const typename Codim<1>::EntitySeed& faceSeed, const int i ) const
1214 {
1215 assert( i>= 0 && i<subEntities( faceSeed, codim ) );
1216 typedef typename Codim<codim>::EntitySeed EntitySeed;
1217 if ( codim == 1 )
1218 {
1219 return EntitySeed( faceSeed.index() );
1220 }
1221 else if ( codim == dim )
1222 {
1223 return EntitySeed( grid_.face_nodes[ grid_.face_nodepos[ faceSeed.index() ] + i ] );
1224 }
1225 else
1226 {
1227 DUNE_THROW(NotImplemented,"codimension not available");
1228 }
1229 }
1230
1231 bool hasBoundaryIntersections(const typename Codim<0>::EntitySeed& seed ) const
1232 {
1233 const int faces = subEntities( seed, 1 );
1234 for( int f=0; f<faces; ++f )
1235 {
1236 const auto faceSeed = this->template subEntitySeed<1>( seed, f );
1237 if( isBoundaryFace( faceSeed ) )
1238 return true;
1239 }
1240 return false;
1241 }
1242
1243 bool isBoundaryFace(const int face ) const
1244 {
1245 assert( face >= 0 && face < grid_.number_of_faces );
1246 const int facePos = 2 * face;
1247 return ((grid_.face_cells[ facePos ] < 0) || (grid_.face_cells[ facePos+1 ] < 0));
1248 }
1249
1250 bool isBoundaryFace(const typename Codim<1>::EntitySeed& faceSeed ) const
1251 {
1252 assert( faceSeed.isValid() );
1253 return isBoundaryFace( faceSeed.index() );
1254 }
1255
1256 int boundarySegmentIndex(const typename Codim<0>::EntitySeed& seed, const int face ) const
1257 {
1258 const auto faceSeed = this->template subEntitySeed<1>( seed, face );
1259 assert( faceSeed.isValid() );
1260 const int facePos = 2 * faceSeed.index();
1261 const int idx = std::min( grid_.face_cells[ facePos ], grid_.face_cells[ facePos+1 ]);
1262 // check that this is actually the boundary
1263 assert( idx < 0 );
1264 return -(idx+1); // +1 to include 0 boundary segment index
1265 }
1266
1267 const std::vector< GeometryType > &geomTypes ( const unsigned int codim ) const
1268 {
1269 static std::vector< GeometryType > emptyDummy;
1270 if (codim < geomTypes_.size())
1271 {
1272 return geomTypes_[codim];
1273 }
1274
1275 return emptyDummy;
1276 }
1277
1278 template < class Seed >
1279 GeometryType geometryType( const Seed& seed ) const
1280 {
1281 if( Seed::codimension == 0 )
1282 {
1283 assert(!geomTypes( Seed::codimension ).empty());
1284 return geomTypes( Seed::codimension )[ 0 ];
1285 }
1286 else
1287 {
1288 // 3d faces
1289 if( dim == 3 && Seed::codimension == 1 )
1290 {
1291 GeometryType face;
1292 const int nVx = corners( seed );
1293 if( nVx == 4 ) // quad face
1294 face = Dune::GeometryTypes::cube(2);
1295 else if( nVx == 3 ) // triangle face
1296 face = Dune::GeometryTypes::simplex(2);
1297 else // polygonal face
1298 face = Dune::GeometryTypes::none(2);
1299 return face;
1300 }
1301
1302 // for codim 2 and codim 3 there is only one option
1303 assert(!geomTypes( Seed::codimension ).empty());
1304 return geomTypes( Seed::codimension )[ 0 ];
1305 }
1306 }
1307
1308 int indexInInside( const typename Codim<0>::EntitySeed& seed, const int i ) const
1309 {
1310 return ( grid_.cell_facetag ) ? cartesianIndexInInside( seed, i ) : i;
1311 }
1312
1313 int cartesianIndexInInside( const typename Codim<0>::EntitySeed& seed, const int i ) const
1314 {
1315 assert( i>= 0 && i<subEntities( seed, 1 ) );
1316 return grid_.cell_facetag[ grid_.cell_facepos[ seed.index() ] + i ] ;
1317 }
1318
1319 typename Codim<0>::EntitySeed
1320 neighbor( const typename Codim<0>::EntitySeed& seed, const int i ) const
1321 {
1322 const int face = this->template subEntitySeed<1>( seed, i ).index();
1323 int nb = grid_.face_cells[ 2 * face ];
1324 if( nb == seed.index() )
1325 {
1326 nb = grid_.face_cells[ 2 * face + 1 ];
1327 }
1328
1329 typedef typename Codim<0>::EntitySeed EntitySeed;
1330 return EntitySeed( nb );
1331 }
1332
1333 int
1334 indexInOutside( const typename Codim<0>::EntitySeed& seed, const int i ) const
1335 {
1336 if( grid_.cell_facetag )
1337 {
1338 // if cell_facetag is present we assume pseudo Cartesian corner point case
1339 const int in_inside = cartesianIndexInInside( seed, i );
1340 return in_inside + ((in_inside % 2) ? -1 : 1);
1341 }
1342 else
1343 {
1344 typedef typename Codim<0>::EntitySeed EntitySeed;
1345 EntitySeed nb = neighbor( seed, i );
1346 const int faces = subEntities( seed, 1 );
1347 for( int face = 0; face<faces; ++ face )
1348 {
1349 if( neighbor( nb, face ).equals(seed) )
1350 {
1351 return indexInInside( nb, face );
1352 }
1353 }
1354 DUNE_THROW(InvalidStateException,"inverse intersection not found");
1355 return -1;
1356 }
1357 }
1358
1359 template <class EntitySeed>
1361 outerNormal( const EntitySeed& seed, const int i ) const
1362 {
1363 const int face = this->template subEntitySeed<1>( seed, i ).index();
1364 const int normalIdx = face * GlobalCoordinate :: dimension ;
1366 const int nb = grid_.face_cells[ 2*face ];
1367 if( nb != seed.index() )
1368 {
1369 normal *= -1.0;
1370 }
1371 return normal;
1372 }
1373
1374 template <class EntitySeed>
1376 unitOuterNormal( const EntitySeed& seed, const int i ) const
1377 {
1378 const int face = this->template subEntitySeed<1>( seed, i ).index();
1379 if( seed.index() == grid_.face_cells[ 2*face ] )
1380 {
1381 return unitOuterNormals_[ face ];
1382 }
1383 else
1384 {
1385 GlobalCoordinate normal = unitOuterNormals_[ face ];
1386 normal *= -1.0;
1387 return normal;
1388 }
1389 }
1390
1391 template <class EntitySeed>
1392 GlobalCoordinate centroids( const EntitySeed& seed ) const
1393 {
1394 if( ! seed.isValid() )
1395 return GlobalCoordinate( 0 );
1396
1397 const int index = GlobalCoordinate :: dimension * seed.index();
1398 const int codim = EntitySeed::codimension;
1399 assert( index >= 0 && index < size( codim ) * GlobalCoordinate :: dimension );
1400
1401 if( codim == 0 )
1402 {
1404 }
1405 else if ( codim == 1 )
1406 {
1408 }
1409 else if( codim == dim )
1410 {
1412 }
1413 else
1414 {
1415 DUNE_THROW(InvalidStateException,"codimension not implemented");
1416 return GlobalCoordinate( 0 );
1417 }
1418 }
1419
1420 GlobalCoordinate copyToGlobalCoordinate( const double* coords ) const
1421 {
1422 GlobalCoordinate coordinate;
1423 for( int i=0; i<GlobalCoordinate::dimension; ++i )
1424 {
1425 coordinate[ i ] = coords[ i ];
1426 }
1427 return coordinate;
1428 }
1429
1430 template <class EntitySeed>
1431 double volumes( const EntitySeed& seed ) const
1432 {
1433 static const int codim = EntitySeed::codimension;
1434 if( codim == dim || ! seed.isValid() )
1435 {
1436 return 1.0;
1437 }
1438 else
1439 {
1440 assert( seed.isValid() );
1441
1442 if( codim == 0 )
1443 {
1444 return grid_.cell_volumes[ seed.index() ];
1445 }
1446 else if ( codim == 1 )
1447 {
1448 return grid_.face_areas[ seed.index() ];
1449 }
1450 else
1451 {
1452 DUNE_THROW(InvalidStateException,"codimension not implemented");
1453 return 0.0;
1454 }
1455 }
1456 }
1457
1458 protected:
1459 // connectCellsAcrossGaps() gives a cell an extra face with the tag of the top: the bottom face of the cell above.
1460 // This tells whether the face is that extra face, and not the top of the cell itself.
1461 //
1462 // The top of the cell has no cell on the other side. A face with the tag of the top that has a cell on both sides is
1463 // therefore an extra face, if the cell also has a top face with no cell on the other side.
1464 //
1465 // The extra face must not be used to find the corners of the cell. It is recognised in the same way if there is space
1466 // between the two cells or if they touch.
1467 bool isFaceAcrossGap ( const int cell, const int face ) const
1468 {
1469 if( grid_.face_cells[ 2*face ] < 0 || grid_.face_cells[ 2*face + 1 ] < 0 )
1470 {
1471 return false;
1472 }
1473 for( unsigned hf = grid_.cell_facepos[ cell ]; hf < grid_.cell_facepos[ cell+1 ]; ++hf )
1474 {
1475 const int f = grid_.cell_faces[ hf ];
1476 if( grid_.cell_facetag[ hf ] == 4 && ( grid_.face_cells[ 2*f ] < 0 || grid_.face_cells[ 2*f + 1 ] < 0 ) )
1477 {
1478 return true;
1479 }
1480 }
1481 return false;
1482 }
1483
1484 void init ()
1485 {
1486 // copy Cartesian dimensions
1487 for( int i=0; i<3; ++i )
1488 {
1489 cartDims_[ i ] = grid_.cartdims[ i ];
1490 }
1491
1492 // setup list of cell vertices
1493 const int numCells = size( 0 );
1494
1495 cellVertices_.resize( numCells );
1496
1497 // sort vertices such that they comply with the dune reference cube
1498 if( grid_.cell_facetag )
1499 {
1500 typedef std::array<int, 3> KeyType;
1501 std::map< const KeyType, const int > vertexFaceTags;
1502 const int vertexFacePattern [8][3] = {
1503 { 0, 2, 4 }, // vertex 0
1504 { 1, 2, 4 }, // vertex 1
1505 { 0, 3, 4 }, // vertex 2
1506 { 1, 3, 4 }, // vertex 3
1507 { 0, 2, 5 }, // vertex 4
1508 { 1, 2, 5 }, // vertex 5
1509 { 0, 3, 5 }, // vertex 6
1510 { 1, 3, 5 } // vertex 7
1511 };
1512
1513 for( int i=0; i<8; ++i )
1514 {
1515 KeyType key; key.fill( 4 ); // default is 4 which is the first z coord (for the 2d case)
1516 for( int j=0; j<dim; ++j )
1517 {
1518 key[ j ] = vertexFacePattern[ i ][ j ];
1519 }
1520
1521 vertexFaceTags.insert( std::make_pair( key, i ) );
1522 }
1523
1524 for (int c = 0; c < numCells; ++c)
1525 {
1526 if( dim == 2 )
1527 {
1528 // for 2d Cartesian grids the face ordering is wrong
1529 int f = grid_.cell_facepos[ c ];
1530 std::swap( grid_.cell_faces[ f+1 ], grid_.cell_faces[ f+2 ] );
1531 std::swap( grid_.cell_facetag[ f+1 ], grid_.cell_facetag[ f+2 ] );
1532 }
1533
1534 typedef std::map< int, std::set<int> > vertexlist_t;
1535 vertexlist_t vertexList;
1536
1537 if( dim == 3 )
1538 {
1539 // A side of a cell consists of several faces if the cell is at a fault. The corners of
1540 // the cell are the nodes on the boundary of three sides, one for each direction. Other
1541 // nodes of the faces are on the edges of the cell (where the neighbors on the other
1542 // side of the fault meet) or inside a side. A corner can be the end of a line that
1543 // divides a side, so counting how many faces of a side have a node does not find them.
1544 typedef std::pair<int,int> EdgeType;
1545 std::vector< std::map< EdgeType, int > > sideEdges( dim*2 );
1546
1547 for (unsigned hf = grid_.cell_facepos[ c ]; hf < grid_.cell_facepos[c+1]; ++hf)
1548 {
1549 const int f = grid_.cell_faces[ hf ];
1550 const int faceTag = grid_.cell_facetag[ hf ];
1551
1552 // The face to the cell above the space that MINPV left is a face of that cell, and the cell has its own top
1553 // face. It is not a face of the top of the cell, which the nodes tell: they are not on the sides of the cell.
1554 // See connectCellsAcrossGaps().
1555 if( faceTag == 4 && isFaceAcrossGap( c, f ) )
1556 {
1557 continue;
1558 }
1559
1560 const unsigned first = grid_.face_nodepos[f];
1561 const unsigned last = grid_.face_nodepos[f+1];
1562 for (unsigned nodepos = first; nodepos < last; ++nodepos )
1563 {
1564 const int a = grid_.face_nodes[ nodepos ];
1565 const int b = grid_.face_nodes[ nodepos + 1 < last ? nodepos + 1 : first ];
1566 ++sideEdges[ faceTag ][ std::minmax( a, b ) ];
1567 }
1568 }
1569
1570 // The edges that belong to one face of a side only are on the boundary of the side.
1571 for( int faceTag = 0; faceTag<dim*2; ++faceTag )
1572 {
1573 for( const auto& edge : sideEdges[ faceTag ] )
1574 {
1575 if( edge.second == 1 )
1576 {
1577 vertexList[ edge.first.first ].insert( faceTag );
1578 vertexList[ edge.first.second ].insert( faceTag );
1579 }
1580 }
1581 }
1582
1583 // A node on the boundary of a side in each direction is a corner. It is more than one
1584 // corner if the cell is collapsed there, such as at the end of a pinched layer.
1585 // If a whole side of the cell is collapsed, to an edge or a point, it has no face. The
1586 // nodes in its place do not belong to any side in that direction and are corners of
1587 // the side that has no face.
1588 std::array< bool, dim*2 > hasSide;
1589 for( int faceTag = 0; faceTag<dim*2; ++faceTag )
1590 {
1591 hasSide[ faceTag ] = ! sideEdges[ faceTag ].empty();
1592 }
1593
1594 cellVertices_[ c ].assign( 8, -1 );
1595 for( auto& [node, sides] : vertexList )
1596 {
1597 // The nodes on the edges of the cell are on the boundary of two sides only, in different
1598 // directions. A node that is on both sides in a direction is collapsed in that direction,
1599 // which makes it a corner even if it is on no other side because they have collapsed.
1600 const bool collapsed = ( sides.count( 0 ) && sides.count( 1 ) ) || ( sides.count( 2 ) && sides.count( 3 ) )
1601 || ( sides.count( 4 ) && sides.count( 5 ) );
1602 if( sides.size() < dim && ! collapsed )
1603 {
1604 continue;
1605 }
1606 for( int direction = 0; direction<dim; ++direction )
1607 {
1608 const int low = 2*direction;
1609 if( ! sides.count( low ) && ! sides.count( low + 1 ) && hasSide[ low ] != hasSide[ low + 1 ] )
1610 {
1611 sides.insert( hasSide[ low ] ? low + 1 : low );
1612 }
1613 }
1614
1615 for( int i=0; i<8; ++i )
1616 {
1617 if( sides.count( vertexFacePattern[ i ][ 0 ] ) && sides.count( vertexFacePattern[ i ][ 1 ] )
1618 && sides.count( vertexFacePattern[ i ][ 2 ] ) )
1619 {
1620 if( cellVertices_[ c ][ i ] >= 0 && cellVertices_[ c ][ i ] != node )
1621 {
1622 OPM_THROW(std::runtime_error,
1623 "PolyhedralGrid: corner " + std::to_string( i ) + " of cell " + std::to_string( c )
1624 + " is not unique. Cells that are twisted are not supported.");
1625 }
1626 cellVertices_[ c ][ i ] = node;
1627 }
1628 }
1629 }
1630 if( std::count( cellVertices_[ c ].begin(), cellVertices_[ c ].end(), -1 ) > 0 )
1631 {
1632 OPM_THROW(std::runtime_error,
1633 "PolyhedralGrid: cell " + std::to_string( c ) + " is missing a corner. "
1634 "Cells that are collapsed in a way that removes a side are not supported.");
1635 }
1636 }
1637 else
1638 {
1639 typedef std::map<int,int> vertexmap_t;
1640 typedef typename vertexmap_t :: iterator iterator;
1641
1642 std::vector< vertexmap_t > cell_pts( dim*2 );
1643
1644 for (unsigned hf = grid_.cell_facepos[ c ]; hf < grid_.cell_facepos[c+1]; ++hf)
1645 {
1646 const int f = grid_.cell_faces[ hf ];
1647 const int faceTag = grid_.cell_facetag[ hf ];
1648
1649 for (unsigned nodepos = grid_.face_nodepos[f]; nodepos < grid_.face_nodepos[f+1]; ++nodepos )
1650 {
1651 const int node = grid_.face_nodes[ nodepos ];
1652 iterator it = cell_pts[ faceTag ].find( node );
1653 if( it == cell_pts[ faceTag ].end() )
1654 {
1655 cell_pts[ faceTag ].insert( std::make_pair( node, 1 ) );
1656 }
1657 else
1658 {
1659 // increase vertex reference counter
1660 (*it).second++;
1661 }
1662 }
1663 }
1664
1665 for( int faceTag = 0; faceTag<dim*2; ++faceTag )
1666 {
1667 for( iterator it = cell_pts[ faceTag ].begin(),
1668 end = cell_pts[ faceTag ].end(); it != end; ++it )
1669 {
1670
1671 // only consider vertices with one appearance
1672 if( (*it).second == 1 )
1673 {
1674 vertexList[ (*it).first ].insert( faceTag );
1675 }
1676 }
1677 }
1678 }
1679
1680 // The corners of a cell in three dimensions were found above.
1681 if( dim != 3 )
1682 {
1683 assert( int(vertexList.size()) == ( dim == 2 ? 4 : 8) );
1684
1685 cellVertices_[ c ].resize( vertexList.size() );
1686 for( auto it = vertexList.begin(), end = vertexList.end(); it != end; ++it )
1687 {
1688 assert( (*it).second.size() == dim );
1689 KeyType key; key.fill( 4 ); // fill with 4 which is the first z coord
1690
1691 std::ranges::copy(it->second, key.begin());
1692 auto vx = vertexFaceTags.find( key );
1693 assert( vx != vertexFaceTags.end() );
1694 if( vx != vertexFaceTags.end() )
1695 {
1696 if( (*vx).second >= int(cellVertices_[ c ].size()) )
1697 cellVertices_[ c ].resize( (*vx).second+1 );
1698 // store node number on correct local position
1699 cellVertices_[ c ][ (*vx).second ] = (*it).first ;
1700 }
1701 }
1702 }
1703 }
1704
1705 // if face_tag is available we assume that the elements follow a cube-like structure
1706 geomTypes_.resize(dim + 1);
1707 GeometryType tmp;
1708 for (int codim = 0; codim <= dim; ++codim)
1709 {
1710 tmp = Dune::GeometryTypes::cube(dim - codim);
1711 geomTypes_[codim].push_back(tmp);
1712 }
1713 }
1714 else // if ( grid_.cell_facetag )
1715 {
1716 int maxVx = 0 ;
1717 int minVx = std::numeric_limits<int>::max();
1718
1719 for (int c = 0; c < numCells; ++c)
1720 {
1721 std::set<int> cell_pts;
1722 for (unsigned hf = grid_.cell_facepos[ c ]; hf < grid_.cell_facepos[c+1]; ++hf)
1723 {
1724 int f = grid_.cell_faces[ hf ];
1725 const int* fnbeg = grid_.face_nodes + grid_.face_nodepos[f];
1726 const int* fnend = grid_.face_nodes + grid_.face_nodepos[f+1];
1727 cell_pts.insert(fnbeg, fnend);
1728 }
1729
1730 cellVertices_[ c ].resize( cell_pts.size() );
1731 std::ranges::copy(cell_pts, cellVertices_[c].begin());
1732 maxVx = std::max( maxVx, int( cell_pts.size() ) );
1733 minVx = std::min( minVx, int( cell_pts.size() ) );
1734 }
1735
1736 if( minVx == maxVx && maxVx == 4 )
1737 {
1738 for (int c = 0; c < numCells; ++c)
1739 {
1740 assert( cellVertices_[ c ].size() == 4 );
1741 GlobalCoordinate center( 0 );
1742 GlobalCoordinate p[ dim+1 ];
1743 for( int i=0; i<dim+1; ++i )
1744 {
1745 const int vertex = cellVertices_[ c ][ i ];
1746
1747 for( int d=0; d<dim; ++d )
1748 {
1749 center[ d ] += grid_.node_coordinates[ vertex*dim + d ];
1750 p[ i ][ d ] = grid_.node_coordinates[ vertex*dim + d ];
1751 }
1752 }
1753 center *= 0.25;
1754 for( int d=0; d<dim; ++d )
1755 {
1756 grid_.cell_centroids[ c*dim + d ] = center[ d ];
1757 }
1758
1759 Dune::GeometryType simplex;
1760 simplex = Dune::GeometryTypes::simplex(dim);
1761
1762 typedef Dune::AffineGeometry< ctype, dim, dimworld> AffineGeometryType;
1763 AffineGeometryType geometry( simplex, p );
1764 grid_.cell_volumes[ c ] = geometry.volume();
1765 }
1766 }
1767
1768 // check face normals
1769 {
1770 const int faces = grid_.number_of_faces;
1771 for( int face = 0 ; face < faces; ++face )
1772 {
1773 const int a = grid_.face_cells[ 2*face ];
1774 const int b = grid_.face_cells[ 2*face + 1 ];
1775
1776 assert( a >=0 || b >=0 );
1777
1778 if( grid_.face_areas[ face ] < 0 )
1779 std::abort();
1780
1781 GlobalCoordinate centerDiff( 0 );
1782 if( b >= 0 )
1783 {
1784 for( int d=0; d<dimworld; ++d )
1785 {
1786 centerDiff[ d ] = grid_.cell_centroids[ b*dimworld + d ];
1787 }
1788 }
1789 else
1790 {
1791 for( int d=0; d<dimworld; ++d )
1792 {
1793 centerDiff[ d ] = grid_.face_centroids[ face*dimworld + d ];
1794 }
1795 }
1796
1797 if( a >= 0 )
1798 {
1799 for( int d=0; d<dimworld; ++d )
1800 {
1801 centerDiff[ d ] -= grid_.cell_centroids[ a*dimworld + d ];
1802 }
1803 }
1804 else
1805 {
1806 for( int d=0; d<dimworld; ++d )
1807 {
1808 centerDiff[ d ] -= grid_.face_centroids[ face*dimworld + d ];
1809 }
1810 }
1811
1812 GlobalCoordinate normal( 0 );
1813 for( int d=0; d<dimworld; ++d )
1814 {
1815 normal[ d ] = grid_.face_normals[ face*dimworld + d ];
1816 }
1817
1818 if( centerDiff.two_norm() < 1e-10 )
1819 std::abort();
1820
1821 // if diff and normal point in different direction, flip faces
1822 if( centerDiff * normal < 0 )
1823 {
1824 grid_.face_cells[ 2*face ] = b;
1825 grid_.face_cells[ 2*face + 1 ] = a;
1826 }
1827 }
1828 }
1829
1830 bool allSimplex = true ;
1831 bool allCube = true ;
1832
1833 for (int c = 0; c < numCells; ++c)
1834 {
1835 const int nVx = cellVertices_[ c ].size();
1836 if( nVx != 4 )
1837 {
1838 allSimplex = false;
1839 }
1840
1841 if( nVx != 8 )
1842 {
1843 allCube = false;
1844 }
1845 }
1846 // Propogate the cell geometry type to all codimensions
1847 geomTypes_.resize(dim + 1);
1848 GeometryType tmp;
1849 for (int codim = 0; codim <= dim; ++codim)
1850 {
1851 if( allSimplex )
1852 {
1853 tmp = Dune::GeometryTypes::simplex(dim - codim);
1854 geomTypes_[ codim ].push_back( tmp );
1855 }
1856 else if ( allCube )
1857 {
1858 tmp = Dune::GeometryTypes::cube(dim - codim);
1859 geomTypes_[ codim ].push_back( tmp );
1860 }
1861 else
1862 {
1863 tmp = Dune::GeometryTypes::none(dim - codim);
1864 geomTypes_[ codim ].push_back( tmp );
1865 }
1866 }
1867
1868 } // end else of ( grid_.cell_facetag )
1869
1870 nBndSegments_ = 0;
1872 for( int face = 0; face < grid_.number_of_faces; ++face )
1873 {
1874 const int normalIdx = face * GlobalCoordinate :: dimension ;
1876 normal /= normal.two_norm();
1877 unitOuterNormals_[ face ] = normal;
1878
1879 if( isBoundaryFace( face ) )
1880 {
1881 // increase number if boundary segments
1882 ++nBndSegments_;
1883 const int facePos = 2 * face ;
1884 // store negative number to indicate boundary
1885 // the abstract value is the segment index
1886 if( grid_.face_cells[ facePos ] < 0 )
1887 {
1888 grid_.face_cells[ facePos ] = -nBndSegments_;
1889 }
1890 else if ( grid_.face_cells[ facePos+1 ] < 0 )
1891 {
1892 grid_.face_cells[ facePos+1 ] = -nBndSegments_;
1893 }
1894 }
1895 }
1896 }
1897
1898 void print( std::ostream& out, const UnstructuredGridType& grid ) const
1899 {
1900 const int numCells = grid.number_of_cells;
1901 for( int c=0; c<numCells; ++c )
1902 {
1903 out << "cell " << c << " : faces = " << std::endl;
1904 for (int hf=grid.cell_facepos[ c ]; hf < grid.cell_facepos[c+1]; ++hf)
1905 {
1906 int f = grid_.cell_faces[ hf ];
1907 const int* fnbeg = grid_.face_nodes + grid_.face_nodepos[f];
1908 const int* fnend = grid_.face_nodes + grid_.face_nodepos[f+1];
1909 out << f << " vx = " ;
1910 while( fnbeg != fnend )
1911 {
1912 out << *fnbeg << " ";
1913 ++fnbeg;
1914 }
1915 out << std::endl;
1916 }
1917 out << std::endl;
1918
1919 const auto& vx = cellVertices_[ c ];
1920 out << "cell " << c << " : vertices = ";
1921 for( size_t i=0; i<vx.size(); ++i )
1922 out << vx[ i ] << " ";
1923 out << std::endl;
1924 }
1925
1926 }
1927
1928 protected:
1931
1933 std::array< int, 3 > cartDims_;
1934 std::vector< std::vector< GeometryType > > geomTypes_;
1935 std::vector< std::vector< int > > cellVertices_;
1936
1937 std::vector< GlobalCoordinate > unitOuterNormals_;
1938
1942
1944
1945 private:
1946 // no copying
1947 PolyhedralGrid ( const PolyhedralGrid& );
1948 };
1949
1950
1951
1952 // PolyhedralGrid::Codim
1953 // -------------
1954
1955 template< int dim, int dimworld, typename coord_t >
1956 template< int codim >
1958 : public Base::template Codim< codim >
1959 {
1968 typedef typename Traits::template Codim< codim >::Entity Entity;
1969
1974 typedef typename Traits::template Codim< codim >::EntityPointer EntityPointer;
1975
1989 typedef typename Traits::template Codim< codim >::Geometry Geometry;
1990
1999 typedef typename Traits::template Codim< codim >::LocalGeometry LocalGeometry;
2000
2006 template< PartitionIteratorType pitype >
2008 {
2009 typedef typename Traits::template Codim< codim >
2012 typedef typename Traits::template Codim< codim >
2015 };
2016
2025
2034
2036 };
2037
2038} // namespace Dune
2039
2043
2044#endif // #ifndef DUNE_POLYHEDRALGRID_GRID_HH
void destroy_grid(struct UnstructuredGrid *g)
struct UnstructuredGrid * allocate_grid(size_t ndims, size_t ncells, size_t nfaces, size_t nfacenodes, size_t ncellfaces, size_t nnodes)
struct UnstructuredGrid * create_grid_cart2d(int nx, int ny, double dx, double dy)
struct UnstructuredGrid * create_grid_hexa3d(int nx, int ny, int nz, double dx, double dy, double dz)
Definition: entity.hh:152
Definition: entityseed.hh:16
Definition: geometry.hh:245
Definition: idset.hh:18
Definition: indexset.hh:25
Definition: intersectioniterator.hh:16
Definition: intersection.hh:22
Definition: iterator.hh:21
Definition: geometry.hh:264
identical grid wrapper
Definition: grid.hh:165
void postAdapt()
Definition: grid.hh:614
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: grid.hh:314
int ghostSize(int, int codim) const
obtain size of ghost region for a grid level
Definition: grid.hh:654
bool loadBalance(CommDataHandleIF< DataHandle, Data > &)
rebalance the load each process has to handle
Definition: grid.hh:758
Partition< All_Partition >::LevelGridView LevelGridView
View types for All_Partition.
Definition: grid.hh:251
Traits::template Codim< EntitySeed::codimension >::EntityPointer entityPointer(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: grid.hh:818
GlobalCoordinate faceAreaNormalEcl(const int face) const
The area normal of a face, defined as for the CpGrid.
Definition: grid.hh:1070
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: grid.hh:829
static void computeGeometry(UnstructuredGridPtr &ug)
Definition: grid.hh:197
bool preAdapt()
Definition: grid.hh:592
std::vector< std::vector< int > > cellVertices_
Definition: grid.hh:1935
GlobalCoordinate outerNormal(const EntitySeed &seed, const int i) const
Definition: grid.hh:1361
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: grid.hh:634
bool loadBalance(DofManager &)
rebalance the load each process has to handle
Definition: grid.hh:778
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: grid.hh:289
int maxLevel() const
obtain maximal grid level
Definition: grid.hh:424
Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
Definition: grid.hh:525
GlobalCoordinate faceCenterEcl(const int cell, const int side) const
The center of a side of a cell, defined as for the CpGrid.
Definition: grid.hh:1036
Codim< codim >::LevelIterator lbegin(const int) const
Definition: grid.hh:532
std::array< int, 3 > cartDims_
Definition: grid.hh:1933
const LeafIndexSet & leafIndexSet() const
Definition: grid.hh:572
const int * globalCellPtr() const
Definition: grid.hh:865
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: grid.hh:277
LevelGridView levelGridView(int) const
View for a grid level for All_Partition.
Definition: grid.hh:802
std::unique_ptr< UnstructuredGridType, UnstructuredGridDeleter > UnstructuredGridPtr
Definition: grid.hh:184
PolyhedralGrid(const std::vector< int > &n, const std::vector< double > &dx)
constructor
Definition: grid.hh:356
bool isBoundaryFace(const typename Codim< 1 >::EntitySeed &faceSeed) const
Definition: grid.hh:1250
static UnstructuredGridPtr allocateGrid(std::size_t nCells, std::size_t nFaces, std::size_t nFaceNodes, std::size_t nCellFaces, std::size_t nNodes)
Definition: grid.hh:187
size_t nBndSegments_
Definition: grid.hh:1943
Codim< codim >::LeafIterator leafbegin() const
Definition: grid.hh:504
Codim< codim >::LevelIterator lend(const int) const
Definition: grid.hh:538
ExtraData extraData() const
Definition: grid.hh:1009
Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: grid.hh:794
void print(std::ostream &out, const UnstructuredGridType &grid) const
Definition: grid.hh:1898
int getMark(const typename Codim< 0 >::Entity &) const
Definition: grid.hh:586
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: grid.hh:231
Codim< 0 >::EntitySeed neighbor(const typename Codim< 0 >::EntitySeed &seed, const int i) const
Definition: grid.hh:1320
CommunicationType comm_
Definition: grid.hh:1932
Codim< codim >::LeafIterator leafend() const
Definition: grid.hh:510
int size(int, int codim) const
obtain number of entites on a level
Definition: grid.hh:437
Partition< pitype >::LevelGridView levelGridView(int) const
View for a grid level.
Definition: grid.hh:785
GlobalCoordinate copyToGlobalCoordinate(const double *coords) const
Definition: grid.hh:1420
void update()
update grid caches
Definition: grid.hh:848
void getIJK(const int c, std::array< int, 3 > &ijk) const
Definition: grid.hh:870
PolyhedralGrid(const Opm::EclipseGrid &inputGrid, const std::vector< double > &poreVolumes=std::vector< double >{}, const bool edge_conformal=false, const bool mergeMinpvCells=false)
constructor
Definition: grid.hh:336
Partition< All_Partition >::LeafGridView LeafGridView
Definition: grid.hh:252
void switchToDistributedView()
Switch to the distributed view.
Definition: grid.hh:708
int overlapSize(int, int) const
obtain size of overlap region for a grid level
Definition: grid.hh:644
int indexInOutside(const typename Codim< 0 >::EntitySeed &seed, const int i) const
Definition: grid.hh:1334
std::vector< std::vector< GeometryType > > geomTypes_
Definition: grid.hh:1934
int size(int codim) const
obtain number of leaf entities
Definition: grid.hh:448
void scatterData(DataHandle &handle) const
Moves data from the global (all data on process) view to the distributed view.
Definition: grid.hh:893
LeafIndexSet leafIndexSet_
Definition: grid.hh:1939
int indexInInside(const typename Codim< 0 >::EntitySeed &seed, const int i) const
Definition: grid.hh:1308
Codim< codim >::EntitySeed subEntitySeed(const EntitySeedArg &baseSeed, const int i) const
Definition: grid.hh:1179
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: grid.hh:306
int corners(const EntitySeed &seed) const
Definition: grid.hh:1012
const GlobalIdSet & globalIdSet() const
Definition: grid.hh:557
typename Traits::Communication Communication
communicator with all other processes having some part of the grid
Definition: grid.hh:317
std::vector< GlobalCoordinate > unitOuterNormals_
Definition: grid.hh:1937
Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
Definition: grid.hh:517
int subEntities(const EntitySeed &seed, const int codim) const
Definition: grid.hh:1150
UnstructuredGridType * createGrid(const std::vector< int > &n, const std::vector< double > &dx) const
Definition: grid.hh:987
const CommunicationType & comm() const
obtain CollectiveCommunication object
Definition: grid.hh:721
int overlapSize(int) const
obtain size of overlap region for the leaf grid
Definition: grid.hh:625
const std::vector< GeometryType > & geomTypes(const unsigned int codim) const
Definition: grid.hh:1267
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: grid.hh:235
Communication CommunicationType
Definition: grid.hh:318
GridFamily::Traits Traits
type of the grid traits
Definition: grid.hh:214
PolyhedralGrid(UnstructuredGridPtr &&gridPtr)
constructor
Definition: grid.hh:375
Codim< codim >::EntitySeed subEntitySeed(const typename Codim< 1 >::EntitySeed &faceSeed, const int i) const
Definition: grid.hh:1213
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: grid.hh:233
bool adapt(DataHandle &)
Definition: grid.hh:608
Codim< codim >::template Partition< pitype >::LevelIterator lend(const int) const
Definition: grid.hh:552
UnstructuredGrid UnstructuredGridType
Definition: grid.hh:172
bool hasBoundaryIntersections(const typename Codim< 0 >::EntitySeed &seed) const
Definition: grid.hh:1231
double volumes(const EntitySeed &seed) const
Definition: grid.hh:1431
int size(int, GeometryType type) const
obtain number of entites on a level
Definition: grid.hh:477
void communicate(DataHandle &, InterfaceType, CommunicationDirection) const
communicate information on leaf entities
Definition: grid.hh:694
Codim< codim >::template Partition< pitype >::LevelIterator lbegin(const int) const
Definition: grid.hh:545
UnstructuredGridPtr gridPtr_
Definition: grid.hh:1929
const LocalIdSet & localIdSet() const
Definition: grid.hh:562
GlobalIdSet globalIdSet_
Definition: grid.hh:1940
size_t numBoundarySegments() const
obtain number of leaf entities
Definition: grid.hh:497
void switchToGlobalView()
Switch to the global view.
Definition: grid.hh:702
GeometryType geometryType(const Seed &seed) const
Definition: grid.hh:1279
const std::array< int, 3 > & logicalCartesianSize() const
Definition: grid.hh:854
bool loadBalance()
rebalance the load each process has to handle
Definition: grid.hh:737
PolyhedralGrid(const UnstructuredGridType &grid)
constructor
Definition: grid.hh:394
LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: grid.hh:809
int boundarySegmentIndex(const typename Codim< 0 >::EntitySeed &seed, const int face) const
Definition: grid.hh:1256
bool isBoundaryFace(const int face) const
Definition: grid.hh:1243
GlobalCoordinate faceCenterEcl(const int cell, const int side, const Intersection &) const
As above, for use where CpGrid::faceCenterEcl() takes the intersection as well.
Definition: grid.hh:1057
int size(GeometryType type) const
returns the number of boundary segments within the macro grid
Definition: grid.hh:486
bool isFaceAcrossGap(const int cell, const int face) const
Definition: grid.hh:1467
int cartesianIndexInInside(const typename Codim< 0 >::EntitySeed &seed, const int i) const
Definition: grid.hh:1313
bool mark(int, const typename Codim< 0 >::Entity &)
Definition: grid.hh:581
Traits::GlobalCoordinate GlobalCoordinate
Definition: grid.hh:320
const LevelIndexSet & levelIndexSet(int) const
Definition: grid.hh:567
void communicate(DataHandle &, InterfaceType, CommunicationDirection, int) const
communicate information on a grid level
Definition: grid.hh:673
bool adapt()
Definition: grid.hh:598
Traits::ExtraData ExtraData
Definition: grid.hh:1008
const int * globalCell() const
Definition: grid.hh:859
const UnstructuredGridType & grid_
Definition: grid.hh:1930
GlobalCoordinate unitOuterNormal(const EntitySeed &seed, const int i) const
Definition: grid.hh:1376
UnstructuredGridType * createGrid(const Opm::EclipseGrid &inputGrid, const std::vector< double > &poreVolumes, const bool edge_conformal, const bool mergeMinpvCells) const
Definition: grid.hh:900
GlobalCoordinate centroids(const EntitySeed &seed) const
Definition: grid.hh:1392
LocalIdSet localIdSet_
Definition: grid.hh:1941
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: grid.hh:267
void globalRefine(int)
Definition: grid.hh:577
void init()
Definition: grid.hh:1484
GlobalCoordinate corner(const EntitySeed &seed, const int i) const
Definition: grid.hh:1123
Transform a corner-point grid ZCORN field to account for MINPV processing.
Definition: MinpvProcessor.hpp:35
Result process(const std::vector< double > &thickness, const double z_tolerance, const double max_gap, const std::vector< double > &pv, const std::vector< double > &minpvv, const std::vector< int > &actnum, const bool mergeMinPVCells, double *zcorn, const bool pinchNOGAP=false, const bool pinchOption4ALL=false, const std::vector< double > &permz={}, const std::function< double(int)> &multZ=[](int){ return 0;}, const double tolerance_unique_points=0) const
void compute_geometry(struct UnstructuredGrid *g)
struct UnstructuredGrid * create_grid_cornerpoint_pinch(const struct grdecl *in, double tol, int edge_conformal, int pinch_active)
int connectCellsAcrossGaps(UnstructuredGrid &grid, const std::vector< std::pair< int, int > > &cells)
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10
FieldVector< T, 3 > cross(const FieldVector< T, 3 > &a, const FieldVector< T, 3 > &b)
Definition: Volumes.hpp:58
int faceTag(const Dune::CpGrid &grid, const Dune::cpgrid::Cell2FacesRow::iterator &cell_face)
Get Eclipse Cartesian tag of a face.
int numCells(const Dune::CpGrid &grid)
Get the number of cells of a grid.
STL namespace.
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator LeafIterator
Definition: grid.hh:2011
Traits::template Codim< codim >::template Partition< pitype >::LevelIterator LevelIterator
Definition: grid.hh:2014
traits structure containing types for a codimension
Definition: grid.hh:1959
Partition< All_Partition >::LeafIterator LeafIterator
type of level iterator
Definition: grid.hh:2024
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: grid.hh:1968
Traits::template Codim< codim >::EntityPointer EntityPointer
type of entity pointer
Definition: grid.hh:1974
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: grid.hh:1999
Partition< All_Partition >::LevelIterator LevelIterator
type of leaf iterator
Definition: grid.hh:2033
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: grid.hh:1989
Types for GridView.
Definition: grid.hh:245
GridFamily::Traits::template Partition< pitype >::LeafGridView LeafGridView
Definition: grid.hh:247
GridFamily::Traits::template Partition< pitype >::LevelGridView LevelGridView
Definition: grid.hh:246
void operator()(UnstructuredGridType *grdPtr)
Definition: grid.hh:177
PolyhedralGridIterator< codim, const Grid, pitype > LeafIteratorImpl
Definition: grid.hh:114
Dune::EntityIterator< codim, const Grid, LeafIteratorImpl > LeafIterator
Definition: grid.hh:115
LeafIterator LevelIterator
Definition: grid.hh:117
Dune::Geometry< dimension-codim, dimensionworld, const Grid, PolyhedralGridLocalGeometry > LocalGeometry
Definition: grid.hh:100
Entity EntityPointer
Definition: grid.hh:106
PolyhedralGridGeometry< dimension-codim, dimensionworld, const Grid > GeometryImpl
Definition: grid.hh:96
Dune::Geometry< dimension-codim, dimensionworld, const Grid, PolyhedralGridGeometry > Geometry
Definition: grid.hh:97
Partition< All_Partition >::LeafIterator LeafIterator
Definition: grid.hh:120
EntityImpl EntityPointerImpl
Definition: grid.hh:105
PolyhedralGridEntitySeed< codim, const Grid > EntitySeed
Definition: grid.hh:109
Dune::Entity< codim, dimension, const Grid, PolyhedralGridEntity > Entity
Definition: grid.hh:103
PolyhedralGridLocalGeometry< dimension-codim, dimensionworld, const Grid > LocalGeometryImpl
Definition: grid.hh:99
Partition< All_Partition >::LevelIterator LevelIterator
Definition: grid.hh:121
PolyhedralGridEntity< codim, dimension, const Grid > EntityImpl
Definition: grid.hh:102
Dune::GridView< PolyhedralGridViewTraits< dim, dimworld, ctype, pitype > > LeafGridView
Definition: grid.hh:137
Dune::GridView< PolyhedralGridViewTraits< dim, dimworld, ctype, pitype > > LevelGridView
Definition: grid.hh:138
PolyhedralGridIterator< 0, const Grid, All_Partition > HierarchicIteratorImpl
Definition: grid.hh:90
Dune::EntityIterator< 0, const Grid, HierarchicIteratorImpl > HierarchicIterator
Definition: grid.hh:91
Dune::IntersectionIterator< const Grid, LevelIntersectionIteratorImpl, LevelIntersectionImpl > LevelIntersectionIterator
Definition: grid.hh:88
GlobalIdSet LocalIdSet
Definition: grid.hh:128
PolyhedralGridIndexSet< dim, dimworld, ctype > LeafIndexSet
Definition: grid.hh:124
Dune::Communication< MPICommunicator > Communication
Definition: grid.hh:131
Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorImpl, LeafIntersectionImpl > LeafIntersectionIterator
Definition: grid.hh:87
PolyhedralGridIntersection< const Grid > LevelIntersectionImpl
Definition: grid.hh:80
PolyhedralGridIntersectionIterator< const Grid > LeafIntersectionIteratorImpl
Definition: grid.hh:81
Dune::Intersection< const Grid, LeafIntersectionImpl > LeafIntersection
Definition: grid.hh:84
PolyhedralGridIntersectionIterator< const Grid > LevelIntersectionIteratorImpl
Definition: grid.hh:82
static const int dimension
Definition: grid.hh:74
const Grid * ExtraData
Definition: grid.hh:70
int Index
Definition: grid.hh:72
Partition< All_Partition >::LevelGridView LevelGridView
Definition: grid.hh:142
Partition< All_Partition >::LeafGridView LeafGridView
Definition: grid.hh:141
PolyhedralGrid< dim, dimworld, coord_t > Grid
Definition: grid.hh:64
PolyhedralGridIdSet< dim, dimworld, ctype > GlobalIdSet
Definition: grid.hh:127
Dune::FieldVector< ctype, dimensionworld > GlobalCoordinate
Definition: grid.hh:77
Dune::Communication< MPICommunicator > CollectiveCommunication
Definition: grid.hh:132
static const int dimensionworld
Definition: grid.hh:75
PolyhedralGridIntersection< const Grid > LeafIntersectionImpl
Definition: grid.hh:79
Dune::MPIHelper::MPICommunicator MPICommunicator
Definition: grid.hh:130
coord_t ctype
Definition: grid.hh:66
Dune::Intersection< const Grid, LevelIntersectionImpl > LevelIntersection
Definition: grid.hh:85
PolyhedralGridIndexSet< dim, dimworld, ctype > LevelIndexSet
Definition: grid.hh:125
Definition: grid.hh:61
std::map< int, int > nnc
Definition: MinpvProcessor.hpp:40
Definition: UnstructuredGrid.h:101
int * face_nodes
Definition: UnstructuredGrid.h:123
grid_size_t * face_nodepos
Definition: UnstructuredGrid.h:129
int number_of_cells
Definition: UnstructuredGrid.h:111
double * face_areas
Definition: UnstructuredGrid.h:175
int * cell_faces
Definition: UnstructuredGrid.h:148
int number_of_faces
Definition: UnstructuredGrid.h:113
double * cell_centroids
Definition: UnstructuredGrid.h:194
int * cell_facetag
Definition: UnstructuredGrid.h:246
double * cell_volumes
Definition: UnstructuredGrid.h:199
int * face_cells
Definition: UnstructuredGrid.h:140
grid_size_t * cell_facepos
Definition: UnstructuredGrid.h:154
double * face_centroids
Definition: UnstructuredGrid.h:170
int number_of_nodes
Definition: UnstructuredGrid.h:115
int cartdims[3]
Definition: UnstructuredGrid.h:229
int * global_cell
Definition: UnstructuredGrid.h:216
double * face_normals
Definition: UnstructuredGrid.h:186
double * node_coordinates
Definition: UnstructuredGrid.h:162
Definition: preprocess.h:56
int dims[3]
Definition: preprocess.h:57
double b(const Dune::FieldVector< ct, dimworld > &, double)
Definition: transportproblem2.hh:25