This package is obsolete. Its functionality, with additional upgrades, is now included in FEMAddOns from Wolfram Research.
Utilities for importing FEM meshes to Mathematica. Currently supported file formats:
The following description is for people who just want to use the package functionality and are not interested in package development.
To use ImportMesh package you need Mathematica version 11. or later.
ImportMesh package is released in the .paclet
file format, which contains code,
documentation and other necessary resources.
Download the latest .paclet
file from the repository "releases" page
to your computer and install it by evaluating the following command in the Mathematica:
(* This built-in package is usually loaded automatically at kernel startup. *)
Needs["PacletManager`"]
(* Path to .paclet file downloaded from repository "releases" page. *)
PacletInstall["full/path/to/ImportMesh-X.Y.Z.paclet"]
This will permanently install the ImportMesh package to $UserBasePacletsDirectory
.
To update the documentation it may be necessary to restart Mathematica.
Mathematica will always use the latest installed version of package and all installed versions
can be enumerated by evaluating PacletFind["ImportMesh"]
.
You can get more detailed information about the package with PacletInformation["ImportMesh"]
.
All versions can be uninstalled with:
PacletUninstall["ImportMesh"]
Alternately load the package directly from online repository by running
Get["https://github.com/raw/c3m-labs/ImportMesh/master/ImportMesh.wl"]
.
The only (currently) public function is ImportMesh
. It creates ElementMesh
object from a text file:
Get["ImportMesh`"]
mesh=ImportMesh["path/to/your_mesh_file"];
mesh["Wireframe"]
There are also functions in the "`Package`"
subcontext that implement ImportMesh
.
Similarly, support is added for Import
registration, so it is possible to import a file as an
"ElementMesh"
and get it to work as expected. For example:
$repURL = "https://github.com/raw/c3m-labs/ImportMesh/master";
file = URLDownload@($repURL <> "/Tests/Gmsh/Hex8_box.msh");
mesh = Import[file, "ElementMesh"];
pic = mesh["Wireframe"["MeshElementStyle" -> FaceForm@LightBlue]]
Support is also provided for import as a string if the format type of the file is known:
inputText = ReadString@($repURL <> "/Tests/Abaqus/Quad4_annulus.inp");
mesh = ImportString[inputText, "AbaqusMesh"];
pic = mesh["Wireframe"["MeshElementStyle" -> FaceForm@LightBlue]]
Specific elements may also be extracted when the format is known:
ImportString[inpText, {"AbaqusMesh", "Elements"}]
(* {"Mesh", "MeshNodes", "MeshElements"} *)
ImportString[inpText, {"AbaqusMesh", "MeshNodes"}]
(* {{0.,1.}, {0., 1.4375}, ... } *)
More information on how to manipulate and visualize ElementMesh
objects is available in official
documentation
You can open a new issue with bug report or feature request.
Contributions to ImportMesh package are very welcome. Guidelines on how to build paclet file from source code can be found in CONTRIBUTING.md file. These are some things you can help with:
- Test package with different mesh files
- Provide sample mesh files from other, not yet supported, software
- Propose code improvements (style or performance)