libMesh
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
libMesh::ConstCouplingRow Class Reference

This proxy class acts like a container of indices from a single coupling row. More...

#include <coupling_matrix.h>

Public Types

typedef ConstCouplingRowConstIterator const_iterator
 

Public Member Functions

 ConstCouplingRow (unsigned int row_in, const CouplingMatrix &mat_in)
 
const_iterator begin () const
 
const_iterator end () const
 
bool operator== (const ConstCouplingRow &other) const
 
bool operator!= (const ConstCouplingRow &other) const
 

Protected Attributes

unsigned int _row_i
 
const CouplingMatrix_mat
 
std::size_t _begin_location
 
CouplingMatrix::rc_type::const_iterator _begin_it
 

Friends

class ConstCouplingRowConstIterator
 

Detailed Description

This proxy class acts like a container of indices from a single coupling row.

Definition at line 335 of file coupling_matrix.h.

Member Typedef Documentation

Definition at line 403 of file coupling_matrix.h.

Constructor & Destructor Documentation

libMesh::ConstCouplingRow::ConstCouplingRow ( unsigned int  row_in,
const CouplingMatrix mat_in 
)

Definition at line 338 of file coupling_matrix.h.

References std::max(), and libMesh::MeshTools::Subdivision::prev.

339  :
340  _row_i(row_in), _mat(mat_in)
341  {
342  libmesh_assert_less(_row_i, _mat.size());
343 
344  // Location for i,N
346 
347  const std::size_t max_size = std::numeric_limits<std::size_t>::max();
348 
349  // Find the range that might contain i,N
350  // lower_bound isn't *quite* what we want
351  _begin_it = std::upper_bound
352  (_mat._ranges.begin(), _mat._ranges.end(),
353  std::make_pair(_begin_location, max_size));
354  if (_begin_it !=_mat._ranges.begin())
355  --_begin_it;
356  else
357  _begin_it=_mat._ranges.end();
358 
359  // If that range doesn't exist then we're an empty row
360  if (_begin_it == _mat._ranges.end())
361  _begin_location = max_size;
362  else
363  {
364  const std::size_t lastloc = _begin_it->second;
365 #ifdef DEBUG
366  const std::size_t firstloc = _begin_it->first;
367  libmesh_assert_less_equal(firstloc, lastloc);
368 #endif
369 
370  // If that range ends before i,0 then we're an empty row
371  std::size_t zero_location = _row_i*_mat.size();
372  if (zero_location > lastloc)
373  {
374  _begin_location = max_size;
375  _begin_it = _mat._ranges.end();
376  }
377  else
378  // We have *some* entry(s) in this row, we just need to find
379  // the earliest
380  {
381  while (_begin_it != _mat._ranges.begin())
382  {
383  CouplingMatrix::rc_type::const_iterator prev =
384  _begin_it;
385  --prev;
386 
387  if (prev->second < zero_location)
388  break;
389 
390  _begin_it = prev;
391  }
392  if (_begin_it->first < zero_location)
393  _begin_location = zero_location;
394  else
395  _begin_location = _begin_it->first;
396  }
397  }
398  }
static const unsigned int prev[3]
A lookup table for the decrement modulo 3 operation, for iterating through the three nodes per elemen...
long double max(long double a, double b)
unsigned int size() const
const CouplingMatrix & _mat
CouplingMatrix::rc_type::const_iterator _begin_it

Member Function Documentation

ConstCouplingRow::const_iterator libMesh::ConstCouplingRow::begin ( ) const

Definition at line 539 of file coupling_matrix.h.

Referenced by libMesh::DofMap::add_neighbors_to_send_list(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), and CouplingMatrixTest::testIteratorAPI().

539  {
540  return const_iterator (*this, _begin_location, _begin_it);
541 }
ConstCouplingRowConstIterator const_iterator
CouplingMatrix::rc_type::const_iterator _begin_it
ConstCouplingRow::const_iterator libMesh::ConstCouplingRow::end ( ) const

Definition at line 544 of file coupling_matrix.h.

References std::max().

Referenced by libMesh::DofMap::add_neighbors_to_send_list(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), and CouplingMatrixTest::testIteratorAPI().

544  {
545  return const_iterator
547  _mat._ranges.end());
548 }
long double max(long double a, double b)
ConstCouplingRowConstIterator const_iterator
const CouplingMatrix & _mat
bool libMesh::ConstCouplingRow::operator!= ( const ConstCouplingRow other) const

Definition at line 426 of file coupling_matrix.h.

427  {
428  return !(*this == other);
429  }
bool libMesh::ConstCouplingRow::operator== ( const ConstCouplingRow other) const

Definition at line 416 of file coupling_matrix.h.

References _begin_it, _begin_location, _mat, and libMesh::libmesh_assert().

417  {
418  // Thinking that rows from different matrix objects are equal is
419  // not even wrong
420  libmesh_assert(&_mat == &other._mat);
421 
422  return ((_begin_location == other._begin_location) &&
423  (_begin_it == other._begin_it));
424  }
libmesh_assert(j)
const CouplingMatrix & _mat
CouplingMatrix::rc_type::const_iterator _begin_it

Friends And Related Function Documentation

friend class ConstCouplingRowConstIterator
friend

Definition at line 432 of file coupling_matrix.h.

Member Data Documentation

CouplingMatrix::rc_type::const_iterator libMesh::ConstCouplingRow::_begin_it
protected

Definition at line 444 of file coupling_matrix.h.

Referenced by operator==().

std::size_t libMesh::ConstCouplingRow::_begin_location
protected

Definition at line 439 of file coupling_matrix.h.

Referenced by operator==().

const CouplingMatrix& libMesh::ConstCouplingRow::_mat
protected

Definition at line 435 of file coupling_matrix.h.

Referenced by operator==().

unsigned int libMesh::ConstCouplingRow::_row_i
protected

Definition at line 434 of file coupling_matrix.h.


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