libMesh::ConstCouplingAccessor Class Reference

#include <coupling_matrix.h>

Inheritance diagram for libMesh::ConstCouplingAccessor:

Public Member Functions

 ConstCouplingAccessor (std::size_t loc_in, const CouplingMatrix &mat_in)
 
 operator bool () const
 

Protected Attributes

std::size_t _location
 
const CouplingMatrix_mat
 

Detailed Description

This accessor class allows simple access to CouplingMatrix values.

Definition at line 134 of file coupling_matrix.h.

Constructor & Destructor Documentation

◆ ConstCouplingAccessor()

libMesh::ConstCouplingAccessor::ConstCouplingAccessor ( std::size_t  loc_in,
const CouplingMatrix mat_in 
)
inline

Definition at line 137 of file coupling_matrix.h.

References _location, _mat, and libMesh::CouplingMatrix::size().

138  :
139  _location(loc_in), _mat(mat_in)
140  {
141  libmesh_assert_less(_location, _mat.size() * _mat.size());
142  }
unsigned int size() const
const CouplingMatrix & _mat

Member Function Documentation

◆ operator bool()

libMesh::ConstCouplingAccessor::operator bool ( ) const
inline

Definition at line 144 of file coupling_matrix.h.

References _location, _mat, libMesh::CouplingMatrix::_ranges, std::max(), and libMesh::MeshTools::Subdivision::next.

144  {
145  const std::size_t max_size = std::numeric_limits<std::size_t>::max();
146 
147  // Find the range that might contain i,j
148  // lower_bound isn't *quite* what we want
149  CouplingMatrix::rc_type::const_iterator lb = std::upper_bound
150  (_mat._ranges.begin(), _mat._ranges.end(),
151  std::make_pair(_location, max_size));
152  if (lb!=_mat._ranges.begin())
153  --lb;
154  else
155  lb=_mat._ranges.end();
156 
157  // If no range might contain i,j then it's 0
158  if (lb == _mat._ranges.end())
159  return false;
160 
161  const std::size_t lastloc = lb->second;
162 
163 #ifdef DEBUG
164  const std::size_t firstloc = lb->first;
165  libmesh_assert_less_equal(firstloc, lastloc);
166  libmesh_assert_less_equal(firstloc, _location);
167 
168  CouplingMatrix::rc_type::const_iterator next = lb;
169  next++;
170  if (next != _mat._ranges.end())
171  {
172  // Ranges should be sorted and should not touch
173  libmesh_assert_greater(next->first, lastloc+1);
174  }
175 #endif
176 
177  return (lastloc >= _location);
178  }
long double max(long double a, double b)
static const unsigned int next[3]
const CouplingMatrix & _mat

Member Data Documentation

◆ _location

std::size_t libMesh::ConstCouplingAccessor::_location
protected

◆ _mat

const CouplingMatrix& libMesh::ConstCouplingAccessor::_mat
protected

Definition at line 183 of file coupling_matrix.h.

Referenced by ConstCouplingAccessor(), and operator bool().


The documentation for this class was generated from the following file: