Skip to content

Commit 217ba88

Browse files
authored
Merge pull request #282 from sethrj/final-cleanup
2 parents 74ec43a + cae3713 commit 217ba88

28 files changed

+384
-1570
lines changed

.clang-format

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Official Tool: clang-format version 8.0.0
2+
BasedOnStyle: google
3+
SortIncludes: false
4+
AlignConsecutiveAssignments: true
5+
AllowShortCaseLabelsOnASingleLine: true
6+
AllowShortIfStatementsOnASingleLine: true

ROADMAP.md

-858
This file was deleted.

ReleaseNotes.txt

-72
This file was deleted.

doc/install.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ wrappers.)
2828
=========== ============== ======================
2929
ForTrilinos Trilinos SWIG
3030
=========== ============== ======================
31-
2.0.0 13.0 4.0.2+fortran
31+
2.0.0 13 4.0.2+fortran
3232
2.0.0-dev3 12.18.1 4.0.2+fortran
3333
2.0.0-dev2 12.18.1 4.0.0+fortran+15e6ed59
3434
2.0.0-dev1 12.17+8a82b322 4.0.0+fortran+15e6ed59
@@ -46,12 +46,12 @@ That code is no longer developed and maintained, and is available using the
4646
Spack
4747
-----
4848

49-
To install ForTrilinos version ``2.0.0-dev2`` through an existing Spack
49+
To install ForTrilinos version ``2.0.0`` through an existing Spack
5050
installation (v0.16 or higher, or the ``develop`` branch):
5151

5252
.. code:: console
5353
54-
$ spack install [email protected]-dev2 ^trilinos@12.18.1+nox+stratimikos
54+
$ spack install [email protected] ^trilinos+nox+stratimikos
5555
5656
Manual
5757
------

scripts/build-yuri.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mkdir build 2>/dev/null || true
88
cd build
99

1010
module purge
11-
SPACK_VIEW=/usr/local/spack/var/spack/environments/fortrilinos/.spack-env/view
11+
SPACK_VIEW=$SPACK_ROOT/var/spack/environments/fortrilinos/.spack-env/view
1212
export CMAKE_PREFIX_PATH=$SPACK_VIEW:$CMAKE_PREFIX_PATH
1313
export PATH=$SPACK_VIEW/bin:$PATH
1414

@@ -19,8 +19,6 @@ cmake -G Ninja \
1919
-DForTrilinos_EXAMPLES:BOOL=ON \
2020
-DForTrilinos_TESTING:BOOL=ON \
2121
-DForTrilinos_USE_SWIG_Fortran:BOOL=ON \
22-
-DSWIG_EXECUTABLE:FILENAME=/rnsdhpc/code/swig-old/swig \
23-
-DSWIG_DIR:FILENAME=/rnsdhpc/code/swig-old/Lib \
2422
..
2523
ninja -v
2624
ctest --output-on-failure

scripts/spack.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
spack:
2+
specs:
3+
- cmake
4+
- ninja
5+
- openmpi
6+
7+
- trilinos +amesos2 +anasazi +belos +teuchos +kokkos +ifpack2 +muelu +nox +tpetra
8+
+stratimikos +mpi gotype=long_long
9+
view: true
10+
concretization: together
11+
packages:
12+
trilinos:
13+
variants: ~adios2 ~alloptpkgs ~boost ~cgns ~chaco ~complex ~debug ~dtk ~exodus
14+
+explicit_template_instantiation ~float +fortran ~glm ~gtest ~hypre ~intrepid2
15+
~isorropia ~matio ~mesquite ~metis ~minitensor ~mumps ~netcdf ~openmp ~phalanx
16+
~piro ~pnetcdf ~python ~rol ~rythmos +shared ~shylu ~stk ~suite-sparse ~superlu
17+
~superlu-dist ~teko ~tempus ~x11 ~xsdkflags ~zlib ~zoltan ~zoltan2 ~epetra
18+
~amesos ~epetraext ~ifpack ~aztec
19+
all:
20+
providers:
21+
blas: [openblas]
22+
lapack: [openblas]
23+
mpi: [openmpi]

src/fortrilinos_hl/eigen_handle.cpp

+22-24
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,11 @@
2727

2828
namespace ForTrilinos {
2929

30-
void TrilinosEigenSolver::init() {
31-
TEUCHOS_ASSERT(status_ == NOT_INITIALIZED);
32-
comm_ = Teuchos::DefaultComm<int>::getComm();
33-
status_ = INITIALIZED;
34-
}
30+
TrilinosEigenSolver::TrilinosEigenSolver()
31+
: comm_(Teuchos::DefaultComm<int>::getComm()), status_(INITIALIZED) {}
3532

36-
void TrilinosEigenSolver::init(const Teuchos::RCP<const Teuchos::Comm<int>>& comm) {
37-
TEUCHOS_ASSERT(status_ == NOT_INITIALIZED);
38-
comm_ = comm;
39-
status_ = INITIALIZED;
40-
}
33+
TrilinosEigenSolver::TrilinosEigenSolver(const Teuchos::RCP<const Teuchos::Comm<int>>& comm)
34+
: comm_(comm), status_(INITIALIZED) {}
4135

4236
void TrilinosEigenSolver::setup_matrix(const Teuchos::RCP<Matrix>& A) {
4337
TEUCHOS_ASSERT(status_ == INITIALIZED);
@@ -128,30 +122,36 @@ namespace ForTrilinos {
128122
status_ = SOLVER_SETUP;
129123
}
130124

125+
int TrilinosEigenSolver::max_eigenvalues() const {
126+
TEUCHOS_ASSERT(status_ >= SOLVER_SETUP);
127+
return numEigenvalues_;
128+
}
129+
131130
int TrilinosEigenSolver::solve(Teuchos::ArrayView<SC> eigenValues,
132131
Teuchos::RCP<MultiVector>& eigenVectors,
133-
Teuchos::ArrayView<int> eigenIndex) const {
132+
Teuchos::ArrayView<int> eigenIndex) {
134133
using Teuchos::RCP;
135134
using Teuchos::ArrayRCP;
136135

137-
TEUCHOS_ASSERT(status_ == SOLVER_SETUP);
136+
TEUCHOS_ASSERT(status_ >= SOLVER_SETUP);
138137

139138
Anasazi::ReturnType r = solver_->solve();
140-
TEUCHOS_ASSERT(r == 0);
139+
status_ = SOLVED;
140+
converged_ = (r == Anasazi::Converged);
141+
numIters_ = solver_->getNumIters();
141142

142143
// Extract solution
143144
Anasazi::Eigensolution<SC,MultiVector> solution = solver_->getProblem().getSolution();
144145

145146
int eNum = solution.numVecs;
146-
TEUCHOS_ASSERT(eNum > 0);
147147
std::vector<Anasazi::Value<SC>>& eValues = solution.Evals;
148148
std::vector<int>& eIndex = solution.index;
149149

150150
size_t numConverged = std::min(eNum, numEigenvalues_);
151151
TEUCHOS_TEST_FOR_EXCEPTION(2 * eigenValues.size() < numConverged, std::runtime_error,
152152
"Insufficient space to store eigenvalues. Please provide at least two times the desired number of eigenvalues.");
153153
TEUCHOS_TEST_FOR_EXCEPTION(eigenIndex.size() < numConverged, std::runtime_error,
154-
"Insufficient space to store index. Please provide at least two times the desired number of eigenvalues.");
154+
"Insufficient space to store index. Please provide at least the desired number of eigenvalues.");
155155

156156
for (size_t i = 0; i < eValues.size(); i++) {
157157
eigenValues[2*i+0] = eValues[i].realpart;
@@ -166,15 +166,13 @@ namespace ForTrilinos {
166166
return eValues.size();
167167
}
168168

169-
void TrilinosEigenSolver::finalize() {
170-
// No need to check the status_, we can finalize() at any moment.
171-
comm_ = Teuchos::null;
172-
A_ = Teuchos::null;
173-
M_ = Teuchos::null;
174-
solver_ = Teuchos::null;
175-
paramList_ = Teuchos::null;
176-
177-
status_ = NOT_INITIALIZED;
169+
bool TrilinosEigenSolver::converged() const {
170+
TEUCHOS_ASSERT(status_ >= SOLVED);
171+
return converged_;
178172
}
179173

174+
int TrilinosEigenSolver::num_iters() const {
175+
TEUCHOS_ASSERT(status_ >= SOLVED);
176+
return numIters_;
177+
}
180178
}

src/fortrilinos_hl/eigen_handle.hpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -44,47 +44,45 @@ namespace ForTrilinos {
4444
public:
4545

4646
// Constructors
47-
TrilinosEigenSolver() : status_(NOT_INITIALIZED) { }
48-
49-
TrilinosEigenSolver(const TrilinosEigenSolver&) = delete;
50-
void operator=(const TrilinosEigenSolver&) = delete;
51-
52-
// Initialize
53-
void init();
54-
void init(const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
47+
TrilinosEigenSolver();
48+
explicit TrilinosEigenSolver(const Teuchos::RCP<const Teuchos::Comm<int>>& comm);
5549

5650
// Setup matrices by construction
57-
void setup_matrix (const Teuchos::RCP<Matrix>& A);
51+
void setup_matrix(const Teuchos::RCP<Matrix>& A);
5852
void setup_matrix_rhs(const Teuchos::RCP<Matrix>& M);
5953

6054
// Setup operators
61-
void setup_operator (const Teuchos::RCP<Operator>& A);
55+
void setup_operator(const Teuchos::RCP<Operator>& A);
6256
void setup_operator_rhs(const Teuchos::RCP<Operator>& M);
6357

6458
// Setup solver based on the parameter list
6559
void setup_solver(const Teuchos::RCP<Teuchos::ParameterList>& paramList);
60+
// Maximum number of eigenvalues to solve for
61+
int max_eigenvalues() const;
6662

6763
// Solve eigen system given rhs
6864
int solve(Teuchos::ArrayView<SC> eigenValues,
6965
Teuchos::RCP<MultiVector>& eigenVectors,
70-
Teuchos::ArrayView<int> eigenIndex) const;
71-
72-
// Free all data
73-
void finalize();
66+
Teuchos::ArrayView<int> eigenIndex);
67+
// Whether the solver converged
68+
bool converged() const;
69+
// Number of iterations used to solve
70+
int num_iters() const;
7471

7572
private:
7673

7774
Teuchos::RCP<const Teuchos::Comm<int>> comm_;
7875
Teuchos::RCP<Operator> A_, M_;
7976
Teuchos::RCP<SolverManager> solver_;
80-
Teuchos::RCP<ParameterList> paramList_;
8177
int numEigenvalues_;
78+
int numIters_;
79+
bool converged_;
8280

8381
enum Status {
84-
NOT_INITIALIZED,
8582
INITIALIZED,
8683
MATRIX_SETUP,
8784
SOLVER_SETUP,
85+
SOLVED,
8886
} status_;
8987
};
9088

src/fortrilinos_hl/fortrilinos_hl.i

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef char Packet;
3030
#include "fortrilinos_hl/eigen_handle.hpp"
3131
%}
3232

33+
%fortransubroutine ForTrilinos::TrilinosSolver::solve;
3334
%include "solver_handle.hpp"
3435
%include "eigen_handle.hpp"
3536

0 commit comments

Comments
 (0)