Changes between Version 4 and Version 5 of MultiPhysics


Ignore:
Timestamp:
01/22/13 16:17:51 (12 years ago)
Author:
Jonathan
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • MultiPhysics

    v4 v5  
    4545    !Note the +1 in the i loop DO statement and the -1d0 in
    4646    !the x coordinate calculation instead of -.5d0
    47     DO i=1, Info%mX(1)
     47    DO i=1, Info%mX(1)+1
    4848      x = Info%xBounds(1,1)+(REAL(i)-1d0)*dx(1)
    49       DO j=1, Info%mX(2)+1
     49      DO j=1, Info%mX(2)
    5050        y = Info%xBounds(2,1)+(REAL(j)-.5d0)*dx(2)
    5151        DO k=1, Info%mX(3)
     
    105105}}}
    106106
    107 Of course the above example works for any field - but does not impose the divergence free constraint. (Presumably the functions {{{Bx}}}, {{{By}}}, and {{{Bz}}} would take care of that) to the degree they are accurately integrated along each edge - but a better approach is to instead initialize the vector potential and then discretely difference it to get the face fields.
     107Of course the above example works for any field - but does not impose the divergence free constraint. Presumably the functions {{{Bx}}}, {{{By}}}, and {{{Bz}}} would take care of that to the degree they are accurate face averages - but a better approach is to instead approximate  the vector potential at cell edges and then discretely difference it to get the face average fields.
     108
     109{{{
     110IF (nDim == 2) THEN
     111  !In 2D the only component of the vector potential that matters is Az
     112  ALLOCATE(A(1:Info%mX(1)+1,1:Info%mX(2)+1,1,1)
     113  DO i=1, Info%mX(1)+1
     114    x = Info%xBounds(1,1)+(REAL(i)-1d0)*dx(1)
     115    DO j=1, Info%mX(2)+1
     116      y = Info%xBounds(2,1)+(REAL(j)-1d0)*dx(2)
     117      A(i,j,1,1)=Az(x,y,z)
     118    END DO
     119  END DO
     120
     121  !Then take the curl of A to get B
     122  FORALL(i=1:Info%mX(1)+1,j=1:Info%mX(2))
     123    Info%aux(i,j,1,1)=+(A(i,j+1,1,1)-A(i,j,1,1))/dx(2)
     124  END FORALL
     125  FORALL(i=1:Info%mX(1),j=1:Info%mX(2)+1)
     126    Info%aux(i,j,1,2)=-(A(i+1,j,1,1)-A(i,j,1,1))/dx(1)
     127  END FORALL
     128
     129ELSEIF (nDim == 3) THEN
     130  !Now the vector potential is a 3 component vector
     131  ALLOCATE(A(1:Info%mX(1)+1,1:Info%mX(2)+1,1:Info%mX(3)+1,3)
     132
     133  !We could do this with three separate loops to avoid calculating
     134  !A(:,:,Info%mX(3)+1,3),A(:,Info%mX(2)+1,:,2), and A(Info%mX(1)+1,:,:,1)
     135  !Since these do not get used in taking the curl...
     136
     137  DO i=1, Info%mX(1)+1
     138    x = Info%xBounds(1,1)+(REAL(i)-1d0)*dx(1)
     139    DO j=1, Info%mX(2)+1
     140      y = Info%xBounds(2,1)+(REAL(j)-1d0)*dx(2)
     141      DO k=1, Info%mX(3)+1
     142        z = Info%xBounds(3,1)+(REAL(k)-1d0)*dx(3)
     143        A(i,j,k,1)=Ax(x+half*dx(1),y,z)
     144        A(i,j,k,2)=Ay(x,y+half*dx(2),z)
     145        A(i,j,k,3)=Az(x,y,z+half*dx(3))
     146      END DO
     147    END DO
     148  END DO
     149
     150  !Then take the curl of A to get B
     151  FORALL(i=1:Info%mX(1)+1,j=1:Info%mX(2),k=1:Info%mX(3))
     152    Info%aux(i,j,k,1)=+(A(i,j+1,k,3)-A(i,j,k,3))/dx(2)-(A(i,j,k+1,2)-A(i,j,k,2))/dx(3)
     153  END FORALL
     154  FORALL(i=1:Info%mX(1),j=1:Info%mX(2)+1,k=1:Info%mX(3))
     155    Info%aux(i,j,k,2)=+(A(i,j,k+1,1)-A(i,j,k,1))/dx(3)-(A(i+1,j,k,3)-A(i,j,k,3))/dx(1)
     156  END FORALL
     157  FORALL(i=1:Info%mX(1),j=1:Info%mX(2),k=1:Info%mX(3)+1)
     158    Info%aux(i,j,k,3)=+(A(i+1,j,k,2)-A(i,j,k,2))/dx(1)-(A(i,j+1,k,1)-A(i,j,k,1))/dx(2)
     159  END FORALL
     160END IF
     161
     162}}}
     163
     164[[Image(Stencil.png, width=400)]]
    108165
    109166==== Cooling ====