Ifpack Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
Ifpack_TriDiContainer.h
Go to the documentation of this file.
1/*@HEADER
2// ***********************************************************************
3//
4// Ifpack: Object-Oriented Algebraic Preconditioner Package
5// Copyright (2002) 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 Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40//@HEADER
41*/
42
43#ifndef IFPACK_TRIDICONTAINER_H
44#define IFPACK_TRIDICONTAINER_H
45
46#include "Ifpack_ConfigDefs.h"
47#include "Ifpack_Container.h"
50#include "Epetra_IntSerialDenseVector.h" // Is this needed \cbl
53
55
119
120public:
121
123
125 Ifpack_TriDiContainer(const int NumRows_in, const int NumVectors_in = 1) :
126 NumRows_(NumRows_in),
127 NumVectors_(NumVectors_in),
131 ComputeFlops_(0.0),
132 ApplyFlops_(0.0),
134 {}
135
138 NumRows_(rhs.NumRows()),
139 NumVectors_(rhs.NumVectors()),
143 {
144 Matrix_ = rhs.Matrix();
147 LHS_ = rhs.LHS();
148 RHS_ = rhs.RHS();
149 ID_ = rhs.ID();
150 }
151
154 {}
156
158
161 {
162 if (&rhs == this)
163 return(*this);
164
165 NumRows_ = rhs.NumRows();
166 NumVectors_ = rhs.NumVectors();
167 IsComputed_ = rhs.IsComputed();
169 Matrix_ = rhs.Matrix();
172 LHS_ = rhs.LHS();
173 RHS_ = rhs.RHS();
174 ID_ = rhs.ID();
175
176 return(*this);
177 }
178
180
182
184 virtual int NumRows() const;
185
187 virtual int NumVectors() const
188 {
189 return(NumVectors_);
190 }
191
193 virtual int SetNumVectors(const int NumVectors_in)
194 {
195 if (NumVectors_ == NumVectors_in)
196 return(0);
197
198 NumVectors_ = NumVectors_in;
201 // zero out vector elements
202 for (int i = 0 ; i < NumRows_ ; ++i)
203 for (int j = 0 ; j < NumVectors_ ; ++j) {
204 LHS_(i,j) = 0.0;
205 RHS_(i,j) = 0.0;
206 }
207 if (NumRows_!=0)
208 {
210 }
211 return(0);
212 }
213
215 virtual double& LHS(const int i, const int Vector = 0);
216
218 virtual double& RHS(const int i, const int Vector = 0);
219
221
230 virtual int& ID(const int i);
231
233 virtual int SetMatrixElement(const int row, const int col,
234 const double value);
235
237 virtual int SetParameters(Teuchos::ParameterList& /* List */)
238 {
239 return(0);
240 }
241
243 virtual bool IsInitialized() const
244 {
245 return(IsInitialized_);
246 }
247
249 virtual bool IsComputed() const
250 {
251 return(IsComputed_);
252 }
253
255 virtual const char* Label() const
256 {
257 return(Label_.c_str());
258 }
259
261 virtual int SetKeepNonFactoredMatrix(const bool flag)
262 {
264 return(0);
265 }
266
268 virtual bool KeepNonFactoredMatrix() const
269 {
271 }
272
274 virtual const Epetra_SerialDenseMatrix& LHS() const
275 {
276 return(LHS_);
277 }
278
280 virtual const Epetra_SerialDenseMatrix& RHS() const
281 {
282 return(RHS_);
283 }
284
286 virtual const Ifpack_SerialTriDiMatrix& Matrix() const
287 {
288 return(Matrix_);
289 }
290
293 {
294 return(NonFactoredMatrix_);
295 }
296
298 virtual const Epetra_IntSerialDenseVector& ID() const
299 {
300 return(ID_);
301 }
302
304
306
307 virtual int Initialize();
308
310 virtual int Compute(const Epetra_RowMatrix& Matrix_in);
311
313 virtual int Apply();
314
316 virtual int ApplyInverse();
317
319
320 virtual double InitializeFlops() const
321 {
322 return(0.0);
323 }
324
325 virtual double ComputeFlops() const
326 {
327 return(ComputeFlops_);
328 }
329
330 virtual double ApplyFlops() const
331 {
332 return(ApplyFlops_);
333 }
334
335 virtual double ApplyInverseFlops() const
336 {
337 return(ApplyInverseFlops_);
338 }
339
341 virtual std::ostream& Print(std::ostream& os) const;
342
343private:
344
346 virtual int Extract(const Epetra_RowMatrix& Matrix_in);
347
371 std::string Label_;
372
379};
380
381#endif
#define IFPACK_CHK_ERR(ifpack_err)
int Reshape(int NumRows, int NumCols)
Ifpack_Container: a pure virtual class for creating and solving local linear problems.
Ifpack_SerialTriDiMatrix: A class for constructing and using real double precision general TriDi matr...
Ifpack_SerialTriDiSolver: A class for solving TriDi linear problems.
int SetVectors(Epetra_SerialDenseMatrix &X, Epetra_SerialDenseMatrix &B)
Sets the pointers for left and right hand side vector(s).
Ifpack_TriDiContainer: a class to define containers for dense matrices.
virtual double ComputeFlops() const
Returns the flops in Compute().
virtual bool IsInitialized() const
Returns true is the container has been successfully initialized.
virtual int Compute(const Epetra_RowMatrix &Matrix_in)
Finalizes the linear system matrix and prepares for the application of the inverse.
double ApplyFlops_
Flops in Apply().
virtual int ApplyInverse()
Apply the inverse of the matrix to RHS, results are stored in LHS.
virtual double & LHS(const int i, const int Vector=0)
Returns the i-th component of the vector Vector of LHS.
virtual const char * Label() const
Returns the label of this container.
virtual const Ifpack_SerialTriDiMatrix & NonFactoredMatrix() const
Returns the non-factored dense matrix (only if stored).
virtual double & RHS(const int i, const int Vector=0)
Returns the i-th component of the vector Vector of RHS.
virtual const Epetra_SerialDenseMatrix & RHS() const
Returns the dense vector containing the RHS.
virtual int Initialize()
Initialize the container.
int NumRows_
Number of rows in the container.
Ifpack_TriDiContainer(const Ifpack_TriDiContainer &rhs)
Copy constructor.
virtual int Apply()
Apply the matrix to RHS, results are stored in LHS.
Epetra_SerialDenseMatrix LHS_
SerialDense vector representing the LHS.
Epetra_SerialDenseMatrix RHS_
SerialDense vector representing the RHS.
virtual double ApplyInverseFlops() const
Returns the flops in ApplyInverse().
Ifpack_SerialTriDiMatrix NonFactoredMatrix_
TriDi matrix, that contains the non-factored matrix.
virtual int SetKeepNonFactoredMatrix(const bool flag)
If flag is true, keeps a copy of the non-factored matrix.
Ifpack_TriDiContainer(const int NumRows_in, const int NumVectors_in=1)
Default constructor.
virtual double ApplyFlops() const
Returns the flops in Apply().
double ApplyInverseFlops_
Flops in ApplyInverse().
virtual int SetMatrixElement(const int row, const int col, const double value)
Set the matrix element (row,col) to value.
Epetra_IntSerialDenseVector ID_
Sets of local rows.
Ifpack_SerialTriDiMatrix Matrix_
TriDi matrix.
virtual int SetParameters(Teuchos::ParameterList &)
Sets all necessary parameters.
virtual const Epetra_IntSerialDenseVector & ID() const
Returns the integer dense vector of IDs.
Ifpack_TriDiContainer & operator=(const Ifpack_TriDiContainer &rhs)
Operator=.
bool IsComputed_
If true, the container has been successfully computed.
virtual const Ifpack_SerialTriDiMatrix & Matrix() const
Returns the dense matrix or its factors.
Ifpack_SerialTriDiSolver Solver_
TriDi solver (solution will be get using LAPACK).
bool IsInitialized_
If true, the container has been successfully initialized.
virtual int Extract(const Epetra_RowMatrix &Matrix_in)
Extract the submatrices identified by the ID set int ID().
virtual int NumRows() const
Returns the number of rows of the matrix and LHS/RHS.
virtual int SetNumVectors(const int NumVectors_in)
Sets the number of vectors for LHS/RHS.
virtual bool KeepNonFactoredMatrix() const
Returns KeepNonFactoredMatrix_.
std::string Label_
Label for this object.
virtual bool IsComputed() const
Returns true is the container has been successfully computed.
virtual int & ID(const int i)
Returns the ID associated to local row i.
virtual double InitializeFlops() const
Returns the flops in Initialize().
double ComputeFlops_
Flops in Compute().
virtual const Epetra_SerialDenseMatrix & LHS() const
Returns the dense vector containing the LHS.
virtual ~Ifpack_TriDiContainer()
Destructor.
bool KeepNonFactoredMatrix_
If true, keeps a copy of the non-factored matrix.
int NumVectors_
Number of vectors in the container.
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
virtual int NumVectors() const
Returns the number of vectors in LHS/RHS.
#define false