GEOS
PetscExport.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 Total, S.A
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_INTERFACES_PETSCEXPORT_HPP_
21 #define GEOS_LINEARALGEBRA_INTERFACES_PETSCEXPORT_HPP_
22 
23 #include "common/DataTypes.hpp"
24 
26 extern "C" struct _p_IS;
27 
29 extern "C" struct _p_VecScatter;
30 
31 namespace geos
32 {
33 
35 class PetscMatrix;
36 
38 class PetscVector;
39 
44 {
45 public:
46 
53 
61  PetscExport( PetscMatrix const & mat, integer targetRank );
62 
67 
80  template< typename OFFSET_TYPE, typename COLUMN_TYPE >
81  void exportCRS( PetscMatrix const & mat,
82  arrayView1d< OFFSET_TYPE > const & rowOffsets,
83  arrayView1d< COLUMN_TYPE > const & colIndices,
84  arrayView1d< real64 > const & values ) const;
85 
98  void exportVector( PetscVector const & vec,
99  arrayView1d< real64 > const & values ) const;
100 
114  PetscVector & vec ) const;
115 
116 private:
117 
119  using IS = struct _p_IS *;
120 
122  using VecScatter = struct _p_VecScatter *;
123 
125  integer m_targetRank = -1;
126 
128  IS m_indexSet{};
129 
131  VecScatter m_scatter{};
132 };
133 
134 } // namespace geos
135 
136 #endif //GEOS_LINEARALGEBRA_INTERFACES_PETSCEXPORT_HPP_
Facilitates exporting Petsc matrix and associated vector objects (either in parallel or serial).
Definition: PetscExport.hpp:44
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:51
This class creates and provides basic support for Vec vector object type used in PETSc.
Definition: PetscVector.hpp:46
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:180
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82