ShyLU  Version of the Day
shylu_local_schur_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_LOCAL_SCHUR_OPERATOR_H
45 #define SHYLU_LOCAL_SCHUR_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_util.h"
57 #include "shylu.h"
58 #include <EpetraExt_Reindex_MultiVector.h>
59 
60 class ShyLU_Local_Schur_Operator : public virtual Epetra_Operator
61 {
62 
63  public:
64 
65  // TODO: Change to RCPs
67  shylu_config *config,
68  shylu_symbolic *ssym, // symbolic structure
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 
75  {
76  ssym_->OrigLP->SetLHS(orig_lhs_);
77  ssym_->OrigLP->SetRHS(orig_rhs_);
78  ssym_->ReIdx_LP->fwd();
79  }
80 
81  int SetUseTranspose(bool useTranspose);
82 
83  int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
84 
85  int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
86 
87  double NormInf() const;
88 
89  const char *Label() const;
90 
91  bool UseTranspose() const;
92 
93  bool HasNormInf() const;
94 
95  const Epetra_Comm& Comm() const;
96 
97  const Epetra_Map& OperatorDomainMap() const;
98 
99  const Epetra_Map& OperatorRangeMap() const;
100 
101  void PrintTimingInfo();
102 
103  void ResetTempVectors(int nvectors);
104 
105  mutable int cntApply;
106 
107  Epetra_CrsMatrix *G_;
108  Epetra_CrsMatrix *R_;
109  Epetra_LinearProblem *LP_;
110  Amesos_BaseSolver *solver_;
111  Ifpack_Preconditioner *ifSolver_;
112  Epetra_CrsMatrix *C_;
113  Epetra_MultiVector *orig_lhs_;
114  Epetra_MultiVector *orig_rhs_;
115  Epetra_Map *localDRowMap_;
116 
117  int nvectors_;
118  Teuchos::RCP<Epetra_MultiVector> temp;
119  Teuchos::RCP<Epetra_MultiVector> temp2;
120  Teuchos::RCP<Epetra_MultiVector> localX;
121  shylu_symbolic *ssym_; // symbolic structure
122  shylu_config *config_;
123 
124 #ifdef TIMING_OUTPUT
125  Teuchos::RCP<Teuchos::Time> matvec_time_;
126  Teuchos::RCP<Teuchos::Time> localize_time_;
127  Teuchos::RCP<Teuchos::Time> trisolve_time_;
128  Teuchos::RCP<Teuchos::Time> dist_time_;
129  Teuchos::RCP<Teuchos::Time> matvec2_time_;
130  Teuchos::RCP<Teuchos::Time> apply_time_;
131  Teuchos::RCP<Teuchos::Time> update_time_;
132 #endif
133 
134 };
135 #endif // SHYLU_LOCAL_SCHUR_OPERATOR_H
Utilities for ShyLU.
Main header file of ShyLU (Include main user calls)