
// Dimensions
MIN_X = -2000.0;
MAX_X = 5000.0;
MIN_Y = 0.0;
MAX_Y = 2000.0;
MIN_Z = -4000.0;
MAX_Z = 2000.0;
// Mesh size
dg = 200.; //70
// Source position
SRC1_X = 857.;
SRC1_Y = 1000.;
SRC1_Z = -10.;

// #################################################################
// #                    Define main points                         #
// #################################################################
Point (1) = {MIN_X, MIN_Y, MIN_Z, dg};
Point (2) = {MIN_X, MAX_Y, MIN_Z, dg};
Point (3) = {MAX_X, MAX_Y, MIN_Z, dg};
Point (4) = {MAX_X, MIN_Y, MIN_Z, dg};
Point (5) = {MIN_X, MIN_Y, 0., dg};
Point (6) = {MIN_X, MAX_Y, 0., dg};
Point (7) = {MAX_X, MAX_Y, 0., dg};
Point (8) = {MAX_X, MIN_Y, 0., dg};
Point (9) = {MIN_X, MIN_Y, MAX_Z, dg*4};
Point (10) = {MIN_X, MAX_Y, MAX_Z, dg*4};
Point (11) = {MAX_X, MAX_Y, MAX_Z, dg*4};
Point (12) = {MAX_X, MIN_Y, MAX_Z, dg*4};

// #################################################################
// #                Layer 1: Sediments (1.0 S/m)                   #
// #################################################################
Line (1) = {1, 2};
Line (2) = {2, 3};
Line (3) = {3, 4};
Line (4) = {4, 1};
Line (5) = {1, 5};
Line (6) = {2, 6};
Line (7) = {3, 7};
Line (8) = {4, 8};
Line (9) = {5, 6};
Line (10) = {6, 7};
Line (11) = {7, 8};
Line (12) = {8, 5};
Line (13) = {5, 9};
Line (14) = {6, 10};
Line (15) = {7, 11};
Line (16) = {8, 12};
Line (17) = {9, 10};
Line (18) = {10, 11};
Line (19) = {11, 12};
Line (20) = {12, 9};

Line Loop (1) = {1, 2, 3, 4};
Plane Surface (1) = {1};

Line Loop (2) = {4, 5, -12, -8};
Plane Surface (2) = {2};

Line Loop (3) = {1, 6, -9, -5};
Plane Surface (3) = {3};

Line Loop (4) = {2, 7, -10, -6};
Plane Surface (4) = {4};

Line Loop (5) = {3, 8, -11, -7};
Plane Surface (5) = {5};

Line Loop (6) = {9, 10, 11, 12};
Plane Surface (6) = {6};

// Define Volume
Surface Loop (1) = {1, 2, 3, 4, 5, 6};
Volume (1) = {1};
Physical Volume ("Sediments", 1) = {1};

Line Loop (7) = {9, 14, -17, -13};
Plane Surface (7) = {7};

Line Loop (8) = {10, 15, -18, -14};
Plane Surface (8) = {8};

Line Loop (9) = {11, 16, -19, -15};
Plane Surface (9) = {9};

Line Loop (10) = {12, 13, -20, -16};
Plane Surface (10) = {10};

Line Loop (11) = {17, 18, 19, 20};
Plane Surface (11) = {11};

// Define Volume
Surface Loop (2) = {6, 7, 8, 9, 10, 11};
Volume (2) = {2};
Physical Volume ("Air", 2) = {2};

// #################################################################
// #                Mesh refinement                                #
// #################################################################
// Source position
Point (101) = {SRC1_X, SRC1_Y, SRC1_Z};
// Receiver positions
Point (102) = {155.0,  1000., -10.};
Point (103) = {253.0,  1000., -10.};
Point (104) = {400.0,  1000., -10.};
Point (105) = {512.5,  1000., -10.};
Point (106) = {611.5,  1000., -10.};
Point (107) = {709.5,  1000., -10.};
Point (108) = {809.5,  1000., -10.}; //
Point (109) = {909.5,  1000., -10.}; //
Point (110) = {1000.5,  1000., -10.}; //
Point (111) = {1083.,  1000., -10.};
Point (112) = {1200.5,  1000., -10.}; //
Point (113) = {1300.5,  1000., -10.}; //
Point (114) = {1400.5,  1000., -10.}; //
Point (115) = {1500.5,  1000., -10.}; //
Point (116) = {1600.5,  1000., -10.}; //
Point (117) = {1700.5,  1000., -10.}; //
Point (118) = {1800.5,  1000., -10.}; //
Point (119) = {1900.5,  1000., -10.}; //
Point (120) = {2000.5,  1000., -10.}; //
Point (121) = {2100.5,  1000., -10.}; //
Point (122) = {2200.5,  1000., -10.}; //
Point (123) = {2300.5,  1000., -10.}; //
Point (124) = {2400.5,  1000., -10.}; //
Point (125) = {2500.5,  1000., -10.}; //
Point (126) = {2600.5,  1000., -10.}; //
Point (127) = {2700.5,  1000., -10.}; //
Point (128) = {2800.5,  1000., -10.}; //
Point (129) = {2900.5,  1000., -10.}; //
Point (130) = {3000.,  1000., -10.};
Point (131) = {3100.5,  1000., -10.}; //
Point (132) = {3200.5,  1000., -10.}; //
Point (133) = {3300.5,  1000., -10.}; //

// Refinement
Field[1] = Attractor;
Field[1].NodesList = {101:105};
Field[2] = Threshold;
Field[2].IField = 1;
Field[2].LcMin = 10;
Field[2].LcMax = 100;
Field[2].DistMin = 100;
Field[2].DistMax = 300;
Background Field = 2;

// Mesh format supported by PETGEM
Mesh.MshFileVersion = 2.2;
