# MIF 2.1
# MIF Example File: octant.mif
# Description: Oxs_ScriptAtlas example, with 8 regions.

Specify Oxs_ScriptAtlas:octant {
    xrange {-20e-9 20e-9}
    yrange {-20e-9 20e-9}
    zrange {-20e-9 20e-9}
    regions { A B C D E F G H }
    script MyRegion
}

Specify Oxs_RectangularMesh:mesh {
  cellsize {10e-9 10e-9 10e-9}
  atlas :octant
}

Specify Oxs_UniaxialAnisotropy {
  K1  { Oxs_UniformScalarField { value 520e3 } }
  axis { Oxs_AtlasVectorField {
      atlas :octant
      norm 1
      values {
	  A {  1  1  1 }
	  B { -1  1  1 }
	  C { -1 -1  1 }
	  D {  1 -1  1 }
	  E {  1  1 -1 }
	  F { -1  1 -1 }
	  G { -1 -1 -1 }
	  H {  1 -1 -1 }
      }
  } }
}

Specify Oxs_UniformExchange:NiFe {
  A  13e-12
}

Specify Oxs_EulerEvolve {
  alpha 0.5
  start_dm 0.01
}

Specify Oxs_TimeDriver {
 basename octant
 evolver Oxs_EulerEvolve
 stopping_dm_dt 0.01
 mesh :mesh
 Ms 8e5
 comment { m0 { Oxs_RandomVectorField {
    min_norm 1
    max_norm 1
 } } }
 m0 { Oxs_AtlasVectorField {
      atlas :octant
      norm 1
      values {
	  A { -1  0 0 }
	  B {  0 -1 0 }
	  C {  1  0 0 }
	  D {  0  1 0 }
	  E {  1 -1 0 }
	  F {  1  1 0 }
	  G { -1  1 0 }
	  H { -1 -1 0 }
      }
  } }
}


array set RegionArray {
1,1,1  1
0,1,1  2
0,0,1  3
1,0,1  4
1,1,0  5
0,1,0  6
0,0,0  7
1,0,0  8
}

proc MyRegion { x y z } {
    global RegionArray
    set xindex [expr {$x>=0.5}]
    set yindex [expr {$y>=0.5}]
    set zindex [expr {$z>=0.5}]
    if {[catch { set id $RegionArray($xindex,$yindex,$zindex) }]} {
	set id 0
    }
    return $id
}
