GEOS
SparsityPatternUtilities.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_SPARSITYPATTERNUTILITIES_HPP_
21 #define GEOS_LINEARALGEBRA_UTILITIES_SPARSITYPATTERNUTILITIES_HPP_
22 
23 #include "common/DataTypes.hpp"
24 
25 namespace geos
26 {
27 
43  SparsityPattern< globalIndex > const & source )
44 {
45  GEOS_ERROR_IF_NE( target.numRows(), source.numRows() );
46  GEOS_ERROR_IF_NE( target.numColumns(), source.numColumns() );
47  for( localIndex row = 0; row < source.numRows(); ++row )
48  {
49  globalIndex const * const columns = source.getColumns( row ).dataIfContiguous();
50  target.insertNonZeros( row, columns, columns + source.numNonZeros( row ) );
51  }
52 }
53 
54 } // namespace geos
55 
56 #endif // GEOS_LINEARALGEBRA_UTILITIES_SPARSITYPATTERNUTILITIES_HPP_
#define GEOS_ERROR_IF_NE(lhs, rhs)
Raise a hard error if two values are not equal.
Definition: Logger.hpp:476
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
LvArray::SparsityPattern< COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer > SparsityPattern
Alias for Sparsity pattern class.
Definition: DataTypes.hpp:297
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
void appendSparsityPattern(SparsityPattern< globalIndex > &target, SparsityPattern< globalIndex > const &source)
Append all entries from one sparsity pattern to another.