Galerkin FEM for elliptic PDEs
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

sphere.geo 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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; // 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. /////////////////////////////////////
  33. // Large Bounding box
  34. pp = newp;
  35. Point(pp) = {X0, Y0, Z0, lc};
  36. Point(pp+1) = {X1, Y0, Z0, lc};
  37. Point(pp+2) = {X1, Y1, Z0, lc};
  38. Point(pp+3) = {X0, Y1, Z0, lc};
  39. lv = newl;
  40. Line(lv) = {pp,pp+1};
  41. Line(lv+1) = {pp+1,pp+2};
  42. Line(lv+2) = {pp+2,pp+3};
  43. Line(lv+3) = {pp+3,pp};
  44. Line Loop(lv+4) = {lv, lv+1, lv+2, lv+3};
  45. // Hard coded doom
  46. Plane Surface(125) = {lv+4};
  47. //v = newv;
  48. v[] = Extrude {0, 0, Z1-Z0} { Surface{125}; };
  49. // Calculate offset effect
  50. theta = Asin(dd/radius);
  51. rr = radius * Cos(theta);
  52. ///////////////////////////////////
  53. // Positive half sphere
  54. // create inner 1/8 shell
  55. p0 = newp;
  56. Point(p0) = { 0, 0, 0, cellSize}; // origin
  57. Point(p0+1) = { -rr, 0, dd, cellSize};
  58. Point(p0+2) = { 0, rr, dd, cellSize};
  59. Point(p0+3) = { 0, 0, radius, cellSize};
  60. Point(p0+4) = { 0, 0, dd, cellSize}; // origin
  61. c0 = newc;
  62. Circle(c0 ) = {p0+1, p0+4, p0+2}; // Tricky, This one needs to be offset!
  63. Circle(c0+1) = {p0+3, p0, p0+1};
  64. Circle(c0+2) = {p0+3, p0, p0+2};
  65. Line Loop(10) = {c0, -(c0+2), c0+1} ;
  66. Ruled Surface (60) = {10};
  67. ////////////////////////////////////////////////////////////
  68. // Negative half sphere
  69. p = newp;
  70. Point( p) = { 0, 0, 0, cellSize};
  71. Point(p+1) = { -rr, 0, -dd, cellSize};
  72. Point(p+2) = { 0, rr, -dd, cellSize};
  73. Point(p+3) = { 0, 0, -radius, cellSize};
  74. Point(p+4) = { 0, 0, -dd, cellSize};
  75. cc = newc;
  76. Circle(cc ) = {p+1, p+4, p+2};
  77. Circle(cc+1) = {p+3, p, p+1};
  78. Circle(cc+2) = {p+3, p, p+2};
  79. Circle(cc+3) = {p+3, p, p+2};
  80. Circle(cc+4) = {p+3, p, p+2};
  81. Circle(cc+5) = {p+3, p, p+2};
  82. ccl = newl;
  83. Line(ccl) = { p0+3, p+3 };
  84. Line Loop(11) = {cc, -(cc+2), cc+1} ;
  85. Ruled Surface (61) = {11};
  86. // create remaining 7/8 inner shells
  87. t1[] = Rotate {{0,0,1},{0,0,0},pio2 } {Duplicata{Surface{60};}};
  88. t2[] = Rotate {{0,0,1},{0,0,0},pio2*2} {Duplicata{Surface{60};}};
  89. t3[] = Rotate {{0,0,1},{0,0,0},pio2*3} {Duplicata{Surface{60};}};
  90. //
  91. t4[] = Rotate {{0,0,1},{0,0,0},pio2 } {Duplicata{Surface{61};}};
  92. t5[] = Rotate {{0,0,1},{0,0,0},pio2*2} {Duplicata{Surface{61};}};
  93. t6[] = Rotate {{0,0,1},{0,0,0},pio2*3} {Duplicata{Surface{61};}};
  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("(2.25 - F1)^2 + %g", cellSize*10 ); // WORKS
  109. //Field[2].F = Sprintf("(%g - F1)^2 + %g", radius, 2*cellSize );
  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