linear elliptic vector equation

Barry Smith bsmith at mcs.anl.gov
Tue Aug 18 21:41:54 CDT 2009


On Aug 18, 2009, at 11:42 AM, nicolas aunai wrote:

> Hello,
>
> Yes it is a bit overkill indeed :-) I was looking at ex29 actually...
> which is still linear and with DA's but scalar.
>
> But I'd rather like not use multigrids, however I have not seen an
> example of a code that uses DA's and KSP solvers.
>
> Every example use multigrids.

    Multigrid is the way to go for this problem, it will be faster  
than some generic preconditioned CG.

>
> When you have a multicomponent linear equation to solve on a
> rectangular uniform grid such as mine, is it good to :
>
> 1/  use DA's to represent your grid
>
> 2/ create the matrix corresponding to your operator once and for all
> (the operator neve changes).( In fact there are 2 matrices because two
> cases possibles (Neumann/periodic or Dirichlet/Periodic, depending on
> the component). but never minds)
>
>
> 3/ Call KSPSolve() 3 times (for each vector component associated  
> with the DA) ?
>
    Yes. You can do all this using the DMMG object.

   Note that the DMMG object in your linear case just manages a KSP  
and the meshes for you. In the end it is a KSPSolve() that actually  
does the solve and you have full control over the solve including  
using -pc_type icc or something else that does not use multigrid.  
Though multigrid will be faster.


    Barry


>
> Thx
> Nico
>
>
> 2009/8/18 Aron Ahmadia <aron.ahmadia at kaust.edu.sa>:
>> ex19 comes to mind, though it's a bit overkill for what you're  
>> doing...
>>
>> http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/src/snes/examples/tutorials/ex19.c.html
>>
>> ex19 uses DAs and DMMG, which is kind of like a meta-DA for using
>> multigrid-style solvers.  Both work well with structured grids.
>>
>> You may also want to review the PETSc manual section on DA.
>>
>> A
>>
>> On Tue, Aug 18, 2009 at 3:30 AM, nicolas aunai <nicolas.aunai at gmail.com 
>> >
>> wrote:
>>>
>>> Dear all,
>>>
>>>
>>> I have a simulation code (particle in cell) in which I have to  
>>> solve a
>>> linear vector equation 4 times per time step. A typical run consists
>>> of 50 000 time steps. The grid is rectangular and uniform of size  
>>> Lx,
>>> Ly, with nx+1 and ny+1 points in the x and y direction  
>>> respectively.,
>>> (nx, ny) could be at max (1024,1024).
>>>
>>> The vector equation is the following :
>>>
>>> B(x,y) - a*Laplacian(B(x,y)) = S(x,y)
>>>
>>>
>>> Where B and S are 2D vector fields with 3 components (Bx, By, Bz and
>>> Sx, Sy, Sz), each depending on the x and y coordinates.
>>>
>>>
>>> 'a' is a positive constant, smaller than one, typically a= 0.02
>>>
>>> Boundary conditions may depend on for which B component we are  
>>> solving
>>> the equation. On the x=cst borders, the boundary is always periodic,
>>> no matter what component is solved, but on y=cst borders, the  
>>> boundary
>>> condition can be either Neumann or Dirichlet.
>>>
>>> So far, I have written a small code that creates a vector  
>>> solution, a
>>> vector RHS and the matrix operator, and solve a scalar equation of
>>> this type. Solving my vector equation would then just call 3 times
>>> this kind of code... but I believe there is another way to deal with
>>> vector fields and linear systems with Petsc, using DAs no ? Could
>>> someone explain me how solve this the proper way and/or show me some
>>> code solving linear system with vector fields ? (is there an example
>>> in the exercices that I would not have seen ?)
>>>
>>>
>>>
>>> Thanks a lot
>>> Nico
>>
>>
>>
>> --
>> Aron Jamil Ahmadia
>> Assistant Research Scientist
>> King Abdullah University of Science and Technology
>>



More information about the petsc-users mailing list