20#ifndef LIBMESH_COUPLING_MATRIX_H
21#define LIBMESH_COUPLING_MATRIX_H
24#include "libmesh/libmesh_common.h"
36class ConstCouplingAccessor;
37class CouplingAccessor;
39class ConstCouplingRow;
41class 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;
This accessor class allows simple access to CouplingMatrix values.
ConstCouplingAccessor(std::size_t loc_in, const CouplingMatrix &mat_in)
const CouplingMatrix & _mat
ConstCouplingRowConstIterator & operator++()
const ConstCouplingRow & _row
ConstCouplingRowConstIterator(const ConstCouplingRow &row_in, std::size_t loc_in, CouplingMatrix::rc_type::const_iterator it_in)
CouplingMatrix::rc_type::const_iterator _it
bool operator==(const ConstCouplingRowConstIterator &other) const
bool operator!=(const ConstCouplingRowConstIterator &other) const
This proxy class acts like a container of indices from a single coupling row.
bool operator==(const ConstCouplingRow &other) const
const std::size_t _end_location
const_iterator end() const
CouplingMatrix::rc_type::const_iterator _begin_it
ConstCouplingRow(std::size_t row_in, const CouplingMatrix &mat_in)
bool operator!=(const ConstCouplingRow &other) const
const CouplingMatrix & _mat
std::size_t _begin_location
const_iterator begin() const
ConstCouplingRowConstIterator const_iterator
This accessor class allows simple setting of CouplingMatrix values.
CouplingAccessor(std::size_t loc_in, CouplingMatrix &mat_in)
CouplingAccessor & operator=(T new_value)
This class defines a coupling matrix.
std::size_t _size
The size of the matrix.
CouplingMatrix(const std::size_t n=0)
Constructor.
CouplingMatrix & operator&=(const CouplingMatrix &other)
std::vector< range_type > rc_type
friend class ConstCouplingAccessor
bool operator()(const std::size_t i, const std::size_t j) const
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.
void resize(const std::size_t n)
Resizes the matrix and initializes all entries to be 0.
friend class CouplingAccessor
void clear()
Clears the matrix.
The libMesh namespace provides an interface to certain functionality in the library.