@@ -219,12 +219,14 @@ This is because low level helper functions (e.g. getNodes) are doing same things
219
219
220
220
(* Spatial dimensions of the problem. *)
221
221
sDim = Last @ Dimensions [nodes ];
222
+
223
+ If [ ! (sDim === 3 || sDim === 2 || sDim === 1 ), Return [ $Failed , Module ]];
222
224
223
225
point = Cases [allElements ,PointElement [__ ],2 ];
224
226
line = Cases [allElements ,LineElement [__ ],2 ];
225
227
surface = Cases [allElements ,TriangleElement [__ ]|QuadElement [__ ],2 ];
226
228
solid = Cases [allElements ,TetrahedronElement [__ ]|HexahedronElement [__ ],2 ];
227
-
229
+
228
230
(* If number of dimensions is 3 but no solid elements are specified,
229
231
then we use ToBoundaryMesh to create ElementMesh. And similarly for 2 dimensions. *)
230
232
If [
@@ -559,8 +561,8 @@ extract element topology (e.g. HexahedronElement) and its order from element typ
559
561
560
562
getNodes [list_ ]:= Module [
561
563
{noNodes ,start ,listOfStrings },
562
- noNodes = getNumber [list ," # number of mesh points" ];
563
- start = getPosition [list ,"# Mesh point coordinates" ];
564
+ noNodes = getNumber [list ," # number of mesh points" | " # number of mesh vertices" ];
565
+ start = getPosition [list ,"# Mesh point coordinates" | "# Mesh vertex coordinates" ];
564
566
listOfStrings = Join @@ MapThread [
565
567
Take [list ,{#1 + 1 ,#1 + #2 }]& ,
566
568
{start ,noNodes }
@@ -595,10 +597,17 @@ extract element topology (e.g. HexahedronElement) and its order from element typ
595
597
getElements [list_ ,type_ ,length_ ,startElement_ ,startDomain_ ]:= With [
596
598
{head = type /. switchType },
597
599
{
598
- head [
599
- (* +1 because node counting starts from 0 *)
600
- (modification [type ,# ]& /@ takeLines [list ,startElement ,length ])+ 1 ,
601
- Flatten @ takeLines [list ,startDomain ,length ]
600
+ If [ startDomain === 0 ,
601
+ head [
602
+ (* +1 because node counting starts from 0 *)
603
+ (modification [type ,# ]& /@ takeLines [list ,startElement ,length ])+ 1
604
+ ]
605
+ ,
606
+ head [
607
+ (* +1 because node counting starts from 0 *)
608
+ (modification [type ,# ]& /@ takeLines [list ,startElement ,length ])+ 1 ,
609
+ Flatten @ takeLines [list ,startDomain ,length ]
610
+ ]
602
611
]
603
612
}
604
613
];
@@ -632,11 +641,11 @@ extract element topology (e.g. HexahedronElement) and its order from element typ
632
641
(* I think both "Domains" and "Geometric entity indices" can be considered as markers. *)
633
642
startMarkers = getPosition [list ,"# Domains" |"# Geometric entity indices" ];
634
643
If [ret === "MeshMarkers" , Return [startMarkers ]];
644
+ If [startMarkers === {}, startMarkers = ConstantArray [0 , {Length [types ]}]];
635
645
636
646
nodes = getNodes [list ];
637
647
If [ret === "MeshNodes" , Return [nodes ]];
638
648
639
-
640
649
allElements = MapThread [
641
650
getElements [list ,#1 ,#2 ,#3 ,#4 ]& ,
642
651
{types ,lengths ,startElements ,startMarkers }
0 commit comments