Git Product home page Git Product logo

gmshlink's Introduction

GmshLink

GmshLink is a Mathematica package to create ElementMesh objects via Gmsh meshing software.

It creates tetrahedral mesh with much better quality than built-in meshing algorithm. Currently it works only for 3D symbolic regions obtained by boolean operations on basic geometric primitives (Cuboid, Ball, Cylinder and Cone).

Usage

Prerequisites

  • The latest release (4.0+) of open source meshing software Gmsh.
  • ImportMesh (0.3.3) package to import .msh files to Mathematica.

Gmsh doesn't require installation, just unzip it to any local directory. Then copy the GmshLink.wl file to your local path FileNameJoin[{$UserBaseDirectory, "Applications"}] and you can already try the following example in Mathematica notebook.

See Examples.nb notebook for more examples on how to use additional options of GmshGenerator function.

 (* Load the package. *)
Get["GmshLink`"]

(* Set path directory containing Gmsh executable. *)
$GmshDirectory ="local/path/to/gmsh-4.4.1-Windows64";

(* Define symbolic region based on boolean operations with geometric primitives. *)
reg = RegionDifference[
  RegionUnion@{
    Ball[{0, 0, 0}, 1],
    Ball[{1, 0, 0}, 4/5],
    Ball[{9/5, 0, 0}, 3/5],
    Ball[{12/5, 0, 0}, 2/5]
    },
  Cuboid[{-2, -2, 0}, {5, 2, 2}]
]

(* Create ElementMesh object from symbolic region. *)
mesh = ToElementMesh[reg,"ElementMeshGenerator" -> GmshGenerator]

(* Visualize the mesh with nice element distribution and accurate boundary representation. *)
mesh["Wireframe"[
    "MeshElement" -> "MeshElements",
    "MeshElementStyle" -> FaceForm@LightBlue
]]

mesh

License

MIT

gmshlink's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gmshlink's Issues

ElementMesh generated misses PointElements

When you run this code:

r = RegionUnion[Cylinder[], Cuboid[]];
mesh = ToElementMesh[r, "BoundaryMeshGenerator" -> None, 
  "ElementMeshGenerator" -> {GmshGenerator}, 
  MaxCellMeasure -> Infinity, "MeshOrder" -> 1]
(*mesh["Wireframe"]*)
mesh["PointElements"]
{PointElement[{{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}}, {0, 0, 0, 0, 
   0, 0, 0, 0}]}

you see that the PointElement only have 8 incidents. Looking at the wireframe this does not seem correct. Most likely there should be as many point elements as there are unique boundary element incidents.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.