Skip to content

Commit

Permalink
Add localToGlobal function to ParallelWellInfo class
Browse files Browse the repository at this point in the history
  • Loading branch information
lisajulia committed Sep 13, 2024
1 parent e3f6e62 commit 6e0d94c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions opm/simulators/wells/ParallelWellInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ GlobalPerfContainerFactory(const IndexSet& local_indices,
}
}

template<class Scalar>
int GlobalPerfContainerFactory<Scalar>::localToGlobal(int localIndex) const {
// todo: check why this does not work:
//return local_indices_[localIndex].global();
if (local_indices_.begin() == local_indices_.end())
return localIndex;
auto it = std::find_if(local_indices_.begin(), local_indices_.end(), [localIndex](const auto& index) {return index.local() == localIndex;});
if (it == local_indices_.end())
OPM_THROW(std::logic_error, "There is no global index for the localIndex " + std::to_string(localIndex) + ".");
return it->global();
}

template<class Scalar>
int GlobalPerfContainerFactory<Scalar>::globalToLocal(int globalIndex) const {
if (local_indices_.begin() == local_indices_.end())
Expand Down
1 change: 1 addition & 0 deletions opm/simulators/wells/ParallelWellInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class GlobalPerfContainerFactory

int numGlobalPerfs() const;
int globalToLocal(int globalIndex) const;
int localToGlobal(int localIndex) const;

private:
const IndexSet& local_indices_;
Expand Down

0 comments on commit 6e0d94c

Please sign in to comment.