11(* ::Package:: *)
22
3- (* ::Section:: *)
3+ (* ::Section::Closed:: *)
44(*Header comments*)
55
66
1313(* :Mathematica Version: 11.2 *)
1414
1515
16- (* ::Section:: *)
16+ (* ::Section::Closed:: *)
1717(*Begin package*)
1818
1919
20- (* ::Input:: *)
21- (*MakeIndentable[]*)
22-
23-
24- (* Mathematica FEM functionality is needed. *)
20+ (* Mathematica FEM functionality (context "NDSolve`FEM`") is needed. *)
2521BeginPackage ["ImportMesh`" ,{"NDSolve`FEM`" }];
2622
2723
28- (* ::Section :: *)
24+ (* ::Subsection::Closed :: *)
2925(*Messages*)
3026
3127
@@ -41,10 +37,14 @@ ImportMesh::abaqus="Incremental node or element generation (*NGEN and *ELGEN key
4137ImportMesh ::fail = "Failed to extract mesh from ``" ;
4238
4339
44- (* ::Section:: *)
40+ (* ::Section::Closed:: *)
4541(*Package Level Functions*)
4642
4743
44+ (* The purpose of this public "`Package`" subcontext is that it makes implementation functions more available.
45+ It won't be loaded by default into the $ContextPath, but it can then be loaded by Needs["ImportMesh`Package`"]
46+ for those who are interested in doing more development work. *)
47+
4848BeginPackage ["`Package`" ];
4949importAbaqusMesh ::usage = "" ;
5050importComsolMesh ::usage = "" ;
@@ -56,7 +56,7 @@ importMeshExamples::usage="";
5656EndPackage [];
5757
5858
59- (* ::Section:: *)
59+ (* ::Section::Closed:: *)
6060(*Code*)
6161
6262
@@ -72,7 +72,7 @@ to be called by their full name.
7272*)
7373
7474
75- (* ::Subsection:: *)
75+ (* ::Subsection::Closed:: *)
7676(*The main public function*)
7777
7878
@@ -120,6 +120,9 @@ $importMeshFormats=
120120 |> ;
121121
122122
123+ (* In the case that importing mesh file is not successful the function ImportMesh should return $Failed,
124+ just like the system function Import. *)
125+
123126Clear [ImportMesh ]
124127Options [ImportMesh ]=
125128 {
@@ -196,29 +199,30 @@ convertToElementMesh[nodes_,allElements_]:=Module[
196199]
197200
198201
199- (* ::Subsection:: *)
202+ (* ::Subsection::Closed:: *)
200203(*Abaqus (.inp)*)
201204
202205
203206(* Begin private context *)
204207Begin ["`Abaqus`" ];
205208
206209(*
207- Abaqus has quite involved specification of .inp input file. A lot of code is used to extract element topology
208- (e.g. TetrahedronElement) its order from element type string (e.g. "TYPE=C3D20R").
210+ Abaqus has quite involved specification of .inp input file. Majority of code in this subcontext is needed just to
211+ extract element topology (e.g. HexahedronElement) and its order from element type string (e.g. "TYPE=C3D20R").
209212Another problem is that element connectivity specification for elements with a lot of nodes sometimes breaks to a
210213new line in a text file and this has to be somehow taken into account.
211- *)
214+ *)
212215
213216
214217(* ::Subsubsection::Closed:: *)
215218(*Process elements*)
216219
217220
221+ (* This is a quick ugly hack to pass around spatial dimension that relies on this global symbol. *)
218222$spatialDimension = 3 ;
219223
220224
221- (* This "type" argumet it the next few functions is used only to issue a message with ful element type string. *)
225+ (* This "type" argumet it the next few functions is used only to issue a message with full element type string. *)
222226processLine [type_ ,string_ ]:= Which [
223227 StringStartsQ [string ,"1" ],{LineElement ,2 },
224228 StringStartsQ [string ,"2" ],{LineElement ,3 },
@@ -266,7 +270,6 @@ processElementType[type_String]:=Module[
266270 keysCont = Alternatives @@ {"C" ,"DC" ,"Q" };
267271 keysStruct = Alternatives @@ {"M3D" ,"DS" ,"STRI" ,"S" };
268272
269- (* This is a quick ugly hack to pass around spatial dimension.*)
270273 $spatialDimension = 3 ;
271274
272275 Which [
@@ -423,7 +426,7 @@ importAbaqusMesh[str_String, opts:OptionsPattern[]]:=
423426End []; (* "`Abaqus`" *)
424427
425428
426- (* ::Subsection:: *)
429+ (* ::Subsection::Closed:: *)
427430(*Comsol (.mphtxt)*)
428431
429432
@@ -540,7 +543,7 @@ importComsolMesh[str_String, opts:OptionsPattern[]]:=
540543End []; (* "`Comsol`" *)
541544
542545
543- (* ::Subsection:: *)
546+ (* ::Subsection::Closed:: *)
544547(*Gmsh (.msh)*)
545548
546549
@@ -655,7 +658,7 @@ importGmshMesh[str_String, opts:OptionsPattern[]]:=
655658End []; (* "`Gmsh`" *)
656659
657660
658- (* ::Subsection:: *)
661+ (* ::Subsection::Closed:: *)
659662(*Elfen (.mes)*)
660663
661664
@@ -774,7 +777,7 @@ importElfenMesh[str_String, opts:OptionsPattern[]]:=
774777End []; (* "`Elfen`" *)
775778
776779
777- (* ::Subsection:: *)
780+ (* ::Subsection::Closed:: *)
778781(*Register converters*)
779782
780783
@@ -826,7 +829,7 @@ If[!TrueQ@$importRegistered,
826829$importRegistered = True
827830
828831
829- (* ::Subsection:: *)
832+ (* ::Subsection::Closed:: *)
830833(*Tests*)
831834
832835
0 commit comments