<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
On 16/6/2012 9:24 AM, Jed Brown wrote:
<blockquote
cite="mid:CAM9tzSmhPtDoQUcHK9Mo5s0Ni=yOz2k+K4g9SBwUZ5oh91QA_Q@mail.gmail.com"
type="cite">
<p>It depends how you want to solve the problem. I usually group
all dofs together. There is a 2D Stokes+Thermodynamics example
in SNES ex30 (or 31?).</p>
</blockquote>
<br>
I tried to understand ex30. I have some questions since it's in C
and I'm using to Fortran programming.<br>
<br>
Supposed I have a field - u,v,w,p, so in order to use them, I do the
following:<br>
<i><br>
type field<br>
<br>
real u,v,w,p<br>
<br>
end type field<br>
<br>
type(field), pointer :: field1(:,:,:) -> make a derived
variable</i><br>
<br>
Also:<br>
<i><br>
Vec field_local,field_global<br>
<br>
call DMDACreate3d with dof = 4<br>
<br>
call DMCreateGlobalVector(da, field_local,ierr)<br>
<br>
call DMCreateLocalVector(da,field_global,ierr)<br>
<br>
call DMGetLocalVector(da, field_local,ierr) -> To insert
values<br>
<br>
call DMDAVecGetArrayF90(da, field_local,field1,ierr)<br>
<br>
do k = zs, zs + zm - 1<br>
<br>
do j = ys, ys + ym -1 <br>
<br>
do i = xs, xs + xm - 1<br>
<br>
field1(i,j,k)%u = ... -> evaluate u,v,w,p etc<br>
<br>
end do<br>
<br>
end do<br>
<br>
call DMDAVecRestoreArrayF90(da,field_local,field1,ierr)<br>
<br>
call
DMLocalToGlobalBegin(da,field_local,INSERT_VALUES,field_global,ierr)<br>
<br>
call
DMLocalToGlobalEnd(da,field_local,INSERT_VALUES,field_global,ierr)<br>
<br>
call DMRestoreLocalVector(da,field_local,ierr)</i><br>
<br>
Is this the correct way?<br>
<br>
Also, supposed I now want to solve my u,v,w momentum eqns. Although
they're not coupled together, I believe it's faster if I assemble
them into 1 big matrix. <br>
<br>
So for Ax = b, x =
(field(1,1,1)%u,field(1,1,1)%v,field(1,1,1)%w,field(2,1,1)%u.... ) <br>
<br>
For b, do I duplicate a Vec similar to field_local?<br>
<br>
What about matrix A? Do I use the MatSetValuesStencil?<br>
<br>
Lastly, the type field contains u,v,w and p. However, I'm only
solving u,v,w. Do I have to skip some values or use identity matrix
to solve it?<br>
<br>
Thanks!<br>
<br>
<br>
<br>
<blockquote
cite="mid:CAM9tzSmhPtDoQUcHK9Mo5s0Ni=yOz2k+K4g9SBwUZ5oh91QA_Q@mail.gmail.com"
type="cite">
<div class="gmail_quote">On Jun 16, 2012 8:11 AM, "TAY wee-beng"
<<a moz-do-not-send="true" href="mailto:zonexo@gmail.com">zonexo@gmail.com</a>>
wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I'm abit unclear about dof used in DMDACreate3d. If I have
u,v,w for my CFD code, does it mean that I should have dof =
3? Or can i create 3 local/global vector using
DMCreateGlobalVector and DMCreateLocalVector to define u,v,w?<br>
<br>
Does it matter if I'm using staggered grids? Also, if I am
only using PETSc for u,v,w (and not pressure, which uses
HYPRE), does it mean a difference?<br>
<br>
I remember there 's an example using staggered grid somewhere
but I can't find it now. May I know which PETSc 's example it
is?<br>
<br>
Thanks!<br>
<br>
-- <br>
Yours sincerely,<br>
<br>
TAY wee-beng<br>
<br>
</blockquote>
</div>
</blockquote>
</body>
</html>