GEOS
BlockVectorWrapper.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 Total, S.A
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_BLOCKVECTORWRAPPER_HPP_
21 #define GEOS_LINEARALGEBRA_UTILITIES_BLOCKVECTORWRAPPER_HPP_
22 
24 #include "common/common.hpp"
25 
26 namespace geos
27 {
28 
37 template< typename VECTOR >
38 class BlockVectorWrapper : public BlockVectorView< VECTOR >
39 {
40 public:
41 
44 
49  explicit BlockVectorWrapper( localIndex const nBlocks )
50  : BlockVectorView< VECTOR >( nBlocks )
51  {}
52 
58 
64 
68  virtual ~BlockVectorWrapper() override = default;
69 
75  void set( localIndex const blockIndex, VECTOR & vec )
76  {
77  GEOS_LAI_ASSERT_GE( blockIndex, 0 );
78  GEOS_LAI_ASSERT_GT( this->blockSize(), blockIndex );
79  this->setPointer( blockIndex, &vec );
80  }
81 };
82 
83 } //namespace geos
84 
85 #endif //GEOS_LINEARALGEBRA_UTILITIES_BLOCKVECTORWRAPPER_HPP_
Abstract view of a block vector.
void setPointer(localIndex i, VECTOR *vec)
Set pointer to a vector.
localIndex blockSize() const
Get block size.
"Shallow" representation of a block vector.
BlockVectorWrapper(BlockVectorWrapper< VECTOR > const &rhs)=default
Deleted copy constructor.
BlockVectorWrapper(localIndex const nBlocks)
Create a vector wrapper of nBlocks blocks.
void set(localIndex const blockIndex, VECTOR &vec)
Assign a sub-block to point to a given vector.
BlockVectorWrapper(BlockVectorWrapper< VECTOR > &&rhs)=default
Deleted move constructor.
virtual ~BlockVectorWrapper() override=default
Destructor.
#define GEOS_LAI_ASSERT_GE(lhs, rhs)
Definition: common.hpp:70
#define GEOS_LAI_ASSERT_GT(lhs, rhs)
Definition: common.hpp:63
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85