/
MeshExportModule.jl
1920 lines (1677 loc) · 49.6 KB
/
MeshExportModule.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
MeshExportModule
Module for export of meshes and data defined on meshes.
"""
module MeshExportModule
__precompile__(true)
function _match_type(d, t)
for k in keys(d)
if t <: k
return d[k]
end
end
return nothing
end
module VTK
################################################################################
# VTK export
################################################################################
import ...FESetModule:
AbstractFESet,
FESetP1,
FESetL2,
FESetT3,
FESetQ4,
FESetT4,
FESetH8,
FESetQ8,
FESetQ9,
FESetL3,
FESetT6,
FESetT10,
FESetH20,
connasarray
import ...FENodeSetModule: FENodeSet
import Base.close
using ..MeshExportModule: _match_type
using Printf
import LinearAlgebra: norm, cross
const P1 = 1
const L2 = 3
const T3 = 5
const Q4 = 9
const T4 = 10
const H8 = 12
const L3 = 21
const T6 = 22
const Q8 = 23
const Q9 = 28
const T10 = 24
const H20 = 25
VTKtypemap = Dict{UnionAll,Int}(
FESetP1 => P1,
FESetL2 => L2,
FESetT3 => T3,
FESetQ4 => Q4,
FESetT4 => T4,
FESetH8 => H8,
FESetQ8 => Q8,
FESetQ9 => Q9,
FESetL3 => L3,
FESetT6 => T6,
FESetT10 => T10,
FESetH20 => H20,
)
numnodesmap = Dict{Int,Int}(
P1 => 1,
L2 => 2,
T3 => 3,
Q4 => 4,
T4 => 4,
H8 => 8,
Q8 => 8,
Q9 => 9,
L3 => 3,
T6 => 6,
T10 => 10,
H20 => 20,
)
"""
vtkexportmesh(theFile::String, fens::FENodeSet, fes::T; opts...) where {T<:AbstractFESet}
Export mesh to a VTK 1.0 file as an unstructured grid.
Arguments:
- `theFile` = file name,
- `fens` = finite element node set,
- `fes` = finite element set,
- `opts` = keyword argument list, where
+ `scalars` = array of tuples, (name, data)
+ `vectors` = array of tuples, (name, data)
For the `scalars`: If `data` is a vector, that data is exported as a single field.
On the other hand, if it is an 2d array, each column is exported as a separate field.
"""
function vtkexportmesh(
theFile::String,
fens::FENodeSet,
fes::T;
opts...,
) where {T<:AbstractFESet}
Cell_type = _match_type(VTKtypemap, typeof(fes))
Cell_type === nothing && error("Unknown type $(typeof(fes))")
return vtkexportmesh(theFile, connasarray(fes), fens.xyz, Cell_type; opts...)
end
"""
vtkexportmesh(theFile::String, Connectivity, Points, Cell_type;
vectors=nothing, scalars=nothing)
Export mesh to a VTK 1.0 file as an unstructured grid.
Arguments:
- `theFile` = file name,
- `Connectivity` = array of connectivities, one row per element,
- `Points` = array of node coordinates, one row per node,
- `Cell_type` = type of the cell, refer to the predefined constants P1, L2, ..., H20, ...
- `scalars` = array of tuples, (name, data)
- `vectors` = array of tuples, (name, data)
For the `scalars`: If `data` is a vector, that data is exported as a single field.
On the other hand, if it is an 2d array, each column is exported as a separate field.
"""
function vtkexportmesh(
theFile::String,
Connectivity,
Points,
Cell_type;
vectors = nothing,
scalars = nothing,
)
X = Points
if size(Points, 2) < 3
X = zeros(size(Points, 1), 3)
for j in axes(Points, 1)
X[j, 1:size(Points, 2)] = Points[j, :]
end
end
numnodes = get(() -> error("Wrong number of connected nodes!"), numnodesmap, Cell_type)
if typeof(Connectivity[1]) <: Tuple # Vector of connectivity tuples: convert to an array
c = fill(0, length(Connectivity), length(Connectivity[1]))
for i in eachindex(Connectivity)
c[i, :] = [Connectivity[i]...]
end
Connectivity = c
end
(numnodes == size(Connectivity, 2)) || error("Wrong number of connected nodes!")
fid = open(theFile, "w")
if (fid == -1)
error(["Could not open " * theFile])
return nothing
end
print(fid, "# vtk DataFile Version 1.0\n")
print(fid, "FinEtools Export\n")
print(fid, "ASCII\n")
print(fid, "\n")
print(fid, "DATASET UNSTRUCTURED_GRID\n")
print(fid, "POINTS ", size(X, 1), " double\n")
for i in axes(X, 1)
for j = 1:(size(X, 2)-1)
print(fid, X[i, j], " ")
end
print(fid, X[i, end], "\n")
end
print(fid, "\n")
print(fid, "\n")
print(
fid,
"CELLS ",
size(Connectivity, 1),
" ",
(size(Connectivity, 1) * (size(Connectivity, 2) + 1)),
"\n",
)
for i in axes(Connectivity, 1)
print(fid, size(Connectivity, 2), " ")
for j = 1:(size(Connectivity, 2)-1)
print(fid, Connectivity[i, j] - 1, " ")
end
print(fid, Connectivity[i, end] - 1, "\n")
end
print(fid, "\n")
print(fid, "\n")
print(fid, "CELL_TYPES ", size(Connectivity, 1), "\n")
for i in axes(Connectivity, 1)
print(fid, Cell_type, "\n")
end
print(fid, "\n")
print(fid, "\n")
did_point_data = false
# First try to write point data
if (scalars !== nothing)
did_point_data = false
for sx in eachindex(scalars)
name, data = scalars[sx]
if (size(data, 1) == size(Points, 1)) # point data
if (!did_point_data)
print(fid, "POINT_DATA ", size(data, 1), "\n")
did_point_data = true
end
if size(data, 2) > 1 # there are multiple scalar fields here
for i in axes(data, 2)
print(fid, "SCALARS ", name * "$(i)", " double\n")
print(fid, "LOOKUP_TABLE default\n")
for j in axes(data, 1)
print(fid, data[j, i], "\n")
end
end
else # there's just one scalar field here
print(fid, "SCALARS ", name, " double\n")
print(fid, "LOOKUP_TABLE default\n")
for j in axes(data, 1)
print(fid, data[j], "\n")
end
end
print(fid, "\n")
elseif (size(data, 1) == size(Connectivity, 1)) # cell data
# Handled below, in the section for cell data
end
end
end
print(fid, "\n")
if vectors !== nothing
for vx in eachindex(vectors)
name, data = vectors[vx]
if (!did_point_data)
print(fid, "POINT_DATA ", size(data, 1), "\n")
did_point_data = true
end
print(fid, "VECTORS ", name, " double\n")
#print(fid,"LOOKUP_TABLE default\n");
if size(data, 2) < 3
X = zeros(size(data, 1), 3)
for j in axes(data, 1)
X[j, 1:size(data, 2)] = data[j, :]
end
else
X = data
end
for j in axes(X, 1)
k = 1
print(fid, X[j, k])
for k = 2:lastindex(X, 2)
print(fid, " ", X[j, k])
end
print(fid, "\n")
end
print(fid, "\n")
end
end
print(fid, "\n")
# Are there any cell data? If so, write out.
if (scalars !== nothing)
did_cell_data = false
for sx in eachindex(scalars)
name, data = scalars[sx]
if (size(data, 1) == size(Points, 1)) # point data
# Handled above for the case of point data
elseif (size(data, 1) == size(Connectivity, 1)) # cell data
if (!did_cell_data)
print(fid, "CELL_DATA ", size(data, 1), "\n")
did_cell_data = true
end
if size(data, 2) > 1 # there are multiple scalar fields here
for i in axes(data, 2)
print(fid, "SCALARS ", name * "$(i)", " double\n")
print(fid, "LOOKUP_TABLE default\n")
for j in axes(data, 1)
print(fid, data[j, i], "\n")
end
end
else # there's just one scalar field here
print(fid, "SCALARS ", name, " double\n")
print(fid, "LOOKUP_TABLE default\n")
for j in axes(data, 1)
print(fid, data[j], "\n")
end
end
print(fid, "\n")
end
end
end
fid = close(fid)
return true
end
"""
vtkexportvectors(theFile::String, Points, vectors)
Export vector data to a VTK 1.0 file.
Arguments:
- `theFile` = file name,
- `Points` = array of collection of coordinates (tuples or vectors),
- `vectors` = array of tuples, `(name, data)`, where `name` is a string, and
`data` is array of collection of coordinates (tuples or vectors).
# Example
```
Points = [(1.0, 3.0), (0.0, -1.0)]
vectors = [("v", [(-1.0, -2.0), (1.0, 1.0)])]
vtkexportvectors("theFile.VTK", Points, vectors)
```
will produce file with
```
# vtk DataFile Version 1.0
FinEtools Export
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 2 double
1.0 3.0 0.0
0.0 -1.0 0.0
POINT_DATA 2
VECTORS v double
-1.0 -2.0 0.0
1.0 1.0 0.0
```
!!! note
The filter "Glyph" must be used within Paraview. Also in the drop-down
menu "Glyph mode" select "all points".
"""
function vtkexportvectors(theFile::String, Points, vectors)
fid = open(theFile, "w")
if (fid == -1)
error(["Could not open " * theFile])
return nothing
end
print(fid, "# vtk DataFile Version 1.0\n")
print(fid, "FinEtools Export\n")
print(fid, "ASCII\n")
print(fid, "\n")
print(fid, "DATASET UNSTRUCTURED_GRID\n")
print(fid, "POINTS ", length(Points), " double\n")
pt = fill(0.0, 3)
for i in eachindex(Points)
for k in eachindex(Points[i])
pt[k] = Points[i][k]
end
for j = 1:(length(pt)-1)
print(fid, pt[j], " ")
end
print(fid, pt[end], "\n")
end
print(fid, "\n")
print(fid, "\n")
did_point_data = false
if vectors !== nothing
for vx in eachindex(vectors)
name, data = vectors[vx]
if (!did_point_data)
print(fid, "POINT_DATA ", length(data), "\n")
did_point_data = true
end
print(fid, "VECTORS ", name, " double\n")
#print(fid,"LOOKUP_TABLE default\n");
for i in eachindex(data)
for k in eachindex(data[i])
pt[k] = data[i][k]
end
for j = 1:(length(pt)-1)
print(fid, pt[j], " ")
end
print(fid, pt[end], "\n")
end
print(fid, "\n")
end
end
print(fid, "\n")
fid = close(fid)
return true
end
end # VTK
module Abaqus
################################################################################
# Abaqus export
################################################################################
import ...FESetModule:
AbstractFESet,
FESetP1,
FESetL2,
FESetT3,
FESetQ4,
FESetT4,
FESetH8,
FESetQ8,
FESetL3,
FESetT6,
FESetT10,
FESetH20,
connasarray
import ...FENodeSetModule: FENodeSet
import Base.close
using LinearAlgebra
"""
AbaqusExporter
Export mesh to Abaqus.
"""
mutable struct AbaqusExporter
filename::AbstractString
ios::IO
element_range::Tuple{Int64,Int64}
function AbaqusExporter(filename::AbstractString)
if match(r".*\.inp$", filename) === nothing
filename = filename * ".inp"
end
ios = open(filename, "w+")
return new(deepcopy(filename), ios, (typemax(Int64), 0))
end
end
"""
COMMENT(self::AbaqusExporter, Text::AbstractString)
Write out the `**` comment option.
"""
function COMMENT(self::AbaqusExporter, Text::AbstractString)
println(self.ios, "**" * Text)
end
"""
HEADING(self::AbaqusExporter, Text::AbstractString)
Write out the `*HEADING` option.
"""
function HEADING(self::AbaqusExporter, Text::AbstractString)
println(self.ios, "*HEADING")
println(self.ios, Text)
end
"""
PART(self::AbaqusExporter, NAME::AbstractString)
Write out the `*PART` option.
"""
function PART(self::AbaqusExporter, NAME::AbstractString)
println(self.ios, "*PART, NAME=" * NAME)
end
"""
END_PART(self::AbaqusExporter)
Write out the `*END PART` option.
"""
function END_PART(self::AbaqusExporter)
println(self.ios, "*END PART")
end
"""
ASSEMBLY(self::AbaqusExporter, NAME::AbstractString)
Write out the `*ASSEMBLY` option.
"""
function ASSEMBLY(self::AbaqusExporter, NAME::AbstractString)
println(self.ios, "*ASSEMBLY, NAME=" * NAME)
end
"""
END_ASSEMBLY(self::AbaqusExporter)
Write out the `*END ASSEMBLY` option.
"""
function END_ASSEMBLY(self::AbaqusExporter)
println(self.ios, "*END ASSEMBLY")
end
"""
INSTANCE(self::AbaqusExporter, NAME::AbstractString, PART::AbstractString)
Write out the `*INSTANCE` option.
"""
function INSTANCE(self::AbaqusExporter, NAME::AbstractString, PART::AbstractString)
println(self.ios, "*INSTANCE, NAME=" * NAME * ", PART=" * PART)
end
"""
END_INSTANCE(self::AbaqusExporter)
Write out the `*END INSTANCE` option.
"""
function END_INSTANCE(self::AbaqusExporter)
println(self.ios, "*END INSTANCE")
end
"""
NODE(self::AbaqusExporter, xyz::AbstractArray{T, 2}) where {T}
Write out the `*NODE` option.
`xyz`=array of node coordinates
"""
function NODE(self::AbaqusExporter, xyz::AbstractArray{T,2}) where {T}
println(self.ios, "*NODE")
for j in axes(xyz, 1)
print(self.ios, "$j,$(xyz[j, 1])")
for ixxxx = 2:1:size(xyz, 2)
print(self.ios, ",$(xyz[j, ixxxx])")
end
print(self.ios, "\n")
end
end
"""
ELEMENT(self::AbaqusExporter, TYPE::AbstractString, ELSET::AbstractString,
start::Integer, conn::AbstractArray{T, 2}) where {T<:Integer}
Write out the `*ELEMENT` option.
`TYPE`= element type code,
`ELSET`= element set to which the elements belong,
`start`= start the element numbering at this integer,
`conn`= connectivity array for the elements, one row per element
"""
function ELEMENT(
self::AbaqusExporter,
TYPE::AbstractString,
ELSET::AbstractString,
start::Integer,
conn::AbstractArray{T,2},
) where {T<:Integer}
# Check that start is valid
(start > 0) || error("The starting element number must be > 0")
# Check that the current element number range is disjoint from the
# range of the elements on input: they must not overlap
((self.element_range[2] < start) ||
(self.element_range[1] > start + size(conn, 1) - 1)) || error("Elements must be given unique numbers")
# Update the element range
self.element_range = (
min(self.element_range[1], start),
max(self.element_range[2], start + size(conn, 1) - 1),
)
println(self.ios, "*ELEMENT, TYPE =" * TYPE * ", ELSET=" * ELSET)
for j in axes(conn, 1)
print(self.ios, "$(j+start-1),")
for ixxxx = 1:(size(conn, 2)-1)
if ixxxx > 15
print(self.ios, "\n")
end
print(self.ios, "$(conn[j,ixxxx]),")
end
print(self.ios, "$(conn[j,size(conn,2)])\n")
end
end
function ELEMENT(
self::AbaqusExporter,
TYPE::AbstractString,
ELSET::AbstractString,
conn::AbstractArray{T,2},
) where {T<:Integer}
start = self.element_range[2] + 1
ELEMENT(self, TYPE, ELSET, start, conn)
end
function ELEMENT(
self::AbaqusExporter,
TYPE::AbstractString,
ELSET::AbstractString,
start::Integer,
conn::Vector{C},
) where {C<:Tuple}
c = fill(0, length(conn), length(conn[1]))
for i in eachindex(conn)
c[i, :] = [conn[i]...]
end
ELEMENT(self, TYPE, ELSET, start, c)
end
function ELEMENT(
self::AbaqusExporter,
TYPE::AbstractString,
ELSET::AbstractString,
conn::Vector{C},
) where {C<:Tuple}
start = self.element_range[2] + 1
ELEMENT(self, TYPE, ELSET, start, conn)
end
"""
NSET_NSET(self::AbaqusExporter, NSET::AbstractString,
n::AbstractVector{T}) where {T<:Integer}
Write out the `*NSET` option.
`NSET` = name of the set,
`n` = array of the node numbers
"""
function NSET_NSET(
self::AbaqusExporter,
NSET::AbstractString,
n::AbstractVector{T},
) where {T<:Integer}
println(self.ios, "*NSET, NSET=" * NSET)
for j = 1:(length(n)-1)
println(self.ios, "$(n[j]),")
end
println(self.ios, "$(n[length(n)])")
end
"""
ELSET_ELSET(self::AbaqusExporter, ELSET::AbstractString, n::AbstractArray{T, 1}) where {T<:Integer}
Write out the `*ELSET` option.
`ELSET` = name of the set,
`n` = array of the node numbers
"""
function ELSET_ELSET(
self::AbaqusExporter,
ELSET::AbstractString,
n::AbstractArray{T,1},
) where {T<:Integer}
println(self.ios, "*ELSET, ELSET=" * ELSET)
for j = 1:(length(n)-1)
println(self.ios, "$(n[j]),")
end
println(self.ios, "$(n[length(n)])")
end
"""
ORIENTATION(self::AbaqusExporter, ORIENTATION::AbstractString,
a::AbstractArray{T,1}, b::AbstractArray{T,1})
Write out the `*ORIENTATION` option.
Invoke at level: Part, Part instance, Assembly
"""
function ORIENTATION(
self::AbaqusExporter,
ORIENTATION::AbstractString,
a::AbstractArray{T,1},
b::AbstractArray{T,1},
) where {T<:Real}
println(self.ios, "*ORIENTATION,NAME=" * ORIENTATION)
println(self.ios, "$(a[1]),$(a[2]),$(a[3]),$(b[1]),$(b[2]),$(b[3])")
println(self.ios, "1,0.0")
end
"""
MATERIAL(self::AbaqusExporter, MATERIAL::AbstractString)
Write out the `*MATERIAL` option.
"""
function MATERIAL(self::AbaqusExporter, MATERIAL::AbstractString)
println(self.ios, "*MATERIAL,NAME=" * MATERIAL)
end
"""
ELASTIC(self::AbaqusExporter, E1::F, E2::F, E3::F, nu12::F, nu13::F, nu23::F,
G12::F, G13::F, G23::F) where {F}
Write out the `*ELASTIC,TYPE=ENGINEERING CONSTANTS` option.
"""
function ELASTIC(
self::AbaqusExporter,
E1::F,
E2::F,
E3::F,
nu12::F,
nu13::F,
nu23::F,
G12::F,
G13::F,
G23::F,
) where {F}
println(self.ios, "*ELASTIC,TYPE=ENGINEERING CONSTANTS")
println(self.ios, "$E1,$E2,$E3,$nu12,$nu13,$nu23,$G12,$G13,")
println(self.ios, "$G23")
end
"""
ELASTIC(self::AbaqusExporter, E::F, nu::F) where {F}
Write out the `*ELASTIC,TYPE=ISOTROPIC` option.
"""
function ELASTIC(self::AbaqusExporter, E::F, nu::F) where {F}
println(self.ios, "*ELASTIC,TYPE=ISOTROPIC ")
println(self.ios, "$E,$nu")
end
"""
EXPANSION(self::AbaqusExporter, CTE::F) where {F}
Write out the `*EXPANSION` option.
"""
function EXPANSION(self::AbaqusExporter, CTE::F) where {F}
println(self.ios, "*EXPANSION")
println(self.ios, "$CTE,")
end
"""
DENSITY(self::AbaqusExporter, rho)
Write out the `*DENSITY` option.
"""
function DENSITY(self::AbaqusExporter, rho)
println(self.ios, "*DENSITY ")
println(self.ios, "$rho")
end
"""
SECTION_CONTROLS(self::AbaqusExporter, NAME::AbstractString,
OPTIONAL::AbstractString)
Write out the `*SECTION CONTROLS` option.
`OPTIONAL` = string, for instance
HOURGLASS=ENHANCED
"""
function SECTION_CONTROLS(
self::AbaqusExporter,
NAME::AbstractString,
OPTIONAL::AbstractString,
)
println(self.ios, "*SECTION CONTROLS, NAME=" * NAME * "," * OPTIONAL)
end
"""
SOLID_SECTION(self::AbaqusExporter, MATERIAL::AbstractString,
ORIENTATION::AbstractString, ELSET::AbstractString,
CONTROLS::AbstractString)
Write out the `*SOLID SECTION` option.
Level: Part, Part instance
"""
function SOLID_SECTION(
self::AbaqusExporter,
MATERIAL::AbstractString,
ORIENTATION::AbstractString,
ELSET::AbstractString,
CONTROLS::AbstractString,
)
println(
self.ios,
"*SOLID SECTION,MATERIAL=" *
MATERIAL *
",ORIENTATION =" *
ORIENTATION *
",ELSET=" *
ELSET *
", CONTROLS =" *
CONTROLS,
)
end
"""
SOLID_SECTION(self::AbaqusExporter, MATERIAL::AbstractString,
ORIENTATION::AbstractString, ELSET::AbstractString)
Write out the `*SOLID SECTION` option.
Level: Part, Part instance
"""
function SOLID_SECTION(
self::AbaqusExporter,
MATERIAL::AbstractString,
ORIENTATION::AbstractString,
ELSET::AbstractString,
)
println(
self.ios,
"*SOLID SECTION,MATERIAL=" *
MATERIAL *
",ORIENTATION =" *
ORIENTATION *
",ELSET=" *
ELSET,
)
end
"""
SOLID_SECTION(self::AbaqusExporter, MATERIAL::AbstractString,
ORIENTATION::AbstractString, ELSET::AbstractString)
Write out the `*SOLID SECTION` option.
Level: Part, Part instance
"""
function SOLID_SECTION(
self::AbaqusExporter,
MATERIAL::AbstractString,
ORIENTATION::AbstractString,
ELSET::AbstractString,
thickness::F,
) where {F}
SOLID_SECTION(self, MATERIAL, ORIENTATION, ELSET)
println(self.ios, "$(thickness),")
end
# """
# HOURGLASS(self::AbaqusExporter, KIND::AbstractString, VALUE::F) where {F}
#
# Write out the `*HOURGLASS` option.
#
# ```
# Example:
# *SOLID SECTION,ELSET=SOLID3,MATERIAL=MAT,CONTROL=Ac
# *HOURGLASS STIFFNESS
# 5.E8
# ```
# """
# function HOURGLASS(self::AbaqusExporter, KIND::AbstractString, VALUE::F) where {F}
# println(self.ios, "*HOURGLASS " * KIND);
# println(self.ios, "$( VALUE )");
# end
"""
SURFACE_SECTION(self::AbaqusExporter, ELSET::AbstractString)
Write out the `*SURFACE SECTION` option.
"""
function SURFACE_SECTION(self::AbaqusExporter, ELSET::AbstractString)
println(self.ios, "*SURFACE SECTION, ELSET=" * ELSET)
end
"""
STEP_PERTURBATION_STATIC(self::AbaqusExporter)
Write out the `*STEP,PERTURBATION` option for linear static analysis.
"""
function STEP_PERTURBATION_STATIC(self::AbaqusExporter)
println(self.ios, "*STEP,PERTURBATION")
println(self.ios, "*STATIC")
end
"""
STEP_PERTURBATION_BUCKLE(self::AbaqusExporter, neigv::Integer)
Write out the `*STEP,PERTURBATION` option for linear buckling analysis.
"""
function STEP_PERTURBATION_BUCKLE(self::AbaqusExporter, neigv::Integer)
println(self.ios, "*STEP, name=Buckling, nlgeom=NO, perturbation")
println(self.ios, "*BUCKLE")
println(self.ios, "$(neigv), , , , ")
end
"""
STEP_FREQUENCY(self::AbaqusExporter, Nmodes::Integer)
Write out the `*STEP,FREQUENCY` option.
"""
function STEP_FREQUENCY(self::AbaqusExporter, Nmodes::Integer)
println(self.ios, "*STEP")
println(self.ios, "*FREQUENCY, EIGENSOLVER=LANCZOS")
println(self.ios, "$(Nmodes), , ,-1.E6 \n")
end
"""
BOUNDARY(self::AbaqusExporter, mesh, nodes, is_fixed::AbstractArray{B,2}, fixed_value::AbstractArray{F,2}) where {B, F}
Write out the `*BOUNDARY` option.
The boundary condition is applied to the nodes specified in
the array `nodes`, in the mesh (or node set) `meshornset`.
`meshornset` = mesh or node set (default is empty)
`nodes` = array of node numbers, the node numbers are attached to the mesh label,
`is_fixed`= array of Boolean flags (true means fixed, or prescribed), one row per node,
`fixed_value`=array of displacements to which the corresponding displacement components is fixed
# Example
```
BOUNDARY(AE, "ASSEM1.INSTNC1", 1:4, fill(true, 4, 1), reshape([uy(fens.xyz[i, :]...) for i in 1:4], 4, 1))
```
"""
function BOUNDARY(
self::AbaqusExporter,
meshornset,
nodes,
is_fixed::AbstractArray{B,2},
fixed_value::AbstractArray{F,2},
) where {B,F}
println(self.ios, "*BOUNDARY")
if meshornset == ""
meshlabel = ""
else
meshlabel = meshornset * "."
end
for j in nodes
for k in axes(is_fixed, 2)
#<node number>, <first dof>, <last dof>, <magnitude of displacement>
if is_fixed[j, k]
println(self.ios, "$(meshlabel)$(j),$k,$k,$(fixed_value[j,k])")
end
end
end
end
function BOUNDARY(
self::AbaqusExporter,
nodes,
is_fixed::AbstractVector{B},
fixed_value::AbstractVector{F},
) where {B,F}
BOUNDARY(
self,
nodes,
reshape(is_fixed, length(is_fixed), 1),
reshape(fixed_value, length(fixed_value), 1),
)
end
"""
BOUNDARY(self::AbaqusExporter, meshornset, is_fixed::AbstractArray{B,2}, fixed_value::AbstractArray{F,2}) where {B, F}
Write out the `*BOUNDARY` option.
- `meshornset` = name of a mesh or a node set,
- `is_fixed`= array of Boolean flags (true means fixed, or prescribed), one row per node, as many columns as there are degrees of freedom per node,
- `fixed_value`=array of displacements to which the corresponding displacement components is fixed, as many columns as there are degrees of freedom per node
"""
function BOUNDARY(
self::AbaqusExporter,
meshornset,
is_fixed::AbstractArray{B,2},
fixed_value::AbstractArray{F,2},
) where {B,F}
BOUNDARY(self, meshornset, 1:size(is_fixed, 1), is_fixed, fixed_value)
end
"""
BOUNDARY(self::AbaqusExporter, NSET::AbstractString, dof::Integer, fixed_value)
Write out the `*BOUNDARY` option.
- `NSET` = name of a node set,
- `is_fixed`= array of Boolean flags (true means fixed, or prescribed), one row per node,
- `fixed_value`=array of displacements to which the corresponding displacement components is fixed
"""
function BOUNDARY(self::AbaqusExporter, NSET::AbstractString, dof::Integer, fixed_value)
println(self.ios, "*BOUNDARY")
println(self.ios, NSET * ",$dof,$dof,$(fixed_value)")
end
"""
BOUNDARY(self::AbaqusExporter, NSET::AbstractString, dof::Integer)
Write out the `*BOUNDARY` option to fix displacements at zero for a node set.
Invoke at Level: Model, Step
- `NSET`= node set,
- `dof`=Degree of freedom, 1, 2, 3
"""
function BOUNDARY(self::AbaqusExporter, NSET::AbstractString, dof::Integer)
BOUNDARY(self, NSET, dof, 0.0)
end
"""
BOUNDARY(self::AbaqusExporter, NSET::AbstractString, dof::Integer,
value::F) where {F}
Write out the `*BOUNDARY` option to fix displacements at nonzero value for a
node set.
- `NSET`= node set,
- `dof`=Degree of freedom, 1, 2, 3
- `typ` = DISPLACEMENT
"""
function BOUNDARY(
self::AbaqusExporter,
NSET::AbstractString,
dof::Integer,
value::F,
typ::AbstractString,
) where {F}
println(self.ios, "*BOUNDARY,TYPE=$(typ)")
println(self.ios, NSET * ",$dof,$dof,$value")