[petsc-users] Setting block size for MPI vectors

Barry Smith bsmith at mcs.anl.gov
Tue Aug 27 16:49:42 CDT 2013


   You need to use the "long winded" construction of vectors to add these options. For example,

    VecCreate()
    VecSetBlockSize()
    VecSetSizes()
    VecSetType()

  the reason is that the Vec may be constructed differently based on these options but the VecCreateMPI() is suppose to produce an already constructed Vec.

   Barry


On Aug 27, 2013, at 4:45 PM, "Vijay S. Mahadevan" <vijay.m at gmail.com> wrote:

> I am trying to create an MPI vector and then trying to set the block
> size after the initial creation. But I receive an error in
> PetscLayoutSetBlockSize. Since there is no explicit block size
> argument during construction, I call VecSetBlockSize afterwards. The
> relevant code and error are below.
> 
> Is there an alternate call to set the block size to the vector so that
> VecSetValuesBlocked will work correctly ? If there is no current way
> to do this, that's fine and I can try to get the local array and set
> the values accordingly.
> 
> Code:
> ierr = VecCreateMPI(PETSC_COMM_WORLD, 10, PETSC_DECIDE, &x);CHKERRQ(ierr);
> ierr = VecSetBlockSize(x, 2);CHKERRQ(ierr);
> ierr = VecSetFromOptions(x);CHKERRQ(ierr);
> 
> Relevant errors:
> 
> 0]PETSC ERROR: Arguments are incompatible!
> [0]PETSC ERROR: Cannot change block size 1 to 2!
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Development GIT revision:
> 0799ffdeffb47ef0458c1305293fae28c4d2cd92  GIT Date: 2013-08-01
> 06:36:16 +0800
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: ./ex1 on a arch-darwin-cxx-debug named
> anlextwls002-168.wl.anl-external.org by mahadevan Tue Aug 27 16:37:18
> 2013
> [0]PETSC ERROR: Libraries linked from /opt/petsc-dbg/lib
> [0]PETSC ERROR: Configure run at Wed Jul 31 18:03:46 2013
> [0]PETSC ERROR: Configure options --prefix=/opt/petsc-dbg
> PETSC_ARCH=arch-darwin-cxx-debug --download-scalapack=1
> --download-blacs=1
> --with-mumps-dir=/Users/mahadevan/source/MUMPS_4.10.0-p3
> --download-hypre=1 --with-metis=1 --with-parmetis=1
> --known-mpi-shared-libraries=1
> --with-blas-lapack-lib=/System/Library/Frameworks/vecLib.framework/vecLib
> --with-c++-support=1 --with-c-support=1 --with-cc=mpicc
> --with-clanguage=C++ --with-moab-dir=/opt/moab
> --with-dynamic-loading=1 --with-fc=mpif90 --with-fortran=1
> --with-mpi=1 --with-shared-libraries=1 --with-valgrind=1
> --with-valgrind-dir=/opt/local --with-cc=mpicc --with-cxx=mpicxx
> COPTFLAGS="-g -fPIC" CXXOPTFLAGS="-g -fPIC" FOPTFLAGS="-g -fPIC"
> --with-metis-dir=/usr/local --with-parmetis-dir=/usr/local
> --with-netcdf-dir=/usr/local --with-zoltan=1
> --with-zoltan-lib="-L/usr/local/lib -lptscotch -lscotch -lscotchmetis
> -lscotcherr -lscotcherrexit -lzoltan"
> --with-zoltan-include=/usr/local/include --with-hdf5
> --with-hdf5-include=/usr/local/include
> --with-hdf5-lib="-L/usr/local/lib -lhdf5_fortran -lhdf5"
> --with-netcdf-dir=/usr/local --with-cmake=/opt/local/bin/cmake
> --with-x-dir=/opt/local
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: PetscLayoutSetBlockSize() line 459 in
> /Users/mahadevan/source/petsc-dev/src/vec/is/utils/pmap.c
> [0]PETSC ERROR: VecSetBlockSize() line 1471 in
> /Users/mahadevan/source/petsc-dev/src/vec/vec/interface/vector.c
> [0]PETSC ERROR: main() line 32 in src/vec/vec/examples/tests/ex1.c
> 
> Thanks,
> Vijay



More information about the petsc-users mailing list