Loading...
Searching...
No Matches
ParallelRestrictedAdditiveSchwarz.hpp
/*
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 Statoil AS
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_PARALLELRESTRICTEDADDITIVESCHWARZ_HEADER_INCLUDED
#define OPM_PARALLELRESTRICTEDADDITIVESCHWARZ_HEADER_INCLUDED
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <dune/istl/preconditioner.hh>
#include <dune/istl/paamg/smoother.hh>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
namespace Opm
{
template<class X, class Y, class C, class T>
class ParallelRestrictedOverlappingSchwarz;
} // end namespace Opm
namespace Dune
{
namespace Amg
{
template<class Range, class Domain, class ParallelInfo, class SeqPreconditioner>
struct ConstructionTraits<Opm::ParallelRestrictedOverlappingSchwarz<Range,
Domain,
ParallelInfo,
SeqPreconditioner> >
{
typedef DefaultParallelConstructionArgs<SeqPreconditioner,ParallelInfo> Arguments;
typedef ConstructionTraits<SeqPreconditioner> SeqConstructionTraits;
typedef std::shared_ptr< Opm::ParallelRestrictedOverlappingSchwarz<Range,
Domain,
ParallelInfo,
SeqPreconditioner> > ParallelRestrictedOverlappingSchwarzPointer;
static inline ParallelRestrictedOverlappingSchwarzPointer
construct(Arguments& args)
{
using PROS =
Opm::ParallelRestrictedOverlappingSchwarz<Range,Domain,
ParallelInfo,SeqPreconditioner>;
return std::make_shared<PROS>(*SeqConstructionTraits::construct(args),
args.getComm());
}
static inline void deconstruct(Opm::ParallelRestrictedOverlappingSchwarz
<Range,Domain,ParallelInfo,SeqPreconditioner>* bp)
{
SeqConstructionTraits
::deconstruct(static_cast<SeqPreconditioner*>(&bp->preconditioner));
delete bp;
}
};
template<class Range, class Domain, class ParallelInfo, class SeqPreconditioner>
struct SmootherTraits<Opm::ParallelRestrictedOverlappingSchwarz<Range,
Domain,
ParallelInfo,
SeqPreconditioner> >
{
typedef DefaultSmootherArgs<typename SeqPreconditioner::matrix_type::field_type> Arguments;
};
} // end namespace Amg
} // end namespace Dune
namespace Opm{
template<class Range, class Domain, class ParallelInfo, class SeqPreconditioner=Dune::Preconditioner<Range,Domain> >
class ParallelRestrictedOverlappingSchwarz
: public Dune::Preconditioner<Range,Domain> {
friend class Dune::Amg
::ConstructionTraits<ParallelRestrictedOverlappingSchwarz<Range,
Domain,
ParallelInfo,
SeqPreconditioner> >;
public:
typedef Domain domain_type;
typedef Range range_type;
typedef typename Domain::field_type field_type;
typedef ParallelInfo communication_type;
// define the category
enum {
category=Dune::SolverCategory::overlapping
};
ParallelRestrictedOverlappingSchwarz (SeqPreconditioner& p, const communication_type& c)
: preconditioner_(p), communication_(c)
{ }
virtual void pre (Domain& x, Range& b)
{
OPM_TIMEBLOCK(pre);
communication_.copyOwnerToAll(x,x); // make dirichlet values consistent
preconditioner_.pre(x,b);
}
virtual void apply (Domain& v, const Range& d)
{
apply<true>(v, d);
}
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);
preconditioner_.template apply<forward>(v,d);
communication_.copyOwnerToAll(v,v);
// Make sure that d is the same as at the beginning of apply.
communication_.project(md);
}
virtual void post (Range& x)
{
OPM_TIMEBLOCK(post);
preconditioner_.post(x);
}
private:
SeqPreconditioner& preconditioner_;
const communication_type& communication_;
};
} // end namespace OPM
#endif
Opm::ParallelRestrictedOverlappingSchwarz
Block parallel preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:128
Opm::ParallelRestrictedOverlappingSchwarz::ParallelRestrictedOverlappingSchwarz
ParallelRestrictedOverlappingSchwarz(SeqPreconditioner &p, const communication_type &c)
Constructor.
Definition ParallelRestrictedAdditiveSchwarz.hpp:157
Opm::ParallelRestrictedOverlappingSchwarz::post
virtual void post(Range &x)
Clean up.
Definition ParallelRestrictedAdditiveSchwarz.hpp:201
Opm::ParallelRestrictedOverlappingSchwarz::field_type
Domain::field_type field_type
The field type of the preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:140
Opm::ParallelRestrictedOverlappingSchwarz::domain_type
Domain domain_type
The domain type of the preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:136
Opm::ParallelRestrictedOverlappingSchwarz::range_type
Range range_type
The range type of the preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:138
Opm::ParallelRestrictedOverlappingSchwarz::communication_type
ParallelInfo communication_type
The type of the communication object.
Definition ParallelRestrictedAdditiveSchwarz.hpp:142
Opm::ParallelRestrictedOverlappingSchwarz::category
@ category
The category the precondtioner is part of.
Definition ParallelRestrictedAdditiveSchwarz.hpp:147
Opm::ParallelRestrictedOverlappingSchwarz::apply
virtual void apply(Domain &v, const Range &d)
Apply the preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:178
Opm::ParallelRestrictedOverlappingSchwarz::pre
virtual void pre(Domain &x, Range &b)
Prepare the preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:166
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Dune::Amg::ConstructionTraits< Opm::ParallelRestrictedOverlappingSchwarz< Range, Domain, ParallelInfo, SeqPreconditioner > >::deconstruct
static void deconstruct(Opm::ParallelRestrictedOverlappingSchwarz< Range, Domain, ParallelInfo, SeqPreconditioner > *bp)
Deconstruct and free a parallel restricted overlapping schwarz preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:74
Dune::Amg::ConstructionTraits< Opm::ParallelRestrictedOverlappingSchwarz< Range, Domain, ParallelInfo, SeqPreconditioner > >::ParallelRestrictedOverlappingSchwarzPointer
std::shared_ptr< Opm::ParallelRestrictedOverlappingSchwarz< Range, Domain, ParallelInfo, SeqPreconditioner > > ParallelRestrictedOverlappingSchwarzPointer
Construct a parallel restricted overlapping schwarz preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:61