hi

I have a test code (attached) that sets up a finite volume mesh using DMPlex, with 2 degrees of freedom per cell.

I then create a matrix using DMCreateMatrix(), having used DMSetMatType() to set the matrix type to MATBAIJ or MATMPIBAIJ, to take advantage of the block structure.

This works OK and gives me the expected matrix structure when I run on > 1 processor, but neither MATBAIJ or MATMPIBAIJ works if I run it in serial:

[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Blocksize of layout 2 must match that of mapping 1
[0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting. [0]PETSC ERROR: Petsc Development GIT revision: v3.6.1-811-gaf4f2ea GIT Date: 2015-08-18 17:44:25 -0500 [0]PETSC ERROR: ./testmat on a linux-gnu-c-opt named des108 by acro018 Wed Sep 16 13:51:27 2015 [0]PETSC ERROR: Configure options --download-netcdf --download-exodusii --with-hdf5-dir=/usr --download-triangle --download-ptscotch -
-download-chaco
[0]PETSC ERROR: #1 PetscLayoutSetISLocalToGlobalMapping() line 248 in /home/acro018/software/PETSc/code/src/vec/is/utils/pmap.c [0]PETSC ERROR: #2 MatSetLocalToGlobalMapping() line 1876 in /home/acro018/software/PETSc/code/src/mat/interface/matrix.c [0]PETSC ERROR: #3 DMCreateMatrix_Plex() line 853 in /home/acro018/software/PETSc/code/src/dm/impls/plex/plex.c [0]PETSC ERROR: #4 DMCreateMatrix() line 961 in /home/acro018/software/PETSc/code/src/dm/interface/dm.c
--------------------------------------------------------------------------

It only works in serial if I use MATAIJ.

Is there a reason why the block matrix types don't appear to work in serial, at least in this case? (I'm running the PETSc 'next' branch.)

- Adrian

--
Dr Adrian Croucher
Senior Research Fellow
Department of Engineering Science
University of Auckland, New Zealand
email: [email protected]
tel: +64 (0)9 923 84611

program testmat

  ! Test constructing matrix from DMPlex

  implicit none

#include <petsc/finclude/petsc.h90>

  PetscInt, parameter :: dof = 2, overlap = 1
  MPI_Comm :: comm
  DM :: dm, dist_dm
  PetscErrorCode :: ierr
  character(40) :: filename = "col10.exo"
  PetscInt :: dim
  PetscFV :: fvm
  PetscDS :: ds
  Mat :: M

  call PetscInitialize(PETSC_NULL_CHARACTER, ierr); CHKERRQ(ierr)
  comm = PETSC_COMM_WORLD

  call DMPlexCreateExodusFromFile(comm, filename, PETSC_TRUE, dm, ierr); CHKERRQ(ierr)

  call DMPlexDistribute(dm, overlap, PETSC_NULL_OBJECT, dist_dm, ierr)
  CHKERRQ(ierr)
  if (dist_dm /= 0) then
     call DMDestroy(dm, ierr); CHKERRQ(ierr)
     dm = dist_dm
  end if

  call PetscFVCreate(comm, fvm, ierr); CHKERRQ(ierr)
  call PetscFVSetNumComponents(fvm, dof, ierr); CHKERRQ(ierr)
  call DMGetDimension(dm, dim, ierr); CHKERRQ(ierr)
  call PetscFVSetSpatialDimension(fvm, dim, ierr); CHKERRQ(ierr)
  call DMGetDS(dm, ds, ierr); CHKERRQ(ierr)
  call PetscDSAddDiscretization(ds, fvm, ierr); CHKERRQ(ierr)

  call DMSetMatType(dm, MATBAIJ, ierr); CHKERRQ(ierr)
  call DMCreateMatrix(dm, M, ierr); CHKERRQ(ierr)
  call MatView(M, PETSC_VIEWER_STDOUT_WORLD, ierr); CHKERRQ(ierr)

  call MatDestroy(M, ierr); CHKERRQ(ierr)
  call DMDestroy(dm, ierr); CHKERRQ(ierr)
  call PetscFinalize(ierr); CHKERRQ(ierr)

end program testmat

Attachment: col10.exo
Description: Binary data

Reply via email to