From 09afaac43d944cddd0bab58e213c79dd2bd65897 Mon Sep 17 00:00:00 2001
From: Guillaume Demesy <guillaume.demesy@fresnel.fr>
Date: Thu, 21 Nov 2019 12:05:26 +0100
Subject: [PATCH] new meshing sequence

---
 DiffractionGratings/grating3D.geo | 49 ++++++++++++++-----------------
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/DiffractionGratings/grating3D.geo b/DiffractionGratings/grating3D.geo
index fc23f83..28ab19d 100644
--- a/DiffractionGratings/grating3D.geo
+++ b/DiffractionGratings/grating3D.geo
@@ -99,22 +99,6 @@ If (tag_geom==6)
   Volume(10) = {2};
 EndIf
 
-L1_n     = Sqrt(Abs(eps_re_L_1));
-L2_n     = Sqrt(Abs(eps_re_L_2));
-L3_n     = Sqrt(Abs(eps_re_L_3));
-L4_n     = Sqrt(Abs(eps_re_L_4));
-L5_n     = Sqrt(Abs(eps_re_L_5));
-L6_n     = Sqrt(Abs(eps_re_L_6));
-Scat_n   = 2 ;
-
-PML_lc     = lambda_m/(paramaille*.5);
-L1_lc      = lambda_m/(paramaille*L1_n);
-L2_lc      = lambda_m/(paramaille*L2_n);
-L3_lc      = lambda_m/(paramaille*L3_n);
-L4_lc      = lambda_m/(paramaille*L4_n);
-L5_lc      = lambda_m/(paramaille*L5_n);
-L6_lc      = lambda_m/(paramaille*L6_n);
-
 Box(1) = {-period_x/2,-period_y/2, PML_bot_hh,period_x,period_y, PML_bot  };
 Box(2) = {-period_x/2,-period_y/2,     hh_L_6,period_x,period_y, thick_L_6};
 Box(3) = {-period_x/2,-period_y/2,     hh_L_5,period_x,period_y, thick_L_5};
@@ -205,18 +189,29 @@ pts_LAYER_L1() = PointsOf{ Physical Volume{7}; };
 pts_PMLTOP()   = PointsOf{ Physical Volume{8}; };
 pts_ROD()      = PointsOf{ Physical Volume{9}; };
 
-// Characteristic Length{:}              = PML_lc/5;
-Characteristic Length{:}              = PML_lc;
-Characteristic Length{pts_LAYER_L1()} = L1_lc/refine_mesh_L1;
-Characteristic Length{pts_LAYER_L2()} = L2_lc/refine_mesh_L2;
-Characteristic Length{pts_LAYER_L6()} = L6_lc/refine_mesh_L6;
-Characteristic Length{pts_LAYER_L5()} = L5_lc/refine_mesh_L5;
-Characteristic Length{pts_LAYER_L4()} = L4_lc/refine_mesh_L4;
-Characteristic Length{pts_LAYER_L3()} = L3_lc/refine_mesh_L3;
-Characteristic Length{pts_ROD()}      = scat_lc;
-If (tag_geom==3) // Split torus weird otherwise
+lc_PML = lambda_m/(paramaille*.5);
+list_lc(0) = lc_PML;
+For k In {1:6}
+  n_L~{k}  = Sqrt(Abs(eps_re_L~{k}));
+  lc_L~{k} = lambda_m/(paramaille*n_L~{k});
+  list_lc(7-k) = lc_L~{k};
+EndFor
+list_lc(7) = lc_PML;
+list_lc(8) = lc_scat;
+
+// This helps meshing: The default behavior of the PointsOf techinque
+// overides points belonging to several domains
+meshing_sequence() = {1,8,2,3,5,6,7,4,9};
+
+// Start with coarsest
+Characteristic Length{:} = lc_PML;
+For k In {0:8}
+  which_dom = meshing_sequence(k);
+  Characteristic Length{PointsOf{Physical Volume{which_dom};}} = list_lc(which_dom-1);
+EndFor
+  If (tag_geom==3) // Split torus weird otherwise
   Mesh.Algorithm = 6;
 EndIf
-// Mesh.Optimimze=1;
+// Mesh.Optimimze3D=1;
 // Mesh.SurfaceEdges = 0;
 Mesh.VolumeEdges = 0;
-- 
GitLab