Fwd: Re: about ghosted vectors and there local representation
Barry Smith
bsmith at mcs.anl.gov
Thu Jun 22 15:13:57 CDT 2006
Send the values of local2global, nc, ghosts, nrows and nghosts for all
processors (2 I hope). Also note that nrows should equal nc + nghosts.
Barry
On Thu, 22 Jun 2006, Thomas Geenen wrote:
> nrows is the global number of rows
> local2global is the local to global renumbering
> nghosts are the number of ghosts
> ghosts is the global row number i want to have local access to after the solve
>
>
> ISLocalToGlobalMappingCreate(PETSC_COMM_WORLD, nrows, local2global, <og);
> VecCreateGhost(PETSC_COMM_WORLD, nc,
> PETSC_DECIDE, nghosts[mype], ghosts, &x);
> VecSetLocalToGlobalMapping(x,ltog);
> VecSetValuesLocal(x, nc, indx, x_values, INSERT_VALUES);
> VecAssemblyBegin(x);
> VecAssemblyEnd(x);
>
> solve the system
>
> ierr = KSPGetSolution(ksp, &x);
> ierr = VecGhostUpdateBegin(x,INSERT_VALUES,SCATTER_FORWARD);
> ierr = VecGhostUpdateEnd(x,INSERT_VALUES,SCATTER_FORWARD);
> ierr = VecGhostGetLocalForm(x, &lx);
>
> nrows is the global number of rows
> local2global is the local to global renumbering
> nghosts are the number of ghosts
> ghosts is the global row number i want to have local access to after the solve
>
>
> thomas
>
> On Thursday 22 June 2006 09:20, you wrote:
>> ---------- Forwarded Message ----------
>>
>> Subject: Re: about ghosted vectors and there local representation
>> Date: Tuesday 20 June 2006 20:39
>> From: Barry Smith <bsmith at mcs.anl.gov>
>> To: petsc-users at mcs.anl.gov
>>
>> The ltog has to exactly match the way the ghosts are provided to
>> VecCreateGhost(). Are they? Please send the exact example code.
>>
>> Barry
>>
>> On Tue, 20 Jun 2006, Thomas Geenen wrote:
>>> Dear Petsc users,
>>>
>>> I think that I do not use the ghosted vector concept in the right way.
>>>
>>> I create a vector with
>>> ierr = VecCreateGhost(PETSC_COMM_WORLD, nc,
>>> PETSC_DECIDE, nghosts, ghosts, &x);
>>> The entries in ghost contain the global vector positions that I want to
>>> have available locally.
>>>
>>> I have a local representation so i apply (after having constructed the
>>> mapping of course)
>>> ierr = VecSetLocalToGlobalMapping(x,ltog);
>>> I now insert the values
>>> ierr = VecSetValuesLocal(x, nc, indx, x_values, INSERT_VALUES);
>>> VecAssemblyBegin(x);
>>> VecAssemblyEnd(x);
>>> I am now under the assumption that petsc divided the vector entries among
>>> processes according to his global representation of the vector.
>>>
>>> I solve my system of equations
>>> KSPSolve(ksp,b,x);
>>> afterwards i do
>>> ierr = KSPGetSolution(ksp, &x);
>>> ierr = VecGhostUpdateBegin(x,INSERT_VALUES,SCATTER_FORWARD);
>>> ierr = VecGhostUpdateEnd(x,INSERT_VALUES,SCATTER_FORWARD);
>>> ierr = VecGhostGetLocalForm(x, &lx);
>>>
>>> I now expect the vector to be in the local form. That means that the
>>> positions that I created as ghost points are filled with the solution
>>> corresponding to the global solution. I expect that they are inserted in
>>> the position in my local vector corresponding to there corresponding
>>> global position.
>>>
>>> apparently this is not what happens.
>>>
>>> a small example
>>> 2 cpu's
>>> each cpu contains 3 vector entries however there is an overlap of 1
>>> on cpu 1 the vector contains points (1, 2, 3)
>>> on cpu 2 the vector contains points (3, 4, 5)
>>>
>>> I make position 1 on cpu 2 a ghost points with nghost=1 ghosts(3)
>>> after solving and restoring I expect vector lx to contain the solution as
>>> (3, 4, 5)
>>>
>>>
>>> I hope I have explained my misunderstanding of the underlying concept
>>> clear enough
>>>
>>> thanks for your help
>>> Thomas Geenen
>>
>> -------------------------------------------------------
>
>
More information about the petsc-users
mailing list