EpetraExt Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EpetraExt_ProductOperator.h
Go to the documentation of this file.
1 //@HEADER
2 // ***********************************************************************
3 //
4 // EpetraExt: Epetra Extended - Linear Algebra Services Package
5 // Copyright (2011) Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
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 Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 //@HEADER
41 
42 #ifndef EPETRAEXT_PRODUCT_OPERATOR_H
43 #define EPETRAEXT_PRODUCT_OPERATOR_H
44 
45 #include "Epetra_Operator.h"
46 #include "Teuchos_RCP.hpp"
47 #include "Teuchos_BLAS_types.hpp"
48 #include <vector>
49 
50 class Epetra_Vector;
51 
52 namespace EpetraExt {
53 
134 public:
135 
138 
141 
143 
146 
148  ProductOperator();
149 
152  const int num_Op
154  ,const Teuchos::ETransp Op_trans[]
155  ,const EApplyMode Op_inverse[]
156  );
157 
221  void initialize(
222  const int num_Op
224  ,const Teuchos::ETransp Op_trans[]
225  ,const EApplyMode Op_inverse[]
226  );
227 
234  void uninitialize(
235  int *num_Op
238  ,EApplyMode p_inverse[]
239  );
240 
258  void applyConstituent(
259  const int k
262  ,const Epetra_MultiVector &X_k
263  ,Epetra_MultiVector *Y_k
264  ) const;
265 
271  int num_Op() const;
272 
285 
292  Teuchos::ETransp Op_trans(int k) const;
293 
300  EApplyMode Op_inverse(int k) const;
301 
303 
306 
308  int SetUseTranspose(bool UseTranspose);
310  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
312  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
314  double NormInf() const;
316  const char * Label() const;
318  bool UseTranspose() const;
320  bool HasNormInf() const;
322  const Epetra_Comm & Comm() const;
324  const Epetra_Map & OperatorDomainMap() const;
326  const Epetra_Map & OperatorRangeMap() const;
327 
329 
330 private:
331 
332  // ////////////////////////////
333  // Private types
334 
335  typedef std::vector<Teuchos::RCP<const Epetra_Operator> > Op_t;
336  typedef std::vector<Teuchos::ETransp> Op_trans_t;
337  typedef std::vector<EApplyMode> Op_inverse_t;
338  typedef std::vector<Teuchos::RCP<Epetra_Vector> > EV_t;
339 
340  // ////////////////////////////
341  // Private data members
342 
347 
348  mutable EV_t range_vecs_;
350 
351  // ////////////////////////////
352  // Private member functions
353 
354  void assertInitialized() const;
355  void validateIndex(int k) const;
356  void initializeTempVecs(bool applyInverse) const;
357 
358 }; // class ProductOperator
359 
360 // ////////////////////////////
361 // Inline members
362 
363 // public
364 
365 inline
367 {
368  return Op_.size();
369 }
370 
371 inline
374 {
375  validateIndex(k);
376  return Op_[k];
377 }
378 
379 inline
382 {
383  validateIndex(k);
384  return Op_trans_[k];
385 }
386 
387 inline
390 {
391  validateIndex(k);
392  return Op_inverse_[k];
393 }
394 
395 
396 // private
397 
398 inline
400 {
402  Op_.size()==0, std::logic_error
403  ,"Epetra::ProductOperator: Error, Client has not called initialize(...) yet!"
404  );
405 }
406 
407 inline
409 {
411  k < 0 || static_cast<int>(Op_.size())-1 < k, std::logic_error
412  ,"Epetra::ProductOperator: Error, k = "<<k<< " is not in the range [0,"<<Op_.size()-1<<"]!"
413  );
414 }
415 
416 } // namespace EpetraExt
417 
418 #endif // EPETRAEXT_PRODUCT_OPERATOR_H
const Epetra_Map & OperatorDomainMap() const
std::vector< Teuchos::ETransp > Op_trans_t
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void initialize(const int num_Op, const Teuchos::RCP< const Epetra_Operator > Op[], const Teuchos::ETransp Op_trans[], const EApplyMode Op_inverse[])
Setup with constituent operators.
Implements Epetra_Operator as a product of one or more Epetra_Operator objects.
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
void initializeTempVecs(bool applyInverse) const
ProductOperator()
Construct to uninitialized.
const Epetra_Comm & Comm() const
int num_Op() const
Return the number of aggregate opeators.
const Epetra_Map & OperatorRangeMap() const
Teuchos::RCP< const Epetra_Operator > Op(int k) const
Access the kth operator (zero-based).
Teuchos::ETransp Op_trans(int k) const
Access the transpose mode of the kth operator (zero-based).
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
std::vector< EApplyMode > Op_inverse_t
EApplyMode Op_inverse(int k) const
Access the inverse mode of the kth operator (zero-based).
void uninitialize(int *num_Op, Teuchos::RCP< const Epetra_Operator > Op[], Teuchos::ETransp Op_trans[], EApplyMode p_inverse[])
Set to an uninitialized state and wipe out memory.
void applyConstituent(const int k, Teuchos::ETransp Op_trans, EApplyMode Op_inverse, const Epetra_MultiVector &X_k, Epetra_MultiVector *Y_k) const
Apply the kth aggregate operator M[k] correctly.
std::vector< Teuchos::RCP< const Epetra_Operator > > Op_t
std::vector< Teuchos::RCP< Epetra_Vector > > EV_t