Merge remote-tracking branch 'origin/master' into frankenstein_merge_master_v2

This commit is contained in:
Andreas Lauser 2016-09-29 18:30:55 +02:00
commit 6722c67534
8 changed files with 193 additions and 2 deletions

View File

@ -152,6 +152,7 @@ list (APPEND PUBLIC_HEADER_FILES
opm/autodiff/BlackoilPropsAdFromDeck.hpp
opm/autodiff/SolventPropsAdFromDeck.hpp
opm/autodiff/BlackoilPropsAdInterface.hpp
opm/autodiff/Compat.hpp
opm/autodiff/CPRPreconditioner.hpp
opm/autodiff/createGlobalCellArray.hpp
opm/autodiff/BlackoilSequentialModel.hpp

184
opm/autodiff/Compat.hpp Normal file
View File

@ -0,0 +1,184 @@
/*
Copyright 2016 Statoil ASA
2016 IRIS
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_SIMULATORS_COMPAT_HPP
#define OPM_SIMULATORS_COMPAT_HPP
#include <opm/common/data/SimulationDataContainer.hpp>
#include <opm/core/props/BlackoilPhases.hpp>
#include <opm/core/simulator/BlackoilState.hpp>
#include <opm/core/simulator/WellState.hpp>
#include <opm/autodiff/BlackoilSolventState.hpp>
#include <opm/output/Cells.hpp>
#include <opm/output/Wells.hpp>
namespace Opm {
inline std::vector< double > destripe( const std::vector< double >& v,
size_t stride,
size_t offset ) {
std::vector< double > dst( v.size() / stride );
size_t di = 0;
for( size_t i = offset; i < v.size(); i += stride ) {
dst[ di++ ] = v[ i ];
}
return dst;
}
inline std::vector< double >& stripe( const std::vector< double >& v,
size_t stride,
size_t offset,
std::vector< double >& dst ) {
/* does little range checking etc; for future revisions */
size_t vi = 0;
for( size_t i = offset; i < dst.size(); i += stride ) {
dst[ i ] = v[ vi++ ];
}
return dst;
}
inline data::Solution simToSolution( const SimulationDataContainer& reservoir,
PhaseUsage phases ) {
using ds = data::Solution::key;
data::Solution sol;
sol.insert( ds::PRESSURE, reservoir.pressure() );
sol.insert( ds::TEMP, reservoir.temperature() );
const auto ph = reservoir.numPhases();
const auto& sat = reservoir.saturation();
const auto aqua = BlackoilPhases::Aqua;
const auto vapour = BlackoilPhases::Vapour;
if( phases.phase_used[ aqua ] ) {
sol.insert( ds::SWAT, destripe( sat, ph, phases.phase_pos[ aqua ] ) );
}
if( phases.phase_used[ vapour ] ) {
sol.insert( ds::SGAS, destripe( sat, ph, phases.phase_pos[ vapour ] ) );
}
if( reservoir.hasCellData( BlackoilState::GASOILRATIO ) ) {
sol.insert( ds::RS, reservoir.getCellData( BlackoilState::GASOILRATIO ) );
}
if( reservoir.hasCellData( BlackoilState::RV ) ) {
sol.insert( ds::RV, reservoir.getCellData( BlackoilState::RV ) );
}
if (reservoir.hasCellData( BlackoilSolventState::SSOL)) {
sol.insert( ds::SSOL, reservoir.getCellData( BlackoilSolventState::SSOL ) );
}
sol.sdc = &reservoir;
return sol;
}
inline void solutionToSim( const data::Solution& sol,
PhaseUsage phases,
SimulationDataContainer& state ) {
using ds = data::Solution::key;
const auto stride = phases.num_phases;
if( sol.has( ds::SWAT ) ) {
stripe( sol[ ds::SWAT ],
stride,
phases.phase_pos[ BlackoilPhases::Aqua ],
state.saturation() );
}
if( sol.has( ds::SGAS ) ) {
stripe( sol[ ds::SGAS ],
stride,
phases.phase_pos[ BlackoilPhases::Vapour ],
state.saturation() );
}
if( sol.has( ds::PRESSURE ) ) {
state.pressure() = sol[ ds::PRESSURE ];
}
if( sol.has( ds::TEMP ) ) {
state.temperature() = sol[ ds::TEMP ];
}
if( sol.has( ds::RS ) ) {
state.getCellData( "GASOILRATIO" ) = sol[ ds::RS ];
}
if( sol.has( ds::RV ) ) {
state.getCellData( "RV" ) = sol[ ds::RV ];
}
if (sol.has( ds::SSOL ) ) {
state.getCellData("SSOL") = sol [ ds::SSOL];
}
}
inline void wellsToState( const data::Wells& wells, WellState& state ) {
state.bhp() = wells.bhp;
state.temperature() = wells.temperature;
state.wellRates() = wells.well_rate;
state.perfPress() = wells.perf_pressure;
state.perfRates() = wells.perf_rate;
}
}
#endif //OPM_SIMULATORS_COMPAT_HPP

View File

@ -296,6 +296,9 @@ namespace Opm
SimulatorReport step_report;
step_report.pressure_time = st;
step_report.total_time = step_timer.secsSinceStart();
step_report.total_newton_iterations = solver->nonlinearIterations();
step_report.total_linear_iterations = solver->linearIterations();
step_report.total_linearizations = solver->linearizations();
step_report.reportParam(tstep_os);
}

View File

@ -27,6 +27,7 @@
#include <opm/output/Cells.hpp>
#include <opm/core/simulator/BlackoilState.hpp>
#include <opm/core/utility/DataMap.hpp>
#include <opm/autodiff/Compat.hpp>
#include <opm/output/vtk/writeVtkData.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/core/utility/miscUtilities.hpp>

View File

@ -22,6 +22,7 @@
#include <opm/core/grid.h>
#include <opm/core/simulator/SimulatorTimerInterface.hpp>
#include <opm/core/simulator/WellState.hpp>
#include <opm/autodiff/Compat.hpp>
#include <opm/core/utility/DataMap.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>

View File

@ -27,7 +27,7 @@
#include <opm/output/Cells.hpp>
#include <opm/core/simulator/BlackoilState.hpp>
#include <opm/core/utility/DataMap.hpp>
#include <opm/core/utility/Compat.hpp>
#include <opm/autodiff/Compat.hpp>
#include <opm/output/vtk/writeVtkData.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/core/utility/miscUtilities.hpp>

View File

@ -33,6 +33,7 @@
#include <opm/output/Cells.hpp>
#include <opm/output/eclipse/EclipseWriter.hpp>
#include <opm/autodiff/Compat.hpp>
#include <opm/autodiff/GridHelpers.hpp>
#include <opm/autodiff/ParallelDebugOutput.hpp>

View File

@ -36,7 +36,7 @@
#include <opm/core/simulator/SimulatorReport.hpp>
#include <opm/core/simulator/SimulatorTimer.hpp>
#include <opm/core/utility/StopWatch.hpp>
#include <opm/core/utility/Compat.hpp>
#include <opm/autodiff/Compat.hpp>
#include <opm/core/utility/DataMap.hpp>
#include <opm/output/vtk/writeVtkData.hpp>
#include <opm/core/utility/miscUtilities.hpp>