Skip to content
Snippets Groups Projects
Commit 2e176398 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

No commit message

No commit message
parent bdcdc39c
No related branches found
No related tags found
No related merge requests found
File deleted
from gmshpy import *
GmshSetOption('General', 'Verbosity', 99.0)
GmshSetOption('Mesh', 'SaveAll', 1.0)
GmshSetOption('Mesh', 'Algorithm', 1.0)
g = GModel()
g.setFactory('Gmsh')
g.load("aneurysm.stl");
g.createTopologyFromMesh();
face = g.getFaceByTag(1);
newent = g.extrudeBoundaryLayer(face, 4, 0.5, 0, -1)
newent2 = g.extrudeBoundaryLayer(face, 4, -0.5, 1, -1)
print "*** face = %d " % face.tag()
print "*** new face = %d newface2 = %d " % (newent[0].tag(), newent2[0].tag())
g.mesh(2)
g.save("aneurysmBL.msh")
This diff is collapsed.
SetFactory("OpenCASCADE");
Mesh.Algorithm = 6;
Mesh.CharacteristicLengthMin = 1;
Mesh.CharacteristicLengthMax = 1;
Macro dendrite
For i In {1:5}
z = -2+7*i;
r = 1 + 0.6*Sin(2*Pi*i/5.);
Point(nump+1) = {x,0,z};
Point(nump+2) = {x+r,0,z};
Point(nump+3) = {x,r,z};
Point(nump+4) = {x-r,0,z};
Point(nump+5) = {x,-r,z};
Circle(numc+1) = {nump+2,nump+1,nump+3};
Circle(numc+2) = {nump+3,nump+1,nump+4};
Circle(numc+3) = {nump+4,nump+1,nump+5};
Circle(numc+4) = {nump+5,nump+1,nump+2};
edges~{i}() = {numc+1:numc+4};
nump += 5;
numc += 4;
EndFor
numr += 1;
ThruSections(numr) = {edges~{1}(),edges~{2}(),edges~{3}(),edges~{4}(),edges~{5}()};
reg() += numr;
Return
Sphere(1) = {0, 0, 0, 8};
reg() = {};
nump = 0; numc = 0; numr = 2;
For x In{-4:4:4}
Call dendrite;
EndFor
DefineConstant[
op = {0, Choices{0="None", 1="Union", 2="Intersection", 3="Subtraction"},
Name "Boolean operation" }
];
// boolean operations can explicitly create an entity with the form
// "op(tag)={}{};", or let Gmsh decide with the form "op{}{}". The first form
// can only be used if the result of the boolean operation is a single
// shape. Only the second form returns the list of created entities.
If(op == 1)
BooleanUnion(100) = { Volume{1}; Delete; }{ Volume{reg(0)}; Delete; };
BooleanUnion(101) = { Volume{100}; Delete; }{ Volume{reg(1)}; Delete; };
BooleanUnion(102) = { Volume{101}; Delete; }{ Volume{reg(2)}; Delete; };
ElseIf(op == 2)
BooleanIntersection(100) = { Volume{1}; }{ Volume{reg(0)}; Delete; };
BooleanIntersection(101) = { Volume{1}; }{ Volume{reg(1)}; Delete; };
BooleanIntersection(102) = { Volume{1}; Delete; }{ Volume{reg(2)}; Delete; };
ElseIf(op == 3)
BooleanSubtraction(100) = { Volume{1}; Delete; }{ Volume{reg(0)}; Delete; };
BooleanSubtraction(101) = { Volume{100}; Delete; }{ Volume{reg(1)}; Delete; };
BooleanSubtraction(102) = { Volume{101}; Delete; }{ Volume{reg(2)}; Delete; };
EndIf
from gmshpy import *
GmshSetOption('Mesh', 'CharacteristicLengthFactor', 0.9)
R = 0.3;
myModel = GModel();
myModel.addSphere(0.5,0.5,0.5,R);
myModel.setAsCurrent();
myModel.mesh(2);
myModel.save("sphere.stl");
from gmshpy import *
lc = 0.5
GmshSetOption('Mesh', 'CharacteristicLengthFactor', lc)
g = GModel()
v1 = g.addVertex(0, 0, 0, lc)
v2 = g.addVertex(1, 0, 0, lc)
v3 = g.addVertex(1, 1, 0, lc)
v4 = g.addVertex(0, 1, 0, lc)
e1 = g.addLine(v2, v1)
e2 = g.addLine(v3, v2)
e3 = g.addLine(v4, v3)
e4 = g.addLine(v4, v1)
v11 = g.addVertex(.4, .4, 0, lc)
v12 = g.addVertex(.6, .4, 0, lc)
v13 = g.addVertex(.6, .5, 0, lc)
v14 = g.addVertex(.4, .6, 0, lc)
e11 = g.addLine(v11, v12)
e12 = g.addLine(v12, v13)
e13 = g.addLine(v13, v14)
e14 = g.addLine(v14, v11)
f = g.addPlanarFace ([[e1,e2,e3,e4],[e11,e12,e13,e14]])
g.mesh(2)
g.save("square1.msh")
#v100 = g.addVertex(0, 0, 0, .1)
#v200 = g.addVertex(0, 0, 1, .1)
#v300 = g.addVertex(0, .1, .33, .1)
#v400 = g.addVertex(.1, .1, .66, .1)
#line = g.addBezier(v100,v200,{{v300:x(),v300:y(),v300:z()},{v400:x(),v400:y(),v400:z()}});
#g.addPipe (f, {line})
#g.glue(1.e-9);
#myTool = GModel();
#myTool:addSphere(0.2,0.2,0.1,.52012);
#g.addSphere(1,1.3,1,.3);
#g.computeDifference(myTool,0);
#g.setAsCurrent();
SetFactory("OpenCASCADE");
Mesh.Algorithm = 6;
Mesh.CharacteristicLengthMin = 0.4;
Mesh.CharacteristicLengthMax = 0.4;
R = DefineNumber[ 1.4 , Name "Parameters/Dimension of the Block" ];
s = DefineNumber[ .7 , Name "Parameters/Cylinder of radius s *R" ];
t = DefineNumber[ 1.25, Name "Parameters/Sphere of radius t *R" ];
Block(1) = {-R,-R,-R, R,R,R};
Sphere(2) = {0,0,0,R*t};
BooleanIntersection(3) = { Volume{1}; Delete; }{ Volume{2}; Delete; };
Cylinder(4) = {-2*R,0,0, 2*R,0,0, R*s};
Cylinder(5) = {0,-2*R,0, 0,2*R,0, R*s};
Cylinder(6) = {0,0,-2*R, 0,0,2*R, R*s};
BooleanUnion(7) = { Volume{4}; Delete; }{ Volume{5}; Delete; };
BooleanUnion(8) = { Volume{6}; Delete; }{ Volume{7}; Delete; };
BooleanSubtraction(9) = { Volume{3}; Delete; }{ Volume{8}; Delete; };
#!/usr/bin/env python
from gmshpy import *
# from http://en.wikipedia.org/wiki/Constructive_solid_geometry
R = 1.4;
s = .7;
t = 1.25;
myModel = GModel();
myModel.addBlock([-R,-R,-R],[R,R,R]);
myTool = GModel();
myTool.addSphere(0,0,0,R*t);
myModel.computeBooleanIntersection(myTool);
myTool2 = GModel();
myTool2.addCylinder([-2*R,0,0],[2*R,0,0],R*s);
myTool3 = GModel();
myTool3.addCylinder([0,-2*R,0],[0,2*R,0],R*s);
myModel2 = GModel();
myModel2.addCylinder([0,0,-2*R],[0,0,2*R],R*s);
myModel2.computeBooleanUnion(myTool2);
myModel2.computeBooleanUnion(myTool3);
myModel.computeBooleanDifference(myModel2);
myModel2.setVisibility(0);
myModel.setAsCurrent();
myModel.setVisibility(1);
GmshSetOption("Mesh", "CharacteristicLengthFactor", 0.4);
#myModel.mesh(3);
#myModel.save("wikipedia.msh");
#myModel.save("wikipedia.brep");
FlGui.instance();
FlGui.run();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment