mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-09-05 04:40:19 -05:00
Fixes test for WellStateFullyImplicitBlackoil
This commit is contained in:
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2020 OPM-OP AS
|
||||||
|
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services.
|
||||||
|
|
||||||
|
This file is part of the Open Porous Media project (OPM).
|
||||||
|
|
||||||
|
OPM is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OPM is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#ifndef OPM_SIMULATOR_TEST_MPIFIXTURE_HPP
|
||||||
|
#define OPM_SIMULATOR_TEST_MPIFIXTURE_HPP
|
||||||
|
|
||||||
|
#include <dune/common/parallel/mpihelper.hh>
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
class MPIError {
|
||||||
|
public:
|
||||||
|
/** @brief Constructor. */
|
||||||
|
MPIError(std::string s, int e) : errorstring(s), errorcode(e){}
|
||||||
|
/** @brief The error string. */
|
||||||
|
std::string errorstring;
|
||||||
|
/** @brief The mpi error code. */
|
||||||
|
int errorcode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_MPI
|
||||||
|
void MPI_err_handler(MPI_Comm *, int *err_code, ...){
|
||||||
|
char *err_string=new char[MPI_MAX_ERROR_STRING];
|
||||||
|
int err_length;
|
||||||
|
MPI_Error_string(*err_code, err_string, &err_length);
|
||||||
|
std::string s(err_string, err_length);
|
||||||
|
std::cerr << "An MPI Error ocurred:"<<std::endl<<s<<std::endl;
|
||||||
|
delete[] err_string;
|
||||||
|
throw MPIError(s, *err_code);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct MPIFixture
|
||||||
|
{
|
||||||
|
MPIFixture()
|
||||||
|
{
|
||||||
|
#if HAVE_MPI
|
||||||
|
int m_argc = boost::unit_test::framework::master_test_suite().argc;
|
||||||
|
char** m_argv = boost::unit_test::framework::master_test_suite().argv;
|
||||||
|
helper = &Dune::MPIHelper::instance(m_argc, m_argv);
|
||||||
|
#ifdef MPI_2
|
||||||
|
MPI_Comm_create_errhandler(MPI_err_handler, &handler);
|
||||||
|
MPI_Comm_set_errhandler(MPI_COMM_WORLD, handler);
|
||||||
|
#else
|
||||||
|
MPI_Errhandler_create(MPI_err_handler, &handler);
|
||||||
|
MPI_Errhandler_set(MPI_COMM_WORLD, handler);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
~MPIFixture()
|
||||||
|
{
|
||||||
|
#if HAVE_MPI
|
||||||
|
MPI_Finalize();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
Dune::MPIHelper* helper;
|
||||||
|
#if HAVE_MPI
|
||||||
|
MPI_Errhandler handler;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#define BOOST_TEST_MODULE WellStateFIBOTest
|
#define BOOST_TEST_MODULE WellStateFIBOTest
|
||||||
|
|
||||||
|
#include "MpiFixture.hpp"
|
||||||
#include <opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp>
|
#include <opm/simulators/wells/WellStateFullyImplicitBlackoil.hpp>
|
||||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||||
|
|
||||||
@@ -42,6 +43,8 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
BOOST_GLOBAL_FIXTURE(MPIFixture);
|
||||||
|
|
||||||
struct Setup
|
struct Setup
|
||||||
{
|
{
|
||||||
Setup(const std::string& filename)
|
Setup(const std::string& filename)
|
||||||
@@ -114,7 +117,8 @@ struct Setup
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Opm::WellStateFullyImplicitBlackoil
|
Opm::WellStateFullyImplicitBlackoil
|
||||||
buildWellState(const Setup& setup, const std::size_t timeStep)
|
buildWellState(const Setup& setup, const std::size_t timeStep,
|
||||||
|
std::vector<Opm::ParallelWellInfo>& pinfos)
|
||||||
{
|
{
|
||||||
auto state = Opm::WellStateFullyImplicitBlackoil{};
|
auto state = Opm::WellStateFullyImplicitBlackoil{};
|
||||||
|
|
||||||
@@ -123,7 +127,7 @@ namespace {
|
|||||||
100.0*Opm::unit::barsa);
|
100.0*Opm::unit::barsa);
|
||||||
|
|
||||||
auto wells = setup.sched.getWells(timeStep);
|
auto wells = setup.sched.getWells(timeStep);
|
||||||
std::vector<Opm::ParallelWellInfo> pinfos(wells.size());
|
pinfos.resize(wells.size());
|
||||||
std::vector<Opm::ParallelWellInfo*> ppinfos(wells.size());
|
std::vector<Opm::ParallelWellInfo*> ppinfos(wells.size());
|
||||||
auto pw = pinfos.begin();
|
auto pw = pinfos.begin();
|
||||||
auto ppw = ppinfos.begin();
|
auto ppw = ppinfos.begin();
|
||||||
@@ -132,6 +136,7 @@ namespace {
|
|||||||
{
|
{
|
||||||
*pw = {well.name()};
|
*pw = {well.name()};
|
||||||
*ppw = &(*pw);
|
*ppw = &(*pw);
|
||||||
|
pw->communicateFirstPerforation(true);
|
||||||
++pw;
|
++pw;
|
||||||
++ppw;
|
++ppw;
|
||||||
}
|
}
|
||||||
@@ -237,7 +242,8 @@ BOOST_AUTO_TEST_CASE(Linearisation)
|
|||||||
const Setup setup{ "msw.data" };
|
const Setup setup{ "msw.data" };
|
||||||
const auto tstep = std::size_t{0};
|
const auto tstep = std::size_t{0};
|
||||||
|
|
||||||
const auto wstate = buildWellState(setup, tstep);
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
||||||
|
const auto wstate = buildWellState(setup, tstep, pinfos);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(wstate.numSegment(), 6 + 1);
|
BOOST_CHECK_EQUAL(wstate.numSegment(), 6 + 1);
|
||||||
|
|
||||||
@@ -258,7 +264,8 @@ BOOST_AUTO_TEST_CASE(Pressure)
|
|||||||
const Setup setup{ "msw.data" };
|
const Setup setup{ "msw.data" };
|
||||||
const auto tstep = std::size_t{0};
|
const auto tstep = std::size_t{0};
|
||||||
|
|
||||||
auto wstate = buildWellState(setup, tstep);
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
||||||
|
auto wstate = buildWellState(setup, tstep, pinfos);
|
||||||
|
|
||||||
const auto& wells = setup.sched.getWells(tstep);
|
const auto& wells = setup.sched.getWells(tstep);
|
||||||
const auto prod01_first = wells[0].name() == "PROD01";
|
const auto prod01_first = wells[0].name() == "PROD01";
|
||||||
@@ -304,7 +311,8 @@ BOOST_AUTO_TEST_CASE(Rates)
|
|||||||
const Setup setup{ "msw.data" };
|
const Setup setup{ "msw.data" };
|
||||||
const auto tstep = std::size_t{0};
|
const auto tstep = std::size_t{0};
|
||||||
|
|
||||||
auto wstate = buildWellState(setup, tstep);
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
||||||
|
auto wstate = buildWellState(setup, tstep, pinfos);
|
||||||
|
|
||||||
const auto wells = setup.sched.getWells(tstep);
|
const auto wells = setup.sched.getWells(tstep);
|
||||||
const auto prod01_first = wells[0].name() == "PROD01";
|
const auto prod01_first = wells[0].name() == "PROD01";
|
||||||
@@ -375,7 +383,9 @@ BOOST_AUTO_TEST_CASE(STOP_well)
|
|||||||
also for wells in the STOP state.
|
also for wells in the STOP state.
|
||||||
*/
|
*/
|
||||||
const Setup setup{ "wells_manager_data_wellSTOP.data" };
|
const Setup setup{ "wells_manager_data_wellSTOP.data" };
|
||||||
auto wstate = buildWellState(setup, 0);
|
|
||||||
|
std::vector<Opm::ParallelWellInfo> pinfos;
|
||||||
|
auto wstate = buildWellState(setup, 0, pinfos);
|
||||||
for (const auto& p : wstate.perfPress())
|
for (const auto& p : wstate.perfPress())
|
||||||
BOOST_CHECK(p > 0);
|
BOOST_CHECK(p > 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user