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 
61 private:
62 
63  void setPointers();
64 
66  array2d< OPERATOR > m_operatorStorage;
67 };
68 
69 template< typename VECTOR, typename OPERATOR >
71  : Base( nRows, nCols ),
72  m_operatorStorage( nRows, nCols )
73 {
74  setPointers();
75 }
76 
77 template< typename VECTOR, typename OPERATOR >
79 {
80  GEOS_LAI_ASSERT_EQ( this->numBlockRows(), m_operatorStorage.size( 0 ) );
81  GEOS_LAI_ASSERT_EQ( this->numBlockCols(), m_operatorStorage.size( 1 ) );
82  for( localIndex i = 0; i < m_operatorStorage.size( 0 ); ++i )
83  {
84  for( localIndex j = 0; j < m_operatorStorage.size( 1 ); ++j )
85  {
86  this->setPointer( i, j, &m_operatorStorage( i, j ) );
87  }
88  }
89 }
90 
91 template< typename VECTOR, typename OPERATOR >
93  : Base( rhs ),
94  m_operatorStorage( rhs.m_operatorStorage )
95 {
96  setPointers();
97 }
98 
99 } // namespace geos
100 
101 #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.
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:191
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84