My Project
CpGrid.hpp
1 //===========================================================================
2 //
3 // File: CpGrid.hpp
4 //
5 // Created: Fri May 29 20:26:36 2009
6 //
7 // Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
8 // B�rd Skaflestad <bard.skaflestad@sintef.no>
9 //
10 // $Date$
11 //
12 // $Revision$
13 //
14 //===========================================================================
15 
16 /*
17  Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
18  Copyright 2009, 2010, 2014 Statoil ASA.
19  Copyright 2014, 2015 Dr. Blatt - HPC-Simulartion-Software & Services
20  Copyright 2015 NTNU
21 
22  This file is part of The Open Porous Media project (OPM).
23 
24  OPM is free software: you can redistribute it and/or modify
25  it under the terms of the GNU General Public License as published by
26  the Free Software Foundation, either version 3 of the License, or
27  (at your option) any later version.
28 
29  OPM is distributed in the hope that it will be useful,
30  but WITHOUT ANY WARRANTY; without even the implied warranty of
31  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32  GNU General Public License for more details.
33 
34  You should have received a copy of the GNU General Public License
35  along with OPM. If not, see <http://www.gnu.org/licenses/>.
36 */
37 
38 #ifndef OPM_CPGRID_HEADER
39 #define OPM_CPGRID_HEADER
40 
41 #include <string>
42 #include <map>
43 #include <array>
44 #include <unordered_set>
45 #include <opm/grid/utility/ErrorMacros.hpp>
46 
47 // Warning suppression for Dune includes.
48 #include <opm/grid/utility/platform_dependent/disable_warnings.h>
49 
50 #include <dune/common/version.hh>
51 
52 #if HAVE_MPI
53 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 7)
54 #include <dune/common/parallel/variablesizecommunicator.hh>
55 #else
56 #include <opm/grid/utility/VariableSizeCommunicator.hpp>
57 #endif
58 #endif
59 
60 #include <dune/grid/common/capabilities.hh>
61 #include <dune/grid/common/grid.hh>
62 #include <dune/grid/common/gridenums.hh>
63 
64 #include <opm/grid/utility/platform_dependent/reenable_warnings.h>
65 
66 #include "cpgrid/Intersection.hpp"
67 #include "cpgrid/Entity.hpp"
68 #include "cpgrid/Geometry.hpp"
69 #include "cpgrid/Iterators.hpp"
70 #include "cpgrid/Indexsets.hpp"
71 #include "cpgrid/DefaultGeometryPolicy.hpp"
72 #include "common/GridEnums.hpp"
73 #include "common/Volumes.hpp"
75 
76 #include <opm/grid/utility/OpmParserIncludes.hpp>
77 
78 #include <iostream>
79 #if ! HAVE_MPI
80 #include <list>
81 #endif
82 
83 namespace Dune
84 {
85 
86  class CpGrid;
87 
88  namespace cpgrid
89  {
90  class CpGridData;
91  }
92 
94  //
95  // CpGridTraits
96  //
98 
99  struct CpGridTraits
100  {
102  typedef CpGrid Grid;
103 
112 
115 
118  template <int cd>
119  struct Codim
120  {
123  typedef cpgrid::Geometry<3-cd, 3> Geometry;
124  //typedef Dune::Geometry<3-cd, 3, CpGrid, cpgrid::Geometry> Geometry;
126  typedef cpgrid::Geometry<3-cd, 3> LocalGeometry;
127  //typedef Dune::Geometry<3-cd, 3, CpGrid, cpgrid::Geometry> LocalGeometry;
130 
133 
136 
139 
142 
145  template <PartitionIteratorType pitype>
146  struct Partition
147  {
152  };
153  };
154 
157  template <PartitionIteratorType pitype>
158  struct Partition
159  {
161  typedef Dune::GridView<DefaultLevelGridViewTraits<CpGrid> > LevelGridView;
163  typedef Dune::GridView<DefaultLeafGridViewTraits<CpGrid> > LeafGridView;
164 
165  };
166 
168  typedef Dune::GridView<DefaultLevelGridViewTraits<CpGrid> > LevelGridView;
170  typedef Dune::GridView<DefaultLeafGridViewTraits<CpGrid> > LeafGridView;
171 
180 
182 
183  typedef Dune::MPIHelper::MPICommunicator MPICommunicator;
184  typedef Dune::CollectiveCommunication<MPICommunicator> CollectiveCommunication;
185  };
186 
188  //
189  // CpGridFamily
190  //
192 
194  {
195  typedef CpGridTraits Traits;
196  };
197 
199  //
200  // CpGrid
201  //
203 
205  class CpGrid
206  : public GridDefaultImplementation<3, 3, double, CpGridFamily >
207  {
208  friend class cpgrid::CpGridData;
209  template<int dim>
210  friend cpgrid::Entity<dim> createEntity(const CpGrid&,int,bool);
211 
212  public:
213 
214  // --- Typedefs ---
215 
216 
219 
220 
221  // --- Methods ---
222 
223 
225  CpGrid();
226 
227  CpGrid(MPIHelper::MPICommunicator comm);
228 
230 
231  void readSintefLegacyFormat(const std::string& grid_prefix);
235 
236 
240  void writeSintefLegacyFormat(const std::string& grid_prefix) const;
241 
242 
243 #if HAVE_ECL_INPUT
262  std::vector<std::size_t> processEclipseFormat(const Opm::EclipseGrid* ecl_grid,
263  Opm::EclipseState* ecl_state,
264  bool periodic_extension, bool turn_normals, bool clip_z,
265  bool pinchActive);
266 
286  std::vector<std::size_t> processEclipseFormat(const Opm::EclipseGrid* ecl_grid,
287  Opm::EclipseState* ecl_state,
288  bool periodic_extension, bool turn_normals = false, bool clip_z = false);
289 
290 #endif
291 
295  void processEclipseFormat(const grdecl& input_data, bool remove_ij_boundary, bool turn_normals = false);
296 
298 
304 
305  void createCartesian(const std::array<int, 3>& dims,
309  const std::array<double, 3>& cellsize);
310 
314  const std::array<int, 3>& logicalCartesianSize() const
315  {
316  return current_view_data_->logical_cartesian_size_;
317  }
318 
326  const std::vector<int>& globalCell() const
327  {
328  return current_view_data_->global_cell_;
329  }
330 
338  void getIJK(const int c, std::array<int,3>& ijk) const
339  {
340  current_view_data_->getIJK(c, ijk);
341  }
343 
347  bool uniqueBoundaryIds() const
348  {
349  return current_view_data_->uniqueBoundaryIds();
350  }
351 
354  void setUniqueBoundaryIds(bool uids)
355  {
356  current_view_data_->setUniqueBoundaryIds(uids);
357  }
358 
359  // --- Dune interface below ---
360 
362  // \@{
367  std::string name() const
368  {
369  return "CpGrid";
370  }
371 
372 
375  int maxLevel() const
376  {
377  return 0;
378  }
379 
380 
382  template<int codim>
383  typename Traits::template Codim<codim>::LevelIterator lbegin (int level) const
384  {
385  if (level<0 || level>maxLevel())
386  DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
387  return cpgrid::Iterator<codim, All_Partition>(*current_view_data_, 0, true);
388  }
389 
390 
392  template<int codim>
393  typename Traits::template Codim<codim>::LevelIterator lend (int level) const
394  {
395  if (level<0 || level>maxLevel())
396  DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
397  return cpgrid::Iterator<codim,All_Partition>(*current_view_data_, size(codim), true );
398 
399  }
400 
401 
403  template<int codim, PartitionIteratorType PiType>
404  typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lbegin (int level) const
405  {
406  if (level<0 || level>maxLevel())
407  DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
408  return cpgrid::Iterator<codim,PiType>(*current_view_data_, 0, true );
409  }
410 
411 
413  template<int codim, PartitionIteratorType PiType>
414  typename Traits::template Codim<codim>::template Partition<PiType>::LevelIterator lend (int level) const
415  {
416  if (level<0 || level>maxLevel())
417  DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
418  return cpgrid::Iterator<codim,PiType>(*current_view_data_, size(codim), true);
419  }
420 
421 
423  template<int codim>
424  typename Traits::template Codim<codim>::LeafIterator leafbegin() const
425  {
426  return cpgrid::Iterator<codim, All_Partition>(*current_view_data_, 0, true);
427  }
428 
429 
431  template<int codim>
432  typename Traits::template Codim<codim>::LeafIterator leafend() const
433  {
434  return cpgrid::Iterator<codim, All_Partition>(*current_view_data_, size(codim), true);
435  }
436 
437 
439  template<int codim, PartitionIteratorType PiType>
440  typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafbegin() const
441  {
442  return cpgrid::Iterator<codim, PiType>(*current_view_data_, 0, true);
443  }
444 
445 
447  template<int codim, PartitionIteratorType PiType>
448  typename Traits::template Codim<codim>::template Partition<PiType>::LeafIterator leafend() const
449  {
450  return cpgrid::Iterator<codim, PiType>(*current_view_data_, size(codim), true);
451  }
452 
453 
455  int size (int level, int codim) const
456  {
457  if (level<0 || level>maxLevel())
458  DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
459  return size(codim);
460  }
461 
462 
464  int size (int codim) const
465  {
466  return current_view_data_->size(codim);
467  }
468 
469 
471  int size (int level, GeometryType type) const
472  {
473  if (level<0 || level>maxLevel())
474  DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
475  return size(type);
476  }
477 
478 
480  int size (GeometryType type) const
481  {
482  return current_view_data_->size(type);
483  }
484 
485 
487  const Traits::GlobalIdSet& globalIdSet() const
488  {
489  return global_id_set_;
490  }
491 
492 
494  const Traits::LocalIdSet& localIdSet() const
495  {
496  return global_id_set_;
497  }
498 
499 
501  const Traits::LevelIndexSet& levelIndexSet(int level) const
502  {
503  if (level<0 || level>maxLevel())
504  DUNE_THROW(GridError, "levelIndexSet of nonexisting level " << level << " requested!");
505  return *current_view_data_->index_set_;
506  }
507 
508 
510  const Traits::LeafIndexSet& leafIndexSet() const
511  {
512  return *current_view_data_->index_set_;
513  }
514 
515 
517  void globalRefine (int)
518  {
519  std::cout << "Warning: Global refinement not implemented, yet." << std::endl;
520  }
521 
522  const std::vector< Dune :: GeometryType >& geomTypes( const int codim ) const
523  {
524  return leafIndexSet().geomTypes( codim );
525  }
526 
528  template <int codim>
530  {
531  return cpgrid::Entity<codim>( *seed );
532  }
533 
534  /* No refinement implemented. GridDefaultImplementation's methods will be used.
535 
545 
546  bool mark(int refCount, const typename Traits::template Codim<0>::EntityPointer & e)
547  {
548  return hostgrid_->mark(refCount, getHostEntity<0>(*e));
549  }
550 
554 
555  int getMark(const typename Traits::template Codim<0>::EntityPointer & e) const
556  {
557  return hostgrid_->getMark(getHostEntity<0>(*e));
558  }
559 
561  bool preAdapt() {
562  return hostgrid_->preAdapt();
563  }
564 
565 
567  bool adapt()
568  {
569  return hostgrid_->adapt();
570  }
571 
573  void postAdapt() {
574  return hostgrid_->postAdapt();
575  }
576 
577  end of refinement section */
578 
580  unsigned int overlapSize(int) const {
581  return 1;
582  }
583 
584 
586  unsigned int ghostSize(int) const {
587  return 0;
588  }
589 
590 
592  unsigned int overlapSize(int, int) const {
593  return 1;
594  }
595 
596 
598  unsigned int ghostSize(int, int) const {
599  return 0;
600  }
601 
603  unsigned int numBoundarySegments() const
604  {
605  if( uniqueBoundaryIds() )
606  {
607  return current_view_data_->unique_boundary_ids_.size();
608  }
609  else
610  {
611  unsigned int numBndSegs = 0;
612  const int num_faces = numFaces();
613  for (int i = 0; i < num_faces; ++i) {
614  cpgrid::EntityRep<1> face(i, true);
615  if (current_view_data_->face_to_cell_[face].size() == 1) {
616  ++numBndSegs;
617  }
618  }
619  return numBndSegs;
620  }
621  }
622 
623 
624  // loadbalance is not part of the grid interface therefore we skip it.
625 
631  bool loadBalance(int overlapLayers=1, bool useZoltan=true)
632  {
633  using std::get;
634  return get<0>(scatterGrid(defaultTransEdgeWgt, false, nullptr, false, nullptr, true, overlapLayers, useZoltan ));
635  }
636 
637  // loadbalance is not part of the grid interface therefore we skip it.
638 
658  std::pair<bool, std::vector<std::pair<std::string,bool> > >
659  loadBalance(const std::vector<cpgrid::OpmWellType> * wells,
660  const double* transmissibilities = nullptr,
661  int overlapLayers=1, bool useZoltan=true)
662  {
663  return scatterGrid(defaultTransEdgeWgt, false, wells, false, transmissibilities, false, overlapLayers, useZoltan);
664  }
665 
666  // loadbalance is not part of the grid interface therefore we skip it.
667 
691  std::pair<bool, std::vector<std::pair<std::string,bool> > >
692  loadBalance(EdgeWeightMethod method, const std::vector<cpgrid::OpmWellType> * wells,
693  const double* transmissibilities = nullptr, bool ownersFirst=false,
694  bool addCornerCells=false, int overlapLayers=1,
695  bool useZoltan = true)
696  {
697  return scatterGrid(method, ownersFirst, wells, false, transmissibilities, addCornerCells, overlapLayers, useZoltan);
698  }
699 
719  template<class DataHandle>
720  std::pair<bool, std::vector<std::pair<std::string,bool> > >
721  loadBalance(DataHandle& data,
722  const std::vector<cpgrid::OpmWellType> * wells,
723  const double* transmissibilities = nullptr,
724  int overlapLayers=1, bool useZoltan = true)
725  {
726  auto ret = loadBalance(wells, transmissibilities, overlapLayers, useZoltan);
727  using std::get;
728  if (get<0>(ret))
729  {
730  scatterData(data);
731  }
732  return ret;
733  }
734 
763  template<class DataHandle>
764  std::pair<bool, std::vector<std::pair<std::string,bool> > >
765  loadBalance(DataHandle& data, EdgeWeightMethod method,
766  const std::vector<cpgrid::OpmWellType> * wells,
767  bool serialPartitioning,
768  const double* transmissibilities = nullptr, bool ownersFirst=false,
769  bool addCornerCells=false, int overlapLayers=1, bool useZoltan = true,
770  double zoltanImbalanceTol = 1.1,
771  bool allowDistributedWells = false)
772  {
773  auto ret = scatterGrid(method, ownersFirst, wells, serialPartitioning, transmissibilities,
774  addCornerCells, overlapLayers, useZoltan, zoltanImbalanceTol, allowDistributedWells);
775  using std::get;
776  if (get<0>(ret))
777  {
778  scatterData(data);
779  }
780  return ret;
781  }
782 
799  template<class DataHandle>
800  std::pair<bool, std::vector<std::pair<std::string,bool> > >
801  loadBalance(DataHandle& data, const std::vector<int>& parts,
802  const std::vector<cpgrid::OpmWellType> * wells,
803  bool ownersFirst=false,
804  bool addCornerCells=false, int overlapLayers=1)
805  {
806  using std::get;
807  auto ret = scatterGrid(defaultTransEdgeWgt, ownersFirst, wells,
808  /* serialPartitioning = */ false,
809  /* transmissibilities = */ {},
810  addCornerCells, overlapLayers, /* useZoltan =*/ false,
811  /* zoltanImbalanceTol (ignored) = */ 0.0,
812  /* allowDistributedWells = */ true, parts);
813  using std::get;
814  if (get<0>(ret))
815  {
816  scatterData(data);
817  }
818  return ret;
819  }
828  template<class DataHandle>
829  bool loadBalance(DataHandle& data,
830 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2, 7)
831  decltype(data.fixedSize(0,0)) overlapLayers=1, bool useZoltan = true)
832 #else
833  decltype(data.fixedsize(0,0)) overlapLayers=1, bool useZoltan = true)
834 #endif
835  {
836  // decltype usage needed to tell the compiler not to use this function if first
837  // argument is std::vector but rather loadbalance by parts
838  bool ret = loadBalance(overlapLayers, useZoltan);
839  if (ret)
840  {
841  scatterData(data);
842  }
843  return ret;
844  }
845 
857  bool loadBalance(const std::vector<int>& parts, bool ownersFirst=false,
858  bool addCornerCells=false, int overlapLayers=1)
859  {
860  using std::get;
861  return get<0>(scatterGrid(defaultTransEdgeWgt, ownersFirst, /* wells = */ {},
862  /* serialPartitioning = */ false,
863  /* trabsmissibilities = */ {},
864  addCornerCells, overlapLayers, /* useZoltan =*/ false,
865  /* zoltanImbalanceTol (ignored) = */ 0.0,
866  /* allowDistributedWells = */ true, parts));
867  }
868 
881  template<class DataHandle>
882  bool loadBalance(DataHandle& data, const std::vector<int>& parts, bool ownersFirst=false,
883  bool addCornerCells=false, int overlapLayers=1)
884  {
885  bool ret = loadBalance(parts, ownersFirst, addCornerCells, overlapLayers);
886  if (ret)
887  {
888  scatterData(data);
889  }
890  return ret;
891  }
892 
898  std::vector<int> zoltanPartitionWithoutScatter(const std::vector<cpgrid::OpmWellType> * wells,
899  const double* transmissibilities, int numParts,
900  const double zoltanImbalanceTol);
901 
909  template<class DataHandle>
910  void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int /*level*/) const
911  {
912  communicate(data, iftype, dir);
913  }
914 
922  template<class DataHandle>
923  void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
924  {
925  current_view_data_->communicate(data, iftype, dir);
926  }
927 
929  const CollectiveCommunication& comm () const
930  {
931  return current_view_data_->ccobj_;
932  }
934 
935  // ------------ End of Dune interface, start of simplified interface --------------
936 
942 
943  // enum { dimension = 3 }; // already defined
944 
945  typedef Dune::FieldVector<double, 3> Vector;
946 
947 
948  const std::vector<double>& zcornData() const {
949  return current_view_data_->zcornData();
950  }
951 
952 
953  // Topology
955  int numCells() const
956  {
957  return current_view_data_->cell_to_face_.size();
958  }
960  int numFaces() const
961  {
962  return current_view_data_->face_to_cell_.size();
963  }
965  int numVertices() const
966  {
967  return current_view_data_->geomVector<3>().size();
968  }
975  int numCellFaces(int cell) const
976  {
977  return current_view_data_->cell_to_face_[cpgrid::EntityRep<0>(cell, true)].size();
978  }
983  int cellFace(int cell, int local_index) const
984  {
985  return current_view_data_->cell_to_face_[cpgrid::EntityRep<0>(cell, true)][local_index].index();
986  }
987 
991  {
992  return current_view_data_->cell_to_face_[cpgrid::EntityRep<0>(cell, true)];
993  }
1004  int faceCell(int face, int local_index) const
1005  {
1006  // In the parallel case we store non-existent cells for faces along
1007  // the front region. Theses marked with index std::numeric_limits<int>::max(),
1008  // orientation might be arbitrary, though.
1010  = current_view_data_->face_to_cell_[cpgrid::EntityRep<1>(face, true)];
1011  bool a = (local_index == 0);
1012  bool b = r[0].orientation();
1013  bool use_first = a ? b : !b;
1014  // The number of valid cells.
1015  int r_size = r.size();
1016  // In the case of only one valid cell, this is the index of it.
1017  int index = 0;
1018  if(r[0].index()==std::numeric_limits<int>::max()){
1019  assert(r_size==2);
1020  --r_size;
1021  index=1;
1022  }
1023  if(r.size()>1 && r[1].index()==std::numeric_limits<int>::max())
1024  {
1025  assert(r_size==2);
1026  --r_size;
1027  }
1028  if (r_size == 2) {
1029  return use_first ? r[0].index() : r[1].index();
1030  } else {
1031  return use_first ? r[index].index() : -1;
1032  }
1033  }
1040  int numCellFaces() const
1041  {
1042  return current_view_data_->cell_to_face_.dataSize();
1043  }
1044  int numFaceVertices(int face) const
1045  {
1046  return current_view_data_->face_to_point_[face].size();
1047  }
1052  int faceVertex(int face, int local_index) const
1053  {
1054  return current_view_data_->face_to_point_[face][local_index];
1055  }
1058  double cellCenterDepth(int cell_index) const
1059  {
1060  // Here cell center depth is computed as a raw average of cell corner depths.
1061  // This generally gives slightly different results than using the cell centroid.
1062  double zz = 0.0;
1063  const int nv = current_view_data_->cell_to_point_[cell_index].size();
1064  const int nd = 3;
1065  for (int i=0; i<nv; ++i) {
1066  zz += vertexPosition(current_view_data_->cell_to_point_[cell_index][i])[nd-1];
1067  }
1068  return zz/nv;
1069  }
1070 
1071  const Vector faceCenterEcl(int cell_index, int face) const
1072  {
1073  // This method is an alternative to the method faceCentroid(...).
1074  // The face center is computed as a raw average of cell corners.
1075  // For faulted cells this gives different results then average of face nodes
1076  // that seems to agree more with eclipse.
1077  // This assumes the cell nodes are ordered
1078  // 6---7
1079  // | T |
1080  // 4---5
1081  // 2---3
1082  // | B |
1083  // 0---1
1084 
1085  // this follows the DUNE reference cube
1086  static const int faceVxMap[ 6 ][ 4 ] = { {0, 2, 4, 6}, // face 0
1087  {1, 3, 5, 7}, // face 1
1088  {0, 1, 4, 5}, // face 2
1089  {2, 3, 6, 7}, // face 3
1090  {0, 1, 2, 3}, // face 4
1091  {4, 5, 6, 7} // face 5
1092  };
1093 
1094 
1095  assert (current_view_data_->cell_to_point_[cell_index].size() == 8);
1096  Vector center(0.0);
1097  for( int i=0; i<4; ++i )
1098  {
1099  center += vertexPosition(current_view_data_->cell_to_point_[cell_index][ faceVxMap[ face ][ i ] ]);
1100  }
1101 
1102  for (int i=0; i<3; ++i) {
1103  center[i] /= 4;
1104  }
1105  return center;
1106 
1107  }
1108 
1109  const Vector faceAreaNormalEcl(int face) const
1110  {
1111  // same implementation as ResInsight
1112  const int nd = Vector::dimension;
1113  const int nv = numFaceVertices(face);
1114  switch (nv)
1115  {
1116  case 0:
1117  case 1:
1118  case 2:
1119  {
1120  return Vector(0.0);
1121  }
1122  break;
1123  case 3:
1124  {
1125  Vector a = vertexPosition(current_view_data_->face_to_point_[face][0]) - vertexPosition(current_view_data_->face_to_point_[face][2]);
1126  Vector b = vertexPosition(current_view_data_->face_to_point_[face][1]) - vertexPosition(current_view_data_->face_to_point_[face][2]);
1127  Vector areaNormal = cross(a,b);
1128  for (int i=0; i<nd; ++i) {
1129  areaNormal[i] /= 2;
1130  }
1131  return areaNormal;
1132  }
1133  break;
1134  case 4:
1135  {
1136  Vector a = vertexPosition(current_view_data_->face_to_point_[face][0]) - vertexPosition(current_view_data_->face_to_point_[face][2]);
1137  Vector b = vertexPosition(current_view_data_->face_to_point_[face][1]) - vertexPosition(current_view_data_->face_to_point_[face][3]);
1138  Vector areaNormal = cross(a,b);
1139  areaNormal *= 0.5;
1140  return areaNormal;
1141  }
1142  break;
1143  default:
1144  {
1145  int h = (nv - 1)/2;
1146  int k = (nv % 2) ? 0 : nv - 1;
1147 
1148  Vector areaNormal(0.0);
1149  // First quads
1150  for (int i = 1; i < h; ++i)
1151  {
1152  Vector a = vertexPosition(current_view_data_->face_to_point_[face][2*i]) - vertexPosition(current_view_data_->face_to_point_[face][0]);
1153  Vector b = vertexPosition(current_view_data_->face_to_point_[face][2*i+1]) - vertexPosition(current_view_data_->face_to_point_[face][2*i-1]);
1154  areaNormal += cross(a,b);
1155  }
1156 
1157  // Last triangle or quad
1158  Vector a = vertexPosition(current_view_data_->face_to_point_[face][2*h]) - vertexPosition(current_view_data_->face_to_point_[face][0]);
1159  Vector b = vertexPosition(current_view_data_->face_to_point_[face][k]) - vertexPosition(current_view_data_->face_to_point_[face][2*h-1]);
1160  areaNormal += cross(a,b);
1161 
1162  areaNormal *= 0.5;
1163 
1164  return areaNormal;
1165  }
1166 
1167  }
1168  }
1169 
1170  // Geometry
1174  const Vector& vertexPosition(int vertex) const
1175  {
1176  return current_view_data_->geomVector<3>()[cpgrid::EntityRep<3>(vertex, true)].center();
1177  }
1180  double faceArea(int face) const
1181  {
1182  return current_view_data_->geomVector<1>()[cpgrid::EntityRep<1>(face, true)].volume();
1183  }
1186  const Vector& faceCentroid(int face) const
1187  {
1188  return current_view_data_->geomVector<1>()[cpgrid::EntityRep<1>(face, true)].center();
1189  }
1193  const Vector& faceNormal(int face) const
1194  {
1195  return current_view_data_->face_normals_.get(face);
1196  }
1199  double cellVolume(int cell) const
1200  {
1201  return current_view_data_->geomVector<0>()[cpgrid::EntityRep<0>(cell, true)].volume();
1202  }
1205  const Vector& cellCentroid(int cell) const
1206  {
1207  return current_view_data_->geomVector<0>()[cpgrid::EntityRep<0>(cell, true)].center();
1208  }
1209 
1212  template<int codim>
1214  : public RandomAccessIteratorFacade<CentroidIterator<codim>,
1215  FieldVector<double, 3>,
1216  const FieldVector<double, 3>&, int>
1217  {
1218  public:
1220  typedef typename std::vector<cpgrid::Geometry<3-codim, 3> >::const_iterator
1225  : iter_(iter)
1226  {}
1227 
1228  const FieldVector<double, 3>& dereference() const
1229  {
1230  return iter_->center();
1231  }
1232  void increment()
1233  {
1234  ++iter_;
1235  }
1236  const FieldVector<double, 3>& elementAt(int n)
1237  {
1238  return iter_[n]->center();
1239  }
1240  void advance(int n)
1241  {
1242  iter_+=n;
1243  }
1244  void decrement()
1245  {
1246  --iter_;
1247  }
1248  int distanceTo(const CentroidIterator& o)
1249  {
1250  return o-iter_;
1251  }
1252  bool equals(const CentroidIterator& o) const
1253  {
1254  return o==iter_;
1255  }
1256  private:
1258  GeometryIterator iter_;
1259  };
1260 
1263  {
1264  return CentroidIterator<0>(current_view_data_->geomVector<0>().begin());
1265  }
1266 
1269  {
1270  return CentroidIterator<1>(current_view_data_->geomVector<1>().begin());
1271  }
1272 
1273  // Extra
1274  int boundaryId(int face) const
1275  {
1276  // Note that this relies on the following implementation detail:
1277  // The grid is always construct such that the faces where
1278  // orientation() returns true are oriented along the positive IJK
1279  // direction. Oriented means that the first cell attached to face
1280  // has the lower index.
1281  int ret = 0;
1282  cpgrid::EntityRep<1> f(face, true);
1283  if (current_view_data_->face_to_cell_[f].size() == 1) {
1284  if (current_view_data_->uniqueBoundaryIds()) {
1285  // Use the unique boundary ids.
1286  ret = current_view_data_->unique_boundary_ids_[f];
1287  } else {
1288  // Use the face tag based ids, i.e. 1-6 for i-, i+, j-, j+, k-, k+.
1289  const bool normal_is_in =
1290  !(current_view_data_->face_to_cell_[f][0].orientation());
1291  enum face_tag tag = current_view_data_->face_tag_[f];
1292  switch (tag) {
1293  case I_FACE:
1294  // LEFT : RIGHT
1295  ret = normal_is_in ? 1 : 2; // min(I) : max(I)
1296  break;
1297  case J_FACE:
1298  // BACK : FRONT
1299  ret = normal_is_in ? 3 : 4; // min(J) : max(J)
1300  break;
1301  case K_FACE:
1302  // Note: TOP at min(K) as 'z' measures *depth*.
1303  // TOP : BOTTOM
1304  ret = normal_is_in ? 5 : 6; // min(K) : max(K)
1305  break;
1306  case NNC_FACE:
1307  // This should not be possible, as NNC "faces" always
1308  // have two cell neighbours.
1309  OPM_THROW(std::logic_error, "NNC face at boundary. This should never happen!");
1310  }
1311  }
1312  }
1313  return ret;
1314  }
1315 
1322  template<class Cell2FacesRowIterator>
1323  int
1324  faceTag(const Cell2FacesRowIterator& cell_face) const
1325  {
1326  // Note that this relies on the following implementation detail:
1327  // The grid is always constructed such that the interior faces constructed
1328  // with orientation set to true are
1329  // oriented along the positive IJK direction. Oriented means that
1330  // the first cell attached to face has the lower index.
1331  // For faces along the boundary (only one cell, always attached at index 0)
1332  // the orientation has to be determined by the orientation of the cell.
1333  // If it is true then in UnstructuredGrid it would be stored at index 0,
1334  // otherwise at index 1.
1335  const int cell = cell_face.getCellIndex();
1336  const int face = *cell_face;
1337  assert (0 <= cell); assert (cell < numCells());
1338  assert (0 <= face); assert (face < numFaces());
1339 
1341 
1342  const cpgrid::EntityRep<1> f(face, true);
1343  const F2C& f2c = current_view_data_->face_to_cell_[f];
1344  const face_tag tag = current_view_data_->face_tag_[f];
1345 
1346  assert ((f2c.size() == 1) || (f2c.size() == 2));
1347 
1348  int inside_cell = 0;
1349 
1350  if ( f2c.size() == 2 ) // Two cells => interior
1351  {
1352  if ( f2c[1].index() == cell )
1353  {
1354  inside_cell = 1;
1355  }
1356  }
1357  const bool normal_is_in = ! f2c[inside_cell].orientation();
1358 
1359  switch (tag) {
1360  case I_FACE:
1361  // LEFT : RIGHT
1362  return normal_is_in ? 0 : 1; // min(I) : max(I)
1363  case J_FACE:
1364  // BACK : FRONT
1365  return normal_is_in ? 2 : 3; // min(J) : max(J)
1366  case K_FACE:
1367  // Note: TOP at min(K) as 'z' measures *depth*.
1368  // TOP : BOTTOM
1369  return normal_is_in ? 4 : 5; // min(K) : max(K)
1370  case NNC_FACE:
1371  // For nnc faces we return the otherwise unused value -1.
1372  return -1;
1373  default:
1374  OPM_THROW(std::logic_error, "Unhandled face tag. This should never happen!");
1375  }
1376  }
1377 
1379 
1380  // ------------ End of simplified interface --------------
1381 
1382  //------------- methods not in the DUNE grid interface.
1383 
1388 
1389  template<class DataHandle>
1399  void scatterData(DataHandle& handle) const
1400  {
1401 #if HAVE_MPI
1402  if(distributed_data_.empty())
1403  OPM_THROW(std::runtime_error, "Moving Data only allowed with a load balanced grid!");
1404  distributed_data_[0]->scatterData(handle, data_[0].get(), distributed_data_[0].get(), cellScatterGatherInterface(),
1406 #else
1407  // Suppress warnings for unused argument.
1408  (void) handle;
1409 #endif
1410  }
1411 
1418  template<class DataHandle>
1419  void gatherData(DataHandle& handle) const
1420  {
1421 #if HAVE_MPI
1422  if(distributed_data_.empty())
1423  OPM_THROW(std::runtime_error, "Moving Data only allowed with a load balance grid!");
1424  distributed_data_[0]->gatherData(handle, data_[0].get(), distributed_data_[0].get());
1425 #else
1426  // Suppress warnings for unused argument.
1427  (void) handle;
1428 #endif
1429  }
1430 #if HAVE_MPI
1431 #if DUNE_VERSION_NEWER(DUNE_GRID, 2, 7)
1433  using InterfaceMap = VariableSizeCommunicator<>::InterfaceMap;
1434 #else
1436  using InterfaceMap = Opm::VariableSizeCommunicator<>::InterfaceMap;
1437 #endif
1438 #else
1439  // bogus definition for the non parallel type. VariableSizeCommunicator not
1440  // availabe
1441 
1443  typedef std::map<int, std::list<int> > InterfaceMap;
1444 #endif
1445 
1475  {
1476  return *cell_scatter_gather_interfaces_;
1477  }
1478 
1482  {
1483  return *point_scatter_gather_interfaces_;
1484  }
1485 
1488  {
1489  current_view_data_=data_[0].get();
1490  }
1491 
1494  {
1495  if (distributed_data_.empty())
1496  OPM_THROW(std::logic_error, "No distributed view available in grid");
1497  current_view_data_=distributed_data_[0].get();
1498  }
1500 
1501 #if HAVE_MPI
1503  typedef cpgrid::CpGridData::ParallelIndexSet ParallelIndexSet;
1505  typedef cpgrid::CpGridData::RemoteIndices RemoteIndices;
1506 
1508  using CommunicationType = cpgrid::CpGridData::CommunicationType;
1509 
1513  const CommunicationType& cellCommunication() const
1514  {
1515  return current_view_data_->cellCommunication();
1516  }
1517 
1518  ParallelIndexSet& getCellIndexSet()
1519  {
1520  return current_view_data_->cellIndexSet();
1521  }
1522 
1523  RemoteIndices& getCellRemoteIndices()
1524  {
1525  return current_view_data_->cellRemoteIndices();
1526  }
1527 
1528  const ParallelIndexSet& getCellIndexSet() const
1529  {
1530  return current_view_data_->cellIndexSet();
1531  }
1532 
1533  const RemoteIndices& getCellRemoteIndices() const
1534  {
1535  return current_view_data_->cellRemoteIndices();
1536  }
1537 
1538 #endif
1539 
1541  const std::vector<int>& sortedNumAquiferCells() const
1542  {
1543  return current_view_data_->sortedNumAquiferCells();
1544  }
1545 
1546  private:
1572  std::pair<bool, std::vector<std::pair<std::string,bool> > >
1573  scatterGrid(EdgeWeightMethod method,
1574  bool ownersFirst,
1575  const std::vector<cpgrid::OpmWellType> * wells,
1576  bool serialPartitioning,
1577  const double* transmissibilities,
1578  bool addCornerCells,
1579  int overlapLayers,
1580  bool useZoltan = true,
1581  double zoltanImbalanceTol = 1.1,
1582  bool allowDistributedWells = true,
1583  const std::vector<int>& input_cell_part = {});
1584 
1589  std::vector<std::shared_ptr<cpgrid::CpGridData>> data_;
1591  cpgrid::CpGridData* current_view_data_;
1593  std::vector<std::shared_ptr<cpgrid::CpGridData>> distributed_data_;
1599  std::shared_ptr<InterfaceMap> cell_scatter_gather_interfaces_;
1600  /*
1601  * @brief Interface for scattering and gathering point data.
1602  *
1603  * @warning Will only update owner cells
1604  */
1605  std::shared_ptr<InterfaceMap> point_scatter_gather_interfaces_;
1609  cpgrid::GlobalIdSet global_id_set_;
1610  }; // end Class CpGrid
1611 
1612 
1613 
1614  namespace Capabilities
1615  {
1617  template <>
1618  struct hasEntity<CpGrid, 0>
1619  {
1620  static const bool v = true;
1621  };
1622 
1624  template <>
1625  struct hasEntity<CpGrid, 3>
1626  {
1627  static const bool v = true;
1628  };
1629 
1630  template<>
1631  struct canCommunicate<CpGrid,0>
1632  {
1633  static const bool v = true;
1634  };
1635 
1636  template<>
1637  struct canCommunicate<CpGrid,3>
1638  {
1639  static const bool v = true;
1640  };
1641 
1643  template <>
1644  struct hasBackupRestoreFacilities<CpGrid>
1645  {
1646  static const bool v = false;
1647  };
1648 
1649  }
1650 
1651 
1652  template<int dim>
1653  cpgrid::Entity<dim> createEntity(const CpGrid& grid,int index,bool orientation)
1654  {
1655  return cpgrid::Entity<dim>(*grid.current_view_data_, index, orientation);
1656  }
1657 
1658 } // namespace Dune
1659 
1660 #include <opm/grid/cpgrid/PersistentContainer.hpp>
1661 #include <opm/grid/cpgrid/CartesianIndexMapper.hpp>
1662 #endif // OPM_CPGRID_HEADER
An iterator over the centroids of the geometry of the entities.
Definition: CpGrid.hpp:1217
CentroidIterator(GeometryIterator iter)
Constructs a new iterator from an iterator over the geometries.
Definition: CpGrid.hpp:1224
std::vector< cpgrid::Geometry< 3-codim, 3 > >::const_iterator GeometryIterator
The type of the iterator over the codim geometries.
Definition: CpGrid.hpp:1221
[ provides Dune::Grid ]
Definition: CpGrid.hpp:207
std::pair< bool, std::vector< std::pair< std::string, bool > > > loadBalance(DataHandle &data, const std::vector< int > &parts, const std::vector< cpgrid::OpmWellType > *wells, bool ownersFirst=false, bool addCornerCells=false, int overlapLayers=1)
Distributes this grid over the available nodes in a distributed machine.
Definition: CpGrid.hpp:801
std::string name() const
Get the grid name.
Definition: CpGrid.hpp:367
void switchToGlobalView()
Switch to the global view.
Definition: CpGrid.hpp:1487
const Vector & faceNormal(int face) const
Get the unit normal of a face.
Definition: CpGrid.hpp:1193
void readSintefLegacyFormat(const std::string &grid_prefix)
Read the Sintef legacy grid format ('topogeom').
Definition: CpGrid.cpp:527
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: CpGrid.hpp:404
const InterfaceMap & pointScatterGatherInterface() const
Get an interface for gathering/scattering data attached to points with communication.
Definition: CpGrid.hpp:1481
unsigned int numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: CpGrid.hpp:603
CpGridFamily GridFamily
Family typedef, why is this not defined by Grid<>?
Definition: CpGrid.hpp:218
void gatherData(DataHandle &handle) const
Moves data from the distributed view to the global (all data on process) view.
Definition: CpGrid.hpp:1419
const std::vector< int > & sortedNumAquiferCells() const
Get sorted active cell indices of numerical aquifer.
Definition: CpGrid.hpp:1541
void globalRefine(int)
global refinement
Definition: CpGrid.hpp:517
const std::array< int, 3 > & logicalCartesianSize() const
The logical cartesian size of the global grid.
Definition: CpGrid.hpp:314
int size(GeometryType type) const
number of leaf entities per geometry type in this process
Definition: CpGrid.hpp:480
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Definition: CpGrid.hpp:393
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: CpGrid.hpp:383
int faceTag(const Cell2FacesRowIterator &cell_face) const
Get the cartesian tag associated with a face tag.
Definition: CpGrid.hpp:1324
void setUniqueBoundaryIds(bool uids)
Set whether we want to have unique boundary ids.
Definition: CpGrid.hpp:354
Traits::template Codim< codim >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: CpGrid.hpp:424
void processEclipseFormat(const grdecl &input_data, bool remove_ij_boundary, bool turn_normals=false)
Read the Eclipse grid format ('grdecl').
Definition: CpGrid.cpp:572
unsigned int overlapSize(int) const
Size of the overlap on the leaf level.
Definition: CpGrid.hpp:580
const Vector & vertexPosition(int vertex) const
Get the Position of a vertex.
Definition: CpGrid.hpp:1174
const Traits::LocalIdSet & localIdSet() const
Access to the LocalIdSet.
Definition: CpGrid.hpp:494
const Traits::GlobalIdSet & globalIdSet() const
Access to the GlobalIdSet.
Definition: CpGrid.hpp:487
int numCellFaces() const
Get the sum of all faces attached to all cells.
Definition: CpGrid.hpp:1040
int maxLevel() const
Return maximum level defined in this grid.
Definition: CpGrid.hpp:375
const cpgrid::OrientedEntityTable< 0, 1 >::row_type cellFaceRow(int cell) const
Get a list of indices identifying all faces of a cell.
Definition: CpGrid.hpp:990
double faceArea(int face) const
Get the area of a face.
Definition: CpGrid.hpp:1180
const Vector & faceCentroid(int face) const
Get the coordinates of the center of a face.
Definition: CpGrid.hpp:1186
std::pair< bool, std::vector< std::pair< std::string, bool > > > loadBalance(DataHandle &data, EdgeWeightMethod method, const std::vector< cpgrid::OpmWellType > *wells, bool serialPartitioning, const double *transmissibilities=nullptr, bool ownersFirst=false, bool addCornerCells=false, int overlapLayers=1, bool useZoltan=true, double zoltanImbalanceTol=1.1, bool allowDistributedWells=false)
Distributes this grid over the available nodes in a distributed machine.
Definition: CpGrid.hpp:765
std::pair< bool, std::vector< std::pair< std::string, bool > > > loadBalance(const std::vector< cpgrid::OpmWellType > *wells, const double *transmissibilities=nullptr, int overlapLayers=1, bool useZoltan=true)
Distributes this grid over the available nodes in a distributed machine.
Definition: CpGrid.hpp:659
int size(int level, int codim) const
Number of grid entities per level and codim.
Definition: CpGrid.hpp:455
cpgrid::Entity< codim > entity(const cpgrid::EntityPointer< codim > &seed) const
given an EntitySeed (or EntityPointer) return an entity object
Definition: CpGrid.hpp:529
int faceVertex(int face, int local_index) const
Get the index identifying a vertex of a face.
Definition: CpGrid.hpp:1052
bool loadBalance(int overlapLayers=1, bool useZoltan=true)
Distributes this grid over the available nodes in a distributed machine.
Definition: CpGrid.hpp:631
std::vector< int > zoltanPartitionWithoutScatter(const std::vector< cpgrid::OpmWellType > *wells, const double *transmissibilities, int numParts, const double zoltanImbalanceTol)
Partitions the grid using Zoltan without decomposing and distributing it among processes.
Definition: CpGrid.cpp:139
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: CpGrid.hpp:448
bool loadBalance(DataHandle &data, decltype(data.fixedsize(0, 0)) overlapLayers=1, bool useZoltan=true)
Distributes this grid and data over the available nodes in a distributed machine.
Definition: CpGrid.hpp:829
unsigned int ghostSize(int, int) const
Size of the ghost cell layer on a given level.
Definition: CpGrid.hpp:598
std::pair< bool, std::vector< std::pair< std::string, bool > > > loadBalance(EdgeWeightMethod method, const std::vector< cpgrid::OpmWellType > *wells, const double *transmissibilities=nullptr, bool ownersFirst=false, bool addCornerCells=false, int overlapLayers=1, bool useZoltan=true)
Distributes this grid over the available nodes in a distributed machine.
Definition: CpGrid.hpp:692
int numVertices() const
Get The number of vertices.
Definition: CpGrid.hpp:965
void getIJK(const int c, std::array< int, 3 > &ijk) const
Extract Cartesian index triplet (i,j,k) of an active cell.
Definition: CpGrid.hpp:338
int cellFace(int cell, int local_index) const
Get a specific face of a cell.
Definition: CpGrid.hpp:983
bool uniqueBoundaryIds() const
Is the grid currently using unique boundary ids?
Definition: CpGrid.hpp:347
const CollectiveCommunication & comm() const
Get the collective communication object.
Definition: CpGrid.hpp:929
void createCartesian(const std::array< int, 3 > &dims, const std::array< double, 3 > &cellsize)
Create a cartesian grid.
Definition: CpGrid.cpp:469
const Vector & cellCentroid(int cell) const
Get the coordinates of the center of a cell.
Definition: CpGrid.hpp:1205
int faceCell(int face, int local_index) const
Get the index identifying a cell attached to a face.
Definition: CpGrid.hpp:1004
int numCellFaces(int cell) const
Get the number of faces of a cell.
Definition: CpGrid.hpp:975
Traits::template Codim< codim >::LeafIterator leafend() const
one past the end of the sequence of leaf entities
Definition: CpGrid.hpp:432
unsigned int overlapSize(int, int) const
Size of the overlap on a given level.
Definition: CpGrid.hpp:592
void writeSintefLegacyFormat(const std::string &grid_prefix) const
Write the Sintef legacy grid format ('topogeom').
Definition: CpGrid.cpp:537
unsigned int ghostSize(int) const
Size of the ghost cell layer on the leaf level.
Definition: CpGrid.hpp:586
Traits::template Codim< codim >::template Partition< PiType >::LevelIterator lend(int level) const
one past the end on this level
Definition: CpGrid.hpp:414
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir) const
The new communication interface.
Definition: CpGrid.hpp:923
CpGrid()
Default constructor.
Definition: CpGrid.cpp:119
CentroidIterator< 0 > beginCellCentroids() const
Get an iterator over the cell centroids positioned at the first one.
Definition: CpGrid.hpp:1262
const InterfaceMap & cellScatterGatherInterface() const
Get an interface for gathering/scattering data attached to cells with communication.
Definition: CpGrid.hpp:1474
const Traits::LevelIndexSet & levelIndexSet(int level) const
Access to the LevelIndexSets.
Definition: CpGrid.hpp:501
void switchToDistributedView()
Switch to the distributed view.
Definition: CpGrid.hpp:1493
CentroidIterator< 1 > beginFaceCentroids() const
Get an iterator over the face centroids positioned at the first one.
Definition: CpGrid.hpp:1268
bool loadBalance(DataHandle &data, const std::vector< int > &parts, bool ownersFirst=false, bool addCornerCells=false, int overlapLayers=1)
Distributes this grid and data over the available nodes in a distributed machine.
Definition: CpGrid.hpp:882
Traits::template Codim< codim >::template Partition< PiType >::LeafIterator leafbegin() const
Iterator to first leaf entity of given codim.
Definition: CpGrid.hpp:440
int numCells() const
Get the number of cells.
Definition: CpGrid.hpp:955
bool loadBalance(const std::vector< int > &parts, bool ownersFirst=false, bool addCornerCells=false, int overlapLayers=1)
Distributes this grid over the available nodes in a distributed machine.
Definition: CpGrid.hpp:857
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition: CpGrid.hpp:471
int numFaces() const
Get the number of faces.
Definition: CpGrid.hpp:960
std::pair< bool, std::vector< std::pair< std::string, bool > > > loadBalance(DataHandle &data, const std::vector< cpgrid::OpmWellType > *wells, const double *transmissibilities=nullptr, int overlapLayers=1, bool useZoltan=true)
Distributes this grid and data over the available nodes in a distributed machine.
Definition: CpGrid.hpp:721
double cellCenterDepth(int cell_index) const
Get vertical position of cell center ("zcorn" average).
Definition: CpGrid.hpp:1058
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir, int) const
The new communication interface.
Definition: CpGrid.hpp:910
const Traits::LeafIndexSet & leafIndexSet() const
Access to the LeafIndexSet.
Definition: CpGrid.hpp:510
int size(int codim) const
number of leaf entities per codim in this process
Definition: CpGrid.hpp:464
double cellVolume(int cell) const
Get the volume of the cell.
Definition: CpGrid.hpp:1199
void scatterData(DataHandle &handle) const
Moves data from the global (all data on process) view to the distributed view.
Definition: CpGrid.hpp:1399
const std::vector< int > & globalCell() const
Retrieve mapping from internal ("compressed") active grid cells to external ("uncompressed") cells.
Definition: CpGrid.hpp:326
std::map< int, std::list< int > > InterfaceMap
The type of the map describing communication interfaces.
Definition: CpGrid.hpp:1443
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:123
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir)
communicate objects for all codims on a given level
Definition: CpGridData.hpp:610
bool uniqueBoundaryIds() const
Is the grid currently using unique boundary ids?
Definition: CpGridData.hpp:249
int size(int codim) const
number of leaf entities per codim in this process
Definition: CpGridData.cpp:144
void getIJK(int c, std::array< int, 3 > &ijk) const
Extract Cartesian index triplet (i,j,k) of an active cell.
Definition: CpGridData.hpp:235
void setUniqueBoundaryIds(bool uids)
Set whether we want to have unique boundary ids.
Definition: CpGridData.hpp:256
const std::vector< int > & sortedNumAquiferCells() const
Get sorted active cell indices of numerical aquifer.
Definition: CpGridData.hpp:368
const std::vector< double > & zcornData() const
Return the internalized zcorn copy from the grid processing, if no cells were adjusted during the min...
Definition: CpGridData.hpp:267
Represents an entity of a given codim, with positive or negative orientation.
Definition: EntityRep.hpp:98
Definition: Entity.hpp:70
This class encapsulates geometry for both vertices, intersections and cells.
Definition: Geometry.hpp:68
The global id set for Dune.
Definition: Indexsets.hpp:325
Only needs to provide interface for doing nothing.
Definition: Iterators.hpp:89
Definition: Indexsets.hpp:54
Definition: Intersection.hpp:291
Definition: Intersection.hpp:68
Iterator intended to be used as LeafIterator and LevelIterator (no difference due to no adaptivity) f...
Definition: Iterators.hpp:56
A class used as a row type for OrientedEntityTable.
Definition: OrientedEntityTable.hpp:55
int size() const
Returns the number of rows in the table.
Definition: SparseTable.hpp:121
int dataSize() const
Returns the number of data elements.
Definition: SparseTable.hpp:141
int size() const
Returns the number of rows in the table.
Definition: SparseTable.hpp:121
Copyright 2019 Equinor AS.
Definition: CartesianIndexMapper.hpp:10
EdgeWeightMethod
enum for choosing Methods for weighting graph-edges correspoding to cell interfaces in Zoltan's graph...
Definition: GridEnums.hpp:34
@ defaultTransEdgeWgt
Use the transmissibilities as edge weights.
Definition: GridEnums.hpp:38
FieldVector< T, 3 > cross(const FieldVector< T, 3 > &a, const FieldVector< T, 3 > &b)
Definition: Volumes.hpp:58
Low-level corner-point processing routines and supporting data structures.
face_tag
Connection taxonomy.
Definition: preprocess.h:66
@ K_FACE
Connection topologically normal to I-J plane.
Definition: preprocess.h:69
@ J_FACE
Connection topologically normal to I-K plane.
Definition: preprocess.h:68
@ NNC_FACE
Arbitrary non-neighbouring connection.
Definition: preprocess.h:70
@ I_FACE
Connection topologically normal to J-K plane.
Definition: preprocess.h:67
Definition: CpGrid.hpp:194
Traits associated with a specific grid partition type.
Definition: CpGrid.hpp:147
cpgrid::Iterator< cd, pitype > LevelIterator
The type of the iterator over the level entities of this codim on this partition.
Definition: CpGrid.hpp:149
cpgrid::Iterator< cd, pitype > LeafIterator
The type of the iterator over the leaf entities of this codim on this partition.
Definition: CpGrid.hpp:151
Traits associated with a specific codim.
Definition: CpGrid.hpp:120
cpgrid::Entity< cd > Entity
The type of the entity.
Definition: CpGrid.hpp:129
cpgrid::Geometry< 3-cd, 3 > Geometry
The type of the geometry associated with the entity.
Definition: CpGrid.hpp:123
cpgrid::Geometry< 3-cd, 3 > LocalGeometry
The type of the local geometry associated with the entity.
Definition: CpGrid.hpp:126
cpgrid::Iterator< cd, All_Partition > LeafIterator
The type of the iterator over all leaf entities of this codim.
Definition: CpGrid.hpp:135
cpgrid::Iterator< cd, All_Partition > LevelIterator
The type of the iterator over all level entities of this codim.
Definition: CpGrid.hpp:132
cpgrid::EntityPointer< cd > EntitySeed
The type of the entity pointer for entities of this codim.
Definition: CpGrid.hpp:141
cpgrid::EntityPointer< cd > EntityPointer
The type of the entity pointer for entities of this codim.
Definition: CpGrid.hpp:138
Traits associated with a specific grid partition type.
Definition: CpGrid.hpp:159
Dune::GridView< DefaultLeafGridViewTraits< CpGrid > > LeafGridView
The type of the leaf grid view associated with this partition type.
Definition: CpGrid.hpp:163
Dune::GridView< DefaultLevelGridViewTraits< CpGrid > > LevelGridView
The type of the level grid view associated with this partition type.
Definition: CpGrid.hpp:161
Definition: CpGrid.hpp:100
cpgrid::IndexSet LevelIndexSet
The type of the level index set.
Definition: CpGrid.hpp:173
cpgrid::IntersectionIterator LeafIntersectionIterator
The type of the intersection iterator at the leafs of the grid.
Definition: CpGrid.hpp:109
Dune::GridView< DefaultLeafGridViewTraits< CpGrid > > LeafGridView
The type of the leaf grid view associated with this partition type.
Definition: CpGrid.hpp:170
Dune::GridView< DefaultLevelGridViewTraits< CpGrid > > LevelGridView
The type of the level grid view associated with this partition type.
Definition: CpGrid.hpp:168
cpgrid::GlobalIdSet GlobalIdSet
The type of the global id set.
Definition: CpGrid.hpp:177
cpgrid::IntersectionIterator LevelIntersectionIterator
The type of the intersection iterator at the levels of the grid.
Definition: CpGrid.hpp:111
cpgrid::IndexSet LeafIndexSet
The type of the leaf index set.
Definition: CpGrid.hpp:175
GlobalIdSet LocalIdSet
The type of the local id set.
Definition: CpGrid.hpp:179
Dune::MPIHelper::MPICommunicator MPICommunicator
The type of the collective communication.
Definition: CpGrid.hpp:183
cpgrid::HierarchicIterator HierarchicIterator
The type of the hierarchic iterator.
Definition: CpGrid.hpp:114
cpgrid::Intersection LevelIntersection
The type of the intersection at the levels of the grid.
Definition: CpGrid.hpp:107
cpgrid::Intersection LeafIntersection
The type of the intersection at the leafs of the grid.
Definition: CpGrid.hpp:105
CpGrid Grid
The type that implements the grid.
Definition: CpGrid.hpp:102
Raw corner-point specification of a particular geological model.
Definition: preprocess.h:56