libMesh
Loading...
Searching...
No Matches
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 (std::size_t 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

std::size_t _row_i
 
const CouplingMatrix_mat
 
std::size_t _begin_location
 
const std::size_t _end_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 336 of file coupling_matrix.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 406 of file coupling_matrix.h.

Constructor & Destructor Documentation

◆ ConstCouplingRow()

libMesh::ConstCouplingRow::ConstCouplingRow ( std::size_t  row_in,
const CouplingMatrix mat_in 
)
inline

Definition at line 339 of file coupling_matrix.h.

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

References _begin_it, _begin_location, _end_location, _mat, libMesh::CouplingMatrix::_ranges, _row_i, and libMesh::CouplingMatrix::size().

Member Function Documentation

◆ begin()

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

Definition at line 553 of file coupling_matrix.h.

554{
556}
ConstCouplingRowConstIterator const_iterator

References _begin_it, and _begin_location.

Referenced by CouplingMatrixTest::testIteratorAPI().

◆ end()

ConstCouplingRow::const_iterator libMesh::ConstCouplingRow::end ( ) const
inline

Definition at line 559 of file coupling_matrix.h.

560{
561 return const_iterator
562 (*this, std::numeric_limits<std::size_t>::max(),
563 _mat._ranges.end());
564}

References _mat, and libMesh::CouplingMatrix::_ranges.

Referenced by CouplingMatrixTest::testIteratorAPI().

◆ operator!=()

bool libMesh::ConstCouplingRow::operator!= ( const ConstCouplingRow other) const
inline

Definition at line 429 of file coupling_matrix.h.

430 {
431 return !(*this == other);
432 }

◆ operator==()

bool libMesh::ConstCouplingRow::operator== ( const ConstCouplingRow other) const
inline

Definition at line 419 of file coupling_matrix.h.

420 {
421 // Thinking that rows from different matrix objects are equal is
422 // not even wrong
423 libmesh_assert(&_mat == &other._mat);
424
425 return ((_begin_location == other._begin_location) &&
426 (_begin_it == other._begin_it));
427 }
libmesh_assert(ctx)

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

Friends And Related Symbol Documentation

◆ ConstCouplingRowConstIterator

friend class ConstCouplingRowConstIterator
friend

Definition at line 435 of file coupling_matrix.h.

Member Data Documentation

◆ _begin_it

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

Definition at line 452 of file coupling_matrix.h.

Referenced by begin(), ConstCouplingRow(), and operator==().

◆ _begin_location

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

Definition at line 442 of file coupling_matrix.h.

Referenced by begin(), ConstCouplingRow(), and operator==().

◆ _end_location

const std::size_t libMesh::ConstCouplingRow::_end_location
protected

◆ _mat

const CouplingMatrix& libMesh::ConstCouplingRow::_mat
protected

◆ _row_i

std::size_t libMesh::ConstCouplingRow::_row_i
protected

Definition at line 437 of file coupling_matrix.h.

Referenced by ConstCouplingRow().


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