# MIF 2.1
# MIF Example File: sample-rotate.mif
# Description: Example use of the Oxs_AffineOrientScalarField,
#   Oxs_AffineTransformScalarField and Oxs_ImageScalarField classes.

set pi [expr {4*atan(1.0)}]
set mu0 [expr {4*$pi*1e-7}]

RandomSeed 0

Specify Oxs_BoxAtlas:atlas {
  xrange {0 335e-9}
  yrange {0 275e-9}
  zrange {0 20e-9}
}

Specify Oxs_RectangularMesh:mesh {
  cellsize {5e-9 5e-9 5e-9}
  atlas :atlas
}

Specify Oxs_UniformExchange:NiFe {
  A  13e-12
}

Specify Oxs_UZeeman [subst {
  multiplier [expr {0.001/$mu0}]
  Hrange {
     {     0  0  0   1000  0  0   10 }
     {  1000  0  0  -1000  0  0   20 }
     { -1000  0  0   1000  0  0   20 }
  }
}]

Specify Oxs_Demag {}

Specify Oxs_RungeKuttaEvolve:evolver {}

# Load scalar field from luigi.gif.  This field will be used
# to define Ms pointwise.  Because this field is rotated by
# the :rotate object, we need to specify the x/y/zrange here
# so that after rotation the field extents map to those
# specified by the main problem atlas, i.e., :atlas.  The
# :atlas extents lie in the first quadrant, and the rotation
# is counterclockwise about the coordinate origin, so
# x/y/zrange should lie in the fourth quadrant.
Specify Oxs_ImageScalarField:luigimag {
   image luigi.gif
   multiplier 8e5
   offset 0
   viewplane xy
   exterior error
   comment { Define range for pre-rotated image }
   xrange {    0    275e-9}
   yrange { -335e-9   0}
   zrange {    0     20e-9}
}

# Rotate image field 90 degrees counterclockwise.
# If we don't use the inverse flag, the matrix "M"
# should represent a 90 degree clockwise rotation.
Specify Oxs_AffineOrientScalarField:rotate {
   field :luigimag
   M { 0 1 0
      -1 0 0
       0 0 1 }
   comment {inverse 1}
   comment {Note: If you enable "inverse 1", you will need
            to change the x/y/z-range of :luigimag}
}

# Sample usage of the Oxs_AffineTranformScalarField that
# reduces the range of Ms values by 25% (multiplier 0.75),
# and then shifts the values up by 25% of the nominal
# full-scale value (offset 2e5; note that 0.25*8e5=2e5).
Specify Oxs_AffineTransformScalarField:flatten {
   field :rotate
   multiplier 0.75
   offset     2e5
}

# Bring in common attributes for Oxs_TimeDriver block
eval [ReadFile sample-attributes.tcl]

Specify Oxs_TimeDriver {
 basename sample-rotate
 comment {Ms :rotate}
 Ms :flatten
 attributes :common_driver_data
}
