Skip to content

Commit 5266dcf

Browse files
committed
Add images for README and related notebook
1 parent 4ce2f08 commit 5266dcf

File tree

4 files changed

+170
-58
lines changed

4 files changed

+170
-58
lines changed

Images/Example1.png

11.7 KB
Loading

Images/Example2.png

14.1 KB
Loading

Images/ProjectImages.nb

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
Notebook[{
2+
Cell[BoxData[
3+
RowBox[{
4+
RowBox[{"(*", " ",
5+
RowBox[{"Use", " ", "development", " ",
6+
RowBox[{"version", "."}]}], " ", "*)"}], "\[IndentingNewLine]",
7+
RowBox[{"PacletDirectoryAdd", "@",
8+
RowBox[{"ParentDirectory", "[",
9+
RowBox[{"NotebookDirectory", "[", "]"}], "]"}]}]}]], "Input",
10+
CellLabel->"In[39]:=",ExpressionUUID->"98a181c1-8163-4c70-bacc-491151bba889"],
11+
12+
Cell[BoxData[
13+
RowBox[{"Get", "[", "\"\<ImportMesh`\>\"", "]"}]], "Input",
14+
CellLabel->"In[40]:=",ExpressionUUID->"4ae1c006-c270-4eb3-a2e1-221f467b368d"],
15+
16+
Cell[CellGroupData[{
17+
18+
Cell["Examples for README", \
19+
"Subsection",ExpressionUUID->"5e6f7ba2-d840-4c47-b2d7-ad0017ea45d5"],
20+
21+
Cell[CellGroupData[{
22+
23+
Cell["Example 1", \
24+
"Subsubsection",ExpressionUUID->"7876bf11-4683-44bd-a88b-01459ea471a6"],
25+
26+
Cell[BoxData[{
27+
RowBox[{
28+
RowBox[{
29+
"$repoURL", "=",
30+
"\"\<https://raw.githubusercontent.com/c3m-labs/ImportMesh/master\>\""}],
31+
";"}], "\[IndentingNewLine]",
32+
RowBox[{"file", "=",
33+
RowBox[{"URLDownload", "@",
34+
RowBox[{"(",
35+
RowBox[{"$repoURL", "<>", "\"\</Tests/Gmsh/Hex8_box.msh\>\""}],
36+
")"}]}]}]}], "Input",
37+
CellLabel->"In[41]:=",ExpressionUUID->"dd54356e-e791-4246-8a59-9f7ef307bc52"],
38+
39+
Cell[BoxData[{
40+
RowBox[{
41+
RowBox[{"mesh", "=",
42+
RowBox[{"Import", "[",
43+
RowBox[{"file", ",", "\"\<ElementMesh\>\""}], "]"}]}],
44+
";"}], "\[IndentingNewLine]",
45+
RowBox[{"pic", "=",
46+
RowBox[{"mesh", "[",
47+
RowBox[{"\"\<Wireframe\>\"", "[",
48+
RowBox[{
49+
RowBox[{"\"\<MeshElementStyle\>\"", "\[Rule]",
50+
RowBox[{"FaceForm", "@", "LightBlue"}]}], ",",
51+
RowBox[{"ImageSize", "\[Rule]",
52+
RowBox[{"{",
53+
RowBox[{"600", ",", "200"}], "}"}]}]}], "]"}], "]"}]}]}], "Input",
54+
CellLabel->"In[43]:=",ExpressionUUID->"40a2695b-63b2-47b0-93db-294470cdb724"],
55+
56+
Cell[BoxData[
57+
RowBox[{"Export", "[", "\[IndentingNewLine]",
58+
RowBox[{
59+
RowBox[{"FileNameJoin", "[",
60+
RowBox[{"{",
61+
RowBox[{
62+
RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\<Example1.png\>\""}],
63+
"}"}], "]"}], ",", "\[IndentingNewLine]", "pic"}], "\[IndentingNewLine]",
64+
"]"}]], "Input",
65+
CellLabel->"In[45]:=",ExpressionUUID->"429474c0-1d91-468f-bbbc-b5d82a771ce6"]
66+
}, Open ]],
67+
68+
Cell[CellGroupData[{
69+
70+
Cell["Example 2", \
71+
"Subsubsection",ExpressionUUID->"58767b91-a7e3-40a3-8c41-979463a2a5fa"],
72+
73+
Cell[BoxData[
74+
RowBox[{
75+
RowBox[{"inputText", "=",
76+
RowBox[{"ReadString", "@",
77+
RowBox[{"(",
78+
RowBox[{"$repoURL", "<>", "\"\</Tests/Abaqus/Quad4_annulus.inp\>\""}],
79+
")"}]}]}], ";"}]], "Input",
80+
CellLabel->"In[46]:=",ExpressionUUID->"7a6c9fc4-cc22-4c5b-9607-806a2970f2a0"],
81+
82+
Cell[BoxData[{
83+
RowBox[{
84+
RowBox[{"mesh", "=",
85+
RowBox[{"ImportString", "[",
86+
RowBox[{"inputText", ",", "\"\<AbaqusMesh\>\""}], "]"}]}],
87+
";"}], "\[IndentingNewLine]",
88+
RowBox[{"pic", "=",
89+
RowBox[{"mesh", "[",
90+
RowBox[{"\"\<Wireframe\>\"", "[",
91+
RowBox[{
92+
RowBox[{"\"\<MeshElementStyle\>\"", "\[Rule]",
93+
RowBox[{"FaceForm", "@", "LightBlue"}]}], ",",
94+
RowBox[{"ImageSize", "\[Rule]",
95+
RowBox[{"{",
96+
RowBox[{"600", ",", "200"}], "}"}]}]}], "]"}], "]"}]}]}], "Input",
97+
CellLabel->"In[47]:=",ExpressionUUID->"aff3a765-208c-41a1-92c0-31890d1fb3cc"],
98+
99+
Cell[BoxData[
100+
RowBox[{"Export", "[", "\[IndentingNewLine]",
101+
RowBox[{
102+
RowBox[{"FileNameJoin", "[",
103+
RowBox[{"{",
104+
RowBox[{
105+
RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\<Example2.png\>\""}],
106+
"}"}], "]"}], ",", "\[IndentingNewLine]", "pic"}], "\[IndentingNewLine]",
107+
"]"}]], "Input",
108+
CellLabel->"In[49]:=",ExpressionUUID->"541bad0d-678d-45ae-83a8-c19c16bccbde"],
109+
110+
Cell[BoxData[
111+
RowBox[{"ImportString", "[",
112+
RowBox[{"inputText", ",",
113+
RowBox[{"{",
114+
RowBox[{"\"\<AbaqusMesh\>\"", ",", "\"\<Elements\>\""}], "}"}]}],
115+
"]"}]], "Input",
116+
CellLabel->"In[50]:=",ExpressionUUID->"1c05be40-31f8-4407-ae3c-1385c0ae97fb"],
117+
118+
Cell[BoxData[
119+
RowBox[{"ImportString", "[",
120+
RowBox[{"inputText", ",",
121+
RowBox[{"{",
122+
RowBox[{"\"\<AbaqusMesh\>\"", ",", "\"\<MeshNodes\>\""}], "}"}]}],
123+
"]"}]], "Input",
124+
CellLabel->"In[51]:=",ExpressionUUID->"51aa3b03-18c2-44ba-843a-d5e564f35b1b"]
125+
}, Open ]]
126+
}, Open ]]
127+
},
128+
WindowSize->{958, 1086},
129+
WindowMargins->{{Automatic, -8}, {Automatic, 0}},
130+
PrivateNotebookOptions->{"FileOutlineCache"->False},
131+
FrontEndVersion->"11.3 for Microsoft Windows (64-bit) (March 6, 2018)",
132+
StyleDefinitions->"Default.nb"
133+
]
134+

README.md

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@ Utilities for importing FEM meshes to Mathematica. Currently supported file form
99

1010
## Installation
1111

12-
The following description is for people who just want to use the package
13-
functionality and are not interested in package development.
12+
The following description is for people who just want to use the package functionality and
13+
are not interested in package development.
1414

1515
To use _ImportMesh_ package you need Mathematica version 11. or later.
1616

1717
_ImportMesh_ package is released in the `.paclet` file format, which contains code,
1818
documentation and other necessary resources.
19-
Download the latest `.paclet` file from the [repository "releases" page](https://github.com/c3m-labs/ImportMesh/releases)
19+
Download the latest `.paclet` file from the repository ["releases"](https://github.com/c3m-labs/ImportMesh/releases) page
2020
to your computer and install it by evaluating the following command in the Mathematica:
2121

22-
```mathematica
23-
(* This is usually loaded automatically at kernel startup. *)
22+
````mathematica
23+
(* This built-in package is usually loaded automatically at kernel startup. *)
2424
Needs["PacletManager`"]
2525
26-
(* Download .paclet file from repository "releases" page. *)
26+
(* Path to .paclet file downloaded from repository "releases" page. *)
2727
PacletInstall["full/path/to/ImportMesh-X.Y.Z.paclet"]
28-
```
28+
````
2929

3030
This will permanently install the _ImportMesh_ package to `$UserBasePacletsDirectory`.
31-
To update the documentation it may be necessary to restart Mathematica.
31+
To update the documentation it may be necessary to restart Mathematica.
3232
Mathematica will always use the latest installed version of package and all installed versions
3333
can be enumerated by evaluating `PacletFind["ImportMesh"]`.
3434
You can get more detailed information about the package with `PacletInformation["ImportMesh"]`.
3535
All versions can be uninstalled with:
3636

37-
```mathematica
37+
````mathematica
3838
PacletUninstall["ImportMesh"]
39-
```
39+
````
4040

4141
Alternately load the package directly from online repository by running
4242
`Get["https://raw.githubusercontent.com/c3m-labs/ImportMesh/master/ImportMesh.wl"]`.
@@ -47,12 +47,12 @@ Alternately load the package directly from online repository by running
4747

4848
The only (currently) public function is `ImportMesh`. It creates `ElementMesh` object from a text file:
4949

50-
```mathematica
50+
````mathematica
5151
Get["ImportMesh`"]
5252
5353
mesh=ImportMesh["path/to/your_mesh_file"];
5454
mesh["Wireframe"]
55-
```
55+
````
5656

5757
![screenshot](https://imgur.com/aq92uqA.gif "Geometry source: https://grabcad.com/library/goose-2")
5858

@@ -62,69 +62,47 @@ There are also functions in the ``"`Package`"`` subcontext that implement `Impor
6262
Similarly, support is added for `Import` registration, so it is possible to import a file as an
6363
`"ElementMesh"` and get it to work as expected. For example:
6464

65-
```mathematica
65+
````mathematica
66+
$repURL = "https://raw.githubusercontent.com/c3m-labs/ImportMesh/master";
67+
file = URLDownload@($repURL <> "/Tests/Gmsh/Hex8_box.msh");
6668
67-
meshExample =
68-
URLDownload@"https://raw.githubusercontent.com/c3m-labs/ImportMesh/master/Tests/Gmsh/box_H1.msh";
69-
Import[meshExample, "ElementMesh"]["Wireframe"]
70-
```
69+
mesh = Import[file, "ElementMesh"];
70+
pic = mesh["Wireframe"["MeshElementStyle" -> FaceForm@LightBlue]]
71+
````
7172

72-
![example](https://i.stack.imgur.com/IAazP.png "Import base")
73+
![example](Images/Example1.png "Import base")
7374

7475
Support is also provided for import as a string if the format type of the file is known:
7576

76-
```mathematica
77+
````mathematica
78+
inputText = ReadString@($repURL <> "/Tests/Abaqus/Quad4_annulus.inp");
79+
mesh = ImportString[inputText, "AbaqusMesh"];
80+
pic = mesh["Wireframe"["MeshElementStyle" -> FaceForm@LightBlue]]
81+
````
7782

78-
inpText =
79-
ReadString@"https://raw.githubusercontent.com/c3m-labs/ImportMesh/master/Tests/Abaqus/nle1xf4f.inp";
80-
ImportString[inpText, "AbaqusMesh"]["Wireframe"]
81-
```
82-
83-
![example](https://i.stack.imgur.com/4cBAV.png "Import string")
84-
85-
This also allows for loading of assets off the web:
86-
87-
```mathematica
88-
89-
Import[
90-
"https://raw.githubusercontent.com/c3m-labs/ImportMesh/master/Tests/Elfen/disc_Q1.mes",
91-
"ElfenMesh"
92-
]["Wireframe"]
93-
```
94-
95-
![example](https://i.stack.imgur.com/EqN8o.png "Import web")
83+
![example](Images/Example2.png "Import string")
9684

9785
Specific elements may also be extracted when the format is known:
9886

99-
```mathematica
100-
87+
````mathematica
10188
ImportString[inpText, {"AbaqusMesh", "Elements"}]
89+
(* {"Mesh", "MeshNodes", "MeshElements"} *)
90+
````
10291

103-
{"Mesh", "MeshNodes", "MeshElements"}
104-
```
105-
106-
```mathematica
107-
92+
````mathematica
10893
ImportString[inpText, {"AbaqusMesh", "MeshNodes"}]
94+
(* {{0.,1.}, {0., 1.4375}, ... } *)
95+
````
10996

110-
{{0.,1.}, {0., 1.4375}, {0., 1.875}, {0., 2.3125}, {0.,2.75}, {0.659994, 0.932966}, {0.742355, 1.34813},
111-
{0.824716, 1.7633}, {0.907077, 2.17846}, {0.989438, 2.59363}, {1.165, 0.81283}, {1.3195, 1.18442},
112-
{1.474, 1.55602}, {1.6285, 1.92761}, {1.783, 2.2992}, {1.53326, 0.649529}, {1.74826, 0.957066},
113-
{1.96326, 1.2646}, {2.17826, 1.57214}, {2.39326, 1.87968}, {1.78302, 0.453}, {2.04547, 0.67675},
114-
{2.30791, 0.9005}, {2.57036, 1.12425}, {2.8328, 1.348}, {1.93252, 0.233178}, {2.22794, 0.354165},
115-
{2.52335, 0.475152}, {2.81877, 0.596139}, {3.11419, 0.717125}, {2., 0.}, {2.3125, 0.}, {2.625, 0.},
116-
{2.9375, 0.}, {3.25, 0.}
117-
}
97+
More information on how to manipulate and visualize `ElementMesh` objects is available in official
98+
[documentation](https://reference.wolfram.com/language/FEMDocumentation/tutorial/ElementMeshVisualization.html)
11899

119-
```
100+
## Contributing and bug reports
120101

121-
More information on how to manipulate and visualize `ElementMesh` objects is available in official [documentation](https://reference.wolfram.com/language/FEMDocumentation/tutorial/ElementMeshVisualization.html)
122-
123-
## Contributions
102+
You can open a new [issue](https://github.com/c3m-labs/ImportMesh/issues/new) with bug report or feature request.
124103

125104
Contributions to ImportMesh package are very welcome.
126-
You can open a [new issue](https://github.com/c3m-labs/ImportMesh/issues/new) with bug report or feature request.
127-
105+
Guidelines on how to build paclet file from source code can be found in [CONTRIBUTING.md]( CONTRIBUTING.md ) file.
128106
These are some things you can help with:
129107

130108
- Test package with different mesh files

0 commit comments

Comments
 (0)