GEOS
BlockOperator.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
21 #define GEOS_LINEARALGEBRA_UTILITIES_BLOCKOPERATOR_HPP_
22 
24 
25 namespace geos
26 {
27 
37 template< typename VECTOR, typename OPERATOR >
38 class BlockOperator : public BlockOperatorView< VECTOR, OPERATOR >
39 {
40 public:
41 
44 
46  using Vector = typename Base::Vector;
47 
53  BlockOperator( localIndex const nRows, localIndex const nCols );
54 
59  BlockOperator( BlockOperator const & rhs );
60 
66 
70  virtual ~BlockOperator() override = default;
71 
72 private:
73 
74  void setPointers();
75 
77  array2d< OPERATOR > m_operatorStorage;
78 };
79 
80 template< typename VECTOR, typename OPERATOR >
82  : Base( nRows, nCols ),
83  m_operatorStorage( nRows, nCols )
84 {
85  setPointers();
86 }
87 
88 template< typename VECTOR, typename OPERATOR >
90 {
91  GEOS_LAI_ASSERT_EQ( this->numBlockRows(), m_operatorStorage.size( 0 ) );
92  GEOS_LAI_ASSERT_EQ( this->numBlockCols(), m_operatorStorage.size( 1 ) );
93  for( localIndex i = 0; i < m_operatorStorage.size( 0 ); ++i )
94  {
95  for( localIndex j = 0; j < m_operatorStorage.size( 1 ); ++j )
96  {
97  this->setPointer( i, j, &m_operatorStorage( i, j ) );
98  }
99  }
100 }
101 
102 template< typename VECTOR, typename OPERATOR >
104  : Base( rhs ),
105  m_operatorStorage( rhs.m_operatorStorage )
106 {
107  setPointers();
108 }
109 
110 template< typename VECTOR, typename OPERATOR >
112  : Base( std::move( rhs ) ),
113  m_operatorStorage( std::move( rhs.m_operatorStorage ) )
114 {
115  setPointers();
116 }
117 
118 } // namespace geos
119 
120 #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:49
Array< T, 2, PERMUTATION > array2d
Alias for 2D array.
Definition: DataTypes.hpp:192
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85