*/
SparseVanka();
+ /**
+ * Constructor which also takes two deprecated inputs.
+ *
+ * @deprecated The use of the last two parameters is deprecated. They are
+ * currently ignored.
+ */
+ DEAL_II_DEPRECATED
+ SparseVanka(const SparseMatrix<number> &M,
+ const std::vector<bool> & selected,
+ const bool conserve_memory,
+ const unsigned int n_threads = MultithreadInfo::n_threads());
+
/**
* Constructor. Gets the matrix for preconditioning and a bit vector with
* entries @p true for all rows to be updated. A reference to this vector
* conceivable that the preconditioner is build up for one matrix once, but
* is used for subsequent steps in a nonlinear process as well, where the
* matrix changes in each step slightly.
- *
- * If @p conserve_mem is @p false, then the inverses of the local systems
- * are computed now; if the flag is @p true, then they are computed every
- * time the preconditioner is applied. This saves some memory, but makes
- * preconditioning very slow. Note also, that if the flag is @p false, then
- * the contents of the matrix @p M at the time of calling this constructor
- * are used, while if the flag is @p true, then the values in @p M at the
- * time of preconditioning are used. This may lead to different results,
- * obviously, of @p M changes.
- *
- * The parameter @p n_threads determines how many threads shall be used in
- * parallel when building the inverses of the diagonal blocks. This
- * parameter is ignored if not in multithreaded mode.
*/
- SparseVanka(const SparseMatrix<number> &M,
- const std::vector<bool> & selected,
- const bool conserve_memory = false,
- const unsigned int n_threads = MultithreadInfo::n_threads());
+ SparseVanka(const SparseMatrix<number> &M, const std::vector<bool> &selected);
/**
* Destructor. Delete all allocated matrices.
/**
* Constructor. For the parameters' description, see below.
*/
+ explicit AdditionalData(const std::vector<bool> &selected);
+
+ /**
+ * Constructor. For the parameters' description, see below.
+ *
+ * @deprecated The use of this constructor is deprecated - the second and
+ * third parameters are ignored.
+ */
+ DEAL_II_DEPRECATED
AdditionalData(const std::vector<bool> &selected,
- const bool conserve_memory = false,
+ const bool conserve_memory,
const unsigned int n_threads = MultithreadInfo::n_threads());
/**
* Indices of those degrees of freedom that we shall work on.
*/
const std::vector<bool> &selected;
-
- /**
- * Conserve memory flag.
- */
- const bool conserve_mem;
-
- /**
- * Number of threads to be used when building the inverses. Only relevant
- * in multithreaded mode.
- */
- const unsigned int n_threads;
};
*/
SmartPointer<const SparseMatrix<number>, SparseVanka<number>> matrix;
- /**
- * Conserve memory flag.
- */
- bool conserve_mem;
-
/**
* Indices of those degrees of freedom that we shall work on.
*/
const std::vector<bool> *selected;
- /**
- * Number of threads to be used when building the inverses. Only relevant in
- * multithreaded mode.
- */
- unsigned int n_threads;
-
/**
* Array of inverse matrices, one for each degree of freedom. Only those
* elements will be used that are tagged in @p selected.
/**
* Constructor. Pass all arguments except for @p n_blocks to the base class.
+ *
+ * @deprecated This constructor is deprecated. The values passed to the last
+ * two arguments are ignored.
*/
+ DEAL_II_DEPRECATED
SparseBlockVanka(const SparseMatrix<number> &M,
const std::vector<bool> & selected,
const unsigned int n_blocks,
const BlockingStrategy blocking_strategy,
- const bool conserve_memory = false,
+ const bool conserve_memory,
const unsigned int n_threads = MultithreadInfo::n_threads());
+ /**
+ * Constructor. Pass all arguments except for @p n_blocks to the base class.
+ */
+ SparseBlockVanka(const SparseMatrix<number> &M,
+ const std::vector<bool> & selected,
+ const unsigned int n_blocks,
+ const BlockingStrategy blocking_strategy);
+
/**
* Apply the preconditioner.
*/
template <typename number>
SparseVanka<number>::SparseVanka()
: matrix()
- , conserve_mem(false)
, selected()
- , n_threads(0)
, inverses()
, _m(0)
, _n(0)
template <typename number>
SparseVanka<number>::SparseVanka(const SparseMatrix<number> &M,
const std::vector<bool> & selected_dofs,
- const bool conserve_mem,
- const unsigned int n_threads)
+ const bool /*conserve_mem*/,
+ const unsigned int /*n_threads*/)
+ : SparseVanka(M, selected_dofs)
+{}
+
+template <typename number>
+SparseVanka<number>::SparseVanka(const SparseMatrix<number> &M,
+ const std::vector<bool> & selected_dofs)
: matrix(&M, typeid(*this).name())
- , conserve_mem(conserve_mem)
, selected(&selected_dofs)
- , n_threads(n_threads)
, inverses(M.m(), nullptr)
, _m(M.m())
, _n(M.n())
Assert(M.m() == selected->size(),
ExcDimensionMismatch(M.m(), selected->size()));
- if (conserve_mem == false)
- compute_inverses();
+ compute_inverses();
}
SparseVanka<number>::initialize(const SparseMatrix<number> &M,
const AdditionalData & additional_data)
{
- matrix = &M;
- conserve_mem = additional_data.conserve_mem;
- selected = &(additional_data.selected);
- n_threads = additional_data.n_threads;
+ matrix = &M;
+ selected = &(additional_data.selected);
inverses.resize(M.m());
_m = M.m();
_n = M.n();
Assert(M.m() == selected->size(),
ExcDimensionMismatch(M.m(), selected->size()));
- if (conserve_mem == false)
- compute_inverses();
+ compute_inverses();
}
template <typename number>
#else
const size_type n_inverses =
std::count(selected->begin(), selected->end(), true);
-
- const size_type n_inverses_per_thread =
+ const std::size_t n_threads = MultithreadInfo::n_threads();
+ const size_type n_inverses_per_thread =
std::max(n_inverses / n_threads, static_cast<size_type>(1U));
// set up start and end index
{
const size_type row_length = structure.row_length(row);
- // if we don't store the
- // inverse matrices, then alias
- // the entry in the global
- // vector to the local matrix
- // to be used
- if (conserve_mem == true)
- {
- inverses[row] = &local_matrix;
- inverses[row]->reinit(row_length, row_length);
- }
-
b.reinit(row_length);
x.reinit(row_length);
// mapping between:
((*dof_mask)[p->column()] == true))
b(i) -= p->value() * dst(p->column());
}
- else
- // if so, then build the
- // matrix out of it
- if (conserve_mem == true)
- (*inverses[row])(i, js->second) = p->value();
}
}
- // Compute new values
- if (conserve_mem == true)
- inverses[row]->gauss_jordan();
-
// apply preconditioner
inverses[row]->vmult(x, b);
// do nothing if not in
// the range
}
-
- // if we don't store the
- // inverses, then unalias the
- // local matrix
- if (conserve_mem == true)
- inverses[row] = nullptr;
}
}
}
+
template <typename number>
SparseVanka<number>::AdditionalData::AdditionalData(
- const std::vector<bool> &selected,
- const bool conserve_mem,
- const unsigned int n_threads)
+ const std::vector<bool> &selected)
: selected(selected)
- , conserve_mem(conserve_mem)
- , n_threads(n_threads)
+{}
+
+
+
+template <typename number>
+SparseVanka<number>::AdditionalData::AdditionalData(
+ const std::vector<bool> &selected,
+ const bool /*conserve_mem*/,
+ const unsigned int /*n_threads*/)
+ : AdditionalData(selected)
{}
const SparseMatrix<number> &M,
const std::vector<bool> & selected,
const unsigned int n_blocks,
- const BlockingStrategy blocking_strategy,
- const bool conserve_memory,
- const unsigned int n_threads)
- : SparseVanka<number>(M, selected, conserve_memory, n_threads)
+ const BlockingStrategy blocking_strategy)
+ : SparseVanka<number>(M, selected)
, n_blocks(n_blocks)
, dof_masks(n_blocks, std::vector<bool>(M.m(), false))
{
}
+template <typename number>
+SparseBlockVanka<number>::SparseBlockVanka(
+ const SparseMatrix<number> &M,
+ const std::vector<bool> & selected,
+ const unsigned int n_blocks,
+ const BlockingStrategy blocking_strategy,
+ const bool /*conserve_memory*/,
+ const unsigned int /*n_threads*/)
+ : SparseBlockVanka(M, selected, n_blocks, blocking_strategy)
+{}
+
+
template <typename number>
void
SparseBlockVanka<number>::compute_dof_masks(