Vec: types, sizes, and block sizes...
Barry Smith
bsmith at mcs.anl.gov
Fri Jul 24 10:33:57 CDT 2009
If all the types,sizes,blocksize are going to be REQUIRED calls
then the object can keep track of what it has received and as soon as
it receives all the "required" information do the final creation (this
is what Matt proposed in his more flowery language). If something like
blocksize is optional then it makes things more complicated (hate to
make blocksize required or require it before setting the sizes).
I don't know of any perfect solution, this is why PETSc is
currently far from perfect.
Barry
On Jul 24, 2009, at 10:15 AM, Lisandro Dalcin wrote:
> 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