24 #ifndef OPM_COLLECT_DATA_ON_IO_RANK_IMPL_HPP 25 #define OPM_COLLECT_DATA_ON_IO_RANK_IMPL_HPP 27 #include <opm/simulators/flow/CollectDataOnIORank.hpp> 29 #include <dune/common/version.hh> 30 #include <dune/grid/common/gridenums.hh> 31 #include <dune/grid/common/mcmgmapper.hh> 32 #include <dune/grid/common/partitionset.hh> 34 #include <opm/grid/common/CartesianIndexMapper.hpp> 44 #include <type_traits> 64 { isInterior_ =
false; }
66 void setId(
int globalId)
67 { globalId_ = globalId; }
68 void setIndex(
int localIndex)
69 { localIndex_ = localIndex; }
71 int localIndex ()
const 72 {
return localIndex_; }
75 bool isInterior()
const 76 {
return isInterior_; }
79 using IndexMapType = std::vector<int>;
80 using IndexMapStorageType = std::vector<IndexMapType>;
81 using P2PCommunicatorType = Dune::Point2PointCommunicator<Dune::SimpleMessageBuffer>;
82 using MessageBufferType =
typename P2PCommunicatorType::MessageBufferType;
86 const std::vector<int>& distributedGlobalIndex_;
87 IndexMapType& localIndexMap_;
88 IndexMapStorageType& indexMaps_;
89 std::map<int, int> globalPosition_;
91 std::vector<int>& ranks_;
95 const std::vector<int>& distributedGlobalIndex,
96 IndexMapType& localIndexMap,
97 IndexMapStorageType& indexMaps,
98 std::vector<int>& ranks,
101 : distributedGlobalIndex_(distributedGlobalIndex)
102 , localIndexMap_(localIndexMap)
103 , indexMaps_(indexMaps)
108 std::size_t size = globalIndex.size();
111 for (std::size_t index = 0; index < size; ++index)
112 globalPosition_.insert(std::make_pair(globalIndex[index], index));
115 if (!indexMaps_.empty()) {
117 ranks_.resize(size, -1);
119 IndexMapType& indexMap = indexMaps_.back();
120 std::size_t localSize = localIndexMap_.size();
121 indexMap.resize(localSize);
122 for (std::size_t i = 0; i < localSize; ++i)
124 int id = distributedGlobalIndex_[localIndexMap_[i]];
132 if (!indexMaps_.size())
137 auto rankIt = recv_.begin();
139 for (
auto& indexMap: indexMaps_)
142 if (rankIt != recv_.end())
145 for (
auto&& entry: indexMap)
147 auto candidate = globalPosition_.find(entry);
148 assert(candidate != globalPosition_.end());
149 entry = candidate->second;
151 ranks_[entry] = std::max(ranks_[entry], rank);
153 if (rankIt != recv_.end())
157 for (
const auto& rank: ranks_)
163 void pack(
int link, MessageBufferType& buffer)
167 throw std::logic_error(
"link in method pack is not 0 as execpted");
170 int size = localIndexMap_.size();
173 for (
int index = 0; index < size; ++index) {
174 int globalIdx = distributedGlobalIndex_[localIndexMap_[index]];
175 buffer.write(globalIdx);
179 void unpack(
int link, MessageBufferType& buffer)
182 IndexMapType& indexMap = indexMaps_[link];
183 assert(!globalPosition_.empty());
187 buffer.read(numCells);
188 indexMap.resize(numCells);
189 for (
int index = 0; index < numCells; ++index) {
190 buffer.read(indexMap[index]);
197 template<
class EquilMapper,
class Mapper>
202 : sendMapper_(sendMapper), recvMapper_(recvMapper), elementIndices_(elementIndices)
204 using DataType = int;
205 bool fixedSize(
int ,
int )
211 std::size_t size(
const T&)
215 template<
class B,
class T>
216 void gather(B& buffer,
const T& t)
218 buffer.write(sendMapper_.index(t));
220 template<
class B,
class T>
221 void scatter(B& buffer,
const T& t, std::size_t)
223 buffer.read(elementIndices_[recvMapper_.index(t)]);
226 bool contains(
int dim,
int codim)
228 return dim==3 && codim==0;
231 const EquilMapper& sendMapper_;
232 const Mapper& recvMapper_;
233 std::vector<int>& elementIndices_;
237 template<
class Mapper>
242 : mapper_(mapper), elementIndices_(elementIndices)
244 using DataType = int;
245 bool fixedSize(
int ,
int )
251 std::size_t size(
const T&)
255 template<
class B,
class T>
256 void gather(B& buffer,
const T& t)
258 buffer.write(elementIndices_[mapper_.index(t)]);
260 template<
class B,
class T>
261 void scatter(B& buffer,
const T& t, std::size_t)
263 buffer.read(elementIndices_[mapper_.index(t)]);
266 bool contains(
int dim,
int codim)
268 return dim==3 && codim==0;
271 const Mapper& mapper_;
272 std::vector<int>& elementIndices_;
277 const data::Solution& localCellData_;
278 data::Solution& globalCellData_;
280 const IndexMapType& localIndexMap_;
281 const IndexMapStorageType& indexMaps_;
285 data::Solution& globalCellData,
286 const IndexMapType& localIndexMap,
287 const IndexMapStorageType& indexMaps,
288 std::size_t globalSize,
290 : localCellData_(localCellData)
291 , globalCellData_(globalCellData)
292 , localIndexMap_(localIndexMap)
293 , indexMaps_(indexMaps)
297 for (
const auto& pair : localCellData_) {
298 const std::string& key = pair.first;
299 std::size_t containerSize = globalSize;
300 [[maybe_unused]]
auto ret = globalCellData_.insert(key, pair.second.dim,
301 std::vector<double>(containerSize),
306 MessageBufferType buffer;
310 doUnpack(indexMaps.back(), buffer);
315 void pack(
int link, MessageBufferType& buffer)
319 throw std::logic_error(
"link in method pack is not 0 as expected");
322 for (
const auto& pair : localCellData_) {
323 const auto& data = pair.second.data<
double>();
326 write(buffer, localIndexMap_, data);
330 void doUnpack(
const IndexMapType& indexMap, MessageBufferType& buffer)
334 for (
auto& pair : localCellData_) {
335 const std::string& key = pair.first;
336 auto& data = globalCellData_.data<
double>(key);
339 read(buffer, indexMap, data);
344 void unpack(
int link, MessageBufferType& buffer)
345 { doUnpack(indexMaps_[link], buffer); }
348 template <
class Vector>
349 void write(MessageBufferType& buffer,
350 const IndexMapType& localIndexMap,
351 const Vector& vector,
352 unsigned int offset = 0,
353 unsigned int stride = 1)
const 355 unsigned int size = localIndexMap.size();
357 assert(vector.size() >= stride * size);
358 for (
unsigned int i=0; i<size; ++i)
360 unsigned int index = localIndexMap[i] * stride + offset;
361 assert(index < vector.size());
362 buffer.write(vector[index]);
366 template <
class Vector>
367 void read(MessageBufferType& buffer,
368 const IndexMapType& indexMap,
370 unsigned int offset = 0,
371 unsigned int stride = 1)
const 373 unsigned int size = 0;
375 assert(size == indexMap.size());
376 for (
unsigned int i=0; i<size; ++i) {
377 unsigned int index = indexMap[i] * stride + offset;
378 assert(index < vector.size());
379 buffer.read(vector[index]);
386 const data::Wells& localWellData_;
387 data::Wells& globalWellData_;
391 data::Wells& globalWellData,
393 : localWellData_(localWellData)
394 , globalWellData_(globalWellData)
397 MessageBufferType buffer;
402 unpack(dummyLink, buffer);
407 void pack(
int link, MessageBufferType& buffer)
411 throw std::logic_error(
"link in method pack is not 0 as expected");
413 localWellData_.write(buffer);
417 void unpack(
int , MessageBufferType& buffer)
418 { globalWellData_.read(buffer); }
424 const data::GroupAndNetworkValues& localGroupAndNetworkData_;
425 data::GroupAndNetworkValues& globalGroupAndNetworkData_;
429 data::GroupAndNetworkValues& globalGroupAndNetworkData,
431 : localGroupAndNetworkData_ (localGroupAndNetworkData)
432 , globalGroupAndNetworkData_(globalGroupAndNetworkData)
434 if (! isIORank) {
return; }
436 MessageBufferType buffer;
437 this->pack(0, buffer);
440 const int dummyLink = -1;
441 this->unpack(dummyLink, buffer);
445 void pack(
int link, MessageBufferType& buffer)
449 throw std::logic_error {
450 "link in method pack is not 0 as expected" 455 this->localGroupAndNetworkData_.write(buffer);
459 void unpack(
int , MessageBufferType& buffer)
460 { this->globalGroupAndNetworkData_.read(buffer); }
471 template <
typename C>
472 concept MapLikeContainer =
473 std::ranges::input_range<C> &&
475 typename C::key_type;
476 typename C::mapped_type;
478 requires (C& container,
479 const typename C::key_type& key,
480 typename C::mapped_type value)
482 { container.insert_or_assign(key, std::move(value)) };
487 template <MapLikeContainer C>
488 using KeyTypeOf = std::remove_const_t<typename std::ranges::range_value_t<C>::first_type>;
490 template <MapLikeContainer C>
491 using MappedTypeOf =
typename std::ranges::range_value_t<C>::second_type;
493 template <MapLikeContainer KeyedMap,
class MessageBufferType>
494 void packKeyedBlockMap(
const KeyedMap& localData, MessageBufferType& buffer)
496 const unsigned int size = localData.size();
498 for (
const auto& [key, value] : localData) {
499 std::apply([&buffer](
const auto&... field) { (buffer.write(field), ...); }, key);
504 template <MapLikeContainer KeyedMap,
class MessageBufferType>
505 void unpackKeyedBlockMap(KeyedMap& globalData, MessageBufferType& buffer)
507 unsigned int size = 0;
512 if constexpr (requires (KeyedMap& m, std::size_t n) { m.reserve(n); }) {
513 globalData.reserve(globalData.size() + size);
516 for (
unsigned int i = 0; i < size; ++i) {
517 KeyTypeOf<KeyedMap> key{};
518 std::apply([&buffer](
auto&... field) { (buffer.read(field), ...); }, key);
520 MappedTypeOf<KeyedMap> value{};
526 globalData.insert_or_assign(std::move(key), std::move(value));
532 const std::map<std::pair<std::string, int>,
double>& localBlockData_;
533 std::map<std::pair<std::string, int>,
double>& globalBlockValues_;
537 std::map<std::pair<std::string, int>,
double>& globalBlockValues,
539 : localBlockData_(localBlockData)
540 , globalBlockValues_(globalBlockValues)
543 MessageBufferType buffer;
548 unpack(dummyLink, buffer);
553 void pack(
int link, MessageBufferType& buffer)
557 throw std::logic_error(
"link in method pack is not 0 as expected");
559 packKeyedBlockMap(localBlockData_, buffer);
563 void unpack(
int , MessageBufferType& buffer)
565 unpackKeyedBlockMap(globalBlockValues_, buffer);
571 const std::map<std::tuple<std::string, int, int>,
double>& localLgrBlockData_;
572 std::map<std::tuple<std::string, int, int>,
double>& globalLgrBlockValues_;
576 std::map<std::tuple<std::string, int, int>,
double>& globalLgrBlockValues,
578 : localLgrBlockData_(localLgrBlockData)
579 , globalLgrBlockValues_(globalLgrBlockValues)
582 MessageBufferType buffer;
587 unpack(dummyLink, buffer);
592 void pack(
int link, MessageBufferType& buffer)
596 throw std::logic_error(
"link in method pack is not 0 as expected");
599 packKeyedBlockMap(localLgrBlockData_, buffer);
603 void unpack(
int , MessageBufferType& buffer)
605 unpackKeyedBlockMap(globalLgrBlockValues_, buffer);
611 const data::WellBlockAveragePressures& localWBPData_;
612 data::WellBlockAveragePressures& globalWBPValues_;
616 data::WellBlockAveragePressures& globalWBPValues,
618 : localWBPData_ (localWBPData)
619 , globalWBPValues_(globalWBPValues)
625 MessageBufferType buffer;
629 const int dummyLink = -1;
630 unpack(dummyLink, buffer);
634 void pack(
int link, MessageBufferType& buffer)
638 throw std::logic_error {
639 "link (" + std::to_string(link) +
640 ") in method pack() is not 0 as expected" 645 this->localWBPData_.write(buffer);
649 void unpack([[maybe_unused]]
const int link,
650 MessageBufferType& buffer)
652 this->globalWBPValues_.read(buffer);
660 WellTestState& globalWTestState,
662 : local_(localWTestState)
663 , global_(globalWTestState)
666 MessageBufferType buffer;
671 unpack(dummyLink, buffer);
675 void pack(
int link, MessageBufferType& buffer) {
677 throw std::logic_error(
"link in method pack is not 0 as expected");
678 this->local_.pack(buffer);
681 void unpack(
int, MessageBufferType& buffer) {
682 this->global_.unpack(buffer);
686 const WellTestState& local_;
687 WellTestState& global_;
692 const data::Aquifers& localAquiferData_;
693 data::Aquifers& globalAquiferData_;
697 data::Aquifers& globalAquiferData,
699 : localAquiferData_(localAquiferData)
700 , globalAquiferData_(globalAquiferData)
703 MessageBufferType buffer;
708 unpack(dummyLink, buffer);
713 void pack(
int link, MessageBufferType& buffer)
717 throw std::logic_error(
"link in method pack is not 0 as expected");
719 int size = localAquiferData_.size();
721 for (
const auto& [key, data] : localAquiferData_) {
728 void unpack(
int , MessageBufferType& buffer)
732 for (
int i = 0; i < size; ++i) {
735 data::AquiferData data;
738 auto& aq = this->globalAquiferData_[key];
740 this->unpackCommon(data, aq);
742 if (
auto const* aquFet = data.typeData.get<data::AquiferType::Fetkovich>();
745 this->unpackAquFet(*aquFet, aq);
747 else if (
auto const* aquCT = data.typeData.get<data::AquiferType::CarterTracy>();
750 this->unpackCarterTracy(*aquCT, aq);
752 else if (
auto const* aquNum = data.typeData.get<data::AquiferType::Numerical>();
755 this->unpackNumericAquifer(*aquNum, aq);
761 void unpackCommon(
const data::AquiferData& data, data::AquiferData& aq)
763 aq.aquiferID = std::max(aq.aquiferID, data.aquiferID);
764 aq.pressure = std::max(aq.pressure, data.pressure);
765 aq.initPressure = std::max(aq.initPressure, data.initPressure);
766 aq.datumDepth = std::max(aq.datumDepth, data.datumDepth);
767 aq.fluxRate += data.fluxRate;
768 aq.volume += data.volume;
771 void unpackAquFet(
const data::FetkovichData& aquFet, data::AquiferData& aq)
773 if (! aq.typeData.is<data::AquiferType::Fetkovich>()) {
774 auto* tData = aq.typeData.create<data::AquiferType::Fetkovich>();
778 const auto& src = aquFet;
779 auto& dst = *aq.typeData.getMutable<data::AquiferType::Fetkovich>();
781 dst.initVolume = std::max(dst.initVolume , src.initVolume);
782 dst.prodIndex = std::max(dst.prodIndex , src.prodIndex);
783 dst.timeConstant = std::max(dst.timeConstant, src.timeConstant);
787 void unpackCarterTracy(
const data::CarterTracyData& aquCT, data::AquiferData& aq)
789 if (! aq.typeData.is<data::AquiferType::CarterTracy>()) {
790 auto* tData = aq.typeData.create<data::AquiferType::CarterTracy>();
794 const auto& src = aquCT;
795 auto& dst = *aq.typeData.getMutable<data::AquiferType::CarterTracy>();
797 dst.timeConstant = std::max(dst.timeConstant , src.timeConstant);
798 dst.influxConstant = std::max(dst.influxConstant, src.influxConstant);
799 dst.waterDensity = std::max(dst.waterDensity , src.waterDensity);
800 dst.waterViscosity = std::max(dst.waterViscosity, src.waterViscosity);
802 dst.dimensionless_time = std::max(dst.dimensionless_time , src.dimensionless_time);
803 dst.dimensionless_pressure = std::max(dst.dimensionless_pressure, src.dimensionless_pressure);
807 void unpackNumericAquifer(
const data::NumericAquiferData& aquNum, data::AquiferData& aq)
809 if (! aq.typeData.is<data::AquiferType::Numerical>()) {
810 auto* tData = aq.typeData.create<data::AquiferType::Numerical>();
814 const auto& src = aquNum;
815 auto& dst = *aq.typeData.getMutable<data::AquiferType::Numerical>();
817 std::ranges::transform(src.initPressure, dst.initPressure, dst.initPressure.begin(),
818 [](
const double p0_1,
const double p0_2)
819 {
return std::max(p0_1, p0_2); });
833 : localInterRegFlows_(localInterRegFlows)
834 , globalInterRegFlows_(globalInterRegFlows)
836 if (! isIORank) {
return; }
838 MessageBufferType buffer;
839 this->pack(0, buffer);
842 const int dummyLink = -1;
843 this->unpack(dummyLink, buffer);
847 void pack(
int link, MessageBufferType& buffer)
851 throw std::logic_error {
852 "link in method pack is not 0 as expected" 857 this->localInterRegFlows_.
write(buffer);
861 void unpack(
int , MessageBufferType& buffer)
862 { this->globalInterRegFlows_.
read(buffer); }
867 const std::array<FlowsData<double>, 3>& localFlows_;
868 std::array<FlowsData<double>, 3>& globalFlows_;
874 : localFlows_(localFlows)
875 , globalFlows_(globalFlows)
877 if (! isIORank) {
return; }
879 MessageBufferType buffer;
880 this->pack(0, buffer);
883 const int dummyLink = -1;
884 this->unpack(dummyLink, buffer);
887 void pack(
int link, MessageBufferType& buffer)
890 throw std::logic_error(
"link in method pack is not 0 as expected");
891 for (
int i = 0; i < 3; ++i) {
892 const auto& name = localFlows_[i].name;
894 const std::size_t size = localFlows_[i].indices.size();
896 for (std::size_t j = 0; j < size; ++j) {
897 const auto& nncIdx = localFlows_[i].indices[j];
898 buffer.write(nncIdx);
899 const auto& flows = localFlows_[i].values[j];
905 void unpack(
int , MessageBufferType& buffer)
907 for (
int i = 0; i < 3; ++i) {
910 globalFlows_[i].name = name;
911 std::size_t size = 0;
913 for (
unsigned int j = 0; j < size; ++j) {
921 globalFlows_[i].values[nncIdx] = data;
927 template <
class Gr
id,
class EquilGr
id,
class Gr
idView>
930 const GridView& localGridView,
933 const std::set<std::string>& fipRegionsInterregFlow)
934 : toIORankComm_(grid.comm())
936 fipRegionsInterregFlow.begin(),
937 fipRegionsInterregFlow.end()
941 if ((!needsReordering && !isParallel()) || (isParallel() && (grid.maxLevel()>0)))
944 const CollectiveCommunication& comm = grid.comm();
947 std::set<int> send, recv;
948 using EquilGridView =
typename EquilGrid::LeafGridView;
949 typename std::is_same<Grid, EquilGrid>::type isSameGrid;
951 typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView> ElementMapper;
952 ElementMapper elemMapper(localGridView, Dune::mcmgElementLayout());
953 sortedCartesianIdx_.reserve(localGridView.size(0));
955 for (
const auto& elem : elements(localGridView, Dune::Partitions::interior))
957 auto idx = elemMapper.index(elem);
958 sortedCartesianIdx_.push_back(cartMapper.cartesianIndex(idx));
961 std::ranges::sort(sortedCartesianIdx_);
962 localIdxToGlobalIdx_.resize(localGridView.size(0), -1);
969 const std::size_t globalSize = equilGrid->leafGridView().size(0);
970 globalCartesianIndex_.resize(globalSize, -1);
971 const EquilGridView equilGridView = equilGrid->leafGridView();
973 using EquilElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper<EquilGridView>;
974 EquilElementMapper equilElemMapper(equilGridView, Dune::mcmgElementLayout());
977 if constexpr (isSameGrid) {
978 ElementIndexScatterHandle<EquilElementMapper,ElementMapper> handle(equilElemMapper, elemMapper, localIdxToGlobalIdx_);
979 grid.scatterData(handle);
983 for (
const auto& elem : elements(equilGrid->leafGridView())) {
984 int elemIdx = equilElemMapper.index(elem);
985 int cartElemIdx = equilCartMapper->cartesianIndex(elemIdx);
986 globalCartesianIndex_[elemIdx] = cartElemIdx;
989 for (
int i = 0; i < comm.size(); ++i) {
1002 if constexpr (isSameGrid) {
1003 ElementIndexScatterHandle<ElementMapper, ElementMapper> handle(elemMapper, elemMapper, localIdxToGlobalIdx_);
1004 grid.scatterData(handle);
1009 if constexpr (isSameGrid) {
1010 ElementIndexHandle<ElementMapper> handle(elemMapper, localIdxToGlobalIdx_);
1011 grid.communicate(handle, Dune::InteriorBorder_All_Interface,
1012 Dune::ForwardCommunication);
1015 localIndexMap_.clear();
1016 const std::size_t gridSize = grid.size(0);
1017 localIndexMap_.reserve(gridSize);
1020 IndexMapType distributedCartesianIndex;
1021 distributedCartesianIndex.resize(gridSize, -1);
1024 for (
const auto& elem : elements(localGridView, Dune::Partitions::interior)) {
1025 int elemIdx = elemMapper.index(elem);
1026 distributedCartesianIndex[elemIdx] = cartMapper.cartesianIndex(elemIdx);
1029 assert(elem.partitionType() == Dune::InteriorEntity);
1031 localIndexMap_.push_back(elemIdx);
1035 toIORankComm_.insertRequest(send, recv);
1039 indexMaps_.resize(comm.size());
1042 DistributeIndexMapping distIndexMapping(globalCartesianIndex_,
1043 distributedCartesianIndex,
1049 toIORankComm_.exchange(distIndexMapping);
1053 template <
class Gr
id,
class EquilGr
id,
class Gr
idView>
1054 void CollectDataOnIORank<Grid,EquilGrid,GridView>::
1055 collect(
const data::Solution& localCellData,
1056 const std::map<std::pair<std::string, int>,
double>& localBlockData,
1057 std::map<std::pair<std::string, int>,
double>& extraBlockData,
1058 const data::Wells& localWellData,
1059 const data::WellBlockAveragePressures& localWBPData,
1060 const data::GroupAndNetworkValues& localGroupAndNetworkData,
1061 const data::Aquifers& localAquiferData,
1062 const WellTestState& localWellTestState,
1063 const InterRegFlowMap& localInterRegFlows,
1064 const std::array<FlowsData<double>, 3>& localFlowsn,
1065 const std::array<FlowsData<double>, 3>& localFloresn,
1066 const std::map<std::tuple<std::string, int, int>,
double>& localLgrBlockData)
1068 globalCellData_ = {};
1069 globalBlockData_.clear();
1070 globalLgrBlockData_.clear();
1071 std::map<std::pair<std::string,int>,
double> globalExtraBlockData;
1072 globalWellData_.clear();
1073 globalWBPData_.values.clear();
1074 globalGroupAndNetworkData_.clear();
1075 globalAquiferData_.clear();
1076 globalWellTestState_.clear();
1077 this->globalInterRegFlows_.clear();
1079 globalFloresn_ = {};
1082 if(!needsReordering && !isParallel())
1086 PackUnPackCellData packUnpackCellData {
1088 this->globalCellData_,
1089 this->localIndexMap_,
1095 if (! isParallel()) {
1101 for (
int i = 0; i < 3; ++i) {
1102 const std::size_t sizeFlr = localFloresn[i].indices.size();
1103 globalFloresn_[i].resize(sizeFlr);
1104 const std::size_t sizeFlo = localFlowsn[i].indices.size();
1105 globalFlowsn_[i].resize(sizeFlo);
1108 PackUnPackWellData packUnpackWellData {
1110 this->globalWellData_,
1114 PackUnPackGroupAndNetworkValues packUnpackGroupAndNetworkData {
1115 localGroupAndNetworkData,
1116 this->globalGroupAndNetworkData_,
1120 PackUnPackBlockData packUnpackBlockData {
1122 this->globalBlockData_,
1126 PackUnPackBlockData packUnpackExtraBlockData {
1128 globalExtraBlockData,
1132 PackUnPackLgrBlockData packUnpackLgrBlockData {
1134 this->globalLgrBlockData_,
1138 PackUnPackWBPData packUnpackWBPData {
1140 this->globalWBPData_,
1144 PackUnPackAquiferData packUnpackAquiferData {
1146 this->globalAquiferData_,
1150 PackUnPackWellTestState packUnpackWellTestState {
1152 this->globalWellTestState_,
1156 PackUnpackInterRegFlows packUnpackInterRegFlows {
1158 this->globalInterRegFlows_,
1162 PackUnpackFlows packUnpackFlowsn {
1164 this->globalFlowsn_,
1168 PackUnpackFlows packUnpackFloresn {
1170 this->globalFloresn_,
1174 toIORankComm_.exchange(packUnpackCellData);
1175 toIORankComm_.exchange(packUnpackWellData);
1176 toIORankComm_.exchange(packUnpackGroupAndNetworkData);
1177 toIORankComm_.exchange(packUnpackBlockData);
1178 toIORankComm_.exchange(packUnpackExtraBlockData);
1179 toIORankComm_.exchange(packUnpackLgrBlockData);
1180 toIORankComm_.exchange(packUnpackWBPData);
1181 toIORankComm_.exchange(packUnpackAquiferData);
1182 toIORankComm_.exchange(packUnpackWellTestState);
1183 toIORankComm_.exchange(packUnpackInterRegFlows);
1184 toIORankComm_.exchange(packUnpackFlowsn);
1185 toIORankComm_.exchange(packUnpackFloresn);
1189 toIORankComm_.barrier();
1192 extraBlockData = globalExtraBlockData;
1195 template <
class Gr
id,
class EquilGr
id,
class Gr
idView>
1196 int CollectDataOnIORank<Grid,EquilGrid,GridView>::
1197 localIdxToGlobalIdx(
unsigned localIdx)
const 1199 if (!isParallel()) {
1203 if (this->localIdxToGlobalIdx_.empty()) {
1204 throw std::logic_error(
"index map is not created on this rank");
1207 if (localIdx >= this->localIdxToGlobalIdx_.size()) {
1208 throw std::logic_error(
"local index is outside map range");
1211 return this->localIdxToGlobalIdx_[localIdx];
1214 template <
class Gr
id,
class EquilGr
id,
class Gr
idView>
1215 bool CollectDataOnIORank<Grid,EquilGrid,GridView>::
1216 isCartIdxOnThisRank(
int cartIdx)
const 1218 if (! this->isParallel()) {
1222 assert (! needsReordering);
1224 auto candidate = std::lower_bound(this->sortedCartesianIdx_.begin(),
1225 this->sortedCartesianIdx_.end(),
1228 return (candidate != sortedCartesianIdx_.end())
1229 && (*candidate == cartIdx);
1234 #endif // OPM_COLLECT_DATA_ON_IO_RANK_IMPL_HPP Definition: CollectDataOnIORank_impl.hpp:865
Definition: CollectDataOnIORank_impl.hpp:422
Definition: CollectDataOnIORank_impl.hpp:690
void read(MessageBufferType &buffer)
Reconstitute internal object representation from MPI message buffer.
Definition: InterRegFlows.hpp:323
Communication handle to scatter the global index.
Definition: CollectDataOnIORank_impl.hpp:238
Definition: CollectDataOnIORank.hpp:56
Definition: CollectDataOnIORank_impl.hpp:51
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
Definition: CollectDataOnIORank_impl.hpp:530
Inter-region flow accumulation maps for all region definition arrays.
Definition: InterRegFlows.hpp:178
void write(MessageBufferType &buffer) const
Serialise internal representation to MPI message buffer.
Definition: InterRegFlows.hpp:296
Communication handle to scatter the global index.
Definition: CollectDataOnIORank_impl.hpp:198
Definition: CollectDataOnIORank_impl.hpp:275
Definition: CollectDataOnIORank_impl.hpp:569
Definition: CollectDataOnIORank_impl.hpp:824
Simple container for FLOWS data.
Definition: FlowsData.hpp:31
Definition: CollectDataOnIORank_impl.hpp:609
Definition: CollectDataOnIORank_impl.hpp:83
Definition: CollectDataOnIORank_impl.hpp:384
Definition: CollectDataOnIORank_impl.hpp:656
Definition: CollectDataOnIORank.hpp:50