#include <deal.II/lac/lapack_full_matrix.h>
#include <deal.II/lac/vector.h>
+#include <deal.II/base/std_cxx14/memory.h>
+
#include <vector>
#include <cmath>
#include <algorithm>
VectorMemory<VectorType> &vmem);
/**
- * Delete all allocated vectors.
+ * Destructor. Delete all allocated vectors.
*/
- ~TmpVectors();
+ ~TmpVectors() = default;
/**
* Get vector number @p i. If this vector was unused before, an error
/**
* Field for storing the vectors.
*/
- std::vector<VectorType *> data;
+ std::vector<typename VectorMemory<VectorType>::Pointer> data;
/**
* Offset of the first vector. This is for later when vector rotation
VectorMemory<VectorType> &vmem)
:
mem(vmem),
- data (max_size, nullptr),
+ data (max_size),
offset(0)
{}
- template <class VectorType>
- inline
- TmpVectors<VectorType>::~TmpVectors ()
- {
- for (typename std::vector<VectorType *>::iterator v = data.begin();
- v != data.end(); ++v)
- if (*v != nullptr)
- mem.free(*v);
- }
-
template <class VectorType>
inline VectorType &
}
+
template <class VectorType>
inline VectorType &
TmpVectors<VectorType>::operator() (const unsigned int i,
ExcIndexRange(i,-offset, data.size()-offset));
if (data[i-offset] == nullptr)
{
- data[i-offset] = mem.alloc();
+ data[i-offset] = std::move(typename VectorMemory<VectorType>::Pointer(mem));
data[i-offset]->reinit(temp);
}
return *data[i-offset];
}
+
template <class VectorType>
unsigned int
TmpVectors<VectorType>::size() const
}
+
// A comparator for better printing eigenvalues
inline
bool complex_less_pred(const std::complex<double> &x,
VectorType &v = tmp_vectors(0, x);
VectorType &p = tmp_vectors(n_tmp_vectors-1, x);
- // Following vectors are needed
- // when not the default residuals
- // are used as stopping criterion
- VectorType *r=nullptr;
- VectorType *x_=nullptr;
- dealii::Vector<double> *gamma_=nullptr;
+ // Following vectors are needed when we are not using the default residuals
+ // as stopping criterion
+ typename VectorMemory<VectorType>::Pointer r;
+ typename VectorMemory<VectorType>::Pointer x_;
+ std::unique_ptr<dealii::Vector<double> > gamma_;
if (!use_default_residual)
{
- r=this->memory.alloc();
- x_=this->memory.alloc();
+ r = std::move(typename VectorMemory<VectorType>::Pointer(this->memory));
+ x_ = std::move(typename VectorMemory<VectorType>::Pointer(this->memory));
r->reinit(x);
x_->reinit(x);
- gamma_ = new dealii::Vector<double> (gamma.size());
+ gamma_ = std_cxx14::make_unique<dealii::Vector<double> >(gamma.size());
}
bool re_orthogonalize = additional_data.force_re_orthogonalization;
if (!krylov_space_signal.empty())
krylov_space_signal(tmp_vectors);
- if (!use_default_residual)
- {
- this->memory.free(r);
- this->memory.free(x_);
-
- delete gamma_;
- }
-
deallog.pop();
// in case of failure: throw exception
// Iteration starts here
double res = -std::numeric_limits<double>::max();
- VectorType *aux = this->memory.alloc();
+ typename VectorMemory<VectorType>::Pointer aux (this->memory);
aux->reinit(x);
do
{
}
while (iteration_state == SolverControl::iterate);
- this->memory.free(aux);
-
deallog.pop();
// in case of failure: throw exception
if (iteration_state != SolverControl::success)