Galerkin FEM for elliptic PDEs
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

sphere.geo 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 08/08/2014 12:19:20 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@xri-geo.com
  14. * @copyright Copyright (c) 2014, XRI Geophysics, LLC
  15. * @copyright Copyright (c) 2014, Trevor Irons
  16. */
  17. D0 = 10; // Top of magnet
  18. D1 = 11; // Bottom of magnet
  19. radius = 2.25; // Radius of the damn thing
  20. lc = radius*10; // 0.25; // Target element size
  21. // Total Solution Space
  22. Box = 10*radius; // The down side of potential
  23. X0 = -Box;
  24. X1 = Box;
  25. Y0 = -Box;
  26. Y1 = Box;
  27. Z0 = -Box;
  28. Z1 = Box;
  29. cellSize=lc; //300;
  30. dd = 0 ; // 1e-5; //cellSize; // .01;
  31. pio2=Pi/2;
  32. // Calculate offset effect
  33. theta = Asin(dd/radius);
  34. rr = radius * Cos(theta);
  35. ///////////////////////////////////
  36. // Positive half sphere
  37. // create inner 1/8 shell
  38. p0 = newp;
  39. Point(p0) = { 0, 0, 0, cellSize}; // origin
  40. Point(p0+1) = { -rr, 0, dd, cellSize};
  41. Point(p0+2) = { 0, rr, dd, cellSize};
  42. Point(p0+3) = { 0, 0, radius, cellSize};
  43. Point(p0+4) = { 0, 0, dd, cellSize}; // origin
  44. c0 = newc;
  45. Circle(c0 ) = {p0+1, p0+4, p0+2}; // Tricky, This one needs to be offset!
  46. Circle(c0+1) = {p0+3, p0, p0+1};
  47. Circle(c0+2) = {p0+3, p0, p0+2};
  48. Line Loop(10) = {c0, -(c0+2), c0+1} ;
  49. Ruled Surface (60) = {10};
  50. ////////////////////////////////////////////////////////////
  51. // Negative half sphere
  52. p = newp;
  53. Point( p) = { 0, 0, 0, cellSize};
  54. Point(p+1) = { -rr, 0, -dd, cellSize};
  55. Point(p+2) = { 0, rr, -dd, cellSize};
  56. Point(p+3) = { 0, 0, -radius, cellSize};
  57. Point(p+4) = { 0, 0, -dd, cellSize};
  58. cc = newc;
  59. Circle(cc ) = {p+1, p+4, p+2};
  60. Circle(cc+1) = {p+3, p, p+1};
  61. Circle(cc+2) = {p+3, p, p+2};
  62. Circle(cc+3) = {p+3, p, p+2};
  63. Circle(cc+4) = {p+3, p, p+2};
  64. Circle(cc+5) = {p+3, p, p+2};
  65. ccl = newl;
  66. Line(ccl) = { p0+3, p+3 };
  67. Line Loop(11) = {cc, -(cc+2), cc+1} ;
  68. Ruled Surface (61) = {11};
  69. // create remaining 7/8 inner shells
  70. t1[] = Rotate {{0,0,1},{0,0,0},pio2 } {Duplicata{Surface{60};}};
  71. t2[] = Rotate {{0,0,1},{0,0,0},pio2*2} {Duplicata{Surface{60};}};
  72. t3[] = Rotate {{0,0,1},{0,0,0},pio2*3} {Duplicata{Surface{60};}};
  73. //
  74. t4[] = Rotate {{0,0,1},{0,0,0},pio2 } {Duplicata{Surface{61};}};
  75. t5[] = Rotate {{0,0,1},{0,0,0},pio2*2} {Duplicata{Surface{61};}};
  76. t6[] = Rotate {{0,0,1},{0,0,0},pio2*3} {Duplicata{Surface{61};}};
  77. /////////////////////////////////////
  78. // Large Bounding box
  79. pp = newp;
  80. Point(pp) = {X0, Y0, Z0, lc};
  81. Point(pp+1) = {X1, Y0, Z0, lc};
  82. Point(pp+2) = {X1, Y1, Z0, lc};
  83. Point(pp+3) = {X0, Y1, Z0, lc};
  84. lv = newl;
  85. Line(lv) = {pp,pp+1};
  86. Line(lv+1) = {pp+1,pp+2};
  87. Line(lv+2) = {pp+2,pp+3};
  88. Line(lv+3) = {pp+3,pp};
  89. Line Loop(lv+4) = {lv, lv+1, lv+2, lv+3};
  90. // Hard coded doom
  91. Plane Surface(125) = {lv+4};
  92. //v = newv;
  93. v[] = Extrude {0, 0, Z1-Z0} { Surface{125}; };
  94. /* This is GOOD */
  95. Surface{60} In Volume{v[1]};
  96. Surface{t1[0]} In Volume{v[1]};
  97. Surface{t2[0]} In Volume{v[1]};
  98. Surface{t3[0]} In Volume{v[1]};
  99. Surface{61} In Volume{v[1]};
  100. Surface{t4[0]} In Volume{v[1]};
  101. Surface{t5[0]} In Volume{v[1]};
  102. Surface{t6[0]} In Volume{v[1]};
  103. ///////////////////////////////////////////////
  104. // Attractor Field
  105. Field[1] = Attractor;
  106. Field[1].NodesList = {p}; //0, p0+1, p0+2, p0+3, p0+4, p, p+1, p+2, p+3, p+4};
  107. Field[2] = MathEval;
  108. //Field[2].F = Sprintf("(.25 - F1)^2 + %g", cellSize ); // WORKS
  109. Field[2].F = Sprintf("(%g - F1)^2 + %g", radius, cellSize/2. );
  110. Background Field = 2;
  111. // Don't extend the elements sizes from the boundary inside the domain
  112. //Mesh.CharacteristicLengthExtendFromBoundary = 0;
  113. Physical Volume(1) = {v[1]};
  114. // To create the mesh run
  115. // gmsh sphere.gmsh -2 -v 0 -format msh -o sphere.msh
  116. //gmsh -3 -format msh1 -o outfile.msh sphere.geo