/[escript]/branches/trilinos_from_5897/trilinoswrap/src/TrilinosMatrixAdapter.h
ViewVC logotype

Contents of /branches/trilinos_from_5897/trilinoswrap/src/TrilinosMatrixAdapter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6104 - (show annotations)
Wed Mar 30 06:01:20 2016 UTC (3 years ago) by caltinay
File MIME type: text/plain
File size: 2727 byte(s)
Factored out and templetized preconditioner,solver and direct solver creation.
The SystemMatrix constructor now takes an optional arg 'isComplex'.
Some complex operations are commented out as we need the complex getSampleData*
methods from trunk for them to work.

It looks like we have to modify the Abstract class in escript eventually as
there is a single method that takes a `double` argument (nullifyRowsAndCols).


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 #ifndef __TRILINOSMATRIXADAPTER_H__
18 #define __TRILINOSMATRIXADAPTER_H__
19
20 #include <escript/AbstractSystemMatrix.h>
21 #include <escript/FunctionSpace.h>
22
23 #include <trilinoswrap/types.h>
24
25 namespace escript {
26 class SolverBuddy;
27 }
28
29 namespace esys_trilinos {
30
31 class TrilinosMatrixAdapter : public escript::AbstractSystemMatrix
32 {
33 public:
34 /**
35 \brief
36 Creates a new Trilinos CRS matrix adapter using a compatible
37 fill-complete Trilinos matrix graph.
38 */
39 TrilinosMatrixAdapter(escript::JMPI mpiInfo, int blocksize,
40 const escript::FunctionSpace& fs,
41 const_TrilinosGraph_ptr graph, bool isComplex=false);
42
43 virtual ~TrilinosMatrixAdapter() {}
44
45 virtual void nullifyRowsAndCols(escript::Data& row_q,
46 escript::Data& col_q,
47 double mdv);
48
49 virtual void saveMM(const std::string& filename) const;
50 virtual void saveHB(const std::string& filename) const;
51 virtual void resetValues();
52
53 /// notifies the matrix that changes are about to happen.
54 inline void resumeFill()
55 {
56 if (m_isComplex)
57 cmat->resumeFill();
58 else
59 mat->resumeFill();
60 }
61
62 /// notifies the matrix that a set of changes has occured.
63 void fillComplete(bool localOnly = true);
64
65 template<typename ST>
66 void add(const std::vector<LO>& rowIndex, const std::vector<ST>& array);
67
68 inline int getBlockSize() const { return getRowBlockSize(); }
69
70 private:
71 virtual void setToSolution(escript::Data& out, escript::Data& in,
72 boost::python::object& options) const;
73
74 virtual void ypAx(escript::Data& y, escript::Data& x) const;
75
76 template<typename ST>
77 void addImpl(Teuchos::RCP<MatrixType<ST> > A,
78 const std::vector<LO>& rowIdx, const std::vector<ST>& array);
79
80 escript::JMPI m_mpiInfo;
81 bool m_isComplex;
82 Teuchos::RCP<RealMatrix> mat;
83 Teuchos::RCP<ComplexMatrix> cmat;
84 Teuchos::RCP<const ImportType> importer;
85 };
86
87 } // namespace esys_trilinos
88
89 #endif // __TRILINOSMATRIXADAPTER_H__
90

  ViewVC Help
Powered by ViewVC 1.1.26