split in API specific classes for Cuda/OpenCL
this to
1) it's cleaner
2) it avoids pulling in openCL code in cuda classes which leads
to clashes between nvidia headers and opencl.hpp
there is still too much API specific things in interface between the
bda components to work through a virtual interface so we still have to cast
to the relevant implementation in various places.
OpenCL header was included and OpenclKernels used unconditionally
in WellContributions.cpp. As this file is compiled if CUDA is found,
too it lead to undefined references for e.g. cl::CommandQueue if
opencl headers were there and compile error if not.
annoyingly, dune has a casting operator for mpicollectivecommunication
-> MPIComm but for some reason does not have a casting operator for
the dummy collectivecommunication -> No_Comm
Removed message in amgclbackend was:
warning: catching polymorphic type ‘class
boost::property_tree::json_parser::json_parser_error’ by value
[-Wcatch-value=]
The reduction rate is computed differently for cases without wells under GRUP
For a well to check whether to switch to GRUP it needed to use the reduction rate
that would have been computed if this particular well was under GRUP control
and thus recompute the reduction rate without entering the no-grup path
This commit extends the guide rate reporting to always extracting
and reporting pertinent production guide rates at the well level
(i.e., WxPGR) if at least one of the groups in the well's upline has
an entry in GCONPROD. This is for increased compatibility with
ECLIPSE.
This commit uses the new GroupTreeWalker helper class to ensure that
we always extract and report pertinent injection guide rates at the
well level (i.e., WxIGR) if at least one of the groups in the well's
upline has an entry for the corresponding phase in GCONINJE. This
is for increased compatibility with ECLIPSE.
Prior to this change we would report zero-valued WWIGR vectors on a
real field case which made analysing simulation results needlessly
difficult.
This commit extracts a helper class, GroupTreeWalker, from the
current implementation of 'calculateAllGroupGuiderates()'. This is
in preparation of adding a similar approach to extracting WxIGR for
all wells for which at least one group in the upline has an entry in
GCONINJE.
The user can add visitor operations for wells and groups, typically
with side effects, and then choose whether to run a pre-order walk
(visit groups before their children) or a post-order walk (visit
children-i.e., wells, before their parents).
The class ISTLSolverEbos has all features of the removed class, and
is not much more complex. The flow_blackoil_dunecpr is the only
program using it, and is redundant.
This guarantees, under the assumption that the group tree does not
have cycles, that we do not accumulate group-level guide rate values
until all of its children are fully evaluated. We use an iterative
depth-first post-order tree traversal with an explicit stack instead
of a recursive implementation.
The previous implementation, which tried to do the same kind of
child-to-parent accumulation, might visit a parent group multiple
times which in turn might lead to losing updates. This is a more
formalised approach to the value accumulation than was originally
employed.
We still request Standard version 1.2 only.
We need to use KernelFunctor instead of make_kernel.
In addition cl::Sources now works on std::string and
does not support std::pair<const char*, in> anymore.
With dune-fem the type of the grid view is
Dune::Fem::AdaptiveLeafGridPart and not the LeafGridView
of the grid. The old approach therefore did not compile
as we passed the wrong view.
In some models there will be only a few cells with rather high pore volume representing the numerical aquifer. Including them (as non-violated cells) in the ratio will make the ratio lower than without the aquifer there and might lead to accepting vectors as converged when they should not.
This is needed for distributed wells to save most of the code
from checking whether a perforation is in the interior.
We add new methods compressedIndexForInterior that return -1
for non-interior cells and use that for the wells. This restores
the old behaviour before 1cfe3e0aad
We used to tie reporting these quantities to whether or not a group
had any guide rates for production (GuideRate::has()), but this is
clearly insufficient for injection guide rates.
This commit adds an overload set named
loadRestartGuideRates
which, collectively, initialises the contained GuideRate object
using guide rate values from the restart file. This is necessary,
but not quite sufficient, to restart models in prediction mode with
group-level constraints.
Mostly for readability in preparation of initialising the guide rate
object with values from the restart file. The new stages, each with
its own 'loadRestart*Data()' member function are
- Connection
- Segment
- Well
- Group
While here, also switch to using std::any_of() in place of a raw
loop.
The output layer expects its input values to be strictly SI, but we
know that the GuideRate container's values are in output units.
Forgotten in PR #3467 (commit 517db198f8).
This commit moves the bodies of the various 'dynamicDispatch_<>()'
cases out to separate helper functions. Not only does this reduce
the number of nested conditionals, it also helps reasoning about
each case in isolation and aids future maintenance.
As multisegment wells may throw in applyUMFPack this is now needed and
the exception needs to communicated to all processes. We do this in
the linearize method of the well model.
Before this change this is what could happen:
- The process with the exception would have chopped the time step
- The others would have successfully setup the systems and entered the
linear solve
This poduced a deadlock. One processes was waiting in
OPM_END_PARALLEL_TRY during the setup of the shorter time step and in
collective communication during the setup of the linear solver for the
unchopped time step.
This saves some (expensive?) lookups that already have been done
in the well model. We had to make the well_container accessible from
the well model for this.
Using the perforation data will automatically make sure that the
perforations are not shut and reside on this process in a parallel run.
There cannot happen any collective blocking communication within a
parallel try-catch clause if exceptions might be thrown before the
communication. The communication has to either be reached by all
processes or no processes.
Although not declared as such, prepareTimeStep seems to be an internal
function (despite usage in a test) and hence error control can be done
in code calling it.
There was the following problem with the try-catch approach taken:
The calling site `BlackoilWellModel::assemble` looked like this:
```
OPM_BEGIN_PARALLEL_TRY_CATCH();
{
if (iterationIdx == 0) {
calculateExplicitQuantities(local_deferredLogger); // no parallel try-catch
prepareTimeStep(local_deferredLogger); //includes parallel try-catch
}
updateWellControls(local_deferredLogger, /* check group controls */ true);
// Set the well primary variables based on the value of well solutions
initPrimaryVariablesEvaluation();
maybeDoGasLiftOptimize(local_deferredLogger);
assembleWellEq(dt, local_deferredLogger);
}
OPM_END_PARALLEL_TRY_CATCH_LOG(local_deferredLogger, "assemble() failed: ",
terminal_output_);
```
calculateExplicitQuantities had no parallel-try-catch clause inside,
but prepareTimeStep had one.
Unfortunately, calculateExplicitQuantities might throw (on some
processors). In that case non-throwing processors will try to trigger a
collective communication (to check for errors) in
prepareTimeStep. While the one throwing will move to the
OPM_END_PARALLEL_TRY_CATCH_LOG macro at the end and also trigger a different
collective communication. Booom, we have a deadlock.
With this patch there is no (nested parallel)-try-catch clause in the
functions called. (And if an exception is thrown in prepareTimeStep, it
will be logged as being an assemble failure).
The other option would have been to add parallel-try-catch clauses
to all functions called. That would have created a lot more
synchronization points limiting scalability even further.
Not a big fan of Macros but here at least they seem ot be the only
option. The problem is that the catch clauses must all catch the same
exceptions that have a entry in ExceptionType, because they might be
nested. In addition we did not have a catch all clause, which is added
now and is needed in case a called method throws an unexpected exception.
Expect non-reference type shared pointers arguments instead of references
to shared pointer. This will make it clear to the caller that the called
function is making a copy of the pointer for its own use and not trying
to modify the original pointer of the caller.
Adds a new constructor to Main.hpp that takes shared pointers to Deck,
EclipseState, Schedule, and SummaryConfig. This makes it possible to
share these variables with Python without worrying about lifetime issues
of the underlying C++ objects. For example, a Python script can first
create an opm.io.schedule.Schedule object which is modified from Python.
Then, assume the same Python script creates an
opm.simulators.BlackOilSimulator which is initialized with the same
schedule object. Since the underlying C++ object is a shared pointer,
the Schedule object in Python may go out of scope (get deleted by Python)
without having the C++ schedule object being deleted. And the Python
BlackOilSimulator may continue to be used after the Python Schedule object
has been deleted since it still has a valid C++ schedule object.
Previously, exceptions happening at this stage have deadlocked
flow. E.g. UniformTabulated2DFunction in opm-material throws
a NumericalIssue if the values passed are outside the tabulated
reason. This function is e.g. called in 2-phase CO2-storage cases
during BlackoilModel::initializeWellState
BTW: This is only the first step as it is not very user friendly that
a simulation aborts at this (late) stage.
We got compile errors like:
/home/build/opm-simulators/opm/simulators/linalg/FlexibleSolver1.cpp:24:1: required from here
/usr/include/dune/istl/ilu.hh:140:29: error: 'double' is not a class, struct, or union type
without this patch.
Hence we use the new internal ILU functions if available.