1// Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at2// the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights3// reserved. See file COPYRIGHT for details.4//5// This file is part of the MFEM library. For more information and source code6// availability see http://mfem.org.7//8// MFEM is free software; you can redistribute it and/or modify it under the9// terms of the GNU Lesser General Public License (as published by the Free10// Software Foundation) version 2.1 dated February 1999.1112/// This HYPRE library interface has been taken originally from MFEM and modified13/// to suit the needs for the MOAB library.14/// Modified by: Vijay Mahadevan1516#ifndef MOAB_HYPREPARVECTOR17#define MOAB_HYPREPARVECTOR1819#include"moab/MOABConfig.h"20#include"moab/Core.hpp"2122#ifdef MOAB_HAVE_EIGEN323#include<Eigen/Core>24#include<Eigen/Sparse>25#else26#error Configure with Eigen3 enabled27#endif2829#ifdef MOAB_HAVE_MPI30#include"moab/ParallelComm.hpp"3132// hypre header files33#include"HYPRE.h"34#include"HYPRE_IJ_mv.h"35#include"_hypre_IJ_mv.h"36#include"HYPRE_parcsr_ls.h"37// #include "seq_mv.h"38#include"temp_multivector.h"3940#ifdef HYPRE_COMPLEX41#error"MOAB does not work with HYPRE's complex numbers support"42#endif4344#include"hypre_parcsr.hpp"4546namespace moab
47 {
4849classHypreParMatrix;
50classHypreSolver;
5152/// Wrapper for hypre's parallel vector class53classHypreParVector54 {
55private:
56int own_ParVector, rstart, rend, size, gsize;
5758/// The actual object59 hypre_ParVector* x_par;
60 HYPRE_IJVector x;
6162friendclassHypreParMatrix;
63friendclassHypreSolver;
6465 moab::ParallelComm* pcomm;
66char initialized;
6768public:
69/** Creates an empty vector with given global comm. */70HypreParVector( moab::ParallelComm* p_comm );
71/** Creates vector with given global size and partitioning of the columns.
72 Processor P owns columns [col[P],col[P+1]) */73HypreParVector( moab::ParallelComm* p_comm, HYPRE_Int glob_size, HYPRE_Int rstart, HYPRE_Int rend );
74/// Creates vector compatible with y75HypreParVector( const HypreParVector& y );
76/// Creates vector compatible with (i.e. in the domain of) A or A^T77HypreParVector( HypreParMatrix& A, int tr = 0 );
7879intresize( HYPRE_Int glob_size, HYPRE_Int rstart, HYPRE_Int rend );
8081/// MPI communicator82moab::ParallelComm* GetParallelCommunicator()
83 {
84return pcomm;
85 }
8687/// Returns the row partitioning88inline HYPRE_Int* Partitioning()
89 {
90return x->partitioning;
91 }
9293/// Returns the global number of rows94inline HYPRE_Int GlobalSize()const
95 {
96return x->global_num_rows;
97 }
9899/// Typecasting to hypre's HYPRE_IJVector*100operatorHYPRE_IJVector()const;
101// #ifndef HYPRE_PAR_VECTOR_STRUCT102/// Typecasting to hypre's HYPRE_ParVector, a.k.a. void *103operatorHYPRE_ParVector()const;
104// #endif105/// Changes the ownership of the the vector106HYPRE_IJVector StealParVector()
107 {
108 own_ParVector = 0;
109return x;
110 }
111112/// Sets ownership of the internal HYPRE_IJVector113voidSetOwnership( int own )
114 {
115 own_ParVector = own;
116 }
117118/// Gets ownership of the internal HYPRE_IJVector119intGetOwnership()const
120 {
121return own_ParVector;
122 }
123124/// Define '=' for hypre vectors.125 HypreParVector& operator=( double d );
126 HypreParVector& operator=( const HypreParVector& y );
127128HYPRE_Int GetValues( constint ndata, const HYPRE_Int* indices, HYPRE_Complex* const _data )const;
129130HYPRE_Int SetValues( constint ndata, const HYPRE_Int* indices, const HYPRE_Complex* const _data );
131132HYPRE_Int AddValues( constint ndata, const HYPRE_Int* indices, const HYPRE_Complex* const _data );
133134HYPRE_Int GetValue( const HYPRE_Int index, HYPRE_Complex* const _data )const;
135136HYPRE_Int SetValue( const HYPRE_Int index, const HYPRE_Complex _data );
137138HYPRE_Int AddValue( const HYPRE_Int index, const HYPRE_Complex _data );
139140/** Sets the data of the HYPRE_IJVector to _data.
141 Must be the same length as the current local size of the vector.
142 If not, this can lead to an inconsistent vector setup. */143HYPRE_Int SetData( double* p_data, HYPRE_Int* p_col = NULL );
144145/** Add the data of the HYPRE_IJVector to _data.
146 Must be the same length as the current local size of the vector.
147 If not, this can lead to an inconsistent vector setup. */148HYPRE_Int AddData( double* p_data, HYPRE_Int* p_col = NULL );
149150HYPRE_Int verbosity( const HYPRE_Int level );
151152HYPRE_Int FinalizeAssembly();
153154// const HYPRE_Complex& operator()(int index) const;155156// HYPRE_Complex& operator()(int index);157158/// Prints the locally owned rows in parallel159voidPrint( constchar* fname )const;
160161/// Calls hypre's destroy function162 ~HypreParVector();
163164staticdoubleInnerProduct( HypreParVector& x, HypreParVector& y );
165 };
166167/// Returns the inner product of x and y168doubleInnerProduct( HypreParVector& x, HypreParVector& y );
169doubleInnerProduct( HypreParVector* x, HypreParVector* y );
170171 } // namespace moab172173#endif// MOAB_HAVE_MPI174175#endif