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 TotalEnergies
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 GEOS_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
20 #define GEOS_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
21 
23 
24 namespace geos
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 
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  GEOS_LAI_ASSERT_EQ( this->numBlockRows(), m_operatorStorage.size( 0 ) );
91  GEOS_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 geos
118 
119 #endif //GEOS_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
Concrete representation of a block operator.
BlockOperator(BlockOperator const &rhs)
Copy constructor.
typename Base::Vector Vector
Alias for vector type.
BlockOperator(localIndex const nRows, localIndex const nCols)
Create an operator with (nRows, nCols) blocks.
virtual ~BlockOperator() override=default
Destructor.
BlockOperator(BlockOperator &&rhs)
Move constructor.
Abstract view of a block operator.
typename Base::Vector Vector
Alias for vector type.
#define GEOS_LAI_ASSERT_EQ(lhs, rhs)
Definition: common.hpp:47
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:232
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125