mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
fix some serious screw-ups
almost all of them were caused by recent changes in the master branch: - there were methods added which depend on the types `V` and `DataBlock`. these do not make much sense in the context of the frankenstein simulator. Also, these types are defined globally for the whole Opm namespace in `BlackoilModelBase_impl.hpp` (which should be prosecuted as a fellony IMO)! Besides this, their names are useless; 'V' is the letter which comes after `U` in the alphabet and when it comes to computers basically everything can be seen as a chunk of data (i.e., a `DataBlock`). - it seems like the new and shiny dense-AD based well model was never compiled with assertations enabled, at least some asserts referenced non-existing variables. - the recent output-related API changes were pretty unfortunate because they had the effect of tying the (sub-optimal, IMO) internal structure of the model even closer to the output code: as far as I can see, `rq` does only make sense if the model works *exactly* like BlackoilModelBase and friends. (for flow_ebos, this could be replicated, but first it would be another unnecessary conversion step and second, most of the quantities in `rq` are of type `ADB` and much of the "frankenstein" excercise is devoted to getting rid of these.) I thus reverted back to an old version of the output code and created a `frankenstein` branch in my personal `opm-output` github fork.
This commit is contained in:
151
opm/autodiff/SimFIBODetails.hpp
Normal file
151
opm/autodiff/SimFIBODetails.hpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
Copyright 2013 SINTEF ICT, Applied Mathematics.
|
||||
Copyright 2014-2016 IRIS AS
|
||||
Copyright 2015 Andreas Lauser
|
||||
|
||||
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_SIM_FIBO_DETAILS_HPP
|
||||
#define OPM_SIM_FIBO_DETAILS_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Events.hpp>
|
||||
#include <opm/core/utility/initHydroCarbonState.hpp>
|
||||
#include <opm/core/well_controls.h>
|
||||
#include <opm/core/wells/DynamicListEconLimited.hpp>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace SimFIBODetails {
|
||||
typedef std::unordered_map<std::string, const Well* > WellMap;
|
||||
|
||||
inline WellMap
|
||||
mapWells(const std::vector< const Well* >& wells)
|
||||
{
|
||||
WellMap wmap;
|
||||
|
||||
for (std::vector< const Well* >::const_iterator
|
||||
w = wells.begin(), e = wells.end();
|
||||
w != e; ++w)
|
||||
{
|
||||
wmap.insert(std::make_pair((*w)->name(), *w));
|
||||
}
|
||||
|
||||
return wmap;
|
||||
}
|
||||
|
||||
inline int
|
||||
resv_control(const WellControls* ctrl)
|
||||
{
|
||||
int i, n = well_controls_get_num(ctrl);
|
||||
|
||||
bool match = false;
|
||||
for (i = 0; (! match) && (i < n); ++i) {
|
||||
match = well_controls_iget_type(ctrl, i) == RESERVOIR_RATE;
|
||||
}
|
||||
|
||||
if (! match) { i = 0; }
|
||||
|
||||
return i - 1; // -1 if no match, undo final "++" otherwise
|
||||
}
|
||||
|
||||
inline bool
|
||||
is_resv(const Wells& wells,
|
||||
const int w)
|
||||
{
|
||||
return (0 <= resv_control(wells.ctrls[w]));
|
||||
}
|
||||
|
||||
inline bool
|
||||
is_resv(const WellMap& wmap,
|
||||
const std::string& name,
|
||||
const std::size_t step)
|
||||
{
|
||||
bool match = false;
|
||||
|
||||
WellMap::const_iterator i = wmap.find(name);
|
||||
|
||||
if (i != wmap.end()) {
|
||||
const Well* wp = i->second;
|
||||
|
||||
match = (wp->isProducer(step) &&
|
||||
wp->getProductionProperties(step)
|
||||
.hasProductionControl(WellProducer::RESV))
|
||||
|| (wp->isInjector(step) &&
|
||||
wp->getInjectionProperties(step)
|
||||
.hasInjectionControl(WellInjector::RESV));
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
inline std::vector<int>
|
||||
resvWells(const Wells* wells,
|
||||
const std::size_t step,
|
||||
const WellMap& wmap)
|
||||
{
|
||||
std::vector<int> resv_wells;
|
||||
if( wells )
|
||||
{
|
||||
for (int w = 0, nw = wells->number_of_wells; w < nw; ++w) {
|
||||
if (is_resv(*wells, w) ||
|
||||
((wells->name[w] != 0) &&
|
||||
is_resv(wmap, wells->name[w], step)))
|
||||
{
|
||||
resv_wells.push_back(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resv_wells;
|
||||
}
|
||||
|
||||
inline void
|
||||
historyRates(const PhaseUsage& pu,
|
||||
const WellProductionProperties& p,
|
||||
std::vector<double>& rates)
|
||||
{
|
||||
assert (! p.predictionMode);
|
||||
assert (rates.size() ==
|
||||
std::vector<double>::size_type(pu.num_phases));
|
||||
|
||||
if (pu.phase_used[ BlackoilPhases::Aqua ]) {
|
||||
const std::vector<double>::size_type
|
||||
i = pu.phase_pos[ BlackoilPhases::Aqua ];
|
||||
|
||||
rates[i] = p.WaterRate;
|
||||
}
|
||||
|
||||
if (pu.phase_used[ BlackoilPhases::Liquid ]) {
|
||||
const std::vector<double>::size_type
|
||||
i = pu.phase_pos[ BlackoilPhases::Liquid ];
|
||||
|
||||
rates[i] = p.OilRate;
|
||||
}
|
||||
|
||||
if (pu.phase_used[ BlackoilPhases::Vapour ]) {
|
||||
const std::vector<double>::size_type
|
||||
i = pu.phase_pos[ BlackoilPhases::Vapour ];
|
||||
|
||||
rates[i] = p.GasRate;
|
||||
}
|
||||
}
|
||||
} // namespace SimFIBODetails
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_SIM_FIBO_DETAILS_HPP
|
||||
Reference in New Issue
Block a user