Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/IceSheet/Greenland/SSA_FRICTION_INIT/OPTIM_BETA.sif
3206 views
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! .sif file for the inverse method
!   Optimize the friction coefficient to reduce mismatch with obs. surface velocities
!   with constraints on the flux divergence and assume smoothness of the friction field
!  
! Author: F. Gillet-Chaulet (IGE-Grenoble-FR)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! FOR DEFAULT USE/UPDATE PARAMETERS IN OPTIM_BETA.IN
include OPTIM_BETA.IN
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!#######################################################
!#######################################################
Header
  Mesh DB "." "$MESH$"
End
!#######################################################
!#######################################################
Constants
  sea level = Real $zsl
  water density = Real $rhow
End
!#######################################################
!#######################################################
Simulation
  Coordinate System  = Cartesian 2D
  Simulation Type = Steady State

  Steady State Min Iterations = 1
  Steady State Max Iterations = $niter

  Post File = "RUN_$name$_.vtu"
  OutPut File = "RUN_$name$_.result"
  Output Intervals = $OutPutIntervals

  Restart File = "RUN0_.result"
  Restart Position = 0
  Restart Time = 0.0
  Restart Before Initial Conditions = Logical true

  max output level = 3
End
!#######################################################
!#######################################################
Body 1
  Equation = 1
  Body Force = 1
  Material = 1
  Initial Condition = 1
End
!#######################################################
!#######################################################
Initial Condition  1
 ! Initial guess of log10(slip coef.)
  alpha = Variable slc0
   REAL procedure "ElmerIceUSF" "Log10A"
End
!#######################################################
!#######################################################
Body Force 1
  Flow BodyForce 1 = Real 0.0            
  Flow BodyForce 2 = Real 0.0              
  Flow BodyForce 3 = Real $gravity

!# For Jdiv
  Top Surface Accumulation = Equals smb
  Bottom Surface Accumulation = Real 0.0
  Observed dhdt = Equals dhdt_obs

!# Cost not computed if H<=Hmin
  Cost_var Passive = Variable H
         Real procedure "USFs" "PassiveCond_H"
  Cost_Cost_DHDT Passive = Variable H
         Real procedure "USFs" "PassiveCond_H"
  Passive Element Min Nodes = Integer 3

!# at the end take slip coef.=10^alpha (for post-processing or restart)
  slc = Variable alpha
      REAL procedure "ElmerIceUSF" "TenPowerA"
End
!#######################################################
!#######################################################
Material 1
! Material properties
  Viscosity Exponent = Real $1/n
  Critical Shear Rate = Real 1.0e-16

  SSA Mean Viscosity = Equals Mu
  SSA Mean Density = Real $rhoi

  SSA Friction Law = String "linear"
  ! The friction parameter is 10^the optimised variable to ensure > 0
  SSA Friction Parameter = Variable alpha
      REAL procedure "ElmerIceUSF" "TenPowerA"
  SSA Friction Parameter Derivative = Variable alpha
     REAL procedure "ElmerIceUSF" "TenPowerA_d"
End
!#######################################################
!#######################################################
Solver 1
  Equation = "SSA"
  Variable = -dofs 2 "SSAVelocity"

  Procedure = "ElmerIceSolvers" "AdjointSSA_SSASolver"

!! NUMERICAL INFORMATION
  !Linear System Solver = Direct
  !Linear System Direct Method = mumps
  !mumps percentage increase working space = integer 40
   Linear System Solver = Iterative
   Linear System Max Iterations = 500
   Linear System Iterative Method = GCR
   Linear System GCR Restart =  250
   Linear System Preconditioning = ILU2
   Linear System Abort Not Converged = False
   Linear System Residual Output = 500
   Linear System Convergence Tolerance = 1.0e-12

   Nonlinear System Max Iterations = 30
   Nonlinear System Convergence Tolerance  = 1.0e-10
   Nonlinear System Newton After Iterations = 20
   Nonlinear System Newton After Tolerance = 1.0e-05
   Nonlinear System Relaxation Factor = 1.00

  Steady State Convergence Tolerance = Real 1.0e-12

!!!!!
  Sub-Element GL parameterization = logical True
  GL integration points number = Integer 20
!!!!!
!! Variables required for the inverse method
  Exported Variable 1 = -global CostValue
  Exported Variable 2 = -nooutput alpha
  Exported Variable 3 = -nooutput DJDalpha
  Exported Variable 4 = -nooutput "Velocityb"
  Exported Variable 4 DOFs = 2
End
!#######################################################
!!! Compute Cost function
!! Here the cost is the discrete sum_1^Ndata 1/2 ||u-u^obs|| evaluated at the data location (which may not correspond to mesh nodes)
Solver 2
  Equation = "Cost"
  procedure = "ElmerIceSolvers" "Adjoint_CostDiscSolver"

   Cost Variable Name = String "CostValue"  ! Name of Cost Variable
   Lambda = Real 1.0
 ! save the cost as a function of iterations (iterations,Cost,rms=sqrt(2*Cost/Ndata)
   Cost Filename = File "Cost_$name$.dat"

   Observed Variable Name = String "SSAVelocity"
   Observed Variable dimension = Integer 2

 ! ASCII File with data: x,y,u,v
   Observation File Name = File "$OBSERVATION_FILE$"
end
!#######################################################
!!! Compute Cost function Jdiv (mismatch between model and observed flux divergence)
!!  Jdiv=int_ 0.5 * (dhdt_obs + div(uH)-MB)^2
Solver 3
  Equation = "Cost_DHDT"
   procedure = "ElmerIceSolvers" "AdjointSSA_CostFluxDivSolver"

   Reset Cost Value = Logical False

   Cost Variable Name = String "CostValue"  ! Name of Cost Variable

   Lambda= Real $LambdaDiv

   Compute DJDZb = Logical False
   Compute DJDZs = Logical False

 ! save the cost as a function of iterations (iterations,Cost,rms=sqrt(2*Cost/area))
   Cost Filename = File "Cost_dHdt_$name$.dat"
end
!#######################################################
!!!!  Adjoint Solution
Solver 4
  Equation = "Adjoint"
  Variable = -nooutput Adjoint
  Variable Dofs = 2

  procedure = "ElmerIceSolvers" "Adjoint_LinearSolver"

!Name of the flow solution solver
   Direct Solver Equation Name = string "SSA"

!  Linear System Solver = Direct
!  Linear System Direct Method = mumps
!  mumps percentage increase working space = integer 40

  Linear System Solver = Iterative
  Linear System Max Iterations = 500
  Linear System Iterative Method = GCR
  Linear System GCR Restart =  250
  Linear System Preconditioning = ILU2
  Linear System Abort Not Converged = False
  Linear System Residual Output = 500
  Linear System Convergence Tolerance = 1.0e-12

End
!#######################################################
!!!!!  Compute Derivative of Cost function / Beta
Solver 5
  Equation = "DJDBeta"
   procedure = "ElmerIceSolvers" "AdjointSSA_GradientSolver"

    Flow Solution Name = String "SSAVelocity"
    Adjoint Solution Name = String "Adjoint"
    ! Derivative with respect to the Friction parameter
    ! here will be with respect to alpha (see Material)
    Compute DJDBeta = Logical True
    DJDBeta Name = String "DJDalpha"
    Reset DJDBeta = Logical True
end
!#######################################################
!!!!!  Compute Regularisation term
!   Regularisation by default is: Lambda * int_{Pb dimension} 0.5 * (d(var)/dx)**2 
!     OUTPUT are : J and DJDvar
Solver 6
  Equation = "CostReg"
   procedure = "ElmerIceSolvers" "Adjoint_CostRegSolver"

    Cost Filename=File "CostReg_$name$.dat"
    Optimized Variable Name= String "alpha"
    Gradient Variable Name= String "DJDalpha"
    Cost Variable Name= String "CostValue"
    Lambda= Real $LambdaReg
    Reset Cost Value= Logical False  !=> DJDapha already initialized in solver DJDBeta; switch off initialisation to 0 at the beginning of this solver
    A priori Regularisation= Logical False

end
!#######################################################
!!!!! Optimization procedure :
Solver 7
  Equation = "Optimize_m1qn3"
  procedure = "ElmerIceSolvers" "Optimize_m1qn3Parallel"

  Cost Variable Name = String "CostValue"
  Optimized Variable Name = String "alpha"
  Gradient Variable Name = String "DJDalpha"
  gradient Norm File = File "GradientNormAdjoint_$name$.dat"

  !!
  Mesh Independent = Logical FALSE

 ! M1QN3 Parameters
  M1QN3 dxmin = Real 1.0e-10
  M1QN3 epsg = Real  1.e-6
  M1QN3 niter = Integer $niter
  M1QN3 nsim = Integer $niter
  M1QN3 impres = Integer 5
  M1QN3 DIS Mode = Logical true
  M1QN3 df1 = Real 0.5
  M1QN3 normtype = String "dfn"
  M1QN3 OutputFile = File  "M1QN3_$name$.out"
  M1QN3 ndz = Integer 20

end
!#######################################################
Solver 8
  Equation = "UpdateExport2"
   Variable = -nooutput "dumy2"
    Procedure = File "ElmerIceSolvers" "UpdateExport"
    Optimize Bandwidth = logical false
! recompute the slip coef. = 10^alpha (for post-processing or restart)
  Exported Variable 1 =  slc
End
!#######################################################
!#######################################################
Equation 1
  Active Solvers(8) = 1 2 3 4 5 6 7 8
End
!#######################################################
!#######################################################
Boundary Condition 1
  Target Boundaries = 1 
  calving front = logical TRUE
End