Skip to content
Snippets Groups Projects
Commit 37d19468 authored by Christoph Grüninger's avatar Christoph Grüninger
Browse files

[!347] Cherry pick/multitypeblockvector size methods

Merge branch 'cherry-pick/multitypeblockvector-size-methods' into 'releases/2.7'

See merge request [core/dune-istl!347]

  [core/dune-istl!347]: Nonecore/dune-istl/merge_requests/347
parents 37f2936f 3df2d55e
Branches
Tags v2.7.0 v2.7.0rc2
No related merge requests found
......@@ -6,23 +6,14 @@
- `BDMatrix` objects now have the method `solve`, which implements that
canonical way to solve block-diagonal linear systems.
- Deprecated the preconditioner implementations `SeqILU0` and `SeqILUn`.
Use `SeqILU` instead, which implements incomplete LU decomposition
of any order.
- The class `VariableBlockVector::CreateIterator` is a true STL output iterator now.
This means that you can use STL algorithms like `std::fill` or `std::copy`
to set the block sizes.
- Support for SuiteSparse's CHOLMOD providing a sparse Cholesky
factorization.
- `MultiTypeBlockVector<Args...>` now inherits the constructors from its
parent type (`std::tuple<Args...>`). This means you can now also construct
`MultiTypeBlockVector`s from values or references of BlockVectors.
- `MultiTypeBlockVector::count()` is now `const`
- All matrix and vector classes can now be instantiated with number types
directly (A number type is any type for which `Dune::IsNumber<T>::value`
is true). For example, you can now use `BlockVector<double>` instead of
......@@ -38,13 +29,39 @@
With the \*_dl_\* versions instead of the \*_di_\* versions UMFPACK will not
have a memory limit of just 2 GiB.
- Deprecated support for SuperLU 4.x. It will be removed after Dune 2.7.
- Support for SuiteSparse's CHOLMOD providing a sparse Cholesky
factorization.
- The interface methods `dot()` and `norm()` of ScalarProduct are now `const`. You will
have to adjust the method signatures in your own scalar product implementations.
- `MultiTypeBlockVector` now implements the interface method `N()`, which
returns the number of vector entries.
- `MultiTypeBlockVector` now implements the interface method `dim()`, which
returns the number of scalar vector entries.
- `MultiTypeBlockVector::count()` is now `const`
- `SeqILU` can now be used with SIMD data types.
## Deprecations and removals
- Deprecated support for SuperLU 4.x. It will be removed after Dune 2.7.
- Deprecated the preconditioner implementations `SeqILU0` and `SeqILUn`.
Use `SeqILU` instead, which implements incomplete LU decomposition
of any order.
- The method `setSolverCategory` of `OwnerOverlapCopyCommunication` is deprecated and
will be removed after Dune 2.7. The solver category can only be set in the constructor.
- The method `MultiTypeBlockVector::count()` has been deprecated, because its name
is inconsistent with the name mandated by the `dune-istl` vector interface.
- The method `MultiTypeBlockMatrix::size()` has been deprecated, because its name
is inconsistent with the name mandated by the `dune-istl` vector interface.
# Release 2.6
- `BDMatrix` objects can now be constructed and assigned from `std::initializer_list`.
......
......@@ -49,22 +49,25 @@ namespace Dune {
*/
typedef MultiTypeBlockMatrix<FirstRow, Args...> type;
/** \brief Type used for sizes */
using size_type = std::size_t;
typedef typename FirstRow::field_type field_type;
/** \brief Return the number of matrix rows */
static constexpr std::size_t N()
static constexpr size_type N()
{
return 1+sizeof...(Args);
}
/** \brief Return the number of matrix rows */
static constexpr std::size_t size()
static constexpr size_type size() DUNE_DEPRECATED_MSG("Use method 'N' instead")
{
return 1+sizeof...(Args);
}
/** \brief Return the number of matrix columns */
static constexpr std::size_t M()
static constexpr size_type M()
{
return FirstRow::size();
}
......@@ -76,18 +79,18 @@ namespace Dune {
* Therefore we implement a trick using std::integral_constant. To access the first row of
* a MultiTypeBlockMatrix named m write
* \code
* std::integral_constant<std::size_t,0> _0;
* std::integral_constant<size_type,0> _0;
* m[_0] = ...
* \endcode
* The name '_0' used here as a static replacement of the integer number zero is arbitrary.
* Any other variable name can be used. If you don't like the separate variable, you can write
* \code
* m[std::integral_constant<std::size_t,0>()] = ...
* m[std::integral_constant<size_type,0>()] = ...
* \endcode
*/
template< std::size_t index >
template< size_type index >
auto
operator[] ( const std::integral_constant< std::size_t, index > indexVariable ) -> decltype(std::get<index>(*this))
operator[] ( const std::integral_constant< size_type, index > indexVariable ) -> decltype(std::get<index>(*this))
{
DUNE_UNUSED_PARAMETER(indexVariable);
return std::get<index>(*this);
......@@ -98,9 +101,9 @@ namespace Dune {
* This is the const version of the random-access operator. See the non-const version for a full
* explanation of how to use it.
*/
template< std::size_t index >
template< size_type index >
auto
operator[] ( const std::integral_constant< std::size_t, index > indexVariable ) const -> decltype(std::get<index>(*this))
operator[] ( const std::integral_constant< size_type, index > indexVariable ) const -> decltype(std::get<index>(*this))
{
DUNE_UNUSED_PARAMETER(indexVariable);
return std::get<index>(*this);
......
......@@ -58,6 +58,9 @@ namespace Dune {
typedef std::tuple<Args...> TupleType;
public:
/** \brief Type used for vector sizes */
using size_type = std::size_t;
/**
* \brief Get the constructors from tuple
*/
......@@ -77,8 +80,19 @@ namespace Dune {
*/
typedef double field_type;
/** \brief Return the number of vector entries */
static constexpr std::size_t size()
/** \brief Return the number of non-zero vector entries
*
* As this is a dense vector data structure, all entries are non-zero,
* and hence 'size' returns the same number as 'N'.
*/
static constexpr size_type size()
{
return sizeof...(Args);
}
/** \brief Number of elements
*/
static constexpr size_type N()
{
return sizeof...(Args);
}
......@@ -86,11 +100,21 @@ namespace Dune {
/**
* number of elements
*/
int count() const
int count() const DUNE_DEPRECATED_MSG("Use method 'N' instead")
{
return sizeof...(Args);
}
/** \brief Number of scalar elements */
size_type dim() const
{
size_type result = 0;
Hybrid::forEach(std::make_index_sequence<N()>{},
[&](auto i){result += std::get<i>(*this).dim();});
return result;
}
/** \brief Random-access operator
*
* This method mimicks the behavior of normal vector access with square brackets like, e.g., v[5] = 1.
......@@ -109,9 +133,9 @@ namespace Dune {
* v[std::integral_constant<std::size_t,0>()] = ...
* \endcode
*/
template< std::size_t index >
template< size_type index >
typename std::tuple_element<index,TupleType>::type&
operator[] ( const std::integral_constant< std::size_t, index > indexVariable )
operator[] ( const std::integral_constant< size_type, index > indexVariable )
{
DUNE_UNUSED_PARAMETER(indexVariable);
return std::get<index>(*this);
......@@ -122,9 +146,9 @@ namespace Dune {
* This is the const version of the random-access operator. See the non-const version for a full
* explanation of how to use it.
*/
template< std::size_t index >
template< size_type index >
const typename std::tuple_element<index,TupleType>::type&
operator[] ( const std::integral_constant< std::size_t, index > indexVariable ) const
operator[] ( const std::integral_constant< size_type, index > indexVariable ) const
{
DUNE_UNUSED_PARAMETER(indexVariable);
return std::get<index>(*this);
......
......@@ -289,13 +289,13 @@ namespace Dune {
* @brief Set right Solver Category (default is overlapping).
*/
void
DUNE_DEPRECATED_MSG("the solver category can only be set in the constructor")
setSolverCategory (SolverCategory set) {
DUNE_DEPRECATED_MSG("The solver category can only be set in the constructor. This method is deprecated and will be removed after Dune 2.7")
setSolverCategory (SolverCategory::Category set) {
category_ = set;
}
SolverCategory::Category
DUNE_DEPRECATED_MSG("use category()")
DUNE_DEPRECATED_MSG("This method is deprecated and will be removed after Dune 2.7, use category() instead.")
getSolverCategory () const {
return category_;
}
......@@ -701,7 +701,8 @@ namespace Dune {
mutable std::vector<double> mask;
int oldseqNo;
GlobalLookupIndexSet* globalLookup_;
const SolverCategory::Category category_;
// re-intruduce const qualifier once deprecated setCategory got removed after Dune 2.7
/* const */ SolverCategory::Category category_;
bool freecomm;
};
......
......@@ -25,16 +25,28 @@ using namespace Dune;
template<typename... Args>
void testMultiVector(const MultiTypeBlockVector<Args...>& multiVector)
{
// Test whether the vector exports 'size_type', and whether that is an integer
using size_type = typename MultiTypeBlockVector<Args...>::size_type;
static_assert(std::numeric_limits<size_type>::is_integer, "size_type is not an integer!");
// test operator<<
std::cout << multiVector << std::endl;
// test method 'count'
std::cout << "multi vector has " << multiVector.count() << " first level blocks" << std::endl;
std::cout << "multi vector has " << multiVector.N() << " first level blocks" << std::endl;
static_assert(MultiTypeBlockVector<Args...>::size()==2, "Method MultiTypeBlockVector::size() returned wrong value!");
DUNE_NO_DEPRECATED_BEGIN
if (multiVector.count() != 2)
DUNE_THROW(Exception, "Method MultiTypeBlockVector::count returned wrong value!");
DUNE_NO_DEPRECATED_END
if (multiVector.N() != 2)
DUNE_THROW(Exception, "Method MultiTypeBlockVector::N returned wrong value!");
if (multiVector.dim() != 11)
DUNE_THROW(Exception, "Method MultiTypeBlockVector::dim returned wrong value!");
// Test copy construction
auto multiVector2 = multiVector;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment