/* This file is part of Lemma, a geophysical modelling and inversion API. * More information is available at http://lemmasoftware.org */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ radius = 2.25; // Radius of the damn thing lc = 15*radius; // 0.25; // Target element size // Total Solution Space Box = 100*radius; // The down side of potential X0 = -Box; X1 = Box; Y0 = -Box; Y1 = Box; Z0 = -Box; Z1 = Box; cellSize=radius/10; ///10; dd = 0 ; // 1e-5; //cellSize; // .01; pio2=Pi/2; ///////////////////////////////////// // Large Bounding box pp = newp; Point(pp) = {X0, Y0, Z0, lc}; Point(pp+1) = {X1, Y0, Z0, lc}; Point(pp+2) = {X1, Y1, Z0, lc}; Point(pp+3) = {X0, Y1, Z0, lc}; lv = newl; Line(lv) = {pp,pp+1}; Line(lv+1) = {pp+1,pp+2}; Line(lv+2) = {pp+2,pp+3}; Line(lv+3) = {pp+3,pp}; Line Loop(lv+4) = {lv, lv+1, lv+2, lv+3}; // Hard coded doom Plane Surface(125) = {lv+4}; //v = newv; v[] = Extrude {0, 0, Z1-Z0} { Surface{125}; }; // Calculate offset effect theta = Asin(dd/radius); rr = radius * Cos(theta); /////////////////////////////////// // Positive half sphere // create inner 1/8 shell p0 = newp; Point(p0) = { 0, 0, 0, cellSize}; // origin Point(p0+1) = { -rr, 0, dd, cellSize}; Point(p0+2) = { 0, rr, dd, cellSize}; Point(p0+3) = { 0, 0, radius, cellSize}; Point(p0+4) = { 0, 0, dd, cellSize}; // origin c0 = newc; Circle(c0 ) = {p0+1, p0+4, p0+2}; // Tricky, This one needs to be offset! Circle(c0+1) = {p0+3, p0, p0+1}; Circle(c0+2) = {p0+3, p0, p0+2}; Line Loop(10) = {c0, -(c0+2), c0+1} ; Ruled Surface (60) = {10}; //////////////////////////////////////////////////////////// // Negative half sphere p = newp; Point( p) = { 0, 0, 0, cellSize}; Point(p+1) = { -rr, 0, -dd, cellSize}; Point(p+2) = { 0, rr, -dd, cellSize}; Point(p+3) = { 0, 0, -radius, cellSize}; Point(p+4) = { 0, 0, -dd, cellSize}; cc = newc; Circle(cc ) = {p+1, p+4, p+2}; Circle(cc+1) = {p+3, p, p+1}; Circle(cc+2) = {p+3, p, p+2}; Circle(cc+3) = {p+3, p, p+2}; Circle(cc+4) = {p+3, p, p+2}; Circle(cc+5) = {p+3, p, p+2}; ccl = newl; Line(ccl) = { p0+3, p+3 }; Line Loop(11) = {cc, -(cc+2), cc+1} ; Ruled Surface (61) = {11}; // create remaining 7/8 inner shells t1[] = Rotate {{0,0,1},{0,0,0},pio2 } {Duplicata{Surface{60};}}; t2[] = Rotate {{0,0,1},{0,0,0},pio2*2} {Duplicata{Surface{60};}}; t3[] = Rotate {{0,0,1},{0,0,0},pio2*3} {Duplicata{Surface{60};}}; // t4[] = Rotate {{0,0,1},{0,0,0},pio2 } {Duplicata{Surface{61};}}; t5[] = Rotate {{0,0,1},{0,0,0},pio2*2} {Duplicata{Surface{61};}}; t6[] = Rotate {{0,0,1},{0,0,0},pio2*3} {Duplicata{Surface{61};}}; /* This is GOOD */ Surface{60} In Volume{v[1]}; Surface{t1[0]} In Volume{v[1]}; Surface{t2[0]} In Volume{v[1]}; Surface{t3[0]} In Volume{v[1]}; Surface{61} In Volume{v[1]}; Surface{t4[0]} In Volume{v[1]}; Surface{t5[0]} In Volume{v[1]}; Surface{t6[0]} In Volume{v[1]}; /////////////////////////////////////////////// // Attractor Field // Field[1] = Attractor; // Field[1].NodesList = {p}; //0, p0+1, p0+2, p0+3, p0+4, p, p+1, p+2, p+3, p+4}; // // Field[2] = MathEval; // Field[2].F = Sprintf("(2.25 - F1)^1.01 + %g", radius/10 ); // WORKS // // Field[3] = MathEval; // Field[3].F = Sprintf("(12.25 - F1)^1.01 + %g", radius/5 ); // WORKS // // Field[4] = MathEval; // Field[4].F = Sprintf("(22.25 - F1)^1.01 + %g", radius ); // WORKS // // Field[5] = MathEval; // Field[5].F = Sprintf("(42.25 - F1)^1.01 + %g", radius*5 ); // WORKS // // //Field[2].F = Sprintf("(%g - F1)^2 + %g", radius, 2*cellSize ); // //Background Field = 2; // // // Finally, let's use the minimum of all the fields as the background mesh field // Field[7] = Min; // Field[7].FieldsList = {2, 3, 4, 5}; // Background Field = 7; // Don't extend the elements sizes from the boundary inside the domain //Mesh.CharacteristicLengthExtendFromBoundary = 0; Physical Volume(1) = {v[1]}; // To create the mesh run // gmsh sphere.gmsh -2 -v 0 -format msh -o sphere.msh //gmsh -3 -format msh1 -o outfile.msh sphere.geo