1!------------------------------------------------------------------
2! Anisotropic mesh adaptation
3!  Example given in sections 2.2 and 2.3 of:
4!    Alauzet, F., Frey, P., 2003.
5!      Estimateur d’erreur géométrique et métriques anisotropes pour l’adaptation de maillage: Partie II: exemples d’applications.
6!       (Sorry - IN FRENCH!)
7!
8!  Example 1: 1-Variable optimisation
9!-------------------------------------------------------------------
10
11Header
12  Mesh DB "." "square"
13End
14
15$ function f1(c) {x=c(0);y=c(1); _f1 = sin(5*(y*y-y+1.0)*(x-0.2)^3.0) }
16
17!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18Simulation
19  Coordinate System  = Cartesian 2D
20  Simulation Type = Steady
21
22  Steady State Min Iterations = 2
23  Steady State Max Iterations = 2
24
25  max output level = 3
26
27  Post File = "Case_Aniso.vtu"
28End
29
30!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31Body 1
32  Equation = 1
33  Body Force = 1
34End
35
36!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
37Body Force 1
38  f1 = Variable Coordinate
39     REAL MATC "f1(tx)"
40
41  M1 Hmin = Real 1.0e-3
42  M1 Hmax = Real 1.0
43  M1 err =  Real 0.0033
44
45End
46!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
47! update f1  at the mesh nodes
48Solver 1
49   Equation = "Initialise fn"
50   Variable = -nooutput dumy
51
52   Procedure = "ElmerIceSolvers" "UpdateExport"
53
54   Optimize Bandwidth = False
55
56   Exported Variable 1 = f1
57End
58
59! Compute the metric associated with f1
60!  1- compute projected gradient of f1
61Solver 2
62  Equation = "Nodal Gradient 1"
63  Variable = -dofs 2 "Gradient1"
64  Procedure = "ElmerIce_MeshAdapt2D" "Compute2DNodalGradient"
65
66  Optimize Bandwidth = False
67
68  Variable Name = string "f1"
69  FE consistent average = Logical True
70End
71! 2- compute:
72!    - the hessian matrix by solving a diffusion equation:
73!      \int_Omega Hij+ k.A nabla(Hij) = int_Omega 0.5(dqi/dxj+dqj/dxi)
74!          Buscaglia, G.C., Dari, E.A., 1997.
75!            Anisotropic mesh optimization and its application in adaptivity. International Journal for Numerical Methods in Engineering 40, 4119–4136.
76!   - the metric tensor
77Solver 3
78   Equation = "Metric1"
79   Variable = -nooutput dumy
80
81   Procedure = "ElmerIce_MeshAdapt2D" "MMG2D_MetricAniso"
82
83   Metric Variable Name = String "M1"
84
85   Hessian Variable Name = String "ddx1"
86   Gradient Name = String "Gradient1"
87   Diffusivity = Real 0.5
88
89   Linear System Solver = Direct
90   Linear System Direct Method = umfpack
91
92  Exported Variable 1 = -dofs 3 "M1"
93  Exported Variable 2 = -dofs 3 "ddx1"
94End
95
96!! Anisotropic mesh adaptation using the MMG library
97Solver 4
98!! mandatory else Model % Mesh % Changed reset to .FALSE. in coupled simulations
99  Exec Solver = after timestep
100
101  Equation = "MMG"
102  Variable = -nooutput dumy
103    Procedure = "ElmerIce_MeshAdapt2D" "MMG2DSolver"
104
105  Optimize Bandwidth = False
106
107  Output file name = "square_aniso"
108  Metric Variable Name = String "M1"  !optimise using M1 (example sec 2.2)
109
110  hausd = Real 1000.0
111  hgrad = Real 1.3
112
113  verbosity = Integer 10
114
115End
116
117Solver 5
118  Exec Solver = after timestep
119  Equation = SaveScalars
120  Procedure =  "SaveData" "SaveScalars"
121  Filename = f.dat
122  Show Norm Index = Integer 1
123  Operator 1 = nodes
124End
125
126!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
127Equation 1
128  Active Solvers(5) = 1 2 3 4 5
129End
130
131!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
132Boundary Condition 1
133  Target Boundaries = 1
134End
135Boundary Condition 2
136  Target Boundaries = 2
137End
138Boundary Condition 3
139  Target Boundaries = 3
140End
141Boundary Condition 4
142  Target Boundaries = 4
143End
144
145
146Solver 5 :: Reference Norm = Real 2055
147Solver 5 :: Reference Norm Tolerance = Real 1E-01
148