58
50
#include "finclude/petscisdef.h"
60
52
#include "finclude/petsc.h"
61
#if PETSC_VERSION_MINOR==0
62
#include "finclude/petscmat.h"
63
#include "finclude/petscvec.h"
64
#include "finclude/petscviewer.h"
65
#include "finclude/petscksp.h"
66
#include "finclude/petscpc.h"
67
#include "finclude/petscmg.h"
68
#include "finclude/petscis.h"
69
#include "finclude/petscsys.h"
72
54
! hack around PetscTruth->PetscBool change in petsc 3.2
73
#if PETSC_VERSION_MINOR==2
55
#if PETSC_VERSION_MINOR>=2
74
56
#define PetscTruth PetscBool
76
58
! options read from command-line (-prns_... options)
93
75
! read in the matrix equation and init. guess:
94
76
call PetscViewerBinaryOpen(MPI_COMM_FEMTOOLS, trim(filename), &
95
77
FILE_MODE_READ, viewer, ierr)
96
#if PETSC_VERSION_MINOR==2
78
#if PETSC_VERSION_MINOR>=2
97
79
! in petsc 3.2 MatLoad and VecLoad do no longer create a new vector
98
80
call MatCreate(MPI_COMM_FEMTOOLS, matrix, ierr)
99
81
call VecCreate(MPI_COMM_FEMTOOLS, rhs, ierr)
753
735
ncomponents=size(petsc_numbering%gnn2unn, 2)
754
736
allocate(unns(1:n*ncomponents))
755
737
unns=reshape( petsc_numbering%gnn2unn(1:n,:), (/ n*ncomponents /))
756
#if PETSC_VERSION_MINOR==2
738
#if PETSC_VERSION_MINOR>=2
757
739
! for petsc 3.2 we have an extra PetscCopyMode argument
758
740
call ISCreateGeneral(MPI_COMM_FEMTOOLS, &
759
741
size(unns), unns, PETSC_COPY_VALUES, row_indexset, ierr)
765
747
m=petsc_numbering%universal_length ! global length
767
#if PETSC_VERSION_MINOR==0
768
! in petsc 3.0 we have to ask for all columns
769
! so we need to create an index set with all universal node numbers(!)
770
allocate( allcols(1:m) )
771
allcols=(/ ( i, i=0, m-1) /)
772
call ISCreateGeneral(MPI_COMM_FEMTOOLS, &
773
m, allcols, col_indexset, ierr)
774
call ISSetIdentity(col_indexset, ierr)
776
! redistribute matrix by asking for owned rows and all columns
777
! n*components is the number of columns we own
778
call MatGetSubMatrix(matrix, row_indexset, col_indexset, n*ncomponents, &
779
MAT_INITIAL_MATRIX, new_matrix, ierr)
780
call ISDestroy(col_indexset, ierr)
782
! in petsc 3.1 we only ask for owned columns (although presumably
749
! we only ask for owned columns (although presumably
783
750
! still all columns of owned rows are stored locally)
784
751
! we only deal with square matrices (same d.o.f. for rows and columns)
785
752
! in fluidity, so we can simply reuse row_indexset as the col_indexset
786
753
call MatGetSubMatrix(matrix, row_indexset, row_indexset, &
787
754
MAT_INITIAL_MATRIX, new_matrix, ierr)
789
756
! destroy the old read-in matrix and replace by the new one
790
757
call MatDestroy(matrix, ierr)
791
758
matrix=new_matrix