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 Total, S.A
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 GEOSX_LINEARALGEBRA_UTILITIES_BLOCKVECTORWRAPPER_HPP_
20 #define GEOSX_LINEARALGEBRA_UTILITIES_BLOCKVECTORWRAPPER_HPP_
21 
23 #include "linearAlgebra/common.hpp"
24 
25 namespace geosx
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 
56  BlockVectorWrapper( BlockVectorWrapper< VECTOR > const & rhs ) = default;
57 
63 
67  virtual ~BlockVectorWrapper() override = default;
68 
74  void set( localIndex const blockIndex, VECTOR & vec )
75  {
76  GEOSX_LAI_ASSERT_GE( blockIndex, 0 );
77  GEOSX_LAI_ASSERT_GT( this->blockSize(), blockIndex );
78  this->setPointer( blockIndex, &vec );
79  }
80 };
81 
82 } //namespace geosx
83 
84 #endif //GEOSX_LINEARALGEBRA_UTILITIES_BLOCKVECTORWRAPPER_HPP_
void setPointer(localIndex i, VECTOR *vec)
Set pointer to a vector.
virtual ~BlockVectorWrapper() override=default
Destructor.
"Shallow" representation of a block vector.
localIndex blockSize() const
Get block size.
BlockVectorWrapper(localIndex const nBlocks)
Create a vector wrapper of nBlocks blocks.
#define GEOSX_LAI_ASSERT_GT(lhs, rhs)
Definition: common.hpp:61
#define GEOSX_LAI_ASSERT_GE(lhs, rhs)
Definition: common.hpp:68
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
Abstract view of a block vector.