GEOSX
BlockVectorWrapper.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_BLOCKVECTORWRAPPER_HPP_
20 #define GEOS_LINEARALGEBRA_UTILITIES_BLOCKVECTORWRAPPER_HPP_
21 
23 #include "common/common.hpp"
24 
25 namespace geos
26 {
27 
36 template< typename VECTOR >
37 class BlockVectorWrapper : public BlockVectorView< VECTOR >
38 {
39 public:
40 
43 
48  explicit BlockVectorWrapper( localIndex const nBlocks )
49  : BlockVectorView< VECTOR >( nBlocks )
50  {}
51 
57 
63 
67  virtual ~BlockVectorWrapper() override = default;
68 
74  void set( localIndex const blockIndex, VECTOR & vec )
75  {
76  GEOS_LAI_ASSERT_GE( blockIndex, 0 );
77  GEOS_LAI_ASSERT_GT( this->blockSize(), blockIndex );
78  this->setPointer( blockIndex, &vec );
79  }
80 };
81 
82 } //namespace geos
83 
84 #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:68
#define GEOS_LAI_ASSERT_GT(lhs, rhs)
Definition: common.hpp:61
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125