Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ms wells test #5747

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions compareECLFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ endfunction()
# - This test class compares the output from a parallel simulation
# to the output from the serial instance of the same model.
function(add_test_compare_parallel_simulation)
set(oneValueArgs CASENAME FILENAME SIMULATOR ABS_TOL REL_TOL DIR MPI_PROCS)
set(oneValueArgs CASENAME FILENAME SIMULATOR ABS_TOL REL_TOL DIR MPI_PROCS ONLY_SMRY)
set(multiValueArgs TEST_ARGS)
cmake_parse_arguments(PARAM "$" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )

Expand All @@ -210,7 +210,22 @@ function(add_test_compare_parallel_simulation)

set(RESULT_PATH ${BASE_RESULT_PATH}/parallel/${PARAM_SIMULATOR}+${PARAM_CASENAME})
set(TEST_ARGS ${OPM_TESTS_ROOT}/${PARAM_DIR}/${PARAM_FILENAME} ${PARAM_TEST_ARGS})
set(DRIVER_ARGS -i ${OPM_TESTS_ROOT}/${PARAM_DIR}

# Handle ONLY_SMRY flag (defaults to 0 if not provided)
if(PARAM_ONLY_SMRY)
if(${PARAM_ONLY_SMRY} EQUAL 1)
set(DRIVER_ARGS -s)
elseif(${PARAM_ONLY_SMRY} EQUAL 0)
set(DRIVER_ARGS "")
else()
message(FATAL_ERROR "ONLY_SMRY must be either 0 or 1.")
endif()
else()
set(DRIVER_ARGS "")
endif()

set(DRIVER_ARGS ${DRIVER_ARGS}
-i ${OPM_TESTS_ROOT}/${PARAM_DIR}
-r ${RESULT_PATH}
-b ${PROJECT_BINARY_DIR}/bin
-f ${PARAM_FILENAME}
Expand Down
9 changes: 4 additions & 5 deletions opm/simulators/flow/FlowGenericVanguard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,13 @@ void FlowGenericVanguard::init()
if (comm.rank() == 0)
{
std::string message =
std::string("Option --allow-distributed-wells=true is only allowed if model\n")
+ "only has only standard wells. You need to provide option \n"
+ " with --enable-multisegement-wells=false to treat existing \n"
std::string("Option --allow-distributed-wells=true in a model with\n")
+ "multisegment wells. This feature is still experimental. You can\n"
+ "set --enable-multisegment-wells=false to treat the existing \n"
+ "multisegment wells as standard wells.";
OpmLog::error(message);
OpmLog::info(message);
}
comm.barrier();
OPM_THROW(std::invalid_argument, "All wells need to be standard wells!");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion opm/simulators/wells/BlackoilWellModel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ namespace Opm {
this->wellState().init(cellPressures, cellTemperatures, this->schedule(), this->wells_ecl_,
this->local_parallel_well_info_, timeStepIdx,
&this->prevWellState(), this->well_perf_data_,
this->summaryState());
this->summaryState(), simulator_.vanguard().enableDistributedWells());
}


Expand Down
10 changes: 6 additions & 4 deletions opm/simulators/wells/WellState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,13 @@ void WellState<Scalar>::init(const std::vector<Scalar>& cellPressures,
const int report_step,
const WellState* prevState,
const std::vector<std::vector<PerforationData<Scalar>>>& well_perf_data,
const SummaryState& summary_state)
const SummaryState& summary_state,
const bool enableDistributedWells)
{
// call init on base class
this->base_init(cellPressures, cellTemperatures, wells_ecl, parallel_well_info,
well_perf_data, summary_state);
this->enableDistributedWells_ = enableDistributedWells;
this->global_well_info = std::make_optional<GlobalWellInfo>(schedule,
report_step,
wells_ecl);
Expand Down Expand Up @@ -439,7 +441,7 @@ void WellState<Scalar>::resize(const std::vector<Well>& wells_ecl,
const SummaryState& summary_state)
{
const std::vector<Scalar> tmp(numCells, 0.0); // <- UGLY HACK to pass the size
init(tmp, tmp, schedule, wells_ecl, parallel_well_info, 0, nullptr, well_perf_data, summary_state);
init(tmp, tmp, schedule, wells_ecl, parallel_well_info, 0, nullptr, well_perf_data, summary_state, this->enableDistributedWells_);

if (handle_ms_well) {
initWellStateMSWell(wells_ecl, nullptr);
Expand Down Expand Up @@ -728,8 +730,8 @@ void WellState<Scalar>::initWellStateMSWell(const std::vector<Well>& wells_ecl,
n_activeperf++;
}
}
if (static_cast<int>(ws.perf_data.size()) != n_activeperf)

if (!this->enableDistributedWells_ && static_cast<int>(ws.perf_data.size()) != n_activeperf)
throw std::logic_error("Distributed multi-segment wells cannot be initialized properly yet.");


Expand Down
5 changes: 4 additions & 1 deletion opm/simulators/wells/WellState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class WellState
const int report_step,
const WellState* prevState,
const std::vector<std::vector<PerforationData<Scalar>>>& well_perf_data,
const SummaryState& summary_state);
const SummaryState& summary_state,
const bool enableDistributedWells);

void resize(const std::vector<Well>& wells_ecl,
const std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>& parallel_well_info,
Expand Down Expand Up @@ -353,6 +354,8 @@ class WellState
}

private:
bool enableDistributedWells_ = false;

bool is_permanently_inactive_well(const std::string& wname) const {
return std::find(this->permanently_inactive_well_names_.begin(), this->permanently_inactive_well_names_.end(), wname) != this->permanently_inactive_well_names_.end();
}
Expand Down
21 changes: 21 additions & 0 deletions parallelTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ add_test_compare_parallel_simulation(CASENAME spe9_dist_z
REL_TOL ${rel_tol_parallel}
TEST_ARGS --linear-solver-reduction=1e-7 --tolerance-cnv=5e-6 --tolerance-mb=1e-8 --enable-drift-compensation=false)

# A test for distributed multisegment wells. We load distribute only along the z-axis
add_test_compare_parallel_simulation(CASENAME msw-simple
FILENAME MSW-SIMPLE # this file contains one Multisegment well without branches that is distributed across several processes
DIR msw
SIMULATOR flow_distribute_z
ONLY_SMRY 1
ABS_TOL 1e4 # the absolute tolerance is pretty high here, yet in this case, we are only interested in the relative tolerance
REL_TOL 1e-5
MPI_PROCS 4
TEST_ARGS --solver-max-time-step-in-days=10 --allow-distributed-wells=true)

add_test_compare_parallel_simulation(CASENAME msw-3d
FILENAME MSW-3D # this file contains one Multisegment well with branches that is distributed across several processes
DIR msw
SIMULATOR flow_distribute_z
ONLY_SMRY 1
ABS_TOL 1e4 # the absolute tolerance is pretty high here, yet in this case, we are only interested in the relative tolerance
REL_TOL 1e-4
MPI_PROCS 4
TEST_ARGS --allow-distributed-wells=true)

add_test_compare_parallel_simulation(CASENAME spe9group
FILENAME SPE9_CP_GROUP
SIMULATOR flow
Expand Down
22 changes: 15 additions & 7 deletions tests/run-parallel-regressionTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ then
echo -e "\t\t -e <filename> Simulator binary to use"
echo -e "\tOptional options:"
echo -e "\t\t -n <procs> Number of MPI processes to use"
echo -e "\t\t -s If given, compare only the SMRY file and skip comparison of the UNRST file."
exit 1
fi

MPI_PROCS=4
OPTIND=1
while getopts "i:r:b:f:a:t:c:e:n:" OPT
ONLY_SUMMARY=false

while getopts "i:r:b:f:a:t:c:e:n:s" OPT
do
case "${OPT}" in
i) INPUT_DATA_PATH=${OPTARG} ;;
Expand All @@ -35,6 +38,7 @@ do
c) COMPARE_ECL_COMMAND=${OPTARG} ;;
e) EXE_NAME=${OPTARG} ;;
n) MPI_PROCS=${OPTARG} ;;
s) ONLY_SUMMARY=true ;;
esac
done
shift $(($OPTIND-1))
Expand All @@ -61,12 +65,16 @@ then
${COMPARE_ECL_COMMAND} -t SMRY -a -R ${RESULT_PATH}/${FILENAME} ${RESULT_PATH}/mpi/${FILENAME} ${ABS_TOL} ${REL_TOL}
fi

echo "=== Executing comparison for restart file ==="
${COMPARE_ECL_COMMAND} -l -t UNRST ${RESULT_PATH}/${FILENAME} ${RESULT_PATH}/mpi/${FILENAME} ${ABS_TOL} ${REL_TOL}
if [ $? -ne 0 ]
then
ecode=1
${COMPARE_ECL_COMMAND} -a -l -t UNRST ${RESULT_PATH}/${FILENAME} ${RESULT_PATH}/mpi/${FILENAME} ${ABS_TOL} ${REL_TOL}
if [ "$ONLY_SUMMARY" = false ]; then
echo "=== Executing comparison for restart file ==="
${COMPARE_ECL_COMMAND} -l -t UNRST ${RESULT_PATH}/${FILENAME} ${RESULT_PATH}/mpi/${FILENAME} ${ABS_TOL} ${REL_TOL}
if [ $? -ne 0 ]
then
ecode=1
${COMPARE_ECL_COMMAND} -a -l -t UNRST ${RESULT_PATH}/${FILENAME} ${RESULT_PATH}/mpi/${FILENAME} ${ABS_TOL} ${REL_TOL}
fi
else
echo "=== Skipping comparison for restart file due to -s flag ==="
fi

exit $ecode
3 changes: 2 additions & 1 deletion tests/test_wellstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ namespace {

state.init(cpress, ctemp, setup.sched,
wells, ppinfos,
timeStep, nullptr, setup.well_perf_data, setup.st);
timeStep, nullptr, setup.well_perf_data, setup.st,
false /*enableDistributedWells*/);

state.initWellStateMSWell(setup.sched.getWells(timeStep),
nullptr);
Expand Down