Utility for checking connections of distributed well.

This commit is contained in:
Markus Blatt 2020-11-27 18:18:40 +01:00
parent 3d92e41cad
commit 317e29d15a
2 changed files with 69 additions and 1 deletions

View File

@ -18,6 +18,7 @@
*/
#include <config.h>
#include <opm/simulators/wells/ParallelWellInfo.hpp>
#include <opm/common/ErrorMacros.hpp>
namespace Opm
{
@ -113,4 +114,47 @@ bool operator!=(const ParallelWellInfo& well, const std::pair<std::string, bool>
{
return pair != well;
}
CheckDistributedWellConnections::CheckDistributedWellConnections(const Well& well,
const ParallelWellInfo& info)
: well_(well), pwinfo_(info)
{
foundConnections_.resize(well.getConnections().size(), 0);
}
void
CheckDistributedWellConnections::connectionFound(std::size_t i)
{
foundConnections_[i] = 1;
}
bool
CheckDistributedWellConnections::checkAllConnectionsFound()
{
// Ecl does not hold any information of remote connections.
assert(pwinfo_.communication().max(foundConnections_.size()) == foundConnections_.size());
pwinfo_.communication().sum(foundConnections_.data(),
foundConnections_.size());
std::string msg = std::string("Cells with these i,j,k indices were not found ")
+ "in grid (well = " + pwinfo_.name() + "):";
bool missingCells = false;
auto start = foundConnections_.begin();
for(auto conFound = start; conFound != foundConnections_.end(); ++conFound)
{
if (*conFound == 0)
{
const auto& completion = well_.getConnections()[conFound - start];
msg = msg + " " + std::to_string(completion.getI()) + "," +
std::to_string(completion.getJ()) + ","
+ std::to_string(completion.getK()) + " ";
missingCells = true;
}
}
if (missingCells && pwinfo_.isOwner())
{
OPM_THROW(std::runtime_error, msg);
}
return !missingCells;
}
} // end namespace Opm

View File

@ -17,11 +17,13 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_PARALLELWELLINFO_HEADER_INCLUDED
#define OPM_PARALLELWELLINFO_HEADER_INCLUDED
#define OPM_PARALLELWELLINFO_HEADER_INCLUDED
#include <dune/common/version.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp>
#include <memory>
namespace Opm
@ -96,6 +98,28 @@ private:
std::unique_ptr<Communication, DestroyComm> comm_;
};
/// \brief Class checking that all connections are on active cells
///
/// Works for distributed wells, too
class CheckDistributedWellConnections
{
public:
CheckDistributedWellConnections(const Well& well,
const ParallelWellInfo& info);
/// \brief Inidicate that the i-th completion was found
///
/// in the local grid.
/// \param index The index of the completion in Well::getConnections
void connectionFound(std::size_t index);
bool checkAllConnectionsFound();
private:
std::vector<std::size_t> foundConnections_;
const Well& well_;
const ParallelWellInfo& pwinfo_;
};
bool operator<(const ParallelWellInfo& well1, const ParallelWellInfo& well2);
bool operator==(const ParallelWellInfo& well1, const ParallelWellInfo& well2);