GEOSX
HypreMGRStrategies.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_INTERFACES_HYPREMGRSTRATEGIES_HPP_
20 #define GEOSX_LINEARALGEBRA_INTERFACES_HYPREMGRSTRATEGIES_HPP_
21 
22 #include "common/DataTypes.hpp"
23 
24 #include <_hypre_utilities.h>
25 
26 namespace geosx
27 {
28 
41  arraySlice1d< localIndex const > const & numLocalDofsPerField )
42 {
44  HYPRE_Int numFields = LvArray::integerConversion< HYPRE_Int >( numLocalDofsPerField.size() );
45 
46  if( numFields > 0 )
47  {
48  HYPRE_Int numTotalLocalDof = 0;
49  for( HYPRE_Int i = 0; i < numFields; ++i )
50  {
51  numTotalLocalDof += LvArray::integerConversion< HYPRE_Int >( numLocalDofsPerField[i] );
52  }
53 
54  ret.resize( numTotalLocalDof );
55 
56  HYPRE_Int firstLabel = 0;
57  HYPRE_Int istr= 0;
58  HYPRE_Int iend;
59  HYPRE_Int numComp;
60  for( HYPRE_Int iFld = 0; iFld < numFields; ++iFld )
61  {
62  numComp = LvArray::integerConversion< HYPRE_Int >( numComponentsPerField[iFld] );
63  array1d< HYPRE_Int > vectorLabels( numComp );
64  for( HYPRE_Int k = 0; k < numComp; ++k )
65  {
66  vectorLabels[k] = k + firstLabel;
67  }
68  iend = istr + LvArray::integerConversion< HYPRE_Int >( numLocalDofsPerField[iFld] );
69  for( localIndex i = istr; i < iend; i += numComp )
70  {
71  for( integer k = 0; k < numComp; ++k )
72  {
73  ret[i+k] = vectorLabels[k];
74  }
75  }
76  istr = iend;
77  firstLabel += numComp;
78  }
79  }
80  return ret;
81 }
82 
83 }
84 
85 #endif /*GEOSX_LINEARALGEBRA_INTERFACES_HYPREMGRSTRATEGIES_HPP_*/
This class serves to provide a sliced multidimensional interface to the family of LvArray classes...
Definition: ArraySlice.hpp:89
array1d< HYPRE_Int > computeLocalDofComponentLabels(arraySlice1d< localIndex const > const &numComponentsPerField, arraySlice1d< localIndex const > const &numLocalDofsPerField)
Compute an array of unique component labels.
constexpr INDEX_TYPE size() const noexcept
Definition: ArraySlice.hpp:171
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
void resize(int const numDims, DIMS_TYPE const *const dims)
Resize the dimensions of the Array to match the given dimensions.
Definition: Array.hpp:277
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55