GEOSX
PetscExport.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2019 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2019 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2019 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All right reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_LINEARALGEBRA_INTERFACES_PETSCEXPORT_HPP_
20 #define GEOS_LINEARALGEBRA_INTERFACES_PETSCEXPORT_HPP_
21 
22 #include "common/DataTypes.hpp"
23 
25 extern "C" struct _p_IS;
26 
28 extern "C" struct _p_VecScatter;
29 
30 namespace geos
31 {
32 
34 class PetscMatrix;
35 
37 class PetscVector;
38 
43 {
44 public:
45 
52 
60  PetscExport( PetscMatrix const & mat, integer targetRank );
61 
66 
79  template< typename OFFSET_TYPE, typename COLUMN_TYPE >
80  void exportCRS( PetscMatrix const & mat,
81  arrayView1d< OFFSET_TYPE > const & rowOffsets,
82  arrayView1d< COLUMN_TYPE > const & colIndices,
83  arrayView1d< real64 > const & values ) const;
84 
97  void exportVector( PetscVector const & vec,
98  arrayView1d< real64 > const & values ) const;
99 
113  PetscVector & vec ) const;
114 
115 private:
116 
118  using IS = struct _p_IS *;
119 
121  using VecScatter = struct _p_VecScatter *;
122 
124  integer m_targetRank = -1;
125 
127  IS m_indexSet{};
128 
130  VecScatter m_scatter{};
131 };
132 
133 } // namespace geos
134 
135 #endif //GEOS_LINEARALGEBRA_INTERFACES_PETSCEXPORT_HPP_
Facilitates exporting Petsc matrix and associated vector objects (either in parallel or serial).
Definition: PetscExport.hpp:43
void importVector(arrayView1d< const real64 > const &values, PetscVector &vec) const
Import the target vector from an array provided by the user.
~PetscExport()
Destructor.
PetscExport()
Parallel export constructor.
PetscExport(PetscMatrix const &mat, integer targetRank)
Single-rank export constructor.
void exportVector(PetscVector const &vec, arrayView1d< real64 > const &values) const
Export the target vector into an array provided by the user.
void exportCRS(PetscMatrix const &mat, arrayView1d< OFFSET_TYPE > const &rowOffsets, arrayView1d< COLUMN_TYPE > const &colIndices, arrayView1d< real64 > const &values) const
Export the matrix into CRS arrays provided by the user.
This class creates and provides basic support for the Mat matrix object type used in PETSc.
Definition: PetscMatrix.hpp:50
This class creates and provides basic support for Vec vector object type used in PETSc.
Definition: PetscVector.hpp:45
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:220
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122