-
Notifications
You must be signed in to change notification settings - Fork 0
/
lang.py
2137 lines (1737 loc) · 55.8 KB
/
lang.py
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
# BlenderFDS, an open tool for the NIST Fire Dynamics Simulator
# Copyright (C) 2013 Emanuele Gissi, http://www.blenderfds.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re, os.path, time, sys, logging
import bpy
from bpy.types import (
bpy_struct,
PropertyGroup,
UIList,
Operator,
Object,
Scene,
Material,
Collection,
)
from bpy.props import (
BoolProperty,
FloatProperty,
IntProperty,
IntVectorProperty,
StringProperty,
PointerProperty,
EnumProperty,
CollectionProperty,
)
from . import geometry
from .types import BFException, Parameter, Namelist, PString, PFYI, POthers
from .config import separator, comment, default_mas
from . import gis
log = logging.getLogger(__name__)
# Collections
namelists = dict()
params = dict()
bl_classes = list()
bf_classes = list()
def subscribe(cls):
"""Subscribe class to related collection."""
if issubclass(cls, Namelist):
namelists[cls.__name__] = cls
elif issubclass(cls, Parameter):
params[cls.__name__] = cls
elif issubclass(cls, bpy_struct):
bl_classes.append(cls)
else:
bf_classes.append(cls)
return cls
# PropertyGroup and UIList
@subscribe
class WM_PG_bf_others(PropertyGroup):
bf_export: BoolProperty(name="Export", default=False)
name: StringProperty(name="Name")
@subscribe
class WM_UL_bf_others_items(UIList):
def draw_item(self, context, layout, data, item, icon, active_data):
col = layout.column()
col.active = item.bf_export
col.prop(item, "name", text="", emboss=False, icon_value=icon)
col = layout.column()
col.prop(item, "bf_export", text="")
@subscribe
class WM_PG_bf_filepaths(PropertyGroup):
bf_export: BoolProperty(name="Export", default=False)
name: StringProperty(name="Name", subtype="FILE_PATH")
@subscribe
class WM_UL_bf_filepaths_items(UIList):
def draw_item(self, context, layout, data, item, icon, active_data):
col = layout.column()
col.active = item.bf_export
col.prop(item, "name", text="", emboss=False, icon_value=icon)
col = layout.column()
col.prop(item, "bf_export", text="")
# HEAD
@subscribe
class SP_HEAD_CHID(Parameter):
label = "CHID"
description = "Case identificator"
fds_label = "CHID"
bf_other = {"copy_protect": True}
bpy_type = Scene
bpy_idname = "name"
def check(self, context):
value = self.element.name
if value and bpy.path.clean_name(value) != value:
raise BFException(self, "Illegal characters in case filename")
@subscribe
class SP_HEAD_TITLE(PFYI):
label = "TITLE"
description = "Case description"
fds_label = "TITLE"
bpy_type = Scene
bpy_idname = "bf_head_title"
bpy_other = {"maxlen": 64}
@subscribe
class SN_HEAD(Namelist):
label = "HEAD"
description = "Case header"
enum_id = 3001
fds_label = "HEAD"
bpy_type = Scene
bpy_export = "bf_head_export"
bpy_export_default = True
param_cls = SP_HEAD_CHID, SP_HEAD_TITLE
# Case Config
@subscribe
class SP_config_directory(Parameter):
label = "Case Directory"
description = "Destination directory for exported case"
bpy_type = Scene
bpy_idname = "bf_head_directory"
bpy_prop = StringProperty
bpy_other = {"subtype": "DIR_PATH", "maxlen": 1024}
def check(self, context):
value = self.element.bf_head_directory
if value and not os.path.exists(bpy.path.abspath(value)):
raise BFException(self, "Case directory path not existing")
@subscribe
class SP_config_min_edge_length(Parameter):
label = "Min Edge Length"
description = "Min allowed edge length"
bpy_type = Scene
bpy_idname = "bf_config_min_edge_length"
bpy_prop = FloatProperty
bpy_default = 1e-05
bpy_other = {"unit": "LENGTH"}
@subscribe
class SP_config_min_face_area(Parameter):
label = "Min Face Area"
description = "Min allowed face area"
bpy_type = Scene
bpy_idname = "bf_config_min_face_area"
bpy_prop = FloatProperty
bpy_default = 1e-05
bpy_other = {"unit": "AREA"}
@subscribe
class SP_config_default_voxel_size(Parameter):
label = "Voxel/Pixel Size"
description = "Default voxel/pixel resolution"
bpy_type = Scene
bpy_idname = "bf_default_voxel_size"
bpy_prop = FloatProperty
bpy_default = 0.1
bpy_other = {"unit": "LENGTH", "step": 1.0, "precision": 3}
@subscribe
class SP_crs(Parameter):
label = "Coordinate Reference System"
description = "Coordinate reference system"
bpy_type = Scene
bpy_idname = "bf_crs"
bpy_prop = EnumProperty
bpy_default = "LonLat"
bpy_other = {
"items": (
(
"LonLat",
"WGS84 Lon/Lat",
"Decimal degrees longitude/latitude geographic coordinates\nwith WGS84 coordinate reference system",
),
(
"UTM",
"WGS84 UTM",
"Universal Transverse Mercator projected coordinates\nwith WGS84 coordinate reference system",
),
)
}
def update_lonlat(self, context):
sc = context.scene
utm = gis.LonLat(sc.bf_lon, sc.bf_lat).to_UTM()
sc["bf_utm_zn"] = utm.zn # avoid triggering another update
sc["bf_utm_ne"] = utm.ne
sc["bf_utm_easting"] = utm.easting
sc["bf_utm_northing"] = utm.northing
def update_utm(self, context):
sc = context.scene
lonlat = gis.UTM(
sc.bf_utm_zn, sc.bf_utm_ne, sc.bf_utm_easting, sc.bf_utm_northing
).to_LonLat()
sc["bf_lon"] = lonlat.lon # avoid triggering another update
sc["bf_lat"] = lonlat.lat
@subscribe
class SP_geoname(Parameter):
label = "Origin Geoname"
description = "Origin location geographic name"
bpy_type = Scene
bpy_idname = "bf_geoname"
bpy_prop = StringProperty
bpy_default = "Monte di Portofino, Genova, Italy"
@subscribe
class SP_lon(Parameter):
label = "Origin Longitude"
description = "Longitude (WGS84, EPSG:4326) of world origin in decimal degrees"
bpy_type = Scene
bpy_idname = "bf_lon"
bpy_prop = FloatProperty
bpy_default = 9.1688903
bpy_other = {"min": -180.0, "max": 180.0, "precision": 9, "update": update_lonlat}
@subscribe
class SP_lat(Parameter):
label = "Origin Latitude"
description = "Latitude (WGS84, EPSG:4326) of world origin in decimal degrees"
bpy_type = Scene
bpy_idname = "bf_lat"
bpy_prop = FloatProperty
bpy_default = 44.3267618
bpy_other = {"min": -80.0, "max": 84.0, "precision": 9, "update": update_lonlat}
@subscribe
class SP_utm_zn(Parameter):
label = "Origin UTM Zone Number"
description = "UTM Zone Number (WGS84) of world origin"
bpy_type = Scene
bpy_idname = "bf_utm_zn"
bpy_prop = IntProperty
bpy_default = 32
bpy_other = {"min": 1, "max": 60, "update": update_utm}
@subscribe
class SP_utm_ne(Parameter):
label = "Origin UTM Northern Emisphere"
description = "UTM northern emisphere (WGS84) of world origin"
bpy_type = Scene
bpy_idname = "bf_utm_ne"
bpy_prop = BoolProperty
bpy_default = True # Monte Fasce, Genova, Italy
bpy_other = {"update": update_utm}
@subscribe
class SP_utm_easting(Parameter):
label = "Origin UTM Easting"
description = "UTM easting (WGS84) of world origin"
bpy_type = Scene
bpy_idname = "bf_utm_easting"
bpy_prop = FloatProperty
bpy_default = 513466.0
bpy_other = {"unit": "LENGTH", "update": update_utm, "min": 0, "max": 1000000}
@subscribe
class SP_utm_northing(Parameter):
label = "Origin UTM Northing"
description = "UTM northing (WGS84) of world origin"
bpy_type = Scene
bpy_idname = "bf_utm_northing"
bpy_prop = FloatProperty
bpy_default = 4908185.0
bpy_other = {"unit": "LENGTH", "update": update_utm, "min": 0, "max": 10000000}
@subscribe
class SP_elevation(Parameter):
label = "Origin Elevation"
description = "Elevation of world origin"
bpy_type = Scene
bpy_idname = "bf_elevation"
bpy_prop = FloatProperty
bpy_default = 610.0
bpy_other = {"unit": "LENGTH", "precision": 4}
@subscribe
class SN_config(Namelist):
label = "Config"
description = "Case configuration"
enum_id = 3008
bpy_type = Scene
def draw(self, context, layout):
sc = self.element
col = layout.column()
col.prop(sc, "bf_head_directory")
col.separator()
row = col.row()
row.prop(sc, "bf_crs", text="Coordinate Ref Sys")
url = gis.LonLat(lon=sc.bf_lon, lat=sc.bf_lat).to_url()
row.operator("wm.url_open", text="", icon="URL").url = url
sub = col.column(align=True)
sub.prop(sc, "bf_geoname", text="Origin Geoname")
if sc.bf_crs == "LonLat":
sub.prop(sc, "bf_lon", text="Longitude")
sub.prop(sc, "bf_lat", text="Latitude")
else:
row = sub.row(align=True)
row.prop(sc, "bf_utm_zn", text="UTM Zone")
row.prop(sc, "bf_utm_ne", text="N", toggle=1)
row.prop(sc, "bf_utm_ne", text="S", toggle=1, invert_checkbox=True)
sub.prop(sc, "bf_utm_easting", text="Easting")
sub.prop(sc, "bf_utm_northing", text="Northing")
sub.prop(sc, "bf_elevation", text="Elevation")
col.separator()
col.prop(sc, "bf_config_min_edge_length")
col.prop(sc, "bf_config_min_face_area")
col.prop(sc, "bf_default_voxel_size")
col.separator()
unit = sc.unit_settings
col.prop(unit, "system")
col = col.column()
col.enabled = unit.system != "NONE"
col.prop(unit, "scale_length")
col.prop(unit, "use_separate")
col.prop(unit, "length_unit", text="Length")
# col.prop(unit, "mass_unit", text="Mass") # Unused
col.prop(unit, "time_unit", text="Time")
def to_fds(self, context):
return
# TIME
@subscribe
class SP_TIME_setup_only(Parameter):
label = "Smokeview Geometry Setup"
description = "Set Smokeview to setup only geometry"
bpy_type = Scene
bpy_idname = "bf_time_setup_only"
bpy_prop = BoolProperty
bpy_default = False
@subscribe
class SP_TIME_T_BEGIN(Parameter):
label = "T_BEGIN [s]"
description = "Simulation starting time"
fds_label = "T_BEGIN"
fds_default = 0.0
bpy_type = Scene
bpy_idname = "bf_time_t_begin"
bpy_prop = FloatProperty
bpy_other = {"unit": "TIME", "step": 100.0, "precision": 1}
@property
def exported(self):
return super().exported and not self.element.bf_time_setup_only
@subscribe
class SP_TIME_T_END(Parameter):
label = "T_END [s]"
description = "Simulation ending time"
fds_label = "T_END"
bpy_type = Scene
bpy_idname = "bf_time_t_end"
bpy_prop = FloatProperty
bpy_default = 1.0
bpy_other = {"unit": "TIME", "step": 100.0, "precision": 1}
@property
def exported(self):
return super().exported and not self.element.bf_time_setup_only
@subscribe
class SP_TIME_other(POthers):
bpy_type = Scene
bpy_idname = "bf_time_others"
bpy_pg = WM_PG_bf_others
bpy_ul = WM_UL_bf_others_items
@subscribe
class SN_TIME(Namelist):
label = "TIME"
description = "Simulation time settings"
enum_id = 3002
fds_label = "TIME"
bpy_type = Scene
bpy_export = "bf_time_export"
bpy_export_default = True
param_cls = SP_TIME_T_BEGIN, SP_TIME_T_END, SP_TIME_other
def draw(self, context, layout):
sc = self.element
layout.prop(sc, "bf_time_setup_only")
sub = layout.column()
sub.active = not sc.bf_time_setup_only
SP_TIME_T_BEGIN(sc).draw(context, sub)
SP_TIME_T_END(sc).draw(context, sub)
SP_TIME_other(sc).draw(context, layout)
# MISC
@subscribe
class SP_MISC_FYI(PFYI):
bpy_type = Scene
bpy_idname = "bf_misc_fyi"
@subscribe
class SP_MISC_OVERWRITE(Parameter):
label = "OVERWRITE"
description = "Do not check for the existence of CHID.out and overwrite files"
fds_label = "OVERWRITE"
fds_default = True
bpy_type = Scene
bpy_prop = BoolProperty
bpy_idname = "bf_misc_overwrite"
@subscribe
class SP_MISC_THICKEN_OBSTRUCTIONS(Parameter):
label = "THICKEN_OBSTRUCTIONS"
description = "Do not allow thin sheet obstructions"
fds_label = "THICKEN_OBSTRUCTIONS"
fds_default = False
bpy_type = Scene
bpy_prop = BoolProperty
bpy_idname = "bf_misc_thicken_obstructions"
@subscribe
class SP_MISC_other(POthers):
bpy_type = Scene
bpy_idname = "bf_misc_others"
bpy_pg = WM_PG_bf_others
bpy_ul = WM_UL_bf_others_items
@subscribe
class SN_MISC(Namelist):
label = "MISC"
description = "Miscellaneous parameters"
enum_id = 3003
fds_label = "MISC"
bpy_type = Scene
bpy_export = "bf_misc_export"
bpy_export_default = False
param_cls = (
SP_MISC_FYI,
SP_MISC_OVERWRITE,
SP_MISC_THICKEN_OBSTRUCTIONS,
SP_MISC_other,
)
# REAC
@subscribe
class SP_REAC_FUEL(PString):
label = "FUEL"
description = "Identificator of fuel species"
fds_label = "FUEL"
bpy_type = Scene
bpy_idname = "bf_reac_fuel"
@subscribe
class SP_REAC_FYI(PFYI):
bpy_type = Scene
bpy_idname = "bf_reac_fyi"
@subscribe
class SP_REAC_FORMULA(PString):
label = "FORMULA"
description = "Chemical formula of fuel species, it can only contain C, H, O, or N"
fds_label = "FORMULA"
bpy_type = Scene
bpy_idname = "bf_reac_formula"
bpy_export = "bf_reac_formula_export"
bpy_export_default = True
@subscribe
class SP_REAC_CO_YIELD(Parameter):
label = "CO_YIELD [kg/kg]"
description = "Fraction of fuel mass converted into carbon monoxide"
fds_label = "CO_YIELD"
fds_default = 0.0
bpy_type = Scene
bpy_prop = FloatProperty
bpy_idname = "bf_reac_co_yield"
bpy_other = {"step": 1.0, "precision": 3, "min": 0.0, "max": 1.0}
bpy_export = "bf_reac_co_yield_export"
bpy_export_default = False
@subscribe
class SP_REAC_SOOT_YIELD(SP_REAC_CO_YIELD):
label = "SOOT_YIELD [kg/kg]"
description = "Fraction of fuel mass converted into smoke particulate"
fds_label = "SOOT_YIELD"
bpy_type = Scene
bpy_idname = "bf_reac_soot_yield"
bpy_export = "bf_reac_soot_yield_export"
bpy_export_default = False
@subscribe
class SP_REAC_HEAT_OF_COMBUSTION(Parameter):
label = "HEAT_OF_COMBUSTION [kJ/kg]"
description = "Fuel heat of combustion"
fds_label = "HEAT_OF_COMBUSTION"
fds_default = 0.0
bpy_type = Scene
bpy_idname = "bf_reac_heat_of_combustion"
bpy_prop = FloatProperty
bpy_other = {"precision": 1, "min": 0.0}
bpy_export = "bf_reac_heat_of_combustion_export"
bpy_export_default = False
@subscribe
class SP_REAC_IDEAL(Parameter):
label = "IDEAL"
description = "Set ideal heat of combustion"
fds_label = "IDEAL"
fds_default = False
bpy_type = Scene
bpy_prop = BoolProperty
bpy_idname = "bf_reac_ideal"
@subscribe
class SP_REAC_other(POthers):
bpy_type = Scene
bpy_idname = "bf_reac_others"
bpy_pg = WM_PG_bf_others
bpy_ul = WM_UL_bf_others_items
@subscribe
class SN_REAC(Namelist):
label = "REAC"
description = "Reaction"
enum_id = 3004
fds_label = "REAC"
bpy_type = Scene
bpy_export = "bf_reac_export"
param_cls = (
SP_REAC_FUEL,
SP_REAC_FYI,
SP_REAC_FORMULA,
SP_REAC_CO_YIELD,
SP_REAC_SOOT_YIELD,
SP_REAC_HEAT_OF_COMBUSTION,
SP_REAC_IDEAL,
SP_REAC_other,
)
# RADI
@subscribe
class SP_RADI_FYI(PFYI):
bpy_type = Scene
bpy_idname = "bf_radi_fyi"
@subscribe
class SP_RADI_RADIATION(Parameter):
label = "RADIATION"
description = "Turn on/off the radiation solver"
fds_label = "RADIATION"
fds_default = True
bpy_type = Scene
bpy_prop = BoolProperty
bpy_idname = "bf_radi_radiation"
@subscribe
class SP_RADI_RADIATIVE_FRACTION(Parameter):
label = "RADIATIVE_FRACTION"
description = (
"Fraction of the total combustion energy that is released "
"in the form of thermal radiation"
)
fds_label = "RADIATIVE_FRACTION"
fds_default = 0.35
bpy_type = Scene
bpy_idname = "bf_radi_radiative_fraction"
bpy_prop = FloatProperty
bpy_other = {"precision": 2, "min": 0.0, "max": 1.0}
@subscribe
class SP_RADI_NUMBER_RADIATION_ANGLES(Parameter):
label = "NUMBER_RADIATION_ANGLES"
description = "Number of angles for spatial resolution of radiation solver"
fds_label = "NUMBER_RADIATION_ANGLES"
fds_default = 100
bpy_type = Scene
bpy_idname = "bf_radi_number_radiation_angles"
bpy_prop = IntProperty
bpy_other = {"min": 1}
@subscribe
class SP_RADI_TIME_STEP_INCREMENT(Parameter):
label = "TIME_STEP_INCREMENT"
description = "Frequency of calls to the radiation solver in time steps"
fds_label = "TIME_STEP_INCREMENT"
fds_default = 3
bpy_type = Scene
bpy_idname = "bf_radi_time_step_increment"
bpy_prop = IntProperty
bpy_other = {"min": 1}
@subscribe
class SP_RADI_ANGLE_INCREMENT(Parameter):
label = "ANGLE_INCREMENT"
description = "Increment over which the angles are updated"
fds_label = "ANGLE_INCREMENT"
fds_default = 5
bpy_type = Scene
bpy_idname = "bf_radi_angle_increment"
bpy_prop = IntProperty
bpy_other = {"min": 1}
@subscribe
class SP_RADI_RADIATION_ITERATIONS(Parameter):
label = "RADIATION_ITERATIONS"
description = "Number of times the radiative intensity is updated in a time step"
fds_label = "RADIATION_ITERATIONS"
fds_default = 1
bpy_type = Scene
bpy_idname = "bf_radi_radiation_iterations"
bpy_prop = IntProperty
bpy_other = {"min": 1}
@subscribe
class SP_RADI_other(POthers):
bpy_type = Scene
bpy_idname = "bf_radi_others"
bpy_pg = WM_PG_bf_others
bpy_ul = WM_UL_bf_others_items
@subscribe
class SN_RADI(Namelist):
label = "RADI"
description = "Radiation parameters"
enum_id = 3006
fds_label = "RADI"
bpy_type = Scene
bpy_export = "bf_radi_export"
bpy_export_default = False
param_cls = (
SP_RADI_FYI,
SP_RADI_RADIATION,
SP_RADI_RADIATIVE_FRACTION,
SP_RADI_NUMBER_RADIATION_ANGLES,
SP_RADI_TIME_STEP_INCREMENT,
SP_RADI_ANGLE_INCREMENT,
SP_RADI_RADIATION_ITERATIONS,
SP_RADI_other,
)
# DUMP
@subscribe
class SP_DUMP_FYI(PFYI):
bpy_type = Scene
bpy_idname = "bf_dump_fyi"
@subscribe
class SP_DUMP_render_file(Parameter):
label = "Export Geometric Description File"
description = "Export geometric description file GE1"
fds_label = "RENDER_FILE"
bpy_type = Scene
bpy_idname = "bf_dump_render_file"
bpy_prop = BoolProperty
bpy_default = True
@property
def value(self):
if self.element.bf_dump_render_file:
return f"{self.element.name}.ge1"
@subscribe
class SP_DUMP_STATUS_FILES(Parameter):
label = "STATUS_FILES"
description = "Export status file (*.notready), deleted when the simulation is completed successfully"
fds_label = "STATUS_FILES"
fds_default = False
bpy_type = Scene
bpy_prop = BoolProperty
bpy_idname = "bf_dump_status_files"
@subscribe
class SP_DUMP_NFRAMES(Parameter):
label = "NFRAMES"
description = "Number of output dumps per calculation"
fds_label = "NFRAMES"
fds_default = 1000
bpy_type = Scene
bpy_idname = "bf_dump_nframes"
bpy_prop = IntProperty
bpy_other = {"min": 1}
@subscribe
class SP_DUMP_set_frequency(Parameter):
label = "Dump Output every 1 s"
description = "Dump output every 1 s"
bpy_type = Scene
bpy_idname = "bf_dump_set_frequency"
bpy_prop = BoolProperty
bpy_default = False
def to_fds(self, context):
return
@subscribe
class SP_DUMP_DT_RESTART(Parameter):
label = "DT_RESTART"
description = "Time interval between restart files are saved"
fds_label = "DT_RESTART"
fds_default = 600
bpy_type = Scene
bpy_idname = "bf_dump_dt_restart"
bpy_prop = IntProperty
bpy_other = {"min": 1}
@subscribe
class SP_DUMP_other(POthers):
bpy_type = Scene
bpy_idname = "bf_dump_others"
bpy_pg = WM_PG_bf_others
bpy_ul = WM_UL_bf_others_items
@subscribe
class SN_DUMP(Namelist):
label = "DUMP"
description = "Output parameters"
enum_id = 3005
fds_label = "DUMP"
bpy_type = Scene
bpy_export = "bf_dump_export"
bpy_export_default = False
param_cls = (
SP_DUMP_FYI,
SP_DUMP_render_file,
SP_DUMP_STATUS_FILES,
SP_DUMP_NFRAMES,
SP_DUMP_set_frequency,
SP_DUMP_DT_RESTART,
SP_DUMP_other,
)
# CATF
# FIXME to_fds
@subscribe
class SP_CATF_check_files(Parameter):
label = "Check File Existance While Exporting"
description = (
"Check file existence and export filepaths relative to the case directory"
)
bpy_type = Scene
bpy_idname = "bf_catf_check_files"
bpy_prop = BoolProperty
bpy_default = True
@subscribe
class SP_CATF_files(POthers): # FIXME
label = "Concatenated Files"
description = "Concatenated files (eg. PROP='/drive/test.catf')"
bpy_type = Scene
bpy_idname = "bf_catf_files"
bpy_pg = WM_PG_bf_filepaths
bpy_ul = WM_UL_bf_filepaths_items
def draw(self, context, layout):
sc = self.element
SP_CATF_check_files(sc).draw(context, layout)
super().draw(context, layout)
@subscribe
class SN_CATF(Namelist): # FIXME
label = "CATF"
description = "Concatenated file paths"
fds_label = "CATF"
bpy_type = Scene
bpy_export = "bf_catf_export"
bpy_export_default = False
param_cls = (SP_CATF_files,)
# Material
def update_MP_namelist_cls(self, context):
# When Material namelist cls is updated:
# Set default appearance
# self.set_default_appearance(context)
pass
@subscribe
class MP_namelist_cls(Parameter):
label = "Namelist"
description = "Identification of FDS namelist"
bpy_type = Material
bpy_idname = "bf_namelist_cls"
bpy_prop = EnumProperty
bpy_other = {
"items": (("MN_SURF", "SURF", "Generic boundary condition", 2000),),
"update": update_MP_namelist_cls,
}
bpy_default = "MN_SURF"
def to_fds(self, context):
if self.element.name in {"INERT", "HVAC", "MIRROR", "OPEN", "PERIODIC"}:
return
super().to_fds(context)
@subscribe
class MP_ID(PString):
label = "ID"
description = "Material identification name"
fds_label = "ID"
bf_other = {"copy_protect": True}
bpy_type = Material
bpy_prop = None # to avoid creation
bpy_idname = "name"
@subscribe
class MP_FYI(PFYI):
bpy_type = Material
bpy_idname = "bf_fyi"
@subscribe
class MP_RGB(Parameter):
label = "RGB, TRANSPARENCY"
description = "Color values (red, green, blue) and transparency"
fds_label = "RGB"
bpy_type = Material
bpy_prop = None # Do not register
bpy_idname = "diffuse_color"
def to_fds(self, context):
c = self.element.diffuse_color
rgb = int(c[0] * 255), int(c[1] * 255), int(c[2] * 255)
return f"RGB={rgb[0]},{rgb[1]},{rgb[2]} TRANSPARENCY={c[3]:.2f}"
@subscribe
class MP_THICKNESS(Parameter):
label = "THICKNESS [m]"
description = "Surface thickness for heat transfer calculation"
fds_label = "THICKNESS"
bpy_type = Material
bpy_idname = "bf_thickness"
bpy_prop = FloatProperty
bpy_default = 0.01
bpy_other = {"step": 1.0, "precision": 6, "min": 0.000001}
bpy_export = "bf_thickness_export"
bpy_export_default = False
@subscribe
class MP_HRRPUA(Parameter):
label = "HRRPUA [kW/m²]"
description = "Heat release rate per unit area"
fds_label = "HRRPUA"
bpy_type = Material
bpy_idname = "bf_hrrpua"
bpy_prop = FloatProperty
bpy_default = 0.0
bpy_other = {"precision": 3, "min": 0.0}
@subscribe
class MP_TAU_Q(Parameter):
label = "TAU_Q [s]"
description = "Ramp time for heat release rate"
fds_label = "TAU_Q"
fds_default = 1.0
bpy_type = Material
bpy_idname = "bf_tau_q"
bpy_prop = FloatProperty
bpy_other = {"step": 10.0, "precision": 1, "unit": "TIME"}
@subscribe
class MP_MATL_ID(PString):
label = "MATL_ID"
description = "Reference to a MATL (Material) line for self properties"
fds_label = "MATL_ID"
bpy_type = Material
bpy_idname = "bf_matl_id"
bpy_export = "bf_matl_id_export"
bpy_export_default = False
@subscribe
class MP_IGNITION_TEMPERATURE(Parameter):
label = "IGNITION_TEMPERATURE [°C]"
description = "Ignition temperature"
fds_label = "IGNITION_TEMPERATURE"
fds_default = 5000.0
bpy_type = Material
bpy_idname = "bf_ignition_temperature"
bpy_prop = FloatProperty
bpy_other = {"step": 100.0, "precision": 1, "min": -273.0}
bpy_export = "bf_ignition_temperature_export"
bpy_export_default = False
@subscribe
class MP_BACKING(Parameter):
label = "BACKING"
description = "Exposition of back side surface"
fds_label = "BACKING"
fds_default = "EXPOSED"
bpy_type = Material
bpy_idname = "bf_backing"
bpy_prop = EnumProperty
bpy_prop_export = "bf_backing_export"
bpy_export_default = False