My Project
Loading...
Searching...
No Matches
ParallelRestrictedAdditiveSchwarz.hpp
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
64 construct(Arguments& args)
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:
140 typedef typename Domain::field_type field_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 communication_.copyOwnerToAll(x,x); // make dirichlet values consistent
169 preconditioner_.pre(x,b);
170 }
171
177 virtual void apply (Domain& v, const Range& d)
178 {
179 apply<true>(v, d);
180 }
181
182 template<bool forward>
183 void apply (Domain& v, const Range& d)
184 {
185 // hack us a mutable d to prevent copying.
186 Range& md = const_cast<Range&>(d);
187 communication_.copyOwnerToAll(md,md);
188 preconditioner_.template apply<forward>(v,d);
189 communication_.copyOwnerToAll(v,v);
190 // Make sure that d is the same as at the beginning of apply.
191 communication_.project(md);
192 }
193
199 virtual void post (Range& x)
200 {
201 preconditioner_.post(x);
202 }
203
204private:
206 SeqPreconditioner& preconditioner_;
207
209 const communication_type& communication_;
210};
211
212
213} // end namespace OPM
214#endif
Definition AquiferInterface.hpp:35
Block parallel preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:128
ParallelRestrictedOverlappingSchwarz(SeqPreconditioner &p, const communication_type &c)
Constructor.
Definition ParallelRestrictedAdditiveSchwarz.hpp:157
virtual void post(Range &x)
Clean up.
Definition ParallelRestrictedAdditiveSchwarz.hpp:199
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
virtual void apply(Domain &v, const Range &d)
Apply the preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:177
virtual void pre(Domain &x, Range &b)
Prepare the preconditioner.
Definition ParallelRestrictedAdditiveSchwarz.hpp:166
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition BlackoilPhases.hpp:27
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