GEOSX
BlockOperator.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 Total, S.A
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOSX_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
20 #define GEOSX_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
21 
23 
24 namespace geosx
25 {
26 
36 template< typename VECTOR, typename OPERATOR >
37 class BlockOperator : public BlockOperatorView< VECTOR, OPERATOR >
38 {
39 public:
40 
43 
45  using Vector = typename Base::Vector;
46 
52  BlockOperator( localIndex const nRows, localIndex const nCols );
53 
58  BlockOperator( BlockOperator const & rhs );
59 
64  BlockOperator( BlockOperator && rhs );
65 
69  virtual ~BlockOperator() override = default;
70 
71 private:
72 
73  void setPointers();
74 
76  array2d< OPERATOR > m_operatorStorage;
77 };
78 
79 template< typename VECTOR, typename OPERATOR >
81  : Base( nRows, nCols ),
82  m_operatorStorage( nRows, nCols )
83 {
84  setPointers();
85 }
86 
87 template< typename VECTOR, typename OPERATOR >
89 {
90  GEOSX_LAI_ASSERT_EQ( this->numBlockRows(), m_operatorStorage.size( 0 ) );
91  GEOSX_LAI_ASSERT_EQ( this->numBlockCols(), m_operatorStorage.size( 1 ) );
92  for( localIndex i = 0; i < m_operatorStorage.size( 0 ); ++i )
93  {
94  for( localIndex j = 0; j < m_operatorStorage.size( 1 ); ++j )
95  {
96  this->setPointer( i, j, &m_operatorStorage( i, j ) );
97  }
98  }
99 }
100 
101 template< typename VECTOR, typename OPERATOR >
103  : Base( rhs ),
104  m_operatorStorage( rhs.m_operatorStorage )
105 {
106  setPointers();
107 }
108 
109 template< typename VECTOR, typename OPERATOR >
111  : Base( std::move( rhs ) ),
112  m_operatorStorage( std::move( rhs.m_operatorStorage ) )
113 {
114  setPointers();
115 }
116 
117 } // namespace geosx
118 
119 #endif //GEOSX_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
BlockOperator(localIndex const nRows, localIndex const nCols)
Create an operator with (nRows, nCols) blocks.
virtual ~BlockOperator() override=default
Destructor.
Abstract view of a block operator.
Concrete representation of a block operator.
#define GEOSX_LAI_ASSERT_EQ(lhs, rhs)
Definition: common.hpp:47
typename Base::Vector Vector
Alias for vector type.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55