Changes between Version 2 and Version 3 of MultiPhysics


Ignore:
Timestamp:
01/22/13 09:41:20 (12 years ago)
Author:
Jonathan
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • MultiPhysics

    v2 v3  
    1919==== MHD ====
    2020
    21 Enabling MHD requires two changes to the data files:
    22  * In {{{global.data}}}, set  the {{{MaintainAuxArrays}}} flag to {{{T}}}.
     21To enable MHD:
    2322 * In {{{physics.data}}}, set {{{lMHD}}} to {{{T}}}.
    2423
    25 You will also need to initialize the {{{aux}}} arrays in your module file.  In fact, magnetic fields are often initialized by setting the {{{aux}}} values first, and then calculating the cell-centered magnetic fields in {{{q}}} by averaging the {{{aux}}} values on either side of a cell:
     24If the code is using constrained transport, then the logical flag {{{MaintainAuxArrays}}} will be {{{.True.}}}.  In that case you will need to initialize the face averaged magnetic field values in the {{{aux}}} array in your module file.  Here is an example for an initial magnetic field that is [[latex(\mathbf {B}=Bx(x,y,z)\mathbf{e_x} + By(x,y,z) \mathbf{e_y} + Bz(x,y,z) \mathbf{e_z})]]
     25
    2626
    2727{{{
    28 Info%q(i,j,k,iBx) = half * (Info%aux(i,j,k,1) + Info%aux(i+1,j,k,1))
    29 Info%q(i,j,k,iBy) = half * (Info%aux(i,j,k,1) + Info%aux(i,j+1,k,2))
    30 Info%q(i,j,k,iBz) = half * (Info%aux(i,j,k,1) + Info%aux(i,j,k+1,3))
     28dx = (/(merge(1d0,0d0,nDim >= i),i=1,3)/)*levels(Info%level)%dx
     29
     30DO i=1, Info%mX(1)
     31  x = Info%xBounds(1,1)+(REAL(i)-.5d0)*dx(1)
     32  DO j=1, Info%mX(2)
     33    y = Info%xBounds(2,1)+(REAL(j)-.5d0)*dx(2)
     34    DO k=1, Info%mX(3)
     35      z = Info%xBounds(3,1)+(REAL(k)-.5d0)*dx(3)
     36      Info%q(i,j,k,iBx)=Bx(x,y,z)
     37      Info%q(i,j,k,iBy)=By(x,y,z)
     38      Info%q(i,j,k,iBz)=Bz(x,y,z)
     39    END DO
     40  END DO
     41END DO
     42
     43IF (MaintainAuxArrays) THEN
     44  IF (nDim >= 1) THEN
     45    !Note the +1 in the i loop DO statement and the -1d0 in
     46    !the x coordinate calculation instead of -.5d0
     47    DO i=1, Info%mX(1)
     48      x = Info%xBounds(1,1)+(REAL(i)-1d0)*dx(1)
     49      DO j=1, Info%mX(2)+1
     50        y = Info%xBounds(2,1)+(REAL(j)-.5d0)*dx(2)
     51        DO k=1, Info%mX(3)
     52          z = Info%xBounds(3,1)+(REAL(k)-.5d0)*dx(3)
     53          Info%aux(i,j,k,1)=Bx(x,y,z)
     54        END DO
     55      END DO
     56    END DO
     57
     58    !Now we can update the cell centered value with the adjacent face average
     59    Info%q(1:Info%mX(1),1:Info%mX(2),1:Info%mX(3),iBx)=.5d0 * (&
     60      Info%aux(1:Info%mX(1),1:Info%mX(2),1:Info%mX(3),1) + &
     61      Info%aux(2:Info%mX(1)+1,1:Info%mX(2),1:Info%mX(3),1) )
     62
     63
     64    IF (nDim >= 2) THEN
     65      !Note the +1 in the j loop DO statement and the -1d0 in
     66      !the y coordinate calculation instead of -.5d0
     67      DO i=1, Info%mX(1)
     68        x = Info%xBounds(1,1)+(REAL(i)-.5d0)*dx(1)
     69        DO j=1, Info%mX(2)+1
     70          y = Info%xBounds(2,1)+(REAL(j)-1d0)*dx(2)
     71          DO k=1, Info%mX(3)
     72            z = Info%xBounds(3,1)+(REAL(k)-.5d0)*dx(3)
     73            Info%aux(i,j,k,2)=By(x,y,z)
     74          END DO
     75        END DO
     76      END DO
     77
     78      !Now we can update the cell centered value with the adjacent face average 
     79      Info%q(1:Info%mX(1),1:Info%mX(2),1:Info%mX(3),iBy)=.5d0 * (&
     80        Info%aux(1:Info%mX(1),1:Info%mX(2),1:Info%mX(3),2) + &
     81        Info%aux(1:Info%mX(1),2:Info%mX(2)+1,1:Info%mX(3),2) )
     82
     83      IF (nDim >= 3) THEN
     84       !Note the +1 in the k loop DO statement and the -1d0 in
     85       !the z coordinate calculation instead of -.5d0
     86       DO i=1, Info%mX(1)
     87         x = Info%xBounds(1,1)+(REAL(i)-.5d0)*dx(1)
     88         DO j=1, Info%mX(2)
     89           y = Info%xBounds(2,1)+(REAL(j)-.5d0)*dx(2)
     90           DO k=1, Info%mX(3)+1
     91             z = Info%xBounds(3,1)+(REAL(k)-1d0)*dx(3)
     92             Info%aux(i,j,k,3)=Bz(x,y,z)
     93           END DO
     94         END DO
     95       END DO
     96
     97      !Now we can update the cell centered value with the adjacent face average
     98       Info%q(1:Info%mX(1),1:Info%mX(2),1:Info%mX(3),iBz)=.5d0 * (&
     99         Info%aux(1:Info%mX(1),1:Info%mX(2),1:Info%mX(3),3) + &
     100         Info%aux(1:Info%mX(1),1:Info%mX(2),2:Info%mX(3)+1,3) )
     101      END IF
     102    END IF
     103  END IF
     104END IF
    31105}}}
    32106