ParallelRestrictedAdditiveSchwarz.hpp
Go to the documentation of this file.
1/*
2 Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
3 Copyright 2015 Statoil AS
4
5 This file is part of the Open Porous Media project (OPM).
6
7 OPM is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 OPM is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with OPM. If not, see <http://www.gnu.org/licenses/>.
19*/
20#ifndef OPM_PARALLELRESTRICTEDADDITIVESCHWARZ_HEADER_INCLUDED
21#define OPM_PARALLELRESTRICTEDADDITIVESCHWARZ_HEADER_INCLUDED
22
23#include <opm/common/utility/platform_dependent/disable_warnings.h>
24#include <dune/istl/preconditioner.hh>
25#include <dune/istl/paamg/smoother.hh>
26#include <opm/common/utility/platform_dependent/reenable_warnings.h>
27
28namespace Opm
29{
30
31template<class X, class Y, class C, class T>
32class ParallelRestrictedOverlappingSchwarz;
33
34} // end namespace Opm
35
36namespace Dune
37{
38
39namespace Amg
40{
41
48template<class Range, class Domain, class ParallelInfo, class SeqPreconditioner>
49struct ConstructionTraits<Opm::ParallelRestrictedOverlappingSchwarz<Range,
50 Domain,
51 ParallelInfo,
52 SeqPreconditioner> >
53{
54 typedef DefaultParallelConstructionArgs<SeqPreconditioner,ParallelInfo> Arguments;
55 typedef ConstructionTraits<SeqPreconditioner> SeqConstructionTraits;
56
58 typedef std::shared_ptr< Opm::ParallelRestrictedOverlappingSchwarz<Range,
59 Domain,
60 ParallelInfo,
62
65 {
66 using PROS =
68 ParallelInfo,SeqPreconditioner>;
69 return std::make_shared<PROS>(*SeqConstructionTraits::construct(args),
70 args.getComm());
71 }
72
75 <Range,Domain,ParallelInfo,SeqPreconditioner>* bp)
76 {
77 SeqConstructionTraits
78 ::deconstruct(static_cast<SeqPreconditioner*>(&bp->preconditioner));
79 delete bp;
80 }
81
82};
83
90template<class Range, class Domain, class ParallelInfo, class SeqPreconditioner>
91struct SmootherTraits<Opm::ParallelRestrictedOverlappingSchwarz<Range,
92 Domain,
93 ParallelInfo,
94 SeqPreconditioner> >
95{
96 typedef DefaultSmootherArgs<typename SeqPreconditioner::matrix_type::field_type> Arguments;
97
98};
99
100} // end namespace Amg
101
102} // end namespace Dune
103
104namespace Opm{
105
126template<class Range, class Domain, class ParallelInfo, class SeqPreconditioner=Dune::Preconditioner<Range,Domain> >
128 : public Dune::Preconditioner<Range,Domain> {
129 friend class Dune::Amg
130 ::ConstructionTraits<ParallelRestrictedOverlappingSchwarz<Range,
131 Domain,
132 ParallelInfo,
133 SeqPreconditioner> >;
134public:
136 typedef Domain domain_type;
138 typedef Range range_type;
140 typedef typename Domain::field_type field_type;
142 typedef ParallelInfo communication_type;
143
144 // define the category
145 enum {
147 category=Dune::SolverCategory::overlapping
148 };
149
158 : preconditioner_(p), communication_(c)
159 { }
160
166 virtual void pre (Domain& x, Range& b)
167 {
168 OPM_TIMEBLOCK(pre);
169 communication_.copyOwnerToAll(x,x); // make dirichlet values consistent
170 preconditioner_.pre(x,b);
171 }
172
178 virtual void apply (Domain& v, const Range& d)
179 {
180 apply<true>(v, d);
181 }
182
183 template<bool forward>
184 void apply (Domain& v, const Range& d)
185 {
186 OPM_TIMEBLOCK(apply);
187 // hack us a mutable d to prevent copying.
188 Range& md = const_cast<Range&>(d);
189 communication_.copyOwnerToAll(md,md);
190 preconditioner_.template apply<forward>(v,d);
191 communication_.copyOwnerToAll(v,v);
192 // Make sure that d is the same as at the beginning of apply.
193 communication_.project(md);
194 }
195
201 virtual void post (Range& x)
202 {
203 OPM_TIMEBLOCK(post);
204 preconditioner_.post(x);
205 }
206
207private:
209 SeqPreconditioner& preconditioner_;
210
212 const communication_type& communication_;
213};
214
215
216} // end namespace OPM
217#endif
Block parallel preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:128
void apply(Domain &v, const Range &d)
Definition: ParallelRestrictedAdditiveSchwarz.hpp:184
ParallelRestrictedOverlappingSchwarz(SeqPreconditioner &p, const communication_type &c)
Constructor.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:157
virtual void post(Range &x)
Clean up.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:201
Domain::field_type field_type
The field type of the preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:140
Domain domain_type
The domain type of the preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:136
Range range_type
The range type of the preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:138
ParallelInfo communication_type
The type of the communication object.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:142
@ category
The category the precondtioner is part of.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:147
virtual void apply(Domain &v, const Range &d)
Apply the preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:178
virtual void pre(Domain &x, Range &b)
Prepare the preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:166
Definition: amgcpr.hh:30
Definition: SupportsFaceTag.hpp:27
Definition: BlackoilPhases.hpp:27
static ParallelRestrictedOverlappingSchwarzPointer construct(Arguments &args)
Definition: ParallelRestrictedAdditiveSchwarz.hpp:64
ConstructionTraits< SeqPreconditioner > SeqConstructionTraits
Definition: ParallelRestrictedAdditiveSchwarz.hpp:55
DefaultParallelConstructionArgs< SeqPreconditioner, ParallelInfo > Arguments
Definition: ParallelRestrictedAdditiveSchwarz.hpp:54
static void deconstruct(Opm::ParallelRestrictedOverlappingSchwarz< Range, Domain, ParallelInfo, SeqPreconditioner > *bp)
Deconstruct and free a parallel restricted overlapping schwarz preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:74
std::shared_ptr< Opm::ParallelRestrictedOverlappingSchwarz< Range, Domain, ParallelInfo, SeqPreconditioner > > ParallelRestrictedOverlappingSchwarzPointer
Construct a parallel restricted overlapping schwarz preconditioner.
Definition: ParallelRestrictedAdditiveSchwarz.hpp:61
DefaultSmootherArgs< typename SeqPreconditioner::matrix_type::field_type > Arguments
Definition: ParallelRestrictedAdditiveSchwarz.hpp:96