19 #ifndef GEOSX_LINEARALGEBRA_UTILITIES_BLOCKOPERATORVIEW_HPP_ 20 #define GEOSX_LINEARALGEBRA_UTILITIES_BLOCKOPERATORVIEW_HPP_ 22 #include "codingUtilities/SFINAE_Macros.hpp" 38 template<
typename VECTOR,
typename OPERATOR = LinearOperator< VECTOR > >
78 HAS_MEMBER_FUNCTION_NO_RTYPE(
applyTranspose, std::declval< Vector const & >(), std::declval< Vector & >() );
95 Vector & dst )
const override 99 dst.
block( i ).zero();
100 VECTOR temp( dst.
block( i ) );
103 if( m_operators( i, j ) != nullptr )
105 m_operators( i, j )->apply( src.
block( j ), temp );
106 dst.
block( i ).axpy( 1.0, temp );
121 template<
typename OP = OPERATOR >
122 std::enable_if_t< HasMemberFunction_applyTranspose< OP > >
128 dst.
block( j ).zero();
129 VECTOR temp( dst.
block( j ) );
132 if( m_operators( j, i ) != nullptr )
134 m_operators( j, i )->applyTranspose( src.
block( i ), temp );
135 dst.
block( j ).axpy( 1.0, temp );
147 return computeRowSize( []( OPERATOR
const &
block ) {
return block.numGlobalRows(); } );
156 return computeColSize( []( OPERATOR
const &
block ) {
return block.numGlobalCols(); } );
164 template<
typename OP = OPERATOR >
165 std::enable_if_t< HasMemberFunction_numLocalRows< OP >,
localIndex >
168 return computeRowSize( []( OPERATOR
const &
block ) {
return block.numLocalRows(); } );
176 template<
typename OP = OPERATOR >
177 std::enable_if_t< HasMemberFunction_numLocalCols< OP >,
localIndex >
180 return computeColSize( []( OPERATOR
const &
block ) {
return block.numLocalCols(); } );
196 return m_operators.size( 0 );
205 return m_operators.size( 1 );
217 return *m_operators( blockRowIndex, blockColIndex );
226 return *m_operators( blockRowIndex, blockColIndex );
234 return block( blockRowIndex, blockColIndex );
242 return block( blockRowIndex, blockColIndex );
255 : m_operators( nRows, nCols )
285 m_operators( blockRowIndex, blockColIndex ) = op;
290 template<
typename FUNC >
291 auto computeRowSize( FUNC func )
const -> decltype( func( std::declval< OPERATOR const >() ) );
293 template<
typename FUNC >
294 auto computeColSize( FUNC func )
const -> decltype( func( std::declval< OPERATOR const >() ) );
300 template<
typename VECTOR,
typename OPERATOR >
301 template<
typename FUNC >
304 using sizeType = decltype( func( std::declval< OPERATOR const >() ) );
305 sizeType rowSize = 0;
310 if( m_operators( i, j ) != nullptr )
312 rowSize += func(
block( i, j ) );
320 template<
typename VECTOR,
typename OPERATOR >
321 template<
typename FUNC >
324 using sizeType = decltype( func( std::declval< OPERATOR const >() ) );
325 sizeType colSize = 0;
330 if( m_operators( i, j ) != nullptr )
332 colSize += func(
block( i, j ) );
localIndex numBlockRows() const
Get number of block rows.
Abstract view of a block operator.
void setPointer(localIndex const blockRowIndex, localIndex const blockColIndex, OPERATOR *op)
Set/replace a pointer to a block.
long long int globalIndex
Global index type (for indexing objects across MPI partitions).
OPERATOR & operator()(localIndex const blockRowIndex, localIndex const blockColIndex=0)
Get the operator corresponding to a sub-block.
std::enable_if_t< HasMemberFunction_numLocalRows< OP >, localIndex > numLocalRows() const
Get the number of local rows.
std::enable_if_t< HasMemberFunction_applyTranspose< OP > > applyTranspose(BlockVectorView< VECTOR > const &src, BlockVectorView< VECTOR > &dst) const
Apply the transpose of block operator to a block vector.
OPERATOR const & block(localIndex const blockRowIndex, localIndex const blockColIndex) const
Get the operator corresponding to a sub-block.
OPERATOR const & operator()(localIndex const blockRowIndex, localIndex const blockColIndex=0) const
Get the operator corresponding to a sub-block.
BlockOperatorView(localIndex const nRows, localIndex const nCols)
Create an operator with given number of block rows and columns.
virtual globalIndex numGlobalCols() const override
Get the number of global columns.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector.
#define GEOSX_LAI_ASSERT_GT(lhs, rhs)
#define GEOSX_LAI_ASSERT_GE(lhs, rhs)
localIndex numBlockCols() const
Get number of block columns.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
VECTOR const & block(localIndex const blockIndex) const
Get a reference to the vector corresponding to block blockRowIndex.
#define GEOSX_LAI_ASSERT(expr)
BlockOperatorView & operator=(BlockOperatorView const &)=delete
Deleted copy assignment.
OPERATOR & block(localIndex const blockRowIndex, localIndex const blockColIndex)
Get the operator corresponding to a sub-block.
Abstract base class for linear operators.
BlockVectorView< VECTOR > Vector
Alias for template parameter.
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
virtual ~BlockOperatorView() override=default
Destructor.
std::enable_if_t< HasMemberFunction_numLocalCols< OP >, localIndex > numLocalCols() const
Get the number of local columns.
virtual globalIndex numGlobalRows() const override
Get the number of global rows.