mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-11-24 10:10:18 -06:00
Merge pull request #4752 from hnil/linearsolver_timing
-- added more timing to get better coverage of cpr solver
This commit is contained in:
commit
840dd9de90
@ -22,7 +22,7 @@
|
||||
#define OPM_FLEXIBLE_SOLVER_IMPL_HEADER_INCLUDED
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/simulators/linalg/matrixblock.hh>
|
||||
#include <opm/simulators/linalg/ilufirstelement.hh>
|
||||
#include <opm/simulators/linalg/FlexibleSolver.hpp>
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/simulators/linalg/ISTLSolverEbos.hpp>
|
||||
|
||||
#include <dune/istl/schwarz.hh>
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/simulators/linalg/MILU.hpp>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <dune/common/version.hh>
|
||||
#include <dune/common/fmatrix.hh>
|
||||
#include <dune/istl/bcrsmatrix.hh>
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
#ifndef OPM_PARALLELOVERLAPPINGILU0_HEADER_INCLUDED
|
||||
#define OPM_PARALLELOVERLAPPINGILU0_HEADER_INCLUDED
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/simulators/linalg/MILU.hpp>
|
||||
#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
|
||||
#include <dune/istl/paamg/smoother.hh>
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
*/
|
||||
virtual void pre (Domain& x, Range& b)
|
||||
{
|
||||
OPM_TIMEBLOCK(pre);
|
||||
communication_.copyOwnerToAll(x,x); // make dirichlet values consistent
|
||||
preconditioner_.pre(x,b);
|
||||
}
|
||||
@ -182,6 +183,7 @@ public:
|
||||
template<bool forward>
|
||||
void apply (Domain& v, const Range& d)
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
// hack us a mutable d to prevent copying.
|
||||
Range& md = const_cast<Range&>(d);
|
||||
communication_.copyOwnerToAll(md,md);
|
||||
@ -198,6 +200,7 @@ public:
|
||||
*/
|
||||
virtual void post (Range& x)
|
||||
{
|
||||
OPM_TIMEBLOCK(post);
|
||||
preconditioner_.post(x);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#ifndef OPM_PRECONDITIONERFACTORY_HEADER
|
||||
#define OPM_PRECONDITIONERFACTORY_HEADER
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
|
||||
|
||||
#include <dune/istl/paamg/aggregates.hh>
|
||||
|
@ -17,10 +17,11 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
|
||||
#include <opm/simulators/linalg/PreconditionerFactory.hpp>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/simulators/linalg/matrixblock.hh>
|
||||
#include <opm/simulators/linalg/amgcpr.hh>
|
||||
|
@ -72,12 +72,14 @@ public:
|
||||
*/
|
||||
void apply(const X& x, Y& y) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
wellMod_.apply(x, y);
|
||||
}
|
||||
|
||||
//! apply operator to x, scale and add: \f$ y = y + \alpha A(x) \f$
|
||||
virtual void applyscaleadd(field_type alpha, const X& x, Y& y) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(applyscaleadd);
|
||||
wellMod_.applyScaleAdd(alpha, x, y);
|
||||
}
|
||||
|
||||
@ -92,10 +94,12 @@ public:
|
||||
}
|
||||
void addWellPressureEquations(PressureMatrix& jacobian, const X& weights,const bool use_well_weights) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(addWellPressureEquations);
|
||||
wellMod_.addWellPressureEquations(jacobian, weights, use_well_weights);
|
||||
}
|
||||
void addWellPressureEquationsStruct(PressureMatrix& jacobian) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(addWellPressureEquationsStruct);
|
||||
wellMod_.addWellPressureEquationsStruct(jacobian);
|
||||
}
|
||||
int getNumberOfExtraEquations() const override
|
||||
@ -149,6 +153,7 @@ public:
|
||||
|
||||
virtual void apply( const X& x, Y& y ) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
A_.mv( x, y );
|
||||
|
||||
// add well model modification to y
|
||||
@ -163,6 +168,7 @@ public:
|
||||
// y += \alpha * A * x
|
||||
virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(applyscaleadd);
|
||||
A_.usmv(alpha,x,y);
|
||||
|
||||
// add scaled well model modification to y
|
||||
@ -178,10 +184,12 @@ public:
|
||||
|
||||
void addWellPressureEquations(PressureMatrix& jacobian, const X& weights,const bool use_well_weights) const
|
||||
{
|
||||
OPM_TIMEBLOCK(addWellPressureEquations);
|
||||
wellOper_.addWellPressureEquations(jacobian, weights, use_well_weights);
|
||||
}
|
||||
void addWellPressureEquationsStruct(PressureMatrix& jacobian) const
|
||||
{
|
||||
OPM_TIMEBLOCK(addWellPressureEquations);
|
||||
wellOper_.addWellPressureEquationsStruct(jacobian);
|
||||
}
|
||||
int getNumberOfExtraEquations() const
|
||||
@ -235,6 +243,7 @@ public:
|
||||
|
||||
virtual void apply( const X& x, Y& y ) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
for (auto row = A_.begin(); row.index() < interiorSize_; ++row)
|
||||
{
|
||||
y[row.index()]=0;
|
||||
@ -252,6 +261,7 @@ public:
|
||||
// y += \alpha * A * x
|
||||
virtual void applyscaleadd (field_type alpha, const X& x, Y& y) const override
|
||||
{
|
||||
OPM_TIMEBLOCK(applyscaleadd);
|
||||
for (auto row = A_.begin(); row.index() < interiorSize_; ++row)
|
||||
{
|
||||
auto endc = (*row).end();
|
||||
@ -268,10 +278,12 @@ public:
|
||||
|
||||
void addWellPressureEquations(PressureMatrix& jacobian, const X& weights,const bool use_well_weights) const
|
||||
{
|
||||
OPM_TIMEBLOCK(addWellPressureEquations);
|
||||
wellOper_.addWellPressureEquations(jacobian, weights, use_well_weights);
|
||||
}
|
||||
void addWellPressureEquationsStruct(PressureMatrix& jacobian) const
|
||||
{
|
||||
OPM_TIMEBLOCK(addWellPressureEquationsStruct);
|
||||
wellOper_.addWellPressureEquationsStruct(jacobian);
|
||||
}
|
||||
int getNumberOfExtraEquations() const
|
||||
|
@ -7,7 +7,7 @@
|
||||
// dune-istl release 2.6.0. Modifications have been kept as minimal as possible.
|
||||
|
||||
#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <dune/common/exceptions.hh>
|
||||
#include <dune/common/version.hh>
|
||||
#include <dune/istl/paamg/amg.hh>
|
||||
@ -42,6 +42,7 @@ namespace Dune
|
||||
redistributeMatrixAmg(M& mat, M& matRedist, PI& info, PI& infoRedist,
|
||||
Dune::RedistributeInformation<PI>& redistInfo)
|
||||
{
|
||||
OPM_TIMEBLOCK(redistributeMatrixAmg);
|
||||
info.buildGlobalLookup(mat.N());
|
||||
redistributeMatrixEntries(mat, matRedist, info, infoRedist, redistInfo);
|
||||
info.freeGlobalLookup();
|
||||
@ -192,6 +193,7 @@ namespace Dune
|
||||
*/
|
||||
void recalculateHierarchy()
|
||||
{
|
||||
OPM_TIMEBLOCK(recalculateHierarch);
|
||||
auto copyFlags = NegateSet<typename PI::OwnerSet>();
|
||||
const auto& matrices = matrices_->matrices();
|
||||
const auto& aggregatesMapHierarchy = matrices_->aggregatesMaps();
|
||||
@ -260,6 +262,7 @@ namespace Dune
|
||||
void createHierarchies(C& criterion, Operator& matrix,
|
||||
const PI& pinfo)
|
||||
{
|
||||
//OPM_TIMEBLOCK(createHierarchies);
|
||||
// create shared_ptr with empty deleter
|
||||
std::shared_ptr< Operator > op( &matrix, []( Operator* ) {});
|
||||
std::shared_ptr< PI > pifo( const_cast< PI* > (&pinfo), []( PI * ) {});
|
||||
@ -466,6 +469,7 @@ namespace Dune
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::update()
|
||||
{
|
||||
OPM_TIMEBLOCK(update);
|
||||
Timer watch;
|
||||
smoothers_.reset(new Hierarchy<Smoother,A>);
|
||||
solver_.reset();
|
||||
@ -488,6 +492,7 @@ namespace Dune
|
||||
void AMGCPR<M,X,S,PI,A>::createHierarchies(C& criterion, std::shared_ptr< Operator > matrix,
|
||||
std::shared_ptr< PI > pinfo )
|
||||
{
|
||||
OPM_TIMEBLOCK(createHierarchies);
|
||||
Timer watch;
|
||||
matrices_.reset(new OperatorHierarchy(matrix, pinfo));
|
||||
|
||||
@ -504,6 +509,7 @@ namespace Dune
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::setupCoarseSolver()
|
||||
{
|
||||
OPM_TIMEBLOCK(setupCoarseSolver);
|
||||
// test whether we should solve on the coarse level. That is the case if we
|
||||
// have that level and if there was a redistribution on this level then our
|
||||
// communicator has to be valid (size()>0) as the smoother might try to communicate
|
||||
@ -607,6 +613,7 @@ namespace Dune
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::pre(Domain& x, Range& b)
|
||||
{
|
||||
OPM_TIMEBLOCK(pre);
|
||||
// Detect Matrix rows where all offdiagonal entries are
|
||||
// zero and set x such that A_dd*x_d=b_d
|
||||
// Thus users can be more careless when setting up their linear
|
||||
@ -700,6 +707,7 @@ namespace Dune
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::apply(Domain& v, const Range& d)
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
LevelContext levelContext;
|
||||
|
||||
if(additive) {
|
||||
@ -729,6 +737,7 @@ namespace Dune
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::initIteratorsWithFineLevel(LevelContext& levelContext)
|
||||
{
|
||||
OPM_TIMEBLOCK(initIteratorsWithFineLevel);
|
||||
levelContext.smoother = smoothers_->finest();
|
||||
levelContext.matrix = matrices_->matrices().finest();
|
||||
levelContext.pinfo = matrices_->parallelInformation().finest();
|
||||
@ -744,7 +753,7 @@ namespace Dune
|
||||
bool AMGCPR<M,X,S,PI,A>
|
||||
::moveToCoarseLevel(LevelContext& levelContext)
|
||||
{
|
||||
|
||||
OPM_TIMEBLOCK(moveToCoarseLevel);
|
||||
bool processNextLevel=true;
|
||||
|
||||
if(levelContext.redist->isSetup()) {
|
||||
@ -793,6 +802,7 @@ namespace Dune
|
||||
void AMGCPR<M,X,S,PI,A>
|
||||
::moveToFineLevel(LevelContext& levelContext, bool processNextLevel)
|
||||
{
|
||||
OPM_TIMEBLOCK(moveToFineLevel);
|
||||
if(processNextLevel) {
|
||||
if(levelContext.matrix != matrices_->matrices().coarsest() || matrices_->levels()<matrices_->maxlevels()) {
|
||||
// previous level is not the globally coarsest one
|
||||
@ -841,6 +851,7 @@ namespace Dune
|
||||
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::mgc(LevelContext& levelContext){
|
||||
//OPM_TIMEBLOCK(mgc);
|
||||
if(levelContext.matrix == matrices_->matrices().coarsest() && levels()==maxlevels()) {
|
||||
// Solve directly
|
||||
InverseOperatorResult res;
|
||||
@ -895,7 +906,7 @@ namespace Dune
|
||||
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::additiveMgc(){
|
||||
|
||||
OPM_TIMEBLOCK(additiveMgc);
|
||||
// restrict residual to all levels
|
||||
typename ParallelInformationHierarchy::Iterator pinfo=matrices_->parallelInformation().finest();
|
||||
typename Hierarchy<Range,A>::Iterator rhs=rhs_->finest();
|
||||
@ -946,6 +957,7 @@ namespace Dune
|
||||
template<class M, class X, class S, class PI, class A>
|
||||
void AMGCPR<M,X,S,PI,A>::post([[maybe_unused]] Domain& x)
|
||||
{
|
||||
OPM_TIMEBLOCK(post);
|
||||
// Postprocess all smoothers
|
||||
typedef typename Hierarchy<Smoother,A>::Iterator Iterator;
|
||||
typedef typename Hierarchy<Domain,A>::Iterator DIterator;
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include "dune/istl/bcrsmatrix.hh"
|
||||
#include <opm/simulators/linalg/matrixblock.hh>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
#include <config.h> // CMake
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#if HAVE_UMFPACK
|
||||
#include <dune/istl/umfpack.hh>
|
||||
#endif // HAVE_UMFPACK
|
||||
@ -69,6 +69,7 @@ MultisegmentWellContribution::~MultisegmentWellContribution()
|
||||
// y -= (C^T * (D^-1 * (B * x)))
|
||||
void MultisegmentWellContribution::apply(double *h_x, double *h_y)
|
||||
{
|
||||
OPM_TIMEBLOCK(apply);
|
||||
// reset z1 and z2
|
||||
std::fill(z1.begin(), z1.end(), 0.0);
|
||||
std::fill(z2.begin(), z2.end(), 0.0);
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <dune/common/timer.hh>
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <config.h>
|
||||
#include <memory>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/simulators/linalg/bda/opencl/BILU0.hpp>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <opm/simulators/wells/MSWellHelpers.hpp>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/MSW/SICD.hpp>
|
||||
|
@ -20,11 +20,11 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/simulators/wells/MultisegmentWellEquations.hpp>
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
|
||||
#include <opm/simulators/wells/MultisegmentWellEquations.hpp>
|
||||
#include <dune/istl/umfpack.hh>
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/input/eclipse/Schedule/MSW/WellSegments.hpp>
|
||||
|
||||
|
@ -20,9 +20,11 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <opm/common/Exceptions.hpp>
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/simulators/wells/StandardWellEquations.hpp>
|
||||
|
||||
#include <opm/common/Exceptions.hpp>
|
||||
|
||||
|
||||
#include <opm/simulators/linalg/bda/WellContributions.hpp>
|
||||
#include <opm/simulators/linalg/istlsparsematrixadapter.hh>
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <opm/simulators/utils/ParallelCommunication.hpp>
|
||||
#include <opm/simulators/wells/WellHelpers.hpp>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <dune/common/dynmatrix.hh>
|
||||
#include <dune/common/dynvector.hh>
|
||||
#include <dune/istl/bcrsmatrix.hh>
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <opm/common/TimingMacros.hpp>
|
||||
#include <opm/simulators/wells/WellHelpers.hpp>
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user