-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmat2tecplot.m
executable file
·12117 lines (10887 loc) · 486 KB
/
mat2tecplot.m
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
function [s] = mat2tecplot(tdata,tecfile)
%
% function s =mat2tecplot(tdata,tecfile)
%
% Program to create tecplot binary data file (.plt).
%
% Format is described here:
% http://download.tecplot.com/360/dataformat.pdf
% on page 149. It is also excerpted into text file in
% ./doc/binaryformat_2012.txt
%
% This program benefitted from the following programs
% http://tecplottalk.com/viewtopic.php?t=879&sid=2775b1aff4a1dc523ee890b85ab08f40
%
% FAQ: plt -> matlab?
% load the *.plt is too complicate, using tecplot to export *CVS file,
% let matlab to import the CVS text file, the file size may be huge.
%
% Python to load matlab data: from scipy.io import matlab
% mat=matlab.loadmat('file.mat')
%
% Here are general rules for binary data in tecplot
%
% http://download.tecplot.com/tecio/360/binaryformat.txt
%
% 1) All character strings in Fortran or matlab must be terminated with
% null character. In Fortran this is done by "MyString"//char(0)
% In matlab, this is done by (after writing the string) :
% dummy_int32 =0;
% fwrite(fid_out,dummy_int32,'int32');
%
% 2) All boolean Flags use value 1 for true and 0 for false
%
% A tecplot structure tdata (first argument) is a structure and
% contain the following information :
%
% tdata.title ---title of the plot, string
% by default, the title name will be 'tecplot data'
%
% tdata.Nvar ---integer, storing number of variables
%
% tdata.varnames ---cell array of variable names, if array size less than
% Nvar, then the rest of them will be named
% as var1,var2,var3,... depending on
% how many of them have names given. If
% length of varnames is larger than Nvar, those
% beyond Nvar will be ignored. varnames{1:Nvar}
%
% tdata.vformat ---integer vector array storing dataformat for
% each variable (1:Nvar). 1- for float
% 2- for double
% 3- for longInt
% 4- for shortInt
% 5- for Byte
% 6- for Bit
% Default is 1
%
% tdata.lines ---an OPTIONAL structure array [Nlines] of line values Y, Z, v
% defined on 1D X ( or with Y, Z for 3D line)
% coordinates with I-ordered format. Each line is
% treated as a zone. Lines contain the
% following metadata information (iline=1:Nlines):
%
% lines(iline).varloc --- location of variables, 0 for nodal
% 1 for center.
%
% lines.zonename ---zone names of each lines, if not given
% it will be named as line1,line2,...
%
% lines.x ---1D x values of the line (must have)
% lines.y ---1D y values of the line (optional)
% default to zero if not given
% lines.z ---1D z values of the line (optional)
% default to zero, if not given
% lines.v ---2D variables defined on the line
% (optional), default to zero, if not
% given and Nvar>3. Each variable
% uses one row. E.g. lines.v(2,:)
% is the 2nd variable in v. Length of
% the row (number of columns) must
% be same as x, y, z. Nvar=3+number of
% rows in v.
%
% lines.varmin --- minimum value of the line, automatically
% calculated if not given
% lines.varmax --- maximum value of the line, automatically
% calculated if not given
%
% lines.auxname --- auxiliary data name for each line, set to
% none if not given or empty
% (cell array of strings or single
% string)
% lines.auxval --- auxiliary data value for each line, set to
% none if not given or empty. Only
% useful if auxname is given.
% (cell array of strings or single
% string)
%
% lines.datapacking ---is it block or not, by default
% it is point, but block will save
% space. This is deprecated.
% By default it is set to zero
% (block)
%
% lines.strandID ---strandID for each of the line
% zone. Each line is treated as a
% zone, and you can assign
% strandID to it. Multiple
% zones can have the same strandID
% such that they grouped together
% and identifiable by the strandID
% If not provided, strandID is set
% to zero by default.
% (Wen Long: we may want to
% default it to -2 so that tecplot
% will assign one automatically.)
%
% lines.solutiontime ---time associated with the line
% multiple zones can have the
% same solutiontime, hence
% useful for grouping zones
% together for animation.
% (Optional), default = 0
%
% tdata.surfaces ---an array of surface values v and Z defined on
% 2D XY coordinates with IJ-ordered format, or v and
% X defined on 2D (YZ) coordinates (JK-ordered
% format) or v and Y defined on 2D (XZ) coordinates
% (IK-ordered format). Each surface is treated
% as a zone. The surfaces contain the following
% information to define the zones.
%
% surfaces.varloc --- location of variables for each
% surface variable, 0-nodal, 1-center
% Note that coordinate variables
% must be nodal. Which variables
% are coordinate variables is
% determined from surfaces.order
%
% surfaces.x --- 2D array giving
% x values of the surface
% (must have if order=1,2)
% (optional if order=1, default to zeros)%
%
% surfaces.y --- 2D array giving
% y values of the surface
% (must have if order=1,3)
% (optional if order=2, default to zeros)
%
% surfaces.z --- 2D array giving
% z values of the surface
% (must have if order=2,3)
% (optional if order=3, default to zeros)
%
% surfaces.v ----2D variables defined on the
% surface (optional). Default to
% zeros if Nvar>3
%
% surfaces.order --- determine order (default is 3)
% 3- IJ order, surface is z=f(x,y),
% x and y must be nodal.
% If z not available, default
% to zero
% 2- IK order, surface is
% y=f(x,z), x and z must be
% nodal.
% If y not available, default
% to zero
% 1- JK order, surface is
% x=f(y,z), y and z must be
% nodal.
% if x not available, default
% to zero
%
% surfaces.zonename --- zone name of each surface, if not
% given, then it will be named as
% surface1,surface2,...
% surfaces.auxname --- auxiliary data name for each surface
% (cell array of strings or single
% string)
% surfaces.auxval --- auxiliary data value for each auxname
% (cell array of strings or single
% string)
% surfaces.datapacking --is it block or point (deprecated
% and set to zero by default)
% surfaces.strandID --- strandID for each surface as
% a zone. Default is -2 so tecplot
% will assign it automatically
% surfaces.solutiontime --- time associated with the
% surface. (Optional) default 0
%
% tdata.cubes ---an array of 3D values v defined on 3D XYZ coordinates
% with IJK-ordered format. Each volume dataset is
% treated as a zone. cubes contain the following
% information to define the zones.
%
% cubes.varloc --- location of variable for each cube data
% 0-nodal, 1-center (default is 0)
% cubes.x --- 3D array giving x coordinate
% values of the surface. (must have)
% size [Imax,Jmax,Kmax]
% cubes.y --- 3D array giving y coordinate values
% of the surface (must have)
% size [Imax,Jmax,Kmax]
% cubes.z --- 3D array giving z coordinate values
% of the surface (must have)
% size [Imax,Jmax,Kmax]
% cubes.v --- 4D array giving value of the variable
% (optional). Default to zeros if
% not given and Nvar>3. First
% dimension is variables, 2nd, 3rd,
% and fourth dimensions are (x,y,z)
% for varilable iv-3, where
% iv=1:Nvar. For nodal data, v is
% of size [Nvar-3,Imax,Jmax,Kmax]; for
% cell centered data (varloc==1)
% v is of size
% [Nvar-3,Imax-1,Jmax-1,Kmax-1]
% cubes.zonename --- zone name of each cube data v, if not
% given, then it will be named as
% cube1,cube2,cube3,... (Optional)
% cubes.auxname --- auxiliary data names for each cube
% (cell array of strings or single
% string) (Optional)
% cubes.auxval --- auxiliary data value for each auxname
% (cell array of strings or single
% string) (Optional)
% cubes.datapacking ---packing method of the cube
% variables (0) for block, 1 for
% point. Note: for point, varloc
% can't be 1-center. (Deprecated
% and set to zero by default)
% cubes.strandID --- standID associated with the cube.
% (Optional). Default is -2
% cubes.solutiontime ---solution time associated with
% the cube zone (Optional).
% Default is 0
%
% tdata.FElines ---an array of finite element 1D data, which is
% a set of line segments defining a 2D or 3D line.
% Each finite element line (segments) is treated as a
% zone. FElines contain the following information to
% define a zone:
%
% FElines.e2n ---element (made of 2 points) node
% connectivity list, for each element
% it consists two node numbers,
% array of size [NE,2] defining
% line element to node connectivity
% where NE is number of elements
% FElines.v ---variable value of each line defined
% on line element (nodal or center
% of line element). 2D dimensional
% 1st dimension is variable
% 2nd dimension is nodal or cell
%
% FElines.x ---x coordinate (1D array)
% FElines.y ---y coordinate (1D array)
% FElines.z ---z coordinate (1D array)
%
% FElines.order ---order of each line (default is 4)
% 0 : 1D line defined on x
% y=f(x), z=f(x),v=f(x)
% 1 : 2D line defined on (x,y)
% z=f(x,y),v=f(x,y)
% 2 : 2D line defined on (x,z)
% y=f(x,z),v=f(x,z)
% 3: 2D line defined on (y,z)
% x=f(y,z),v=f(y,z)
% 4: 3D line defined on (x,y,z)
% v=f(x,y,z)
% Default is 4
% FElines.datapacking --- whether it is block or point
% (deprecated and set to zero
% by default)
% FElines.standID ---strandID associated with the
% zone. (Optional), Default is -2
% FElines.solutiontime --- solution time associated
% with the FEline zone (Optional)
% Default is 0
% FElines.zonename --- zone name of each line, if not
% given, then it will be named as
% FELine1,FELine2,...
% FElines.auxname --- auxiliary data name for each
% line,(cell array of strings
% or single string) (Optional)
% FElines.auxval --- auxiliary data value for each
% auxname (cell array of strings
% or single string) (Optional)
%
% tdata.FEsurfaces ---an array of finite element 2D surface data of
% triangle or quadrilateral or polygon elements defined
% on 2D XY coordinates or 3D XYZ coordinates. Each
% surface is treated as zone. FEsurfaces contain
% the following information to define the zones:
%
% FEsurfaces.e2n ---element connectivity list. For
% each element, it consists of
% 3 (triangular) or 4 (quadrilateral)
% node numbes, or (polygon) with
% arbitrary number of points
% (>=3). In case of a
% polygon, e2n is structure
% array rather than an
% integer array. In the
% structure e2n(icell).nodes
% give the 1D array of node
% numbers for each cell
% number icell, where
% 1<=icell<=NumElements.
% For triangular or
% quadrilateral elements, e2n
% has size [NE,3] or [NE,4]
% where NE is number of
% elements. Each row
% (row=1:NE) gives 3 or 4
% node numbers of the
% element.
%
% FEsurfaces.f2n ---face to node connectivity list
% This is not required for FETRIANGLE
% and FEQUADRILATERAL, but can
% be provided to speed up tecplot.
% For FEPOLYGON, this IS required
% as polygons have user-defined
% number of nodes and edges(face) for
% each polygonal element.
% f2n is an array of size [NFx2] for
% FETRIANGLE and FEQUADRILATERAL,
% where NF=NE*3 for FETRIANGLE and
% NF=NE*4 for FEQUADRILATERAL, as
% each triangular element has 3 faces
% (edges) and each quadrilateral elem-
% ent has 4 faces (edges).
% For FEPOLYGON, f2n is a 1D structure
% array of size [NFx1], and
% f2n(iface).nodes(1:2) gives the node
% numbers of face number iface.
% 1<=iface<=NF. NF is total number of
% faces.
% ***f2n is not yet implemented***
%
% FEsurfaces.varloc ---location of variable (0-nodal)
% 1-cell center (center of element))
% FEsurfaces.v ---value of each variable(nodal or cell)
% 2D [nv,Nne]. where nv is number
% of variables in v, Nne=Nn
% if nodal. Nne=Ne if cell-center
% Nn is number of nodes
% Ne is number of elements
%
% FEsurfaces.x ---x coordinate (1D array)
% FEsurfaces.y ---y coordinate (1D array)
% FEsurfaces.z ---z coordinate (1D array)
%
% FEsurfaces.order ---order of each surface,
% 3 : 2D surface defined on (x,y)
% z=f(x,y),v=f(x,y),z is set
% to zero if not given
% 2 : 2D surface defined on (x,z)
% y=f(x,z),v=f(x,z),y is set
% to zero if not given
% 1: 2D surface defined on (y,z)
% x=f(y,z),v=f(y,z), x is
% set to zero if not given
% 4: 3D surface defined on (x,y,z)
% v=f(x,y,z)
% Default is 4.
%
% FEsurfaces.auxname ---auxiliary variable name
% (cell array of strings or single
% string)
% FEsurfaces.auxval ---auxiliary variable value
% (cell array of strings or single
% string)
% FEsurfaces.datapacking --- is it block or point
% (deprecated and set to
% zero by default)
% FEsurfaces.strandID ---strandID of the zone.
% Optional, default = -2
% FEsurfaces.solutiontime --- solution time
% associated with the zone
% Optional, default =0
%
% tdata.FEvolumes ---an array of finite element 3D volume data with
% tetrahedron elements (4 points per element) or
% brick elements (8 points per element) defined on 3D
% XYZ coordinates. Each finite element volume is
% treated as a zone. FEvolumes contain the
% following information to define the zones:
%
%
% FEvolumes.e2n ---element connectivity list. For
% each element, it consists of
% 4 (tetrahedron)
% or 8 (brick) node numbers.
% For FEPOLYHEDRON elements,
% e2n is a structure vector,
% with e2n(icell).nodes
% storing node numbers of
% element indexed by icell.
%
% FEvolumes.f2n ---face to node connectivity list
% This is not required for FETETRAHEDRON
% FEBRICK, but can be provided to
% speed up tecplot.
% For FEPOLYHEDRON, this IS required
% as polyhedrons have user-defined
% number of nodes and faces for
% each polyhedron element.
% f2n is an array of size [NFx3] for
% FETETRAHEDRON and [NFx4] for
% FEBRICK,
% where NF=NE*4 for FETETRAHEDRON and
% NF=NE*6 for FEBRICK, as
% each tetrahedron element has 4 faces
% and each quadrilateral (brick) elem-
% ent has 6 faces. Each face has
% 3 nodes for FETETRAHEDRON and 4 nodes
% for FEBRICK.
% For FEPOLYHEDRON, f2n is a 1D structure
% array of size [NFx1], and
% f2n(iface).nodes(1:NNOF) gives the node
% numbers of face number iface.
% 1<=iface<=NF. NF is total number of
% faces. Where NNOF is number of nodes
% on face number iface.
% ****f2n is not yet implemented*****
%
% FEvolumes.varloc ---location of variable (0-nodal,
% 1-cell center)
% FEvolumes.v ---value of each variable(nodal or cell)
% 2D [nv,Nne]. where nv is number
% of variables in v, Nne=Nn
% if nodal. Nne=Ne if cell-center
% Nn is number of nodes
% Ne is number of elements
%
% FEvolumes.x ---x coordinate of each node
% FEvolumes.y ---y coordinate of each node
% FEvolumes.z ---z coordinate of each node
% FEvolumes.auxname ---auxiliary variable name
% (cell array of strings or single
% string)
% FEvolumes.auxval ---auxiliary variable value
% (cell array of strings or single
% string)
% FEvolumes.datapacking --- is it block or point
% (deprecated and set to
% zero by default)
% FEvolumes.strandID --- standID associated with
% the zone (Optional), Default
% is -2
% FEvolumes.solutiontime --- solutiontime associated with
% the zone. (Optional)
%
%
% tdata.texts --- a structure arry of texts that can coexsist with the
% zones. Each element of texts is treated
% as a text record (similar to zone). Each text
% record can be associated with a zone. texts
% contain the following information to define the
% text records:
%
% texts.str --- string value of the text
% Must have it.
% Multiple line text
% is given by 'line1 \n
% line2' with "\n" separating
% different lines
%
% texts.cs ---coordinate system of the text
% 0= Grid,
% 1= Frame,
% 2= FrameOffset(not used)
% 3= OldWindow(not used)
% 4= Grid3D(New to V10)
% Default is 0
% texts.scope ---scope of the text
% 0-global, 1-local
% Default is 0.
%
% texts.x -- x coordinate of
% starting location
% texts.y -- y coordinate of
% starting location
% texts.z -- z coordinate of starting
% location (Default to zero)
% Only used for Grid3D coordiante
% system
% texts.theta -- polar angle of starting location
% when x is not given
% texts.r -- polar radius of starting location
% when y is not given
% texts.fonttype-- Font of the text
% 0-Font_Helvetica,
% 1-Font_HelveticaBold,
% 2-Font_Greek,
% 3-Font_Math,
% 4-Font_UserDefined,
% 5-Font_Times,
% 6-Font_TimesItalic,
% 7-Font_TimesItalicBold,
% 8-Font_TimesBold,
% 9-Font_Courier,
% 10-Font_CourierBold
% Default is 5
% texts.charheightunit
% -- unit of font size
% 0-grid, 1-frame, 2-Point
% Default is Point
% texts.charheight -- height of the characters
% Default is 12. E.g. 12 Point
% if charheightunit is 2
% texts.boxtype -- to draw box around text
% 0-NOBOX, 1-FILLED, 2-HOLLOW
% Default is 0
%
% texts.boxmargin ---margin of text box
% Default is 1
% texts.boxlinewidth ---line thickness
% Default is 1
% texts.boxlinecolor ---outline color of box
% Default is 0 (black)
% texts.boxfillcolor ---fill color of box
% Default is 7 (white)
% texts.angle ---angle of texts in degrees
% Default is 0
%
% texts.linespace --- spacing for multi-line
% texts,1-single, 2-double,
% 1.5- one and half, etc
% Multiple line text
% is given by "line1 \\n
% line2" with "\\n" separating
% different lines
% Default is 1
%
% texts.anchor ---position of the anchor point
% There are nine possible
% anchor positions:
% 0=left, 1=center,
% 2=right, 3=midleft,
% 4=midcenter, 5=midright,
% 6=headleft, 7=headcenter,
% 8=headright
% Default is 0
%
% texts.zone ---zone that the text will
% be attached to.
% Defalut is 0 (all)
%
% texts.color --- color of the text
% 0-Black, 1-R, 2-G,3-B
% 4-Cyan 5-Yellow
% 6-Purple,7-White
% Defalut is 0
% texts.clipping --- clipping method
% 0-ClipToAxes
% 1-ClipToViewport
% 2-ClipToFrame
% Default is 0
%
% tdata.geometries --- an array of geometries that can coexist with
% data zones. Each element of geometries array
% is treated as a geometry record. Each geometry
% record can be associated with a zone.
% geometries contain the following information to
% define the geometry records:
%
% geometries.geomtype ---type of geometry
% which can be SQUARE,
% RECTANGLE,CIRCLE,
% ELLIPSE,LINE,LINE3D
% 0=Line, 1=Rectangle
% 2=Square, 3=Circle,
% 4=ellipse,5=Line3D
% Must have. Where
% Line3D is only
% available when
% geometries.cs is Grid3D
%
% geometries.cs --- coordinate system of
% geometry, which can be
% 0= Grid,
% 1= Frame,
% 2= FrameOffset(not used)
% 3= OldWindow(not used)
% 4= Grid3D(New to V10)
% Default is 0
%
% geometries.scope --- Scope of the geometry
% 0-global, 1-local
% Default is 0.
%
% geometries.draworder --- order of drawing
% 0-after, 1-before
% Default is 0.
%
% geometries.zone --- zone number to attach
% geometry to. (0 for all zones)
% Default is 0
%
% geometries.color --- color of the geometry
% 0-Black, 1-Red, 2-Green
% 3-Blue, 4-Cyan, 5-Yellow
% 6-Purple,7-White
% Default is 0.
%
% geometries.fillcolor
% ---fill color of the geometry
% 0-Black,1-Red, 2-Green,
% 3-Blue, 4-Cyan, 5-Yellow,
% 6-Purple,7-White. Default
% is 0.
%
% geometries.isfilled
% ---0 = not filled
% 1 = filled
% Default is 0
%
% geometries.x --- x coordinate of geometry's
% anchor point
% geometries.y --- y coordinate of geometry's
% anchor point
% geometrrie.z --- z coordiante of LINE3D's
% anchor point. Default is 0
% geometries.theta --- angle of polar line
% when x not given
% (used for polar
% coordinate). When both x
% and theta available, x is
% used.
% geometries.r --- radius of polar line
% when y not given
% (used for polar
% coordinate). When both y
% and r available, y is
% used.
% geometries.linepattern
% --- pattern of lines used
% to draw the geometry,
% which can be:
% 0-SOLID, 1-DASHED,
% 2-DOTTED, 3-DASHDOT,
% 4-LONGDASH,
% 6-DASHDOTDOT
% Default is 0
%
% geometries.linethickness --- thickness of
% drawing line in frame units.
% Default is 0.001, i.e. 0.1%
%
% geometries.patternlength --- patternleinght
% in frame units.
% Default is 0.01.
%
% geometries.data ---data array that describes
% the geometry
% for SQUARE - one number of
% side length
% for RECTANGLE - two numbers of
% width and height
% for CIRCLE - one number of radius
%
% for ELLIPSE - two numbers of hor-
% izontal axis and vertical
% axis length
%
% for LINE or LINE3D, the data is a
% colloection of up to 50 polylines
% and each polyline is defined by
% a number of XY or XYZ coordinates
% The cooridnates are relative
% to the anchor point.
%
% % data(iline).x -- x coordinate vector
% % data(iline).y -- y coordinate vector
% % data(ilien).z -- z coordinate vector
% z is only required for LINE3D
%
% geometries.datapacking --point or block
% for POINT, the LINE and LINE3D
% data are written point by point
% for BLOCK, the LINE and LINE3D
% data are written block by block
% (deprecated and set to zero by
% default)
%
% geometries.datatype -- datatype (DT) of the
% point coordinates for LINE and
% LINE3D data. (1-float, 2-double)
% Default 1.
%
% geometries.numellipsepts -- number of points
% used to draw circles and ellipses
% for CIRCLE and ELLIPSE types.
% Default value is 72
%
% geometries.clipping -- method of cliping
% the geometry.
% 0=ClipToAxes
% 1=ClipToViewport
% 2=ClipToFrame
% Default is 0
%
% Following are only related to LINE geometry
% geometries.arrowheadstyle ---0-plain
% 1-hollow
% 2-filled
% Default 0
% geometries.arrowheadattach ---0-none
% 1-beginning
% 2-end
% 3-both
% Default 0
% geometries.arrowheadsize ---size of arrow
% head in frame units
% Default 0.01
% geometries.arrowheadangle ---angle of arrow head
% in degrees. Default 0
%
%
% tdata.customlabels --- cell array of custom labels for axis, contour
% legend, value or node labels etc.
%
% tdata.auxdata --- Meta data structure array that are used to
% describe the whole dataset file.
%
% auxdata.name ---name of an aux data
% auxdata.value ---value of an aux data
% (string only).
%
% Input:
% tdata --- A structure that contains all kinds of data structure
% that tecplot can visualize
% tecfile --- filename to be created.
%
% Output:
%
% s --- 0 if successful
% -1 if unsuccessful
%
% Example 1: generate a 3D line in (x,y,z) with temperature
% T defined on (x,y,z)
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.lines(1).zonename='myline zone'
% tdata.lines(1).x=[1,2,3,4,5,6,7,8,9,10];
% tdata.lines(1).y=[1,2,3,4,5,6,7,8,9,10]+10;
% tdata.lines(1).z=[1,2,3,4,5,6,7,8,9,10]+1;
% tdata.lines(1).v(1,:)=[10,20,30,30,20,10,10,10,20,20];
% mat2tecplot(tdata,'myline3D.plt')
%
% Example 2: generate a 2D line in (x,y) with temperaature T deined on
% (x,y)
% tdata=[];
% tdata.Nvar=3;
% tdata.varnames={'x','y','T'};
% tdata.lines(1).zonename='myline zone';
% tdata.lines(1).x=[1,2,3,4,5,6,7,8,9,10];
% tdata.lines(1).y=[1,2,3,4,5,6,7,8,9,10]+10;
% tdata.lines(1).v(1,:)=[10,20,30,30,20,10,10,10,20,20];
% mat2tecplot(tdata,'myline2DT_xy.plt')
%
% Example 3: generate a 2D surface in (x,y) with temperaature T deined on
% (x,y)
% tdata=[];
% tdata.Nvar=4; %z is set to zero automatically
% %even z dos not exit in surfaces(1) below
% %it has to be accounted in Nvar and
% %varnames
% tdata.varnames={'x','y','z','T'};
% tdata.surfaces(1).zonename='mysurface zone';
% tdata.surfaces(1).x=[1,2,3;1,2,3;1,2,3]; %size 3x3
% tdata.surfaces(1).y=[1,1,1;2,2,2;3,3,3]; %size 3x3
% tdata.surfaces(1).v(1,:,:)=[10,20,30;30,20,10;10,10,20];
% mat2tecplot(tdata,'mysurf2DT_xy.plt')
%
% Example 4: generate a 2D surface in (x,z) with temperaature T deined on
% (x,z)
% tdata=[];
% tdata.Nvar=4; %z is set to zero automatically
% %even z dos not exit in surfaces(1) below
% %it has to be accounted in Nvar and
% %varnames
% tdata.varnames={'x','y','z','T'};
% tdata.surfaces(1).zonename='mysurface zone';
% tdata.surfaces(1).x=[1,2,3;1,2,3;1,2,3]; %size 3x3
% tdata.surfaces(1).z=[1,1,1;2,2,2;3,3,3]; %size 3x3
% tdata.surfaces(1).v(1,:,:)=[10,20,30;30,20,10;10,10,20];
% tdata.surfaces(1).order=2; %order of surface is 2
% %with (x,z) being coordinate
% %variables
% mat2tecplot(tdata,'mysurf2DT_xz.plt')
%
% %Now re-do it with T defined on cell center only
% tdata.surfaces(1).v=[];
% tdata.surfaces(1).v(1,:,:)=[10,20;30 10]; %only 2x2 elements
% %[Imax-1,Kmax-1]
% tdata.surfaces(1).varloc=1; %specify variable at cell center
% mat2tecplot(tdata,'mysurf2DT_xz_cellcenter.plt')
%
%
% Example 5: Combine Example 3 and 4, 2 surfaces, one in (x,y) plane
% (ordre 3 by default), the other in (x,z) plane (order =2).
% And add a third surface in (y,z) plane (order =1).
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.surfaces(1).zonename='mysurface zone1';
% tdata.surfaces(1).x=[1,2,3;1,2,3;1,2,3]; %size 3x3
% tdata.surfaces(1).y=[1,1,1;2,2,2;3,3,3]; %size 3x3
% tdata.surfaces(1).v(1,:,:)=[10,20,30;30,20,10;10,10,20];
% tdata.surfaces(1).strandID=1;
% tdata.surfaces(2).zonename='mysurface zone2';
% tdata.surfaces(2).x=[1,2,3;1,2,3;1,2,3]; %size 3x3
% tdata.surfaces(2).z=[1,1,1;2,2,2;3,3,3]; %size 3x3
% tdata.surfaces(2).v(1,:,:)=[10,20,30;30,20,10;10,10,20];
% tdata.surfaces(2).strandID=2;
% tdata.surfaces(2).order=2; %order of surface is 2
% %with (x,z) being coordinate
% %variables
% tdata.surfaces(3).zonename='mysurface zone3';
% tdata.surfaces(3).y=[1,2,3;1,2,3;1,2,3]; %size 3x3
% tdata.surfaces(3).z=[1,1,1;2,2,2;3,3,3]; %size 3x3
% tdata.surfaces(3).v(1,:,:)=[10,20,30;30,20,10;10,10,20];
% tdata.surfaces(3).strandID=3;
% tdata.surfaces(3).order=1; %order of surface is 2
% %with (x,z) being coordinate
% %variables
% mat2tecplot(tdata,'mysurf2DT_xy_xz_yz.plt')
%
% Example 6: A 3D Finite Element line defined by (x,y,z) and temperature
% T on the line
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.FElines(1).zonename='mysurface zone';
% tdata.FElines(1).x=[0,1,1,1]; %line made of 4 points (nodes)
% tdata.FElines(1).y=[0,0,1,1];
% tdata.FElines(1).z=[0,0,0,1];
% tdata.FElines(1).v(1,:)=[10,20,30,10];%temperature on 4 nodes
% tdata.FElines(1).e2n=[1,2;2,3;3,4]; %element connectivity
% %of 3 elements (line
% %segment), each row
% %gives the two node
% %points of an element
% mat2tecplot(tdata,'myFEline3D.plt')
%
% Example 7: a 2D Finite Element surface defiend in (x,y) plane, with
% Temperature data on it. T=T(x,y)
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.FEsurfaces(1).zonename='my surface zone';
% tdata.FEsurfaces(1).x=[0,1,0.5]; %triangle of 3 points
% tdata.FEsurfaces(1).y=[0,0,1];
% tdata.FEsurfaces(1).order=3; %surface defiend on (x,y) coord
% tdata.FEsurfaces(1).e2n(1,:)=[1,2,3]; %only one element
% %one row of 3
% %node numbers
% tdata.FEsurfaces(1).v(1,:)=[10,20,30]; %temperature on 3 nodes
% mat2tecplot(tdata,'myFEsurface_xy.plt')
%
% Example 8: a 2D Finite Element (triangle) defined in (y,z) plane with
% Temperature data on it T=T(y,z)
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.FEsurfaces(1).zonename='my surface zone';
% tdata.FEsurfaces(1).y=[1,2,2.5,3.5,4]; %totally 5 nodes
% tdata.FEsurfaces(1).z=[1,3,1,5,1];
% tdata.FEsurfaces(1).order=1; %surface defiend on (y,z) coord
% tdata.FEsurfaces(1).e2n=[1,2,3;3,2,4;3,5,4];%3 elements(row)
% %each with 3 node numbers
% %(column)
% tdata.FEsurfaces(1).v(1,:)=[10,20,30,10,10];
% %temperature on 5 nodes
% %only one row (temperatue)
% %each row has 5 columns
% mat2tecplot(tdata,'myFEsurface_yz.plt')
%
% %now re-do it with T defined on cell centers only:
% tdata.FEsurfaces(1).v=[];
% tdata.FEsurfaces(1).v(1,:)=[10,20,30]; %only 3 elements
% tdata.FEsurfaces(1).varloc=1; %specify variable location at cell
% %center
% mat2tecplot(tdata,'myFEsurface_yz_cellcenter.plt')
%
% Example 9: a 3D Finite Element brick with 12 nodes, 2 elements, and
% temperature T=T(x,y,z)
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.FEvolumes(1).zonename='my FE volume zone';
% tdata.FEvolumes(1).x=[0,3,6,0,3,6,0,3,6,0,3,6]; %totally 12 nodes
% tdata.FEvolumes(1).y=[0,0,0,6,6,6,0,0,0,6,6,6];
% tdata.FEvolumes(1).z=[0,1,3,3,4,6,8,9,11,11,12,14];
% tdata.FEvolumes(1).e2n=[1,2,8,7,4,5,11,10;2,3,9,8,5,6,12,11];
% %2 elements(row)
% %each with 8 node numbers
% %(column)
% tdata.FEvolumes(1).v(1,:)=[10,20,30,10,10,20,10,10,20,30,10,10];
% %temperature on 12 nodes
% %only one row (temperatue)
% %each row has 12 columns
% mat2tecplot(tdata,'myFEvolume_brick.plt')
%
% Exampple 10: Same as Example 9, but using IJK-ordered (cube) zonetype
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.cubes(1).zonename='my IJK volume zone';
% %totally 12 nodes [3x2x2]
% tdata.cubes(1).x=reshape([0,3,6,0,3,6,0,3,6,0,3,6],[3,2,2]);
% tdata.cubes(1).y=reshape([0,0,0,6,6,6,0,0,0,6,6,6],[3,2,2]);
% tdata.cubes(1).z=reshape([0,1,3,3,4,6,8,9,11,11,12,14],[3,2,2]);
% tdata.cubes(1).v(1,:,:,:)=reshape([10,20,30,10,10,20,10,10,20,30,10,10],[3,2,2]);
% mat2tecplot(tdata,'mycube_IJK_order.plt')
%
% Exampple 11: Same as Example 10, but temperature T is cell-centered
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.cubes(1).zonename='my IJK volume zone';
% %totally 12 nodes [3x2x2]
% tdata.cubes(1).x=reshape([0,3,6,0,3,6,0,3,6,0,3,6],[3,2,2]);
% tdata.cubes(1).y=reshape([0,0,0,6,6,6,0,0,0,6,6,6],[3,2,2]);
% tdata.cubes(1).z=reshape([0,1,3,3,4,6,8,9,11,11,12,14],[3,2,2]);
% tdata.cubes(1).v(1,:,:,:)=reshape([10,20],[2,1,1]);
% tdata.cubes(1).varloc=1; %variables are provided
% %at cell centers (center of elements)
% %i.e. v has size [Imax-1,Jmax-1,Kmax-1]
% %==[3,1,1]
% mat2tecplot(tdata,'mycube_IJK_order_cellcenter.plt')
%
% Example 12: a 3D Finite Element Tetrhedron with 4 nodes, 1 element, and
% T=T(x,y,z)
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.FEvolumes(1).zonename='my FE volume zone';
% tdata.FEvolumes(1).x=[0,1,0.5,0.5]; %tetrahedron of 4 points
% tdata.FEvolumes(1).y=[0,0,1 ,0.5];
% tdata.FEvolumes(1).z=[0,0,0 ,1 ];
% tdata.FEvolumes(1).e2n(1,:)=[1,2,3,4]; %1 elements(row)
% %each with 4 node numbers
% %(column)
% tdata.FEvolumes(1).v(1,:)=[10,20,30,10]; %T on 4 nodes
% %only one row (temperatue)
% %each row has 4 columns
% mat2tecplot(tdata,'myFEvolume_tetrahedron.plt')
%
% Example 13: Same as Example 12, a 3D Finite Element Tetrhedron with
% 4 nodes, 1 element, and T=T(x,y,z), but T is cell-centered
%
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.FEvolumes(1).zonename='my FE volume zone';
% tdata.FEvolumes(1).x=[0,1,0.5,0.5]; %tetrahedron of 4 points
% tdata.FEvolumes(1).y=[0,0,1 ,0.5];
% tdata.FEvolumes(1).z=[0,0,0 ,1 ];
% tdata.FEvolumes(1).e2n(1,:)=[1,2,3,4]; %1 elements(row)
% %each with 4 node numbers
% %(column)
% tdata.FEvolumes(1).v(1,:)=[15]; %T on 1 element center
% %Only one variable (row)
% %only one element (column)
% tdata.FEvolumes(1).varloc=1; %variables are cell-centered
% mat2tecplot(tdata,'myFEvolume_tetrahedron_cellcenter.plt')
%
% Example 14: A tetramesh example.
%
% d = [-1 1];
% [x,y,z] = meshgrid(d,d,d); % A cube
% x = [x(:);0]; % [x,y,z] are corners of a cube plus the center.
% y = [y(:);0];
% z = [z(:);0];
% dt = DelaunayTri(x,y,z);
% Tes = dt(:,:); %Tes gives connectivity of the tetrahedrons
% X = [x(:) y(:) z(:)];
% tetramesh(Tes,X);camorbit(20,0)
% tdata=[];
% tdata.Nvar=4;
% tdata.varnames={'x','y','z','T'};
% tdata.FEvolumes(1).zonename='my tetra mesh zone';
% tdata.FEvolumes(1).x=x';
% tdata.FEvolumes(1).y=y';
% tdata.FEvolumes(1).z=z';
% %temperature