ShyLU  Version of the Day
shylu_probing_operator.h
1 
2 //@HEADER
3 // ************************************************************************
4 //
5 // ShyLU: Hybrid preconditioner package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 
43 
44 #ifndef SHYLU_PROBING_OPERATOR_H
45 #define SHYLU_PROBING_OPERATOR_H
46 
47 #include <Epetra_Operator.h>
48 #include <Epetra_CrsMatrix.h>
49 #include <Epetra_LinearProblem.h>
50 #include <Amesos_BaseSolver.h>
51 #include <Epetra_MultiVector.h>
52 #include <Epetra_Map.h>
53 #include <Epetra_Comm.h>
54 #include <Teuchos_Time.hpp>
55 #include <Teuchos_RCP.hpp>
56 #include "shylu_symbolic.h"
57 #include "shylu_util.h"
58 #include "shylu_config.h"
59 
60 
61 class ShyLU_Probing_Operator : public virtual Epetra_Operator
62 {
63 
64  public:
65 
66  // TODO: Change to RCPs
68  shylu_symbolic *sym,
69  Epetra_CrsMatrix *G, Epetra_CrsMatrix *R,
70  Epetra_LinearProblem *LP, Amesos_BaseSolver *solver,
71  Ifpack_Preconditioner *ifSolver, Epetra_CrsMatrix *C,
72  Epetra_Map *LocalDRowMap, int nvectors);
73 
74  int SetUseTranspose(bool useTranspose);
75 
76  int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
77 
78  int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
79 
80  double NormInf() const;
81 
82  const char *Label() const;
83 
84  bool UseTranspose() const;
85 
86  bool HasNormInf() const;
87 
88  const Epetra_Comm& Comm() const;
89 
90  const Epetra_Map& OperatorDomainMap() const;
91 
92  const Epetra_Map& OperatorRangeMap() const;
93 
94  void PrintTimingInfo();
95 
96  void ResetTempVectors(int nvectors);
97 
98  mutable int cntApply;
99 
100  Epetra_CrsMatrix *G_;
101  Epetra_CrsMatrix *R_;
102  Epetra_LinearProblem *LP_;
103  Amesos_BaseSolver *solver_;
104  Ifpack_Preconditioner *ifSolver_;
105  Epetra_CrsMatrix *C_;
106  Epetra_Map *localDRowMap_;
107 
108  int nvectors_;
109  Teuchos::RCP<Epetra_MultiVector> temp;
110  Teuchos::RCP<Epetra_MultiVector> temp2;
111  Teuchos::RCP<Epetra_MultiVector> ltemp;
112  Teuchos::RCP<Epetra_MultiVector> localX;
113  shylu_symbolic * ssym_; // symbolic structure
114  shylu_config * config_;
115 
116 #ifdef TIMING_OUTPUT
117  Teuchos::RCP<Teuchos::Time> matvec_time_;
118  Teuchos::RCP<Teuchos::Time> localize_time_;
119  Teuchos::RCP<Teuchos::Time> trisolve_time_;
120  Teuchos::RCP<Teuchos::Time> dist_time_;
121  Teuchos::RCP<Teuchos::Time> matvec2_time_;
122  Teuchos::RCP<Teuchos::Time> apply_time_;
123  Teuchos::RCP<Teuchos::Time> update_time_;
124 #endif
125 
126 };
127 #endif // SHYLU_PROBING_OPERATOR_H
Utilities for ShyLU.