48#ifndef OPM_CPGRIDDATA_HEADER
49#define OPM_CPGRIDDATA_HEADER
52#include <dune/common/parallel/mpihelper.hh>
54#include <dune/istl/owneroverlapcopy.hh>
57#include <dune/common/parallel/communication.hh>
58#include <dune/common/parallel/variablesizecommunicator.hh>
59#include <dune/grid/common/gridenums.hh>
62#include <opm/input/eclipse/EclipseState/Grid/NNC.hpp>
67#include "Entity2IndexDataHandle.hpp"
68#include "CpGridDataTraits.hpp"
71#include "Geometry.hpp"
74#include <initializer_list>
91class LevelGlobalIdSet;
92class PartitionTypeIndicator;
93template<
int,
int>
class Geometry;
94template<
int>
class Entity;
95template<
int>
class EntityRep;
101 const std::array<int,3>&,
102 const std::vector<int>&,
109 const std::array<int, 3>&,
112void refinePatch_and_check(
const std::array<int,3>&,
113 const std::array<int,3>&,
114 const std::array<int,3>&);
117 const std::vector<std::array<int,3>>&,
118 const std::vector<std::array<int,3>>&,
119 const std::vector<std::array<int,3>>&,
120 const std::vector<std::string>&);
125void fieldProp_check(
const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::string deck_string);
127void testInactiveCellsLgrs(
const std::string&,
128 const std::vector<std::array<int,3>>&,
129 const std::vector<std::array<int,3>>&,
130 const std::vector<std::array<int,3>>&,
131 const std::vector<std::string>&);
139template<
class T,
int i>
struct Mover;
157 const std::array<int,3>&,
158 const std::vector<int>&,
166 const std::array<int, 3>&,
169 void ::refinePatch_and_check(
const std::array<int,3>&,
170 const std::array<int,3>&,
171 const std::array<int,3>&);
175 const std::vector<std::array<int,3>>&,
176 const std::vector<std::array<int,3>>&,
177 const std::vector<std::array<int,3>>&,
178 const std::vector<std::string>&);
184 void ::fieldProp_check(
const Dune::CpGrid& grid, Opm::EclipseGrid eclGrid, std::string deck_string);
186 void ::testInactiveCellsLgrs(
const std::string&,
187 const std::vector<std::array<int,3>>&,
188 const std::vector<std::array<int,3>>&,
189 const std::vector<std::array<int,3>>&,
190 const std::vector<std::string>&);
197#ifndef MAX_DATA_COMMUNICATED_PER_ENTITY
217 explicit CpGridData(MPIHelper::MPICommunicator comm, std::vector<std::shared_ptr<CpGridData>>& data);
222 explicit CpGridData(std::vector<std::shared_ptr<CpGridData>>& data);
230 int size(
int codim)
const;
233 int size (GeometryType type)
const
236 return size(3 - type.dim());
247 void readEclipseFormat(
const std::string& filename,
bool periodic_extension,
bool turn_normals =
false);
258 void processEclipseFormat(
const Opm::Deck& deck,
bool periodic_extension,
bool turn_normals =
false,
bool clip_z =
false,
259 const std::vector<double>& poreVolume = std::vector<double>());
274 std::vector<std::size_t>
276 bool periodic_extension,
bool turn_normals =
false,
bool clip_z =
false,
277 bool pinchActive =
true);
293 Opm::EclipseState* ecl_state,
295 std::array<std::set<std::pair<int, int>>, 2>& nnc,
296 bool remove_ij_boundary,
bool turn_normals,
bool pinchActive,
297 double tolerance_unique_points);
306 void getIJK(
int c, std::array<int,3>& ijk)
const
308 ijk =
getIJK(global_cell_[c], logical_cartesian_size_);
317 std::array<int,3>
getIJK(
int idx_in_parent_cell,
const std::array<int,3>& cells_per_dim)
const
321 assert(cells_per_dim[0]);
322 assert(cells_per_dim[1]);
323 assert(cells_per_dim[2]);
325 std::array<int,3> ijk = {0,0,0};
326 ijk[0] = idx_in_parent_cell % cells_per_dim[0]; idx_in_parent_cell /= cells_per_dim[0];
327 ijk[1] = idx_in_parent_cell % cells_per_dim[1];
328 ijk[2] = idx_in_parent_cell /cells_per_dim[1];
337 bool disjointPatches(
const std::vector<std::array<int,3>>& startIJK_vec,
const std::vector<std::array<int,3>>& endIJK_vec)
const;
347 getPatchesCells(
const std::vector<std::array<int,3>>& startIJK_vec,
const std::vector<std::array<int,3>>& endIJK_vec)
const;
351 bool hasNNCs(
const std::vector<int>& cellIndices)
const;
359 void validStartEndIJKs(
const std::vector<std::array<int,3>>& startIJK_vec,
const std::vector<std::array<int,3>>& endIJK_vec)
const;
369 bool patchesShareFace(
const std::vector<std::array<int,3>>& startIJK_vec,
const std::vector<std::array<int,3>>& endIJK_vec)
const;
371 int sharedFaceTag(
const std::vector<std::array<int,3>>& startIJK_2Patches,
const std::vector<std::array<int,3>>& endIJK_2Patches)
const;
404 std::array<Dune::FieldVector<double,3>,8> getReferenceRefinedCorners(
int idx_in_parent_cell,
const std::array<int,3>& cells_per_dim)
const;
413 std::array<int,3> getPatchDim(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
422 std::vector<int> getPatchCorners(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
431 std::vector<int> getPatchFaces(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
440 std::vector<int> getPatchCells(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
449 std::vector<int> getPatchBoundaryCorners(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
458 std::array<std::vector<int>,6> getBoundaryPatchFaces(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
461 std::array<std::vector<double>,3> getWidthsLengthsHeights(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
477 Geometry<3,3> cellifyPatch(
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK,
479 std::array<int,8>& cellifiedPatch_to_point,
480 std::array<int,8>& allcorners_cellifiedPatch)
const;
486 std::array<double,3> getAverageArr(
const std::vector<std::array<double,3>>& vec)
const;
498 if ((level_data_ptr_ ->
size() >1) && (level_ == 0) && (!child_to_parent_cells_.empty())) {
499 return level_data_ptr_->size() -1;
504 std::vector<std::shared_ptr<Dune::cpgrid::CpGridData>>
levelData()
const
506 return *level_data_ptr_;
531 std::tuple< const std::shared_ptr<CpGridData>,
532 const std::vector<std::array<int,2>>,
533 const std::vector<std::tuple<int,std::vector<int>>>,
534 const std::tuple<int, std::vector<int>>,
535 const std::vector<std::array<int,2>>,
536 const std::vector<std::array<int,2>>>
537 refineSingleCell(
const std::array<int,3>& cells_per_dim,
const int& parent_idx)
const;
551 std::tuple< std::shared_ptr<CpGridData>,
552 const std::vector<std::array<int,2>>,
553 const std::vector<std::tuple<int,std::vector<int>>>,
554 const std::vector<std::tuple<int,std::vector<int>>>,
555 const std::vector<std::tuple<int,std::vector<int>>>,
556 const std::vector<std::array<int,2>>,
557 const std::vector<std::array<int,2>>>
558 refinePatch(
const std::array<int,3>& cells_per_dim,
const std::array<int,3>& startIJK,
const std::array<int,3>& endIJK)
const;
566 std::array<double,3> computeEclCentroid(
const int idx)
const;
574 std::array<double,3> computeEclCentroid(
const Entity<0>& elem)
const;
577 void computeUniqueBoundaryIds();
584 return use_unique_boundary_ids_;
591 use_unique_boundary_ids_ = uids;
592 if (use_unique_boundary_ids_ && unique_boundary_ids_.empty()) {
593 computeUniqueBoundaryIds();
615 return *local_id_set_;
621 return *global_id_set_;
629 return logical_cartesian_size_;
637 const std::vector<int>& cell_part);
644 template<
class DataHandle>
645 void communicate(DataHandle& data, InterfaceType iftype, CommunicationDirection dir);
647 void computeCellPartitionType();
649 void computePointPartitionType();
651 void computeCommunicationInterfaces(
int noexistingPoints);
657 using CollectiveCommunication = CpGridDataTraits::CollectiveCommunication;
663 using Communicator = CpGridDataTraits::Communicator;
666 using InterfaceMap = CpGridDataTraits::InterfaceMap;
669 using CommunicationType = CpGridDataTraits::CommunicationType;
672 using ParallelIndexSet = CpGridDataTraits::ParallelIndexSet;
675 using RemoteIndices = CpGridDataTraits::RemoteIndices;
680 CommunicationType& cellCommunication()
688 const CommunicationType& cellCommunication()
const
693 ParallelIndexSet& cellIndexSet()
695 return cellCommunication().indexSet();
698 const ParallelIndexSet& cellIndexSet()
const
700 return cellCommunication().indexSet();
703 RemoteIndices& cellRemoteIndices()
705 return cellCommunication().remoteIndices();
708 const RemoteIndices& cellRemoteIndices()
const
710 return cellCommunication().remoteIndices();
717 return aquifer_cells_;
723 void populateGlobalCellIndexSet();
732 template<
class DataHandle>
733 void gatherData(DataHandle& data,
CpGridData* global_view,
743 template<
int codim,
class DataHandle>
744 void gatherCodimData(DataHandle& data,
CpGridData* global_data,
753 template<
class DataHandle>
754 void scatterData(DataHandle& data,
CpGridData* global_data,
755 CpGridData* distributed_data,
const InterfaceMap& cell_inf,
756 const InterfaceMap& point_inf);
765 template<
int codim,
class DataHandle>
766 void scatterCodimData(DataHandle& data,
CpGridData* global_data,
777 template<
int codim,
class DataHandle>
779 const Interface& interface);
789 template<
int codim,
class DataHandle>
791 const InterfaceMap& interface);
795 void computeGeometry(
CpGrid& grid,
797 const std::vector<int>& globalAquiferCells,
800 std::vector<int>& aquiferCells,
802 const std::vector< std::array<int,8> >& cell2Points);
818 std::vector< std::array<int,8> > cell_to_point_;
825 std::array<int, 3> logical_cartesian_size_{};
832 std::vector<int> global_cell_;
838 typedef FieldVector<double, 3> PointType;
844 std::unique_ptr<cpgrid::IndexSet> index_set_;
846 std::shared_ptr<const cpgrid::IdSet> local_id_set_;
848 std::shared_ptr<LevelGlobalIdSet> global_id_set_;
850 std::shared_ptr<PartitionTypeIndicator> partition_type_indicator_;
852 std::vector<int> mark_;
856 std::vector<std::shared_ptr<CpGridData>>* level_data_ptr_;
859 std::vector<int> level_to_leaf_cells_;
860 // {level LGR, {child0, child1, ...}}
861 std::vector<std::tuple<int,std::vector<int>>> parent_to_children_cells_;
863 std::array<int,3> cells_per_dim_;
865 // {level, cell index in that level}
866 std::vector<std::array<int,2>> leaf_to_level_cells_;
868 std::vector<std::array<int,2>> corner_history_;
870 // {level parent cell, parent cell index}
871 std::vector<std::array<int,2>> child_to_parent_cells_;
874 std::vector<int> cell_to_idxInParentCell_;
882 bool use_unique_boundary_ids_;
889 std::vector<double> zcorn;
892 std::vector<int> aquifer_cells_;
897 CommunicationType cell_comm_;
900 std::tuple<Interface,Interface,Interface,Interface,Interface> cell_interfaces_;
905 std::tuple<InterfaceMap,InterfaceMap,InterfaceMap,InterfaceMap,InterfaceMap>
909 std::tuple<InterfaceMap,InterfaceMap,InterfaceMap,InterfaceMap,InterfaceMap>
916 const EntityVariable<Geometry<3 - codim, 3>, codim>& geomVector()
const
922 template<
int>
friend class Entity;
923 template<
int>
friend class EntityRep;
924 friend class Intersection;
925 friend class PartitionTypeIndicator;
939T& getInterface(InterfaceType iftype,
940 std::tuple<T,T,T,T,T>& interfaces)
945 return std::get<0>(interfaces);
947 return std::get<1>(interfaces);
949 return std::get<2>(interfaces);
951 return std::get<3>(interfaces);
953 return std::get<4>(interfaces);
955 OPM_THROW(std::runtime_error,
"Invalid Interface type was used during communication");
960template<
int codim,
class DataHandle>
961void CpGridData::communicateCodim(Entity2IndexDataHandle<DataHandle, codim>& data, CommunicationDirection dir,
962 const Interface& interface)
964 this->
template communicateCodim<codim>(data, dir, interface.interfaces());
967template<
int codim,
class DataHandle>
968void CpGridData::communicateCodim(Entity2IndexDataHandle<DataHandle, codim>& data_wrapper, CommunicationDirection dir,
969 const InterfaceMap& interface)
971 Communicator comm(ccobj_, interface);
973 if(dir==ForwardCommunication)
974 comm.forward(data_wrapper);
976 comm.backward(data_wrapper);
980template<
class DataHandle>
982 CommunicationDirection dir)
985 if(data.contains(3,0))
988 communicateCodim<0>(data_wrapper, dir, getInterface(iftype, cell_interfaces_));
990 if(data.contains(3,3))
993 communicateCodim<3>(data_wrapper, dir, getInterface(iftype, point_interfaces_));
1005#include <opm/grid/cpgrid/Entity.hpp>
1006#include <opm/grid/cpgrid/Indexsets.hpp>
1020 data=buffer_[index_++];
1022 void write(
const T& data)
1024 buffer_[index_++]=data;
1030 void resize(std::size_t size)
1032 buffer_.resize(size);
1036 std::vector<T> buffer_;
1037 typename std::vector<T>::size_type index_;
1039template<
class DataHandle,
int codim>
1044template<
class DataHandle>
1047 BaseMover(DataHandle& data)
1051 void moveData(
const E& from,
const E& to)
1053 std::size_t size=data_.size(from);
1054 buffer.resize(size);
1055 data_.gather(buffer, from);
1057 data_.scatter(buffer, to, size);
1060 MoveBuffer<typename DataHandle::DataType> buffer;
1064template<
class DataHandle>
1065struct Mover<DataHandle,0> :
public BaseMover<DataHandle>
1067 Mover<DataHandle,0>(DataHandle& data, CpGridData* gatherView,
1068 CpGridData* scatterView)
1069 : BaseMover<DataHandle>(data), gatherView_(gatherView), scatterView_(scatterView)
1072 void operator()(std::size_t from_cell_index,std::size_t to_cell_index)
1074 Entity<0> from_entity=Entity<0>(*gatherView_, from_cell_index,
true);
1075 Entity<0> to_entity=Entity<0>(*scatterView_, to_cell_index,
true);
1076 this->moveData(from_entity, to_entity);
1078 CpGridData* gatherView_;
1079 CpGridData* scatterView_;
1082template<
class DataHandle>
1083struct Mover<DataHandle,1> :
public BaseMover<DataHandle>
1085 Mover<DataHandle,1>(DataHandle& data, CpGridData* gatherView,
1086 CpGridData* scatterView)
1087 : BaseMover<DataHandle>(data), gatherView_(gatherView), scatterView_(scatterView)
1090 void operator()(std::size_t from_cell_index,std::size_t to_cell_index)
1092 typedef typename OrientedEntityTable<0,1>::row_type row_type;
1093 EntityRep<0> from_cell=EntityRep<0>(from_cell_index,
true);
1094 EntityRep<0> to_cell=EntityRep<0>(to_cell_index,
true);
1095 OrientedEntityTable<0,1>& table = gatherView_->cell_to_face_;
1096 row_type from_faces=table.operator[](from_cell);
1097 row_type to_faces=scatterView_->cell_to_face_[to_cell];
1099 for(
int i=0; i<from_faces.size(); ++i)
1100 this->moveData(from_faces[i], to_faces[i]);
1102 CpGridData *gatherView_;
1103 CpGridData *scatterView_;
1106template<
class DataHandle>
1107struct Mover<DataHandle,3> :
public BaseMover<DataHandle>
1109 Mover<DataHandle,3>(DataHandle& data, CpGridData* gatherView,
1110 CpGridData* scatterView)
1111 : BaseMover<DataHandle>(data), gatherView_(gatherView), scatterView_(scatterView)
1113 void operator()(std::size_t from_cell_index,std::size_t to_cell_index)
1115 const std::array<int,8>& from_cell_points=
1116 gatherView_->cell_to_point_[from_cell_index];
1117 const std::array<int,8>& to_cell_points=
1118 scatterView_->cell_to_point_[to_cell_index];
1119 for(std::size_t i=0; i<8; ++i)
1121 this->moveData(Entity<3>(*gatherView_, from_cell_points[i],
true),
1122 Entity<3>(*scatterView_, to_cell_points[i],
true));
1125 CpGridData* gatherView_;
1126 CpGridData* scatterView_;
1131template<
class DataHandle>
1132void CpGridData::scatterData(DataHandle& data, CpGridData* global_data,
1133 CpGridData* distributed_data,
const InterfaceMap& cell_inf,
1134 const InterfaceMap& point_inf)
1137 if(data.contains(3,0))
1139 Entity2IndexDataHandle<DataHandle, 0> data_wrapper(*global_data, *distributed_data, data);
1140 communicateCodim<0>(data_wrapper, ForwardCommunication, cell_inf);
1142 if(data.contains(3,3))
1144 Entity2IndexDataHandle<DataHandle, 3> data_wrapper(*global_data, *distributed_data, data);
1145 communicateCodim<3>(data_wrapper, ForwardCommunication, point_inf);
1150template<
int codim,
class DataHandle>
1151void CpGridData::scatterCodimData(DataHandle& data, CpGridData* global_data,
1152 CpGridData* distributed_data)
1154 CpGridData *gather_view, *scatter_view;
1155 gather_view=global_data;
1156 scatter_view=distributed_data;
1158 mover::Mover<DataHandle,codim> mover(data, gather_view, scatter_view);
1161 for(
auto index=distributed_data->cellIndexSet().begin(),
1162 end = distributed_data->cellIndexSet().end();
1163 index!=end; ++index)
1165 std::size_t from=index->global();
1166 std::size_t to=index->local();
1174template<
int codim,
class T,
class F>
1175void visitInterior(CpGridData& distributed_data, T begin, T endit, F& func)
1177 for(T it=begin; it!=endit; ++it)
1179 Entity<codim> entity(distributed_data, it-begin,
true);
1180 PartitionType pt = entity.partitionType();
1181 if(pt==Dune::InteriorEntity)
1188template<
class DataHandle>
1189struct GlobalIndexSizeGatherer
1191 GlobalIndexSizeGatherer(DataHandle& data_,
1192 std::vector<int>& ownedGlobalIndices_,
1193 std::vector<int>& ownedSizes_)
1194 : data(data_), ownedGlobalIndices(ownedGlobalIndices_), ownedSizes(ownedSizes_)
1197 template<
class T,
class E>
1198 void operator()(T& i, E& entity)
1200 ownedGlobalIndices.push_back(i);
1201 ownedSizes.push_back(data.size(entity));
1204 std::vector<int>& ownedGlobalIndices;
1205 std::vector<int>& ownedSizes;
1208template<
class DataHandle>
1211 DataGatherer(mover::MoveBuffer<typename DataHandle::DataType>& buffer_,
1213 : buffer(buffer_), data(data_)
1216 template<
class T,
class E>
1217 void operator()(T& , E& entity)
1219 data.gather(buffer, entity);
1221 mover::MoveBuffer<typename DataHandle::DataType>& buffer;
1227template<
class DataHandle>
1228void CpGridData::gatherData(DataHandle& data, CpGridData* global_data,
1229 CpGridData* distributed_data)
1232 if(data.contains(3,0))
1233 gatherCodimData<0>(data, global_data, distributed_data);
1234 if(data.contains(3,3))
1235 gatherCodimData<3>(data, global_data, distributed_data);
1239template<
int codim,
class DataHandle>
1240void CpGridData::gatherCodimData(DataHandle& data, CpGridData* global_data,
1241 CpGridData* distributed_data)
1245 const std::vector<int>& mapping =
1246 distributed_data->global_id_set_->getMapping<codim>();
1250 std::vector<int> owned_global_indices;
1251 std::vector<int> owned_sizes;
1252 owned_global_indices.reserve(mapping.size());
1253 owned_sizes.reserve(mapping.size());
1255 GlobalIndexSizeGatherer<DataHandle> gisg(data, owned_global_indices, owned_sizes);
1256 visitInterior<codim>(*distributed_data, mapping.begin(), mapping.end(), gisg);
1259 int no_indices=owned_sizes.size();
1262 if ( owned_global_indices.empty() )
1263 owned_global_indices.resize(1);
1264 if ( owned_sizes.empty() )
1265 owned_sizes.resize(1);
1266 std::vector<int> no_indices_to_recv(distributed_data->ccobj_.size());
1267 distributed_data->ccobj_.allgather(&no_indices, 1, &(no_indices_to_recv[0]));
1271 std::vector<int> displ(distributed_data->ccobj_.size()+1, 0);
1272 std::transform(displ.begin(), displ.end()-1, no_indices_to_recv.begin(), displ.begin()+1,
1274 int global_size=displ[displ.size()-1];
1275 std::vector<int> global_indices(global_size);
1276 std::vector<int> global_sizes(global_size);
1277 MPI_Allgatherv(&(owned_global_indices[0]), no_indices, MPITraits<int>::getType(),
1278 &(global_indices[0]), &(no_indices_to_recv[0]), &(displ[0]),
1279 MPITraits<int>::getType(),
1280 distributed_data->ccobj_);
1281 MPI_Allgatherv(&(owned_sizes[0]), no_indices, MPITraits<int>::getType(),
1282 &(global_sizes[0]), &(no_indices_to_recv[0]), &(displ[0]),
1283 MPITraits<int>::getType(),
1284 distributed_data->ccobj_);
1285 std::vector<int>().swap(owned_global_indices);
1287 std::vector<int> no_data_send(distributed_data->ccobj_.size());
1288 for(
typename std::vector<int>::iterator begin=no_data_send.begin(),
1289 i=begin, end=no_data_send.end(); i!=end; ++i)
1290 *i = std::accumulate(global_sizes.begin()+displ[i-begin],
1291 global_sizes.begin()+displ[i-begin+1], std::size_t());
1293 std::vector<int>().swap(owned_sizes);
1296 std::transform(displ.begin(), displ.end()-1, no_data_send.begin(), displ.begin()+1,
1297 std::plus<std::size_t>());
1299 int no_data_recv = displ[displ.size()-1];
1302 mover::MoveBuffer<typename DataHandle::DataType> local_data_buffer, global_data_buffer;
1303 if ( no_data_send[distributed_data->ccobj_.rank()] )
1305 local_data_buffer.resize(no_data_send[distributed_data->ccobj_.rank()]);
1309 local_data_buffer.resize(1);
1311 global_data_buffer.resize(no_data_recv);
1313 DataGatherer<DataHandle> gatherer(local_data_buffer, data);
1314 visitInterior<codim>(*distributed_data, mapping.begin(), mapping.end(), gatherer);
1315 MPI_Allgatherv(&(local_data_buffer.buffer_[0]), no_data_send[distributed_data->ccobj_.rank()],
1316 MPITraits<typename DataHandle::DataType>::getType(),
1317 &(global_data_buffer.buffer_[0]), &(no_data_send[0]), &(displ[0]),
1318 MPITraits<typename DataHandle::DataType>::getType(),
1319 distributed_data->ccobj_);
1320 Entity2IndexDataHandle<DataHandle, codim> edata(*global_data, data);
1322 for(
int i=0; i< codim; ++i)
1323 offset+=global_data->size(i);
1325 typename std::vector<int>::const_iterator s=global_sizes.begin();
1326 for(
typename std::vector<int>::const_iterator i=global_indices.begin(),
1327 end=global_indices.end();
1330 edata.scatter(global_data_buffer, *i-offset, *s);
[ provides Dune::Grid ]
Definition CpGrid.hpp:201
Struct that hods all the data needed to represent a Cpgrid.
Definition CpGridData.hpp:147
void postAdapt()
Clean up refinement/coarsening markers - set every element to the mark 0 which represents 'doing noth...
Definition CpGridData.cpp:2703
const cpgrid::LevelGlobalIdSet & globalIdSet() const
Get the global index set.
Definition CpGridData.hpp:619
@ MAX_DATA_PER_CELL
The maximum data items allowed per cell (DUNE < 2.5.2)
Definition CpGridData.hpp:204
std::vector< int > getPatchesCells(const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec) const
Compute cell indices of selected patches of cells (Cartesian grid required).
Definition CpGridData.cpp:2186
int size(GeometryType type) const
number of leaf entities per geometry type in this process
Definition CpGridData.hpp:233
const std::array< int, 3 > & logicalCartesianSize() const
The logical cartesian size of the grid.
Definition CpGridData.hpp:627
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir)
communicate objects for all codims on a given level
Definition CpGridData.hpp:981
bool uniqueBoundaryIds() const
Is the grid currently using unique boundary ids?
Definition CpGridData.hpp:582
std::array< int, 3 > getIJK(int idx_in_parent_cell, const std::array< int, 3 > &cells_per_dim) const
Extract Cartesian index triplet (i,j,k) given an index between 0 and NXxNYxNZ -1 where NX,...
Definition CpGridData.hpp:317
bool patchesShareFace(const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec) const
Determine if a finite amount of patches (of cells) share a face.
Definition CpGridData.cpp:2023
int size(int codim) const
number of leaf entities per codim in this process
Definition CpGridData.cpp:146
void readEclipseFormat(const std::string &filename, bool periodic_extension, bool turn_normals=false)
Read the Eclipse grid format ('grdecl').
CpGridDataTraits::Communication Communication
The type of the collective communication.
Definition CpGridData.hpp:656
~CpGridData()
Destructor.
Definition CpGridData.cpp:99
void getIJK(int c, std::array< int, 3 > &ijk) const
Extract Cartesian index triplet (i,j,k) of an active cell.
Definition CpGridData.hpp:306
const IndexSet & indexSet() const
Get the index set.
Definition CpGridData.hpp:607
std::tuple< std::shared_ptr< CpGridData >, const std::vector< std::array< int, 2 > >, const std::vector< std::tuple< int, std::vector< int > > >, const std::vector< std::tuple< int, std::vector< int > > >, const std::vector< std::tuple< int, std::vector< int > > >, const std::vector< std::array< int, 2 > >, const std::vector< std::array< int, 2 > > > refinePatch(const std::array< int, 3 > &cells_per_dim, const std::array< int, 3 > &startIJK, const std::array< int, 3 > &endIJK) const
Refine a (connected block-shaped) patch of cells.
Definition CpGridData.cpp:2443
int getMark(const cpgrid::Entity< 0 > &element) const
Return refinement mark for entity.
Definition CpGridData.cpp:2677
CpGridDataTraits::MPICommunicator MPICommunicator
The type of the mpi communicator.
Definition CpGridData.hpp:654
void processEclipseFormat(const grdecl &input_data, std::array< std::set< std::pair< int, int > >, 2 > &nnc, bool remove_ij_boundary, bool turn_normals, bool pinchActive, double tolerance_unique_points)
Read the Eclipse grid format ('grdecl').
Definition processEclipseFormat.cpp:409
std::tuple< const std::shared_ptr< CpGridData >, const std::vector< std::array< int, 2 > >, const std::vector< std::tuple< int, std::vector< int > > >, const std::tuple< int, std::vector< int > >, const std::vector< std::array< int, 2 > >, const std::vector< std::array< int, 2 > > > refineSingleCell(const std::array< int, 3 > &cells_per_dim, const int &parent_idx) const
Refine a single cell and return a shared pointer of CpGridData type.
Definition CpGridData.cpp:2312
void distributeGlobalGrid(CpGrid &grid, const CpGridData &view_data, const std::vector< int > &cell_part)
Redistribute a global grid.
Definition CpGridData.cpp:1515
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:600
void setUniqueBoundaryIds(bool uids)
Set whether we want to have unique boundary ids.
Definition CpGridData.hpp:589
bool preAdapt()
Set mightVanish flags for elements that will be refined in the next adapt() call Need to be called af...
Definition CpGridData.cpp:2682
int getGridIdx() const
Add doc/or remove method and replace it with better approach.
Definition CpGridData.hpp:490
bool hasNNCs(const std::vector< int > &cellIndices) const
Check all cells selected for refinement have no NNCs (no neighbor connections).
Definition CpGridData.cpp:2197
bool mark(int refCount, const cpgrid::Entity< 0 > &element)
Mark entity for refinement or coarsening.
Definition CpGridData.cpp:2660
std::vector< std::shared_ptr< Dune::cpgrid::CpGridData > > levelData() const
Add doc/or remove method and replace it with better approach.
Definition CpGridData.hpp:504
const cpgrid::IdSet & localIdSet() const
Get the local index set.
Definition CpGridData.hpp:613
bool adapt()
TO DO: Documentation. Triggers the grid refinement process - Currently, returns preAdapt()
Definition CpGridData.cpp:2698
void checkCuboidShape(const std::vector< int > &cellIdx_vec) const
Check that every cell to be refined has cuboid shape.
Definition CpGridData.cpp:1827
bool disjointPatches(const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec) const
Determine if a finite amount of patches (of cells) are disjoint, namely, they do not share any corner...
Definition CpGridData.cpp:1974
const std::vector< int > & sortedNumAquiferCells() const
Get sorted active cell indices of numerical aquifer.
Definition CpGridData.hpp:715
void validStartEndIJKs(const std::vector< std::array< int, 3 > > &startIJK_vec, const std::vector< std::array< int, 3 > > &endIJK_vec) const
Check startIJK and endIJK of each patch of cells to be refined are valid, i.e.
Definition CpGridData.cpp:2221
Definition DefaultGeometryPolicy.hpp:53
const EntityVariable< cpgrid::Geometry< 3 - codim, 3 >, codim > & geomVector() const
Definition DefaultGeometryPolicy.hpp:86
Wrapper that turns a data handle suitable for dune-grid into one based on integers instead of entitie...
Definition Entity2IndexDataHandle.hpp:56
A class design to hold a variable with a value for each entity of the given codimension,...
Definition EntityRep.hpp:272
Definition PartitionTypeIndicator.hpp:46
This class encapsulates geometry for vertices, intersections, and cells.
Definition Geometry.hpp:75
The global id set for Dune.
Definition Indexsets.hpp:431
Only needs to provide interface for doing nothing.
Definition Iterators.hpp:108
Definition Indexsets.hpp:196
Definition Indexsets.hpp:53
Definition Indexsets.hpp:349
Represents the topological relationships between sets of entities, for example cells and faces.
Definition OrientedEntityTable.hpp:139
A class design to hold a variable with a value for each entity of the given codimension,...
Definition EntityRep.hpp:307
A SparseTable stores a table with rows of varying size as efficiently as possible.
Definition SparseTable.hpp:55
Copyright 2019 Equinor AS.
Definition CartesianIndexMapper.hpp:10
Holds the implementation of the CpGrid as a pimple.
Definition CellQuadrature.cpp:68
Low-level corner-point processing routines and supporting data structures.
MPIHelper::MPICommunicator MPICommunicator
The type of the collective communication.
Definition CpGridDataTraits.hpp:55
AttributeSet
The type of the set of the attributes.
Definition CpGridDataTraits.hpp:65
Definition CpGridData.hpp:139
Raw corner-point specification of a particular geological model.
Definition preprocess.h:56