20 #ifndef LIBMESH_COUPLING_MATRIX_H 21 #define LIBMESH_COUPLING_MATRIX_H 24 #include "libmesh/libmesh_common.h" 36 class ConstCouplingAccessor;
37 class CouplingAccessor;
39 class ConstCouplingRow;
41 class ConstCouplingRowConstIterator;
68 const std::size_t j)
const;
81 std::size_t
size()
const;
87 void resize(
const std::size_t n);
144 operator bool()
const 146 const std::size_t max_size = std::numeric_limits<std::size_t>::max();
150 CouplingMatrix::rc_type::const_iterator lb = std::upper_bound
162 const std::size_t lastloc = lb->second;
165 const std::size_t firstloc = lb->first;
166 libmesh_assert_less_equal(firstloc, lastloc);
167 libmesh_assert_less_equal(firstloc,
_location);
169 CouplingMatrix::rc_type::const_iterator
next = lb;
174 libmesh_assert_greater(
next->first, lastloc+1);
198 template <
typename T>
203 const bool as_bool = new_value;
204 libmesh_assert_equal_to(new_value, as_bool);
212 const std::size_t max_size = std::numeric_limits<std::size_t>::max();
216 CouplingMatrix::rc_type::iterator lb =
228 if (new_value ==
true)
234 const std::size_t firstloc = lb->first;
235 const std::size_t lastloc = lb->second;
236 libmesh_assert_less_equal(firstloc, lastloc);
237 libmesh_assert_less_equal(firstloc,
_location);
241 CouplingMatrix::rc_type::const_iterator
next = lb;
246 libmesh_assert_greater(
next->first, lastloc+1);
253 if (new_value ==
false)
263 libmesh_assert_less (lb->first, lastloc);
269 libmesh_assert_less (firstloc, lb->second);
275 libmesh_assert_less_equal(
_location+1, lastloc);
279 libmesh_assert_less_equal(firstloc,
_location-1);
289 CouplingMatrix::rc_type::iterator
next = lb;
291 const std::size_t nextloc =
293 std::numeric_limits<std::size_t>::max() :
297 libmesh_assert_greater(nextloc, lastloc+1);
305 next->first = firstloc;
350 const std::size_t max_size = std::numeric_limits<std::size_t>::max();
367 const std::size_t lastloc =
_begin_it->second;
369 const std::size_t firstloc =
_begin_it->first;
370 libmesh_assert_less_equal(firstloc, lastloc);
375 if (zero_location > lastloc)
386 CouplingMatrix::rc_type::const_iterator
prev =
390 if (
prev->second < zero_location)
431 return !(*
this == other);
462 CouplingMatrix::rc_type::const_iterator it_in) :
475 libmesh_assert_equal_to
476 (
_location, std::numeric_limits<size_t>::max());
483 libmesh_assert_not_equal_to
484 (
_location, std::numeric_limits<std::size_t>::max());
490 libmesh_assert_not_equal_to
491 (
_location, std::numeric_limits<std::size_t>::max());
501 _location = std::numeric_limits<std::size_t>::max();
507 _location = std::numeric_limits<std::size_t>::max();
512 _location = std::numeric_limits<std::size_t>::max();
535 return !(*
this == other);
545 CouplingMatrix::rc_type::const_iterator
_it;
562 (*
this, std::numeric_limits<std::size_t>::max(),
581 const std::size_t j)
const 583 libmesh_assert_less (i,
_size);
584 libmesh_assert_less (j,
_size);
586 const std::size_t location = std::size_t(i)*
_size + j;
598 const std::size_t location = std::size_t(i)*
_size + j;
641 #endif // LIBMESH_COUPLING_MATRIX_H void clear()
Clears the matrix.
ConstCouplingAccessor(std::size_t loc_in, const CouplingMatrix &mat_in)
CouplingMatrix & operator &=(const CouplingMatrix &other)
bool operator!=(const ConstCouplingRowConstIterator &other) const
void resize(const std::size_t n)
Resizes the matrix and initializes all entries to be 0.
This proxy class acts like a container of indices from a single coupling row.
std::size_t _begin_location
The libMesh namespace provides an interface to certain functionality in the library.
const std::size_t _end_location
bool operator==(const ConstCouplingRow &other) const
This accessor class allows simple setting of CouplingMatrix values.
ConstCouplingRowConstIterator & operator++()
ConstCouplingRowConstIterator(const ConstCouplingRow &row_in, std::size_t loc_in, CouplingMatrix::rc_type::const_iterator it_in)
friend class ConstCouplingAccessor
bool operator()(const std::size_t i, const std::size_t j) const
friend class CouplingAccessor
const_iterator end() const
std::size_t _size
The size of the matrix.
const ConstCouplingRow & _row
std::pair< std::size_t, std::size_t > range_type
Coupling matrices are typically either full or very sparse, and all values are only zero or one...
std::vector< range_type > rc_type
CouplingMatrix(const std::size_t n=0)
Constructor.
CouplingMatrix::rc_type::const_iterator _it
This accessor class allows simple access to CouplingMatrix values.
ConstCouplingRowConstIterator const_iterator
const_iterator begin() const
ConstCouplingRow(std::size_t row_in, const CouplingMatrix &mat_in)
const CouplingMatrix & _mat
const CouplingMatrix & _mat
bool operator!=(const ConstCouplingRow &other) const
CouplingMatrix::rc_type::const_iterator _begin_it
CouplingAccessor & operator=(T new_value)
CouplingAccessor(std::size_t loc_in, CouplingMatrix &mat_in)
bool operator==(const ConstCouplingRowConstIterator &other) const
This class defines a coupling matrix.