go2D :: JobRequest -> IO ()
go2D jobReq = do
  simul <- runVirMat2D jobReq
  let
    fm :: FlexMicro Vec2 ()
    fm = mkFlexMicro $ grainSet simul
    fmMorph = add2DGrainMorph 2 fm
    showLeng = RenderGrainProp ("Length", \_ x -> fmap (getLength . grainLength . fst) x)
    showArea = RenderGrainProp ("Area", \_ x -> fmap (getArea . grainArea . fst) x)
    showNeig = RenderGrainProp ("Neighbors", \_ x -> fmap (grainNeighbors . fst) x)
    showall = [showGrainID, showLeng, showArea, showNeig]
  writeMultiVTKfile "virmat-2d.vtu" True $ renderFlexMicro showall 1 fmMorph

  writeFM "fm.vtu" fm 2
  let
    quads = IM.elems $ mapCP0D fm
    ps    = V.map controlPoint . V.fromList . IM.elems . controlPoints $ fm

  let
    upQ    = replicate 10 updateQuads
    quadFM = L.foldl' (\acc f -> f acc) fm upQ

  let
    ts = getAllGBTriangles fm 0
    ns = V.map getNormalTri ts
    plot = renderPoleFigureGB Lambert ns
    in renderSVGFile "pf.svg" (sizeSpec (Just 200, Nothing)) plot

  print "Get Stable Quadriple junctions..."
  writeFM "fmQuad.vtu" quadFM 2

  print "first angles"
  print $ listAngle fm

  print "first angles"
  print $ listAngle quadFM
go2D :: JobRequest -> IO ()
go2D jobReq = do
  simul <- runVirMat2D jobReq
  let
    fm :: FlexMicro Vec2 ()
    fm = mkFlexMicro $ grainSet simul
    fmMorph = add2DGrainMorph 2 fm
    showLeng = RenderGrainProp ("Length", \_ x -> fmap (getLength . grainLength . fst) x)
    showArea = RenderGrainProp ("Area", \_ x -> fmap (getArea . grainArea . fst) x)
    showNeig = RenderGrainProp ("Neighbors", \_ x -> fmap (grainNeighbors . fst) x)
    showall = [showGrainID, showLeng, showArea, showNeig]
  writeMultiVTKfile "virmat-2d.vtu" True $ renderFlexMicro showall 1 fmMorph

  writeFM "fm.vtu" fm 2
  let
    quads = IM.elems $ mapCP0D fm
    ps    = V.map controlPoint . V.fromList . IM.elems . controlPoints $ fm

  let
    upQ    = replicate 10 updateQuads
    quadFM = L.foldl' (\acc f -> f acc) fm upQ

  let
    ts = getAllGBTriangles fm 0
    ns = V.map getNormalTri ts
    plot = renderPoleFigureGB Lambert ns
    in renderSVGFile "pf.svg" (sizeSpec (Just 200, Nothing)) plot

  print "Get Stable Quadriple junctions..."
  writeFM "fmQuad.vtu" quadFM 2

  print "first angles"
  print $ listAngle fm

  print "first angles"
  print $ listAngle quadFM
go2D jobReq = do
  simul <- runVirMat2D jobReq
  let
    fm :: FlexMicro Vec2 ()
    fm = mkFlexMicro $ grainSet simul
    fmMorph = add2DGrainMorph 2 fm
    showLeng = RenderGrainProp ("Length", \_ x -> fmap (getLength . grainLength . fst) x)
    showArea = RenderGrainProp ("Area", \_ x -> fmap (getArea . grainArea . fst) x)
    showNeig = RenderGrainProp ("Neighbors", \_ x -> fmap (grainNeighbors . fst) x)
    showall = [showGrainID, showLeng, showArea, showNeig]
  writeMultiVTKfile "virmat-2d.vtu" True $ renderFlexMicro showall 1 fmMorph

  writeFM "fm.vtu" fm 2
  let
    quads = IM.elems $ mapCP0D fm
    ps    = V.map controlPoint . V.fromList . IM.elems . controlPoints $ fm

  let
    upQ    = replicate 10 updateQuads
    quadFM = L.foldl' (\acc f -> f acc) fm upQ

  let
    ts = getAllGBTriangles fm 0
    ns = V.map getNormalTri ts
    plot = renderPoleFigureGB Lambert ns
    in renderSVGFile "pf.svg" (sizeSpec (Just 200, Nothing)) plot

  print "Get Stable Quadriple junctions..."
  writeFM "fmQuad.vtu" quadFM 2

  print "first angles"
  print $ listAngle fm

  print "first angles"
  print $ listAngle quadFM