Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultPreconditioner_decl.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_DEFUALT_PRECONDITIONER_DECL_HPP
43 #define THYRA_DEFUALT_PRECONDITIONER_DECL_HPP
44 
45 #include "Thyra_PreconditionerBase.hpp"
46 #include "Teuchos_ConstNonconstObjectContainer.hpp"
47 
48 
49 namespace Thyra {
50 
51 
79 template <class Scalar>
80 class DefaultPreconditioner : virtual public PreconditionerBase<Scalar>
81 {
82 public:
83 
86 
90 
95  const Teuchos::RCP<LinearOpBase<Scalar> > &leftPrecOp,
96  const Teuchos::RCP<LinearOpBase<Scalar> > &rightPrecOp
97  );
98 
103  const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp,
104  const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
105  );
106 
110  const Teuchos::RCP<LinearOpBase<Scalar> > &unspecifiedPrecOp
111  );
112 
116  const Teuchos::RCP<const LinearOpBase<Scalar> > &unspecifiedPrecOp
117  );
118 
121  void initializeLeft(
122  const Teuchos::RCP<LinearOpBase<Scalar> > &leftPrecOp
123  );
124 
127  void initializeLeft(
128  const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp
129  );
130 
133  void initializeRight(
134  const Teuchos::RCP<LinearOpBase<Scalar> > &rightPrecOp
135  );
136 
139  void initializeRight(
140  const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
141  );
142 
145  void initializeLeftRight(
146  const Teuchos::RCP<LinearOpBase<Scalar> > &leftPrecOp
147  ,const Teuchos::RCP<LinearOpBase<Scalar> > &rightPrecOp
148  );
149 
152  void initializeLeftRight(
153  const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp
154  ,const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
155  );
156 
161  const Teuchos::RCP<LinearOpBase<Scalar> > &unspecifiedPrecOp
162  );
163 
168  const Teuchos::RCP<const LinearOpBase<Scalar> > &unspecifiedPrecOp
169  );
170 
177  void uninitialize();
178 
180 
184  std::string description() const;
186  void describe(
188  const Teuchos::EVerbosityLevel verbLevel
189  ) const;
191 
195  bool isLeftPrecOpConst() const;
201  bool isRightPrecOpConst() const;
207  bool isUnspecifiedPrecOpConst() const;
213 
214 private:
215 
219 
220 };
221 
222 // ///////////////////////
223 // Related functions
224 
225 
231 template <class Scalar>
234  const Teuchos::RCP<const LinearOpBase<Scalar> > &unspecifiedPrecOp
235  )
236 {
237  return Teuchos::rcp(new DefaultPreconditioner<Scalar>(unspecifiedPrecOp));
238 }
239 
240 
246 template <class Scalar>
249  const Teuchos::RCP<LinearOpBase<Scalar> > &unspecifiedPrecOp
250  )
251 {
252  return Teuchos::rcp(new DefaultPreconditioner<Scalar>(unspecifiedPrecOp));
253 }
254 
255 
261 template <class Scalar>
264  const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp
265  )
266 {
267  return Teuchos::rcp(new DefaultPreconditioner<Scalar>(leftPrecOp,Teuchos::null));
268 }
269 
275 template <class Scalar>
278  const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
279  )
280 {
281  return Teuchos::rcp(new DefaultPreconditioner<Scalar>(Teuchos::null,rightPrecOp));
282 }
283 
289 template <class Scalar>
292  const Teuchos::RCP<const LinearOpBase<Scalar> > &leftPrecOp
293  ,const Teuchos::RCP<const LinearOpBase<Scalar> > &rightPrecOp
294  )
295 {
296  return Teuchos::rcp(new DefaultPreconditioner<Scalar>(leftPrecOp,rightPrecOp));
297 }
298 
299 
300 } // namespace Thyra
301 
302 
303 #endif // THYRA_DEFUALT_PRECONDITIONER_DECL_HPP
void initializeUnspecified(const Teuchos::RCP< LinearOpBase< Scalar > > &unspecifiedPrecOp)
Initialize a single unspecified preconditioner operator.
Teuchos::RCP< const DefaultPreconditioner< Scalar > > leftPrec(const Teuchos::RCP< const LinearOpBase< Scalar > > &leftPrecOp)
Create a precondioner from a single linear operator targeted to be used on the left.
void initializeRight(const Teuchos::RCP< LinearOpBase< Scalar > > &rightPrecOp)
Initialize a right preconditioner.
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstUnspecifiedPrecOp()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::RCP< const DefaultPreconditioner< Scalar > > rightPrec(const Teuchos::RCP< const LinearOpBase< Scalar > > &rightPrecOp)
Create a precondioner from a single linear operator targeted to be used on the right.
Teuchos::RCP< const LinearOpBase< Scalar > > getRightPrecOp() const
Default implementation of a PreconditionerBase that just accepts precreated preconditioner linear ope...
Teuchos::RCP< const DefaultPreconditioner< Scalar > > unspecifiedPrec(const Teuchos::RCP< const LinearOpBase< Scalar > > &unspecifiedPrecOp)
Create a precondioner from a single linear operator not targeted to be used on the left or the right...
Base class for all linear operators.
Teuchos::RCP< const LinearOpBase< Scalar > > getLeftPrecOp() const
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstLeftPrecOp()
Teuchos::RCP< LinearOpBase< Scalar > > getNonconstRightPrecOp()
Teuchos::RCP< const LinearOpBase< Scalar > > getUnspecifiedPrecOp() const
void initializeLeftRight(const Teuchos::RCP< LinearOpBase< Scalar > > &leftPrecOp, const Teuchos::RCP< LinearOpBase< Scalar > > &rightPrecOp)
Initialize a split left/right preconditioner.
Teuchos::RCP< const DefaultPreconditioner< Scalar > > splitPrec(const Teuchos::RCP< const LinearOpBase< Scalar > > &leftPrecOp, const Teuchos::RCP< const LinearOpBase< Scalar > > &rightPrecOp)
Create a split precondioner from two linear operators, one to be applied on the left and one to be ap...
DefaultPreconditioner()
Construct to uninitialized.
void initializeLeft(const Teuchos::RCP< LinearOpBase< Scalar > > &leftPrecOp)
Initialize a left preconditioner.
Teuchos::RCP< DefaultPreconditioner< Scalar > > nonconstUnspecifiedPrec(const Teuchos::RCP< LinearOpBase< Scalar > > &unspecifiedPrecOp)
Create a precondioner from a single linear operator not targeted to be used on the left or the right...