Skip to content

Commit 617f0f5

Browse files
committed
Fixes issue #14.
For a binary GMSH file formart we now give a message that this is not supported and to try to generate an ASCII version.
1 parent ee3c207 commit 617f0f5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

FEMAddOns/ImportMesh/Kernel/ImportMesh.m

+13-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
ImportMesh::abaqus="Incremental node or element generation (*NGEN and *ELGEN keywords) is not supported.";
5555
ImportMesh::fail="Failed to extract mesh from ``";
5656
ImportMesh::gmshfrmt="GMSH file format version `1` is not supported.";
57+
ImportMesh::gmshbin="The file is a binary GMSH file. The binary file format is not supported. Try to generate an ASCII file format.";
5758

5859

5960
(* ::Subsection:: *)
@@ -762,12 +763,22 @@ extract element topology (e.g. HexahedronElement) and its order from element typ
762763

763764
importGmshMesh[list_List, opts:OptionsPattern[]]:=Module[
764765
{version,nodes,markers,allElements,ret},
765-
766-
version=First@StringSplit@Part[list,getStartPosition[list,"$MeshFormat"]+1];
766+
767+
startPos = getStartPosition[list,"$MeshFormat"]+1;
768+
prolog = StringSplit@Part[list,startPos];
769+
770+
version=First[prolog];
767771
If[
768772
Not@MemberQ[{"2.2"},version],
769773
Message[ImportMesh::gmshfrmt,version];Return[$Failed]
770774
];
775+
776+
If[ Length[prolog] > 1,
777+
binaryQ = prolog[[2]] === "1";
778+
If[ binaryQ,
779+
Message[ImportMesh::gmshbin];Return[$Failed]
780+
];
781+
];
771782

772783
ret=OptionValue["ReturnElement"];
773784

0 commit comments

Comments
 (0)