3 #ifndef DUNE_POLYHEDRALGRID_GRID_HH 4 #define DUNE_POLYHEDRALGRID_GRID_HH 10 #include <opm/grid/utility/platform_dependent/disable_warnings.h> 13 #include <dune/common/version.hh> 14 #include <dune/common/parallel/mpihelper.hh> 17 #include <dune/grid/common/grid.hh> 19 #include <dune/common/parallel/communication.hh> 22 #include <opm/grid/polyhedralgrid/capabilities.hh> 23 #include <opm/grid/polyhedralgrid/declaration.hh> 24 #include <opm/grid/polyhedralgrid/entity.hh> 25 #include <opm/grid/polyhedralgrid/entityseed.hh> 26 #include <opm/grid/polyhedralgrid/geometry.hh> 27 #include <opm/grid/polyhedralgrid/gridview.hh> 28 #include <opm/grid/polyhedralgrid/idset.hh> 31 #include <opm/grid/utility/platform_dependent/reenable_warnings.h> 33 #include <opm/grid/utility/ErrorMacros.hpp> 38 #include <opm/grid/GridManager.hpp> 40 #include <opm/grid/MinpvProcessor.hpp> 43 #include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp> 53 template<
int dim,
int dimworld,
typename coord_t >
60 typedef coord_t ctype;
68 static const int dimension = dim;
69 static const int dimensionworld = dimworld;
71 typedef Dune::FieldVector< ctype, dimensionworld > GlobalCoordinate ;
78 typedef Dune::Intersection< const Grid, LeafIntersectionImpl > LeafIntersection;
79 typedef Dune::Intersection< const Grid, LevelIntersectionImpl > LevelIntersection;
81 typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorImpl, LeafIntersectionImpl > LeafIntersectionIterator;
82 typedef Dune::IntersectionIterator< const Grid, LevelIntersectionIteratorImpl, LevelIntersectionImpl > LevelIntersectionIterator;
85 typedef Dune::EntityIterator< 0, const Grid, HierarchicIteratorImpl > HierarchicIterator;
97 typedef Dune::Entity< codim, dimension, const Grid, PolyhedralGridEntity > Entity;
100 typedef Entity EntityPointer;
105 template< PartitionIteratorType pitype >
109 typedef Dune::EntityIterator< codim, const Grid, LeafIteratorImpl > LeafIterator;
111 typedef LeafIterator LevelIterator;
114 typedef typename Partition< All_Partition >::LeafIterator LeafIterator;
115 typedef typename Partition< All_Partition >::LevelIterator LevelIterator;
124 typedef Dune::MPIHelper::MPICommunicator MPICommunicator;
125 using Communication = Dune::Communication<MPICommunicator>;
126 using CollectiveCommunication = Dune::Communication<MPICommunicator>;
128 template< PartitionIteratorType pitype >
131 typedef Dune::GridView< PolyhedralGridViewTraits< dim, dimworld, ctype, pitype > > LeafGridView;
132 typedef Dune::GridView< PolyhedralGridViewTraits< dim, dimworld, ctype, pitype > > LevelGridView;
135 typedef typename Partition< All_Partition >::LeafGridView LeafGridView;
136 typedef typename Partition< All_Partition >::LevelGridView LevelGridView;
153 template <
int dim,
int dimworld,
typename coord_t >
156 :
public GridDefaultImplementation
157 < dim, dimworld, coord_t, PolyhedralGridFamily< dim, dimworld, coord_t > >
162 typedef GridDefaultImplementation
178 typedef std::unique_ptr< UnstructuredGridType, UnstructuredGridDeleter > UnstructuredGridPtr;
180 static UnstructuredGridPtr
181 allocateGrid ( std::size_t nCells, std::size_t nFaces, std::size_t nFaceNodes, std::size_t nCellFaces, std::size_t nNodes )
186 DUNE_THROW( GridError,
"Unable to allocate grid" );
187 return UnstructuredGridPtr( grid );
191 computeGeometry ( UnstructuredGridPtr& ug )
201 typedef PolyhedralGridFamily< dim, dimworld, coord_t > GridFamily;
207 typedef typename GridFamily::Traits
Traits;
216 template<
int codim >
237 template< PartitionIteratorType pitype >
240 typedef typename GridFamily::Traits::template Partition< pitype >::LevelGridView LevelGridView;
241 typedef typename GridFamily::Traits::template Partition< pitype >::LeafGridView LeafGridView;
246 typedef typename Partition< All_Partition >::LeafGridView LeafGridView;
307 typedef typename Traits::ctype
ctype;
314 typedef typename Traits :: GlobalCoordinate GlobalCoordinate;
328 const std::vector<double>& poreVolumes = std::vector<double>{},
329 const bool edge_conformal =
false)
330 : gridPtr_ { createGrid(inputGrid, poreVolumes, static_cast<int>(edge_conformal)) }
331 , grid_ { *gridPtr_ }
332 , comm_ { MPIHelper::getCommunicator() }
333 , leafIndexSet_ { *
this }
334 , globalIdSet_ { *
this }
335 , localIdSet_ { *
this }
336 , nBndSegments_ { 0 }
348 const std::vector< double >& dx )
349 : gridPtr_( createGrid( n, dx ) ),
351 comm_( MPIHelper::getCommunicator()),
352 leafIndexSet_( *this ),
353 globalIdSet_( *this ),
354 localIdSet_( *this ),
367 : gridPtr_(
std::move( gridPtr ) ),
369 comm_( MPIHelper::getCommunicator() ),
370 leafIndexSet_( *this ),
371 globalIdSet_( *this ),
372 localIdSet_( *this ),
388 comm_( MPIHelper::getCommunicator() ),
389 leafIndexSet_( *this ),
390 globalIdSet_( *this ),
391 localIdSet_( *this ),
401 operator const UnstructuredGridType& ()
const {
return grid_; }
428 int size (
int ,
int codim )
const 430 return size( codim );
445 else if ( codim == 1 )
449 else if ( codim == dim )
455 std::cerr <<
"Warning: codimension " << codim <<
" not available in PolyhedralGrid" << std::endl;
468 int size (
int , GeometryType type )
const 470 return size( dim - type.dim() );
477 int size ( GeometryType type )
const 479 return size( dim - type.dim() );
490 return nBndSegments_;
494 template<
int codim >
497 return leafbegin< codim, All_Partition >();
500 template<
int codim >
503 return leafend< codim, All_Partition >();
506 template<
int codim, PartitionIteratorType pitype >
507 typename Codim< codim >::template Partition< pitype >::LeafIterator
510 typedef typename Traits::template Codim< codim >::template Partition< pitype >::LeafIteratorImpl Impl;
511 return Impl( extraData(),
true );
514 template<
int codim, PartitionIteratorType pitype >
515 typename Codim< codim >::template Partition< pitype >::LeafIterator
518 typedef typename Traits::template Codim< codim >::template Partition< pitype >::LeafIteratorImpl Impl;
519 return Impl( extraData(),
false );
522 template<
int codim >
525 return leafbegin< codim, All_Partition >();
528 template<
int codim >
531 return leafend< codim, All_Partition >();
534 template<
int codim, PartitionIteratorType pitype >
535 typename Codim< codim >::template Partition< pitype >::LevelIterator
536 lbegin (
const int )
const 538 return leafbegin< codim, pitype > ();
541 template<
int codim, PartitionIteratorType pitype >
542 typename Codim< codim >::template Partition< pitype >::LevelIterator
543 lend (
const int )
const 545 return leafend< codim, pitype > ();
560 return leafIndexSet();
565 return leafIndexSet_;
568 void globalRefine (
int )
598 template<
class DataHandle >
627 return (codim == 0 ) ? 1 : 0;
663 template<
class DataHandle>
666 CommunicationDirection ,
669 OPM_THROW(std::runtime_error,
"communicate not implemented for polyhedreal grid!");
684 template<
class DataHandle>
687 CommunicationDirection )
const 689 OPM_THROW(std::runtime_error,
"communicate not implemented for polyhedreal grid!");
695 OPM_THROW(std::runtime_error,
"switch to global view not implemented for polyhedreal grid!");
701 OPM_THROW(std::runtime_error,
"switch to distributed view not implemented for polyhedreal grid!");
712 const CommunicationType &
comm ()
const 748 template<
class DataHandle,
class Data >
768 template<
class DofManager >
775 template< PartitionIteratorType pitype >
778 typedef typename Partition< pitype >::LevelGridView View;
779 typedef typename View::GridViewImp ViewImp;
780 return View( ViewImp( *
this ) );
784 template< PartitionIteratorType pitype >
787 typedef typename Traits::template Partition< pitype >::LeafGridView View;
788 typedef typename View::GridViewImp ViewImp;
789 return View( ViewImp( *
this ) );
795 typedef typename LevelGridView::GridViewImp ViewImp;
802 typedef typename LeafGridView::GridViewImp ViewImp;
803 return LeafGridView( ViewImp( *
this ) );
807 template<
class EntitySeed >
814 return EntityPointer( EntityPointerImpl( EntityImpl( extraData(), seed ) ) );
818 template<
class EntitySeed >
823 return EntityImpl( extraData(), seed );
845 const std::array<int, 3>& logicalCartesianSize()
const 850 const int* globalCell()
const 856 const int* globalCellPtr()
const 861 void getIJK(
const int c, std::array<int,3>& ijk)
const 863 int gc = globalCell()[c];
864 ijk[0] = gc % logicalCartesianSize()[0]; gc /= logicalCartesianSize()[0];
865 ijk[1] = gc % logicalCartesianSize()[1];
866 ijk[2] = gc / logicalCartesianSize()[1];
874 template<
class DataHandle>
886 OPM_THROW(std::runtime_error,
"ScatterData not implemented for polyhedral grid!");
891 UnstructuredGridType*
892 createGrid(
const Opm::EclipseGrid& inputGrid,
893 const std::vector<double>& poreVolumes,
894 const bool edge_conformal)
const 898 g.
dims[0] = inputGrid.getNX();
899 g.dims[1] = inputGrid.getNY();
900 g.dims[2] = inputGrid.getNZ();
902 std::vector<double> coord = inputGrid.getCOORD( );
903 std::vector<double> zcorn = inputGrid.getZCORN( );
904 std::vector<int> actnum = inputGrid.getACTNUM( );
906 g.coord = coord.data();
907 g.zcorn = zcorn.data();
908 g.actnum = actnum.data();
910 const double z_tolerance = inputGrid.isPinchActive() ? inputGrid.getPinchThresholdThickness() : 0.0;
912 if (!poreVolumes.empty() && (inputGrid.getMinpvMode() != Opm::MinpvMode::Inactive))
915 const std::vector<double>& minpvv = inputGrid.getMinpvVector();
920 const size_t cartGridSize = g.dims[0] * g.dims[1] * g.dims[2];
921 std::vector<double> thickness(cartGridSize);
922 for (
size_t i = 0; i < cartGridSize; ++i) {
923 thickness[i] = inputGrid.getCellThickness(i);
925 mp.process(thickness, z_tolerance, inputGrid.getPinchMaxEmptyGap() , poreVolumes,
926 minpvv, actnum, opmfil, zcorn.data());
941 (&g, z_tolerance, static_cast<int>(edge_conformal));
943 if (cgrid ==
nullptr) {
944 OPM_THROW(std::runtime_error,
"Failed to construct grid.");
951 UnstructuredGridType* createGrid(
const std::vector< int >& n,
const std::vector< double >& dx )
const 953 UnstructuredGridType* cgrid = nullptr ;
954 assert(
int(n.size()) == dim );
966 OPM_THROW(std::runtime_error,
"Failed to construct grid.");
972 typedef typename Traits :: ExtraData ExtraData;
973 ExtraData extraData ()
const {
return this; }
975 template <
class EntitySeed>
976 int corners(
const EntitySeed& seed )
const 978 const int codim = EntitySeed :: codimension;
979 const int index = seed.index();
981 return cellVertices_[ index ].size();
989 template <
class EntitySeed>
991 corner (
const EntitySeed& seed,
const int i )
const 993 const int codim = EntitySeed :: codimension;
996 const int coordIndex = GlobalCoordinate :: dimension * cellVertices_[ seed.index() ][ i ];
1004 const int crners = corners( seed );
1005 const int crner = (crners == 4 && EntitySeed :: dimension == 3 && i > 1 ) ? 5 - i : i;
1007 return copyToGlobalCoordinate( grid_.
node_coordinates + GlobalCoordinate :: dimension * faceVertex );
1011 const int coordIndex = GlobalCoordinate :: dimension * seed.index();
1014 return GlobalCoordinate( 0 );
1017 template <
class EntitySeed>
1018 int subEntities(
const EntitySeed& seed,
const int codim )
const 1020 const int index = seed.index();
1021 if( seed.codimension == 0 )
1028 return cellVertices_[ index ].size();
1030 else if( seed.codimension == 1 )
1037 else if ( seed.codimension == dim )
1045 template <
int codim,
class EntitySeedArg >
1046 typename Codim<codim>::EntitySeed
1047 subEntitySeed(
const EntitySeedArg& baseSeed,
const int i )
const 1049 assert( codim >= EntitySeedArg::codimension );
1050 assert( i>= 0 && i<subEntities( baseSeed, codim ) );
1051 typedef typename Codim<codim>::EntitySeed EntitySeed;
1054 if( codim == EntitySeedArg::codimension )
1056 return EntitySeed( baseSeed.index() );
1059 if( EntitySeedArg::codimension == 0 )
1065 else if ( codim == dim )
1067 return EntitySeed( cellVertices_[ baseSeed.index() ][ i ] );
1070 else if ( EntitySeedArg::codimension == 1 && codim == dim )
1075 DUNE_THROW(NotImplemented,
"codimension not available");
1076 return EntitySeed();
1079 template <
int codim>
1080 typename Codim<codim>::EntitySeed
1081 subEntitySeed(
const typename Codim<1>::EntitySeed& faceSeed,
const int i )
const 1083 assert( i>= 0 && i<subEntities( faceSeed, codim ) );
1084 typedef typename Codim<codim>::EntitySeed EntitySeed;
1087 return EntitySeed( faceSeed.index() );
1089 else if ( codim == dim )
1095 DUNE_THROW(NotImplemented,
"codimension not available");
1099 bool hasBoundaryIntersections(
const typename Codim<0>::EntitySeed& seed )
const 1101 const int faces = subEntities( seed, 1 );
1102 for(
int f=0; f<faces; ++f )
1104 const auto faceSeed = this->
template subEntitySeed<1>( seed, f );
1105 if( isBoundaryFace( faceSeed ) )
1111 bool isBoundaryFace(
const int face )
const 1114 const int facePos = 2 * face;
1118 bool isBoundaryFace(
const typename Codim<1>::EntitySeed& faceSeed )
const 1120 assert( faceSeed.isValid() );
1121 return isBoundaryFace( faceSeed.index() );
1124 int boundarySegmentIndex(
const typename Codim<0>::EntitySeed& seed,
const int face )
const 1126 const auto faceSeed = this->
template subEntitySeed<1>( seed, face );
1127 assert( faceSeed.isValid() );
1128 const int facePos = 2 * faceSeed.index();
1135 const std::vector< GeometryType > &geomTypes (
const unsigned int codim )
const 1137 static std::vector< GeometryType > emptyDummy;
1138 if (codim < geomTypes_.size())
1140 return geomTypes_[codim];
1146 template <
class Seed >
1147 GeometryType geometryType(
const Seed& seed )
const 1149 if( Seed::codimension == 0 )
1151 assert(!geomTypes( Seed::codimension ).empty());
1152 return geomTypes( Seed::codimension )[ 0 ];
1157 if( dim == 3 && Seed::codimension == 1 )
1160 const int nVx = corners( seed );
1162 face = Dune::GeometryTypes::cube(2);
1164 face = Dune::GeometryTypes::simplex(2);
1166 face = Dune::GeometryTypes::none(2);
1171 assert(!geomTypes( Seed::codimension ).empty());
1172 return geomTypes( Seed::codimension )[ 0 ];
1176 int indexInInside(
const typename Codim<0>::EntitySeed& seed,
const int i )
const 1178 return ( grid_.
cell_facetag ) ? cartesianIndexInInside( seed, i ) : i;
1181 int cartesianIndexInInside(
const typename Codim<0>::EntitySeed& seed,
const int i )
const 1183 assert( i>= 0 && i<subEntities( seed, 1 ) );
1187 typename Codim<0>::EntitySeed
1188 neighbor(
const typename Codim<0>::EntitySeed& seed,
const int i )
const 1190 const int face = this->
template subEntitySeed<1>( seed, i ).index();
1192 if( nb == seed.index() )
1197 typedef typename Codim<0>::EntitySeed EntitySeed;
1198 return EntitySeed( nb );
1202 indexInOutside(
const typename Codim<0>::EntitySeed& seed,
const int i )
const 1207 const int in_inside = cartesianIndexInInside( seed, i );
1208 return in_inside + ((in_inside % 2) ? -1 : 1);
1212 typedef typename Codim<0>::EntitySeed EntitySeed;
1213 EntitySeed nb = neighbor( seed, i );
1214 const int faces = subEntities( seed, 1 );
1215 for(
int face = 0; face<faces; ++ face )
1217 if( neighbor( nb, face ).equals(seed) )
1219 return indexInInside( nb, face );
1222 DUNE_THROW(InvalidStateException,
"inverse intersection not found");
1227 template <
class EntitySeed>
1229 outerNormal(
const EntitySeed& seed,
const int i )
const 1231 const int face = this->
template subEntitySeed<1>( seed, i ).index();
1232 const int normalIdx = face * GlobalCoordinate :: dimension ;
1233 GlobalCoordinate normal = copyToGlobalCoordinate( grid_.
face_normals + normalIdx );
1235 if( nb != seed.index() )
1242 template <
class EntitySeed>
1244 unitOuterNormal(
const EntitySeed& seed,
const int i )
const 1246 const int face = this->
template subEntitySeed<1>( seed, i ).index();
1247 if( seed.index() == grid_.
face_cells[ 2*face ] )
1249 return unitOuterNormals_[ face ];
1253 GlobalCoordinate normal = unitOuterNormals_[ face ];
1259 template <
class EntitySeed>
1260 GlobalCoordinate centroids(
const EntitySeed& seed )
const 1262 if( ! seed.isValid() )
1263 return GlobalCoordinate( 0 );
1265 const int index = GlobalCoordinate :: dimension * seed.index();
1266 const int codim = EntitySeed::codimension;
1267 assert( index >= 0 && index <
size( codim ) * GlobalCoordinate :: dimension );
1273 else if ( codim == 1 )
1277 else if( codim == dim )
1283 DUNE_THROW(InvalidStateException,
"codimension not implemented");
1284 return GlobalCoordinate( 0 );
1288 GlobalCoordinate copyToGlobalCoordinate(
const double* coords )
const 1290 GlobalCoordinate coordinate;
1291 for(
int i=0; i<GlobalCoordinate::dimension; ++i )
1293 coordinate[ i ] = coords[ i ];
1298 template <
class EntitySeed>
1299 double volumes(
const EntitySeed& seed )
const 1301 static const int codim = EntitySeed::codimension;
1302 if( codim == dim || ! seed.isValid() )
1308 assert( seed.isValid() );
1314 else if ( codim == 1 )
1320 DUNE_THROW(InvalidStateException,
"codimension not implemented");
1330 for(
int i=0; i<3; ++i )
1332 cartDims_[ i ] = grid_.
cartdims[ i ];
1336 const int numCells =
size( 0 );
1338 cellVertices_.resize( numCells );
1343 typedef std::array<int, 3> KeyType;
1344 std::map< const KeyType, const int > vertexFaceTags;
1345 const int vertexFacePattern [8][3] = {
1356 for(
int i=0; i<8; ++i )
1358 KeyType key; key.fill( 4 );
1359 for(
int j=0; j<dim; ++j )
1361 key[ j ] = vertexFacePattern[ i ][ j ];
1364 vertexFaceTags.insert( std::make_pair( key, i ) );
1367 for (
int c = 0; c < numCells; ++c)
1377 typedef std::map<int,int> vertexmap_t;
1378 typedef typename vertexmap_t :: iterator iterator;
1380 std::vector< vertexmap_t > cell_pts( dim*2 );
1389 const int node = grid_.
face_nodes[ nodepos ];
1390 iterator it = cell_pts[ faceTag ].find( node );
1391 if( it == cell_pts[ faceTag ].end() )
1393 cell_pts[ faceTag ].insert( std::make_pair( node, 1 ) );
1403 typedef std::map< int, std::set<int> > vertexlist_t;
1404 vertexlist_t vertexList;
1406 for(
int faceTag = 0; faceTag<dim*2; ++faceTag )
1408 for( iterator it = cell_pts[ faceTag ].begin(),
1409 end = cell_pts[ faceTag ].end(); it != end; ++it )
1413 if( (*it).second == 1 )
1415 vertexList[ (*it).first ].insert( faceTag );
1420 assert(
int(vertexList.size()) == ( dim == 2 ? 4 : 8) );
1422 cellVertices_[ c ].resize( vertexList.size() );
1423 for(
auto it = vertexList.begin(), end = vertexList.end(); it != end; ++it )
1425 assert( (*it).second.size() == dim );
1426 KeyType key; key.fill( 4 );
1428 std::ranges::copy(it->second, key.begin());
1429 auto vx = vertexFaceTags.find( key );
1430 assert( vx != vertexFaceTags.end() );
1431 if( vx != vertexFaceTags.end() )
1433 if( (*vx).second >=
int(cellVertices_[ c ].size()) )
1434 cellVertices_[ c ].resize( (*vx).second+1 );
1436 cellVertices_[ c ][ (*vx).second ] = (*it).first ;
1442 geomTypes_.resize(dim + 1);
1444 for (
int codim = 0; codim <= dim; ++codim)
1446 tmp = Dune::GeometryTypes::cube(dim - codim);
1447 geomTypes_[codim].push_back(tmp);
1453 int minVx = std::numeric_limits<int>::max();
1455 for (
int c = 0; c < numCells; ++c)
1457 std::set<int> cell_pts;
1463 cell_pts.insert(fnbeg, fnend);
1466 cellVertices_[ c ].resize( cell_pts.size() );
1467 std::ranges::copy(cell_pts, cellVertices_[c].begin());
1468 maxVx = std::max( maxVx,
int( cell_pts.size() ) );
1469 minVx = std::min( minVx,
int( cell_pts.size() ) );
1472 if( minVx == maxVx && maxVx == 4 )
1474 for (
int c = 0; c < numCells; ++c)
1476 assert( cellVertices_[ c ].
size() == 4 );
1477 GlobalCoordinate center( 0 );
1478 GlobalCoordinate p[ dim+1 ];
1479 for(
int i=0; i<dim+1; ++i )
1481 const int vertex = cellVertices_[ c ][ i ];
1483 for(
int d=0; d<dim; ++d )
1490 for(
int d=0; d<dim; ++d )
1495 Dune::GeometryType simplex;
1496 simplex = Dune::GeometryTypes::simplex(dim);
1498 typedef Dune::AffineGeometry< ctype, dim, dimworld> AffineGeometryType;
1499 AffineGeometryType geometry( simplex, p );
1507 for(
int face = 0 ; face < faces; ++face )
1510 const int b = grid_.
face_cells[ 2*face + 1 ];
1512 assert( a >=0 || b >=0 );
1517 GlobalCoordinate centerDiff( 0 );
1520 for(
int d=0; d<dimworld; ++d )
1527 for(
int d=0; d<dimworld; ++d )
1535 for(
int d=0; d<dimworld; ++d )
1542 for(
int d=0; d<dimworld; ++d )
1548 GlobalCoordinate normal( 0 );
1549 for(
int d=0; d<dimworld; ++d )
1554 if( centerDiff.two_norm() < 1e-10 )
1558 if( centerDiff * normal < 0 )
1566 bool allSimplex = true ;
1567 bool allCube = true ;
1569 for (
int c = 0; c < numCells; ++c)
1571 const int nVx = cellVertices_[ c ].size();
1583 geomTypes_.resize(dim + 1);
1585 for (
int codim = 0; codim <= dim; ++codim)
1589 tmp = Dune::GeometryTypes::simplex(dim - codim);
1590 geomTypes_[ codim ].push_back( tmp );
1594 tmp = Dune::GeometryTypes::cube(dim - codim);
1595 geomTypes_[ codim ].push_back( tmp );
1599 tmp = Dune::GeometryTypes::none(dim - codim);
1600 geomTypes_[ codim ].push_back( tmp );
1610 const int normalIdx = face * GlobalCoordinate :: dimension ;
1611 GlobalCoordinate normal = copyToGlobalCoordinate( grid_.
face_normals + normalIdx );
1612 normal /= normal.two_norm();
1613 unitOuterNormals_[ face ] = normal;
1615 if( isBoundaryFace( face ) )
1619 const int facePos = 2 * face ;
1624 grid_.
face_cells[ facePos ] = -nBndSegments_;
1626 else if ( grid_.
face_cells[ facePos+1 ] < 0 )
1628 grid_.
face_cells[ facePos+1 ] = -nBndSegments_;
1634 void print( std::ostream& out,
const UnstructuredGridType& grid )
const 1636 const int numCells = grid.number_of_cells;
1637 for(
int c=0; c<numCells; ++c )
1639 out <<
"cell " << c <<
" : faces = " << std::endl;
1640 for (
int hf=grid.cell_facepos[ c ]; hf < grid.cell_facepos[c+1]; ++hf)
1645 out << f <<
" vx = " ;
1646 while( fnbeg != fnend )
1648 out << *fnbeg <<
" ";
1655 const auto& vx = cellVertices_[ c ];
1656 out <<
"cell " << c <<
" : vertices = ";
1657 for(
size_t i=0; i<vx.size(); ++i )
1658 out << vx[ i ] <<
" ";
1665 UnstructuredGridPtr gridPtr_;
1666 const UnstructuredGridType& grid_;
1668 CommunicationType comm_;
1669 std::array< int, 3 > cartDims_;
1670 std::vector< std::vector< GeometryType > > geomTypes_;
1671 std::vector< std::vector< int > > cellVertices_;
1673 std::vector< GlobalCoordinate > unitOuterNormals_;
1679 size_t nBndSegments_;
1691 template<
int dim,
int dimworld,
typename coord_t >
1692 template<
int codim >
1693 struct PolyhedralGrid< dim, dimworld, coord_t >::Codim
1694 :
public Base::template Codim< codim >
1742 template< PartitionIteratorType pitype >
1746 ::template Partition< pitype >::LeafIterator
1749 ::template Partition< pitype >::LevelIterator
1776 #include <opm/grid/polyhedralgrid/persistentcontainer.hh> 1777 #include <opm/grid/polyhedralgrid/cartesianindexmapper.hh> 1778 #include <opm/grid/polyhedralgrid/gridhelpers.hh> 1780 #endif // #ifndef DUNE_POLYHEDRALGRID_GRID_HH int * cell_facetag
If non-null, this array contains a number for cell-face adjacency indicating the face's position with...
Definition: UnstructuredGrid.h:246
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: grid.hh:261
typename Traits::Communication Communication
communicator with all other processes having some part of the grid
Definition: grid.hh:311
void switchToDistributedView()
Switch to the distributed view.
Definition: grid.hh:699
int * global_cell
If non-null, this array contains the logical cartesian indices (in a lexicographic ordering) of each ...
Definition: UnstructuredGrid.h:216
void scatterData([[maybe_unused]] DataHandle &handle) const
Moves data from the global (all data on process) view to the distributed view.
Definition: grid.hh:884
Definition: intersection.hh:21
int size(int, int codim) const
obtain number of entites on a level
Definition: grid.hh:428
Traits::template Codim< codim >::Entity Entity
type of entity
Definition: grid.hh:1704
Definition: geometry.hh:22
Raw corner-point specification of a particular geological model.
Definition: preprocess.h:56
void compute_geometry(struct UnstructuredGrid *g)
Compute derived geometric primitives in a grid.
Definition: cornerpoint_grid.c:140
int ghostSize(int codim) const
obtain size of ghost region for the leaf grid
Definition: grid.hh:625
double * cell_volumes
Exact or approximate cell volumes.
Definition: UnstructuredGrid.h:199
bool adapt()
Definition: grid.hh:589
double * node_coordinates
Node coordinates, stored consecutively for each node.
Definition: UnstructuredGrid.h:162
double * face_centroids
Exact or approximate face centroids, stored consecutively for each face.
Definition: UnstructuredGrid.h:170
struct UnstructuredGrid * create_grid_cornerpoint(const struct grdecl *in, double tol, int edge_conformal)
Construct grid representation from corner-point specification of a particular geological model...
Definition: cornerpoint_grid.c:166
The namespace Dune is the main namespace for all Dune code.
Definition: CartesianIndexMapper.hpp:9
void update()
update grid caches
Definition: grid.hh:839
Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: grid.hh:785
int number_of_cells
The number of cells in the grid.
Definition: UnstructuredGrid.h:111
void communicate(DataHandle &, InterfaceType, CommunicationDirection) const
communicate information on leaf entities
Definition: grid.hh:685
Partition< pitype >::LevelGridView levelGridView(int) const
View for a grid level.
Definition: grid.hh:776
void destroy_grid(struct UnstructuredGrid *g)
Destroy and deallocate an UnstructuredGrid and all its data.
Definition: UnstructuredGrid.c:30
bool loadBalance(DofManager &)
rebalance the load each process has to handle
Definition: grid.hh:769
Definition: Intersection.hpp:329
bool preAdapt()
Definition: grid.hh:583
Main OPM-Core grid data structure along with helper functions for construction, destruction and readi...
int overlapSize(int, int) const
obtain size of overlap region for a grid level
Definition: grid.hh:635
GridFamily::Traits Traits
type of the grid traits
Definition: grid.hh:208
struct UnstructuredGrid * create_grid_cart2d(int nx, int ny, double dx, double dy)
Form geometrically Cartesian grid in two space dimensions with equally sized cells.
Definition: cart_grid.c:95
Partition< All_Partition >::LevelIterator LevelIterator
type of leaf iterator
Definition: grid.hh:1769
PolyhedralGrid(const std::vector< int > &n, const std::vector< double > &dx)
constructor
Definition: grid.hh:347
PolyhedralGrid(UnstructuredGridPtr &&gridPtr)
constructor
Definition: grid.hh:366
const CommunicationType & comm() const
obtain CollectiveCommunication object
Definition: grid.hh:712
Definition: iterator.hh:19
double * cell_centroids
Exact or approximate cell centroids, stored consecutively for each cell.
Definition: UnstructuredGrid.h:194
double * face_normals
Exact or approximate face normals, stored consecutively for each face.
Definition: UnstructuredGrid.h:186
Traits::LevelIndexSet LevelIndexSet
type of level index set
Definition: grid.hh:271
Traits::LeafIntersectionIterator LeafIntersectionIterator
iterator over intersections with other entities on the leaf level
Definition: grid.hh:227
int number_of_faces
The number of faces in the grid.
Definition: UnstructuredGrid.h:113
Types for GridView.
Definition: grid.hh:238
traits structure containing types for a codimension
Definition: grid.hh:217
Traits::LevelIntersectionIterator LevelIntersectionIterator
iterator over intersections with other entities on the same level
Definition: grid.hh:229
void communicate(DataHandle &, InterfaceType, CommunicationDirection, int) const
communicate information on a grid level
Definition: grid.hh:664
struct UnstructuredGrid * create_grid_hexa3d(int nx, int ny, int nz, double dx, double dy, double dz)
Form geometrically Cartesian grid in three space dimensions with equally sized cells.
Definition: cart_grid.c:59
bool adapt(DataHandle &)
Definition: grid.hh:599
grid_size_t * cell_facepos
For a cell c, cell_facepos[c] contains the starting index for c's faces in the cell_faces array...
Definition: UnstructuredGrid.h:154
Definition: entityseed.hh:15
void postAdapt()
Definition: grid.hh:605
int size(int, GeometryType type) const
obtain number of entites on a level
Definition: grid.hh:468
Traits::template Codim< codim >::EntityPointer EntityPointer
type of entity pointer
Definition: grid.hh:1710
Routines to construct fully formed grid structures from a simple Cartesian (i.e., tensor product) des...
Definition: intersectioniterator.hh:15
int size(int codim) const
obtain number of leaf entities
Definition: grid.hh:439
int ghostSize(int, int codim) const
obtain size of ghost region for a grid level
Definition: grid.hh:645
identical grid wrapper
Definition: declaration.hh:10
Traits::HierarchicIterator HierarchicIterator
iterator over the grid hierarchy
Definition: grid.hh:225
Traits::template Codim< codim >::LocalGeometry LocalGeometry
type of local geometry
Definition: grid.hh:1735
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: grid.hh:820
int * face_cells
For a face f, face_cells[2*f] and face_cells[2*f + 1] contain the cell indices of the cells adjacent ...
Definition: UnstructuredGrid.h:140
bool loadBalance()
rebalance the load each process has to handle
Definition: grid.hh:728
int * cell_faces
Contains for each cell, the indices of its adjacent faces.
Definition: UnstructuredGrid.h:148
Partition< All_Partition >::LevelGridView LevelGridView
View types for All_Partition.
Definition: grid.hh:245
size_t numBoundarySegments() const
obtain number of leaf entities
Definition: grid.hh:488
Traits::template Codim< codim >::Geometry Geometry
type of world geometry
Definition: grid.hh:1725
Traits::template Codim< EntitySeed::codimension >::EntityPointer entityPointer(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: grid.hh:809
LevelGridView levelGridView(int) const
View for a grid level for All_Partition.
Definition: grid.hh:793
Definition: indexset.hh:23
double * face_areas
Exact or approximate face areas.
Definition: UnstructuredGrid.h:175
Partition< All_Partition >::LeafIterator LeafIterator
type of level iterator
Definition: grid.hh:1760
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: grid.hh:283
int dims[3]
Cartesian box dimensions.
Definition: preprocess.h:57
Definition: entity.hh:151
struct UnstructuredGrid * allocate_grid(size_t ndims, size_t ncells, size_t nfaces, size_t nfacenodes, size_t ncellfaces, size_t nnodes)
Allocate and initialise an UnstructuredGrid where pointers are set to location with correct size...
Definition: UnstructuredGrid.c:85
Low-level corner-point processing routines and supporting data structures.
int maxLevel() const
obtain maximal grid level
Definition: grid.hh:415
Definition: geometry.hh:23
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: grid.hh:300
int size(GeometryType type) const
returns the number of boundary segments within the macro grid
Definition: grid.hh:477
int * face_nodes
Contains for each face, the indices of its adjacent nodes.
Definition: UnstructuredGrid.h:123
Routines to form a complete UnstructuredGrid from a corner-point specification.
Traits::ctype ctype
type of vector coordinates (e.g., double)
Definition: grid.hh:308
Data structure for an unstructured grid, unstructured meaning that any cell may have an arbitrary num...
Definition: UnstructuredGrid.h:100
PolyhedralGrid(const UnstructuredGridType &grid)
constructor
Definition: grid.hh:385
int number_of_nodes
The number of nodes in the grid.
Definition: UnstructuredGrid.h:115
Transform a corner-point grid ZCORN field to account for MINPV processing.
Definition: MinpvProcessor.hpp:34
grid_size_t * face_nodepos
For a face f, face_nodepos[f] contains the starting index for f's nodes in the face_nodes array...
Definition: UnstructuredGrid.h:129
void switchToGlobalView()
Switch to the global view.
Definition: grid.hh:693
int overlapSize(int) const
obtain size of overlap region for the leaf grid
Definition: grid.hh:616
bool loadBalance(CommDataHandleIF< DataHandle, Data > &)
rebalance the load each process has to handle
Definition: grid.hh:749
int cartdims[3]
Contains the size of the logical cartesian structure (if any) of the grid.
Definition: UnstructuredGrid.h:229
LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: grid.hh:800