Vec: types, sizes, and block sizes...

Lisandro Dalcin dalcinl at gmail.com
Fri Jul 24 10:15:00 CDT 2009


Barry, I started to code all this, and have more or less ready the
parts up to VecSetUp(), but found a serious issue...

The following sequence of calls should work

VecCreate()
VecSetType()
VecSetSizes()
VecSetBlockSize()
VecGetArray() /* gotcha !!!*/

VecGetArray() is intended to be a local operation, then I cannot make
it automatically call the collective VecSetUp()... Asking users to
call VecSetUp() before VecGetArray() seems a nonsense...


On Wed, Jul 22, 2009 at 6:53 PM, Barry Smith<bsmith at mcs.anl.gov> wrote:
>
>    VecCreate()
>    VecSetXXX
>    VecSetYYY
>    VecSetBlockSize()
>    VecSetUp()   (called also automatically as needed by later vector
> routines, like PCSetUp()/KSPSetUp()/SNESSetUp()/TSSetUp() are called)
>      use the beast
>
>    To make this universal we need to fix Mat to have the
> MatXXXSetPreallocation() to just stash the preallocation information not do
> the allocation on the spot, but wait until the MatSetUp().
>
>
>   Barry
>
>
> On Jul 22, 2009, at 1:47 PM, Lisandro Dalcin wrote:
>
>> Starting a new thread ...
>>
>> Here you have simple example about creating Vec's. PETSc let me set
>> first the type, or first the size and block size... However...
>> setting FIRST the TYPE is currently broken...
>>
>> Anything we are going to do to fix this will require to handle the
>> case above... At first, the only way I can imagine of doing that is by
>> using a macro VecPreallocated() (more or less like in Mat), in charge
>> of checking and setting-up the sizes&blocksizes and the allocated
>> array. But then this macro have to be called on almost all Vec
>> interface calls...
>>
>> Note: the code below have to be run in 2(two) processes to show the
>> problems (at second block, when creating vector "y")...
>>
>> #include "petscvec.h"
>>
>> #undef __FUNCT__
>> #define __FUNCT__ "main"
>> int main(int argc,char **argv)
>> {
>>  PetscErrorCode ierr;
>>  ierr = PetscInitialize(&argc,&argv,0,0);CHKERRQ(ierr);
>>  if (1) {
>>   Vec x;
>>   ierr = VecCreate(PETSC_COMM_WORLD, &x);CHKERRQ(ierr);
>>   ierr = VecSetSizes(x, PETSC_DECIDE, 9);CHKERRQ(ierr);
>>   ierr = VecSetBlockSize(x, 3);CHKERRQ(ierr);
>>   ierr = VecSetType(x, VECMPI);CHKERRQ(ierr);
>>   ierr = VecDestroy(x);CHKERRQ(ierr);
>>  }
>>  if (1) {
>>   Vec y;
>>   ierr = VecCreate(PETSC_COMM_WORLD, &y);CHKERRQ(ierr);
>>   ierr = VecSetType(y, VECMPI);CHKERRQ(ierr);
>>   ierr = VecSetSizes(y, PETSC_DECIDE, 9);CHKERRQ(ierr);
>>   ierr = VecSetBlockSize(y, 3);CHKERRQ(ierr);
>>   ierr = VecDestroy(y);CHKERRQ(ierr);
>>  }
>>  ierr = PetscFinalize();CHKERRQ(ierr);
>>  return 0;
>> }
>>
>>
>>
>> --
>> Lisandro Dalcín
>> ---------------
>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>> Tel/Fax: +54-(0)342-451.1594
>
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594



More information about the petsc-dev mailing list