New CAD features, Gmsh 3.0 and API - ONELAB · Set OpenCASCADE internal CAD modeler Explicit tags...
Transcript of New CAD features, Gmsh 3.0 and API - ONELAB · Set OpenCASCADE internal CAD modeler Explicit tags...
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
NewCADfeatures,Gmsh3.0andAPIC.Geuzaine
UniversityofLiège,Belgium
1
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 2
First,ali<lebitofhistory
• Gmshwasstartedin1996,asatoyprojectbyJFandmyself• Firstpublicreleasein1998• OpenSource(GNUGPL)in2003• Gmsh2.0in2006• IJNMEpaperandswitchtoCMakein2009• Pythonwrappersin2011• Curvilinearmeshing:2012–• Quad-Hexmeshing:2012–• Homology:2013–• Parallelmeshing:2015–• NewCADinterfaceandswitchtoGit/Gitlab:2017
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 3
First,ali<lebitofhistory
• Today,Gmshrepresentsabout400klinesofC++code
• sdllsame2coredevelopers;about100with>=1commit
• about1,000peopleonmailinglists
• about10,000downloadspermonth(75%Windows)
• about400citadonsperyear–theGmshpaperiscitedabout2,200dmes
• Gmshprobablyoneofthemostpopularopensourcefiniteelementmeshgeneratorintheworld?
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 4
FirstworkshopheldinBraives,September15-16,2011
hkps://gitlab.onelab.info/gmsh/gmsh/wikis/FirstGmshWorkshop
First,ali<lebitofhistory
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 5
SecondworkshopheldinMoressée,May23-24,2013
hkps://gitlab.onelab.info/gmsh/gmsh/wikis/SecondGmshWorkshop
First,ali<lebitofhistory
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 6
First,ali<lebitofhistory
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
• ThewholeinternalCADinterfacehasbeenrewritenoverthelast2months
• GEO_Internalsinterfacesallthelegacyfeaturesofthebuilt-inGmshCADengine
• OCC_Internalsinterfacestop-levelOpenCASCADEfeatures,includingbooleanoperadons
• AllCADoperadonsarehandledinternallyintheseclasses;theonlyfuncdonthatinteractswithGModelissynchronize(GModel *)
• The.geofileparserhasbeenrewrikentoonlyusetheGEO_Internal/OCC_InternalAPI
• ThisAPIdoesnotexposeanystructuresorclasses:onlyint,double,string,pairandvector
7
NewCADfeatures
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 8
NewCADfeaturesclass GEO_Internals{ public: // add shapes bool addVertex(int num, double x, double y, double z, double lc); bool addLine(int num, int startTag, int endTag); bool addCircleArc(int num, int startTag, int centerTag, int EndTag, double nx=0., double ny=0., double nz=0.); bool addBSpline(int num, const std::vector<int> &vertexTags); bool addLineLoop(int num, const std::vector<int> &edgeTags); bool addPlaneSurface(int num, const std::vector<int> &wireTags); ... // extrude and revolve bool extrude(const std::vector<std::pair<int, int> > &inDimTags, double dx, double dy, double dz, std::vector<std::pair<int, int> > &outDimTags); ... // apply transformations bool translate(const std::vector<std::pair<int, int> > &dimTags, double dx, double dy, double dz); ... // remove bool remove(const std::vector<std::pair<int, int> > &dimTags, bool recursive=false); ... // synchronize internal CAD data with the given GModel void synchronize(GModel *model); ...}
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 9
NewCADfeaturesclass OCC_Internals{ public: // add shapes bool addVertex(int tag, double x, double y, double z, double meshSize=MAX_LC); bool addLine(int tag, int startTag, int endTag); ... bool addSphere(int tag, double xc, double yc, double zc, double radius, double angle1, double angle2, double angle3); bool addThruSections(int tag, const std::vector<int> &wireTags, std::vector<std::pair<int, int> > &outDimTags, bool makeSolid, bool makeRuled); ... // extrude and revolve bool extrude(const std::vector<std::pair<int, int> > &inDimTags, double dx, double dy, double dz, std::vector<std::pair<int, int> > &outDimTags); ... // apply boolean operator bool applyBooleanOperator(int tag, BooleanOperator op, const std::vector<std::pair<int, int> > &objectDimTags, const std::vector<std::pair<int, int> > &toolDimTags, std::vector<std::pair<int, int> > &outDimTags, bool removeObject, bool removeTool); ... // synchronize internal CAD data with the given GModel void synchronize(GModel *model);}
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
• Somemeshingconstraintsarestoredin{GEO,OCC}_Internals(theymustcanbecopiedaround),butmosthavebeenmoveddirectlytoGModel
• GEO_Internalsisalwaysallocated;OCC_Internalsisonlycreatedon-demand(evenifGmshiscompiledwithOCCsupport)
• In.geofiles
• SwitchbetweeninternalCADmodelers:SetFactory("name")
• Currently:"Built-in"or"OpenCASCADE"
• Forceasynchronizadon:SyncModel
• Bydefault:"Built-in"
• 99.99%backwardcompadblewithexisdng.geofiles10
NewCADfeatures
• Knownincompadbilides:embeddedenddesarenowcreatedonlyinGModel
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
• Allexisdng.geocommandsareconserved• Newormodified.geocommands:• Shapes(withexplicitnumbering):Circle, Ellipse, Wire,
Surface, Sphere, Block, Torus, Rectangle, Disk, Cylinder, Cone, Wedge, ThickSolid, ThruSections, Ruled ThruSections
• Operadons(implicitnumbering):ThruSections, Ruled ThruSections, Fillet, Extrude
• Booleanoperadons(explicitorimplicitnumbering):BooleanUnion, BooleanIntersection, BooleanDifference, BooleanFragments
• Other:ShapeFromFile, Recursive Delete, In Surface, In Volume
11
NewCADfeatures
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 12
NewCADfeatures
hkp://gitlab.onelab.info/gmsh/gmsh/tree/master/demos/boolean/boolean.geo
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 13
NewCADfeatures
SetFactory("OpenCASCADE");
// from http://en.wikipedia.org/wiki/Constructive_solid_geometry
R = DefineNumber[ 1.4 , Min 0.1, Max 2, Step 0.01, Name "Parameters/Block dimension" ];Rs = DefineNumber[ R*.7 , Min 0.1, Max 2, Step 0.01, Name "Parameters/Cylinder radius" ];Rt = DefineNumber[ R*1.25, Min 0.1, Max 2, Step 0.01, Name "Parameters/Sphere radius" ];
Block(1) = {-R,-R,-R, R,R,R};
Sphere(2) = {0,0,0,Rt};
BooleanIntersection(3) = { Volume{1}; Delete; }{ Volume{2}; Delete; };
Cylinder(4) = {-2*R,0,0, 2*R,0,0, Rs};Cylinder(5) = {0,-2*R,0, 0,2*R,0, Rs};Cylinder(6) = {0,0,-2*R, 0,0,2*R, Rs};
BooleanUnion(7) = { Volume{4}; Delete; }{ Volume{5,6}; Delete; };BooleanDifference(8) = { Volume{3}; Delete; }{ Volume{7}; Delete; };
SetOpenCASCADEinternalCADmodeler
Explicittags Deleteobjectandtool
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 14
NewCADfeatures
hkp://gitlab.onelab.info/gmsh/gmsh/tree/master/demos/boolean/import.geo
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 15
NewCADfeatures
SetFactory("OpenCASCADE");
DefineConstant[ z = {16, Name "Parameters/z position of block"} sph = {0, Choices{0,1}, Name "Parameters/Add sphere?"}];
a() = ShapeFromFile("component8.step");b() = 2;Block(b(0)) = {0,156,z, 10,170,z+10};
If(sph) b() += 3; Sphere(b(1)) = {0,150,0, 20};EndIf
r() = BooleanFragments{ Volume{a()}; Delete; }{ Volume{b()}; Delete; };Save "merged.brep";
Physical Volume("Combined volume", 1) = {r()};Physical Surface("Combined boundary", 2) = CombinedBoundary{ Volume{r()}; }
Import(highestdim)shapesfromSTEPorBREP
Implicittags
BooleanFragmentsintersectseverything
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
• Moreexamplesonhkp://gitlab.onelab.info/gmsh/gmsh/tree/master/demos/boolean
• OpenCASCADEfeaturesrequireOCCT>=6.9
• Recommended:OCCT7.1
• Muld-threaded2DmeshgeneradonOK(configureGmshwith-DENABLE_OPENMP=1)
• Muld-threadedbooleanoperadons(testwithGeometry.OCCParallel=1;)
• Fuzzybooleanoperadons(Geometry.ToleranceBoolean)
• Let’susetheGit+Debugsessionthisarernoontogeteveryoneup-to-date
16
NewCADfeatures
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
• Otherrecentfeaturesin.geofiles:
• structures(contributedbyPatrick);sdllexperimental,butexamplesavalailableon
hkp://gitlab.onelab.info/gmsh/gmsh/tree/master/demos/struct• Uniqueoperator
• RuledSurface->Surface
• Otherrecentchangespushedinthemasterbranch
• Faster3Dtetrahedralmeshopdmizadonenabledbydefault
17
NewCADfeatures
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
• IwouldliketoreleaseGmsh3.0withthesenewfeaturesrightarertheworkshop
• Intensivedebugsessionthisarernoon!
• …andintroducdontoGitbyJonrightarerthistalk
• IwouldwaitforGmsh3.1(or4.0)tobreakthings:
• newreparametrizadoncodefromPierre-Alexandre(cf.histalktomorrow)…andremovaloftheoldone
• newinidal3Dmesher(collaboradonwithHangSi):sdllsomesmallbugs:pleasetestwithMesh.Algorithm3D=2;
• new3Drefinementcode:sdllsomebugs…butmuchfaster:pleasetestwithMesh.OldRefinement=0;
18
Gmsh3.0
ThirdGmshWorkshop-LanzaroteMarch29-31,2017
• IwouldliketoexportaC-typeAPIforthenewCADinterface,themeshingalgorithms(andcombinethiswithHXT)andthepost-pro• shouldbepurelyfuncdonal(weshoulddecideonanaming
convendon)• shouldonlyusestandardtypes(int,double,vector,pair,map)—
nopointers,noclasses,nostructs• shouldbedocumentedandcouldbewrappedinwhatever
(Python,Java,Julia,…)• dynamiclibrariesexposingthisAPIshouldbemadeavailable
• ThecurrentPython/JavawrappersshouldbereservedforGmshdevelopers,andclearlymarkedassuch;theyshouldnotbedistributedbydefault(e.g.inDebian)
19
API
ThirdGmshWorkshop-LanzaroteMarch29-31,2017 20
Thankyou!