-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathconfig.py
More file actions
1151 lines (980 loc) · 40.4 KB
/
Copy pathconfig.py
File metadata and controls
1151 lines (980 loc) · 40.4 KB
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
"""
Class Config provides functionality to read a JSON file and pass the values to the Micro Manager.
"""
import json
import os
import importlib.metadata
class Config:
"""
Handles the reading of parameters in the JSON configuration file provided by the user. This class is based on
the config class in https://github.com/precice/fenics-adapter/tree/develop/fenicsadapter
"""
def __init__(self, config_file_name):
"""
Constructor of the Config class.
Parameters
----------
config_file_name : string
Name of the JSON configuration file
"""
self._config_file_name = config_file_name
self._logger = None
self._micro_file_name = None
self._micro_stateless = False
self._precice_config_file_name = None
self._macro_mesh_name = None
self._read_data_names = None
self._write_data_names = None
self._micro_dt = None
self._macro_domain_bounds = None
self._ranks_per_axis = None
self._micro_output_n = 1
self._diagnostics_data_names = None
self._mem_usage_output_type = ""
self._mem_usage_output_n = 1
self._interpolate_crash = False
self._adaptivity = False
self._adaptivity_type = ""
self._data_for_adaptivity = dict()
self._local_data_for_adaptivity = dict()
self._adaptivity_n = 1
self._adaptivity_history_param = 0.5
self._adaptivity_coarsening_constant = 0.5
self._adaptivity_refining_constant = 0.5
self._adaptivity_every_implicit_iteration = False
self._adaptivity_similarity_measure = "L2rel"
self._adaptivity_output_type = ""
self._adaptivity_output_n = 1
self._adaptivity_is_load_balancing = False
self._load_balancing_n = 1
self._load_balancing_threshold = 0
self._balance_inactive_sims = False
# Snapshot information
self._parameter_file_name = None
self._postprocessing_file_name = None
self._initialize_once = False
self._output_file_name = "snapshot_data"
self._output_dir = None
self._lazy_initialization = False
# Model Adaptivity information
self._m_adap = False
self._m_adap_micro_file_names = None
self._m_adap_micro_stateless = None
self._m_adap_switching_function = None
# Tasking
self._task_is_slurm = False
self._task_backend = "socket"
self._task_num_workers = 1
self._task_mpi_impl = "open"
self._task_pinning_hostfile = "./hosts.micro"
def set_logger(self, logger):
"""
Set the logger for the Config class.
Parameters
----------
logger : object of logging
Logger defined from the standard package logging
"""
self._logger = logger
def _read_json(self, config_file_name):
"""
Reads JSON configuration file.
Parameters
----------
config_file_name : string
Name of the JSON configuration file
"""
self._logger.log_info_rank_zero(
"Micro Manager version: "
+ importlib.metadata.version("micro-manager-precice")
)
self._folder = os.path.dirname(os.path.join(os.getcwd(), config_file_name))
path = os.path.join(self._folder, os.path.basename(config_file_name))
with open(path, "r") as read_file:
self._data = json.load(read_file)
self._logger.log_info_rank_zero("Reading JSON configuration file: " + path)
# convert paths to python-importable paths
self._micro_file_name = (
self._data["micro_file_name"]
.replace("/", ".")
.replace("\\", ".")
.replace(".py", "")
)
try:
self._micro_stateless = self._data["micro_stateless"]
self._logger.log_info_rank_zero(
"Only creating one full instance of MicroSimulation."
)
except:
self._micro_stateless = False
self._logger.log_info_rank_zero(
"Creating an instance of MicroSimulation for each mesh vertex."
)
self._logger.log_info_rank_zero(
"Micro simulation file name: " + self._data["micro_file_name"]
)
try:
self._output_dir = self._data["output_directory"]
self._logger.log_info_rank_zero(
"Logging and metrics output directory: " + self._output_dir
)
except BaseException:
self._logger.log_info_rank_zero(
"No output directory provided. Output (including logging) will be saved in the current working directory."
)
try:
self._mem_usage_output_type = self._data["memory_usage_output_type"]
if self._mem_usage_output_type not in ["all", "local", "global"]:
raise Exception(
"Memory usage output can be either 'all', 'local' or 'global'."
)
self._logger.log_info_rank_zero(
"Memory usage output type: " + self._mem_usage_output_type
)
except BaseException:
self._logger.log_info_rank_zero(
"Micro Manager will not output memory usage."
)
try:
self._mem_usage_output_n = self._data["memory_usage_output_n"]
self._logger.log_info_rank_zero(
"Memory usage will be output every "
+ str(self._mem_usage_output_n)
+ " time windows."
)
except BaseException:
self._logger.log_info_rank_zero(
"No output interval for memory usage output provided. Memory usage will be output every time window."
)
try:
self._write_data_names = self._data["coupling_params"]["write_data_names"]
if not isinstance(self._write_data_names, list):
raise Exception("Write data entry is not a list")
self._logger.log_info_rank_zero(
"Micro Manager is writing the following data: "
+ str(self._write_data_names)
)
except BaseException:
self._logger.log_info_rank_zero(
"No write data names provided. Micro manager will only read data from preCICE."
)
try:
self._read_data_names = self._data["coupling_params"]["read_data_names"]
if not isinstance(self._read_data_names, list):
raise Exception("Read data entry is not a list")
self._logger.log_info_rank_zero(
"Micro Manager is reading the following data: "
+ str(self._read_data_names)
)
except BaseException:
self._logger.log_info_rank_zero(
"No read data names provided. Micro manager will only write data to preCICE."
)
self._micro_dt = self._data["simulation_params"]["micro_dt"]
try:
if self._data["tasking"]:
backend = self._data["tasking"]["backend"]
if backend not in ["mpi", "socket"]:
raise Exception("Backend must be either 'mpi' or 'socket'.")
self._task_backend = backend
if "is_slurm" in self._data["tasking"]:
self._task_is_slurm = self._data["tasking"]["is_slurm"]
if "num_workers" in self._data["tasking"]:
self._task_num_workers = self._data["tasking"]["num_workers"]
if self._task_is_slurm and backend == "mpi":
raise Exception("MPI backend not supported on SLURM systems.")
if "mpi_impl" in self._data["tasking"]:
self._task_mpi_impl = self._data["tasking"]["mpi_impl"]
if self._task_mpi_impl not in ["open", "intel"]:
raise Exception("mpi_impl must be either 'open' or 'intel'.")
if "hostfile" in self._data["tasking"]:
self._task_pinning_hostfile = self._data["tasking"]["hostfile"]
except BaseException:
self._logger.log_info_rank_zero(
"No or incorrect tasking information provided. Micro manager will not create workers and instead solve micro simulations locally."
)
def read_json_micro_manager(self):
"""
Reads Micro Manager relevant information from JSON configuration file
and saves the data to the respective instance attributes.
"""
self._read_json(self._config_file_name) # Read base information
self._precice_config_file_name = os.path.join(
self._folder, self._data["coupling_params"]["precice_config_file_name"]
)
self._logger.log_info_rank_zero(
"preCICE configuration file name: " + self._precice_config_file_name
)
self._macro_mesh_name = self._data["coupling_params"]["macro_mesh_name"]
self._logger.log_info_rank_zero("Macro mesh name: " + self._macro_mesh_name)
self._macro_domain_bounds = self._data["simulation_params"][
"macro_domain_bounds"
]
self._logger.log_info_rank_zero(
"Macro domain bounds: " + str(self._macro_domain_bounds)
)
try:
self._ranks_per_axis = self._data["simulation_params"]["decomposition"]
if not isinstance(self._ranks_per_axis, list):
raise Exception("Ranks per axis entry is not a list")
self._logger.log_info_rank_zero(
"Axis-wise domain decomposition: " + str(self._ranks_per_axis)
)
except BaseException:
self._logger.log_info_rank_zero(
"Domain decomposition is not specified, so the Micro Manager will expect to be run in serial."
)
try:
if self._data["simulation_params"]["adaptivity"]:
self._adaptivity = True
self._logger.log_info_rank_zero(
"Micro Manager will adaptively run micro simulations."
)
if not self._data["simulation_params"]["adaptivity_settings"]:
raise Exception(
"Adaptivity is turned on but no adaptivity settings are provided."
)
else:
self._adaptivity = False
if self._data["simulation_params"]["adaptivity_settings"]:
raise Exception(
"Adaptivity settings are provided but adaptivity is turned off."
)
except BaseException:
self._logger.log_info_rank_zero(
"Micro Manager will not adaptively run micro simulations, but instead will run all micro simulations."
)
if self._adaptivity:
if (
self._data["simulation_params"]["adaptivity_settings"]["type"]
== "local"
):
self._adaptivity_type = "local"
elif (
self._data["simulation_params"]["adaptivity_settings"]["type"]
== "global"
):
self._adaptivity_type = "global"
else:
raise Exception("Adaptivity type can be either local or global.")
self._logger.log_info_rank_zero("Adaptivity type: " + self._adaptivity_type)
if self._data["simulation_params"]["adaptivity_settings"].get(
"lazy_initialization"
):
self._lazy_initialization = True
self._logger.log_info_rank_zero(
"Micro simulations will be created only when they are required to be active for the very first time."
)
self._data_for_adaptivity = self._data["simulation_params"][
"adaptivity_settings"
]["data"]
self._local_data_for_adaptivity = self._data["simulation_params"][
"adaptivity_settings"
].get("local_data", {})
if self._local_data_for_adaptivity:
self._logger.log_info_rank_zero(
"Local data used only for adaptivity (not sent to macro): "
+ str(self._local_data_for_adaptivity)
)
self._logger.log_info_rank_zero(
"Data used for adaptivity: " + str(self._data_for_adaptivity)
)
if self._data_for_adaptivity == self._write_data_names:
self._logger.log_info_rank_zero(
"Only micro simulation data is used for similarity computation in adaptivity. This would lead to the"
" same set of active and inactive simulations for the entire simulation time. If this is not intended,"
" please include macro data as well."
)
try:
self._adaptivity_n = self._data["simulation_params"][
"adaptivity_settings"
]["adaptivity_every_n_time_windows"]
self._logger.log_info_rank_zero(
"Adaptivity will be computed every "
+ str(self._adaptivity_n)
+ " time windows."
)
except BaseException:
self._logger.log_info_rank_zero(
"No interval for adaptivity computation provided. Adaptivity will be computed in every time window."
)
try:
self._adaptivity_output_type = self._data["simulation_params"][
"adaptivity_settings"
]["output_type"]
if self._adaptivity_output_type not in ["all", "local", "global"]:
raise Exception(
"Adaptivity output type can be either 'all', 'local' or 'global'."
)
self._logger.log_info_rank_zero(
"Adaptivity output type: " + self._adaptivity_output_type
)
except BaseException:
self._logger.log_info_rank_zero(
"No adaptivity output type provided. No metrics will be output."
)
try:
self._adaptivity_output_n = self._data["simulation_params"][
"adaptivity_settings"
]["output_n"]
self._logger.log_info_rank_zero(
"Adaptivity metrics will be output every "
+ str(self._adaptivity_output_n)
+ " time windows."
)
except BaseException:
self._logger.log_info_rank_zero(
"No output interval for adaptivity provided. Adaptivity metrics will be output every time window."
)
self._adaptivity_history_param = self._data["simulation_params"][
"adaptivity_settings"
]["history_param"]
self._logger.log_info_rank_zero(
"Adaptivity history parameter: " + str(self._adaptivity_history_param)
)
self._adaptivity_coarsening_constant = self._data["simulation_params"][
"adaptivity_settings"
]["coarsening_constant"]
self._logger.log_info_rank_zero(
"Adaptivity coarsening constant: "
+ str(self._adaptivity_coarsening_constant)
)
self._adaptivity_refining_constant = self._data["simulation_params"][
"adaptivity_settings"
]["refining_constant"]
self._logger.log_info_rank_zero(
"Adaptivity refining constant: "
+ str(self._adaptivity_refining_constant)
)
if (
"similarity_measure"
in self._data["simulation_params"]["adaptivity_settings"]
):
self._adaptivity_similarity_measure = self._data["simulation_params"][
"adaptivity_settings"
]["similarity_measure"]
self._logger.log_info_rank_zero(
"Adaptivity similarity measure: "
+ str(self._adaptivity_similarity_measure)
)
else:
self._logger.log_info_rank_zero(
"No similarity measure provided, using L1 norm as default."
)
self._adaptivity_similarity_measure = "L1"
try:
adaptivity_every_implicit_iteration = self._data["simulation_params"][
"adaptivity_settings"
]["every_implicit_iteration"]
if adaptivity_every_implicit_iteration:
self._adaptivity_every_implicit_iteration = True
self._logger.log_info_rank_zero(
"Micro Manager will compute adaptivity in every implicit iteration, if implicit coupling is done."
)
elif not adaptivity_every_implicit_iteration:
self._adaptivity_every_implicit_iteration = False
self._logger.log_info_rank_zero(
"Micro Manager will compute adaptivity once at the start of every time window."
)
except:
self._logger.log_info_rank_zero(
"Micro Manager will compute adaptivity once at the start of every time window."
)
self._adaptivity_every_implicit_iteration = False
self._write_data_names.append("Active-State")
self._write_data_names.append("Active-Steps")
try:
self._adaptivity_is_load_balancing = self._data["simulation_params"][
"load_balancing"
]
if self._adaptivity_is_load_balancing:
self._logger.log_info_rank_zero(
"Micro Manager will dynamically balance micro simulations based on the adaptivity computation."
)
self._write_data_names.append("rank_of_sim")
if not self._adaptivity_type == "global":
raise Exception(
"Load balancing can be done only with global adaptivity."
)
except BaseException:
self._logger.log_info_rank_zero(
"Micro Manager will not dynamically balance micro simulations based on the adaptivity computation."
)
if self._adaptivity_is_load_balancing:
self._load_balancing_n = self._data["simulation_params"][
"load_balancing_settings"
]["every_n_time_windows"]
self._logger.log_info_rank_zero(
"Load balancing will be done every "
+ str(self._load_balancing_n)
+ " time windows."
)
try:
self._load_balancing_threshold = self._data["simulation_params"][
"load_balancing_settings"
]["balancing_threshold"]
self._logger.log_info_rank_zero(
"Load balancing threshold: " + str(self._load_balancing_threshold)
)
except BaseException:
self._logger.log_info_rank_zero(
"No load balancing threshold provided. The threshold will be set to 0."
)
try:
self._balance_inactive_sims = self._data["simulation_params"][
"load_balancing_settings"
]["balance_inactive_sims"]
if self._balance_inactive_sims:
self._logger.log_info_rank_zero(
"Micro Manager will redistribute inactive simulations in the load balancing."
)
except BaseException:
self._logger.log_info_rank_zero(
"Micro Manager will not redistribute inactive simulations in the load balancing. Only active simulations will be redistributed. Note that this may significantly increase the communication cost of the adaptivity."
)
try:
if self._data["simulation_params"]["model_adaptivity"]:
self._m_adap = True
self._logger.log_info_rank_zero(
"Micro Manager will use Model Adaptivity."
)
if not self._data["simulation_params"]["model_adaptivity_settings"]:
raise Exception(
"Model Adaptivity is turned on but no model adaptivity settings are provided."
)
else:
self._m_adap = False
if self._data["simulation_params"]["model_adaptivity_settings"]:
raise Exception(
"Model Adaptivity settings are provided but model adaptivity is turned off."
)
except BaseException:
self._logger.log_info_rank_zero(
"Micro Manager will not adaptively switch simulation models."
)
if self._m_adap:
self._m_adap_micro_file_names = [
name.replace("/", ".").replace("\\", ".").replace(".py", "")
for name in self._data["simulation_params"][
"model_adaptivity_settings"
]["micro_file_names"]
]
if len(self._m_adap_micro_file_names) < 2:
self._logger.log_info_rank_zero(
"Not enough Micro Models provided for Model Adaptivity. Need min 2."
)
self._logger.log_info_rank_zero("Disabling Model Adaptivity.")
self._m_adap = False
self._m_adap_switching_function = self._data["simulation_params"][
"model_adaptivity_settings"
]["switching_function"]
if (
"micro_stateless"
in self._data["simulation_params"]["model_adaptivity_settings"]
):
self._m_adap_micro_stateless = self._data["simulation_params"][
"model_adaptivity_settings"
]["micro_stateless"]
else:
self._m_adap_micro_stateless = [False] * len(
self._m_adap_micro_file_names
)
for i in range(len(self._m_adap_micro_file_names)):
if self._m_adap_micro_stateless[i]:
self._logger.log_info_rank_zero(
f"Only creating one full instance of Micro Model {i}."
)
else:
self._logger.log_info_rank_zero(
f"Creating full instance of Micro Model {i} per mesh vertex."
)
if "interpolate_crash" in self._data["simulation_params"]:
if self._data["simulation_params"]["interpolate_crash"]:
self._interpolate_crash = True
self._logger.log_info_rank_zero(
"Micro Manager will interpolate output of crashed micro simulations from its neighbors."
)
try:
diagnostics_data_names = self._data["diagnostics"]["data_from_micro_sims"]
if not isinstance(diagnostics_data_names, list):
raise Exception("Diagnostics data entry is not a list")
except BaseException:
self._logger.log_info_rank_zero(
"No diagnostics data is defined. Micro Manager will not output any diagnostics data."
)
try:
self._micro_output_n = self._data["diagnostics"]["micro_output_n"]
except BaseException:
self._logger.log_info_rank_zero(
"Output interval of micro simulations not specified, if output is available then it will be called "
"in every time window."
)
def read_json_snapshot(self):
"""
Reads Snapshot relevant information from JSON configuration file
"""
self._read_json(self._config_file_name) # Read base information
self._logger.log_info_rank_zero(
"Reading JSON configuration file: " + self._config_file_name
)
self._logger.log_info_rank_zero("Micro Manager is running in snapshot mode.")
self._parameter_file_name = os.path.join(
self._folder, self._data["coupling_params"]["parameter_file_name"]
)
self._logger.log_info_rank_zero(
"Parameter file name: " + self._parameter_file_name
)
try:
self._output_file_name = self._data["snapshot_params"]["output_file_name"]
self._logger.log_info_rank_zero(
"Output file name: " + self._output_file_name
)
except BaseException:
self._logger.log_info_rank_zero(
"No snapshot output file name provided. Defaulting to 'snapshot_data'."
)
self._output_file_name = "snapshot_data"
try:
self._postprocessing_file_name = (
self._data["snapshot_params"]["post_processing_file_name"]
.replace("/", ".")
.replace("\\", ".")
.replace(".py", "")
)
self._logger.log_info_rank_zero(
"Post-processing file name: " + self._postprocessing_file_name
)
except BaseException:
self._logger.log_info_rank_zero(
"No post-processing file name provided. Snapshot computation will not perform any post-processing."
)
self._postprocessing_file_name = None
try:
diagnostics_data_names = self._data["diagnostics"]["data_from_micro_sims"]
if not isinstance(diagnostics_data_names, list):
raise Exception("Diagnostics data entry is not a list")
self._logger.log_info_rank_zero(
"Diagnostics data: " + str(diagnostics_data_names)
)
except BaseException:
self._logger.log_info_rank_zero(
"No diagnostics data is defined. Snapshot computation will not output any diagnostics data."
)
try:
if self._data["snapshot_params"]["initialize_once"]:
self._initialize_once = True
self._logger.log_info_rank_zero(
"Micro Manager will initialize only one micro simulations object for snapshot computation."
)
except BaseException:
self._logger.log_info_rank_zero(
"For each snapshot a new micro simulation object will be created."
)
def get_precice_config_file_name(self):
"""
Get the name of the preCICE XML configuration file.
Returns
-------
config_file_name : string
Name of the preCICE XML configuration file.
"""
return self._precice_config_file_name
def get_macro_mesh_name(self):
"""
Get the name of the macro mesh. This name is expected to be the same as the one defined in the preCICE
configuration file.
Returns
-------
macro_mesh_name : string
Name of the macro mesh as stated in the JSON configuration file.
"""
return self._macro_mesh_name
def get_read_data_names(self):
"""
Get the user defined dictionary carrying information of the data to be read from preCICE.
Returns
-------
read_data_names: dict_like
A dictionary containing the names of the data to be read from preCICE as keys and information on whether
the data are scalar or vector as values.
"""
return self._read_data_names
def get_write_data_names(self):
"""
Get the user defined dictionary carrying information of the data to be written to preCICE.
Returns
-------
write_data_names: dict_like
A dictionary containing the names of the data to be written to preCICE as keys and information on whether
the data are scalar or vector as values.
"""
return self._write_data_names
def get_macro_domain_bounds(self):
"""
Get the upper and lower bounds of the macro domain.
Returns
-------
macro_domain_bounds : list
List containing upper and lower bounds of the macro domain.
Format in 2D is [x_min, x_max, y_min, y_max]
Format in 2D is [x_min, x_max, y_min, y_max, z_min, z_max]
"""
return self._macro_domain_bounds
def get_ranks_per_axis(self):
"""
Get the ranks per axis for a parallel simulation
Returns
-------
ranks_per_axis : list
List containing ranks in the x, y and z axis respectively.
"""
return self._ranks_per_axis
def get_micro_file_name(self):
"""
Get the path to the Python script of the micro-simulation.
Returns
-------
micro_file_name : string
String carrying the path to the Python script of the micro-simulation.
"""
return self._micro_file_name
def turn_on_micro_stateless(self):
"""
Boolean stating whether micro model is stateless or not.
Returns
-------
stateless : bool
True if micro model is stateless, False otherwise.
"""
return self._micro_stateless
def get_micro_output_n(self):
"""
Get the micro output frequency
Returns
-------
micro_output_n : int
Output frequency of micro simulations, so output every N timesteps
"""
return self._micro_output_n
def turn_on_adaptivity(self):
"""
Boolean stating whether adaptivity is ot or not.
Returns
-------
adaptivity : bool
True is adaptivity settings are done, False otherwise.
"""
return self._adaptivity
def get_adaptivity_type(self):
"""
String stating type of adaptivity computation, either "local" or "global".
Returns
-------
adaptivity_type : str
Either "local" or "global" depending on the type of adaptivity computation
"""
return self._adaptivity_type
def get_data_for_adaptivity(self):
"""
Get names of data to be used for similarity distance calculation in adaptivity
Returns
-------
data_for_adaptivity : dict_like
A dictionary containing the names of the data to be used in adaptivity as keys and information on whether
the data are scalar or vector as values.
"""
return self._data_for_adaptivity
def get_local_data_for_adaptivity(self):
"""
Get names of micro simulation local data to be used only for similarity distance calculation in adaptivity.
This data is not sent to the macro simulation.
Returns
-------
local_data_for_adaptivity : dict_like
A dictionary containing the names of the local adaptivity data as keys and information on whether
the data are scalar or vector as values.
"""
return self._local_data_for_adaptivity
def get_adaptivity_n(self):
"""
Get the frequency of adaptivity computation.
Returns
-------
adaptivity_n : int
Frequency of adaptivity computation, as a multiple of time windows.
"""
return self._adaptivity_n
def get_adaptivity_output_type(self):
"""
Get the type of adaptivity output.
Returns
-------
adaptivity_output_type : str
Type of adaptivity output, can be "all", "local" or "global".
"""
return self._adaptivity_output_type
def get_adaptivity_output_n(self):
"""
Get the output frequency of adaptivity metrics.
Returns
-------
adaptivity_output_n : int
Output frequency of adaptivity metrics, so output every N timesteps
"""
return self._adaptivity_output_n
def get_adaptivity_hist_param(self):
"""
Get adaptivity history parameter.
More details: https://precice.org/tooling-micro-manager-configuration.html#adaptivity
Returns
-------
adaptivity_hist_param : float
Adaptivity history parameter
"""
return self._adaptivity_history_param
def get_adaptivity_coarsening_const(self):
"""
Get adaptivity coarsening constant.
More details: https://precice.org/tooling-micro-manager-configuration.html#adaptivity
Returns
-------
adaptivity_coarsening_constant : float
Adaptivity coarsening constant
"""
return self._adaptivity_coarsening_constant
def get_adaptivity_refining_const(self):
"""
Get adaptivity refining constant.
More details: https://precice.org/tooling-micro-manager-configuration.html#adaptivity
Returns
-------
adaptivity_refining_constant : float
Adaptivity refining constant
"""
return self._adaptivity_refining_constant
def get_adaptivity_similarity_measure(self):
"""
Get measure to be used to calculate similarity between pairs of simulations.
More details: https://precice.org/tooling-micro-manager-configuration.html#adaptivity
Returns
-------
adaptivity_similarity_measure : str
String of measure to be used in calculating similarity between pairs of simulations.
"""
return self._adaptivity_similarity_measure
def is_adaptivity_required_in_every_implicit_iteration(self):
"""
Check if adaptivity needs to be calculated in every time iteration or every time window.
Returns
-------
adaptivity_every_implicit_iteration : bool
True if adaptivity needs to be calculated in every time iteration, False otherwise.
"""
return self._adaptivity_every_implicit_iteration
def is_adaptivity_with_load_balancing(self):
"""
Check if adaptivity computation needs to be done with load balancing.
Returns
-------
adaptivity_is_load_balancing : bool
True if adaptivity computation needs to be done with load balancing, False otherwise.
"""
return self._adaptivity_is_load_balancing
def get_load_balancing_n(self):
"""
Get the load balancing frequency.
Returns
-------
load_balancing_n : int
Load balancing frequency
"""
return self._load_balancing_n
def get_load_balancing_threshold(self):
"""
Get the load balancing threshold to control how balanced the micro simulations need to be.
Returns
-------
load_balancing_threshold : float
Load balancing threshold
"""
return self._load_balancing_threshold
def balance_inactive_sims(self):
"""
Check if inactive simulations are to be redistributed in the load balancing.
Returns
-------
balance_inactive_sims : bool
True if inactive simulations are to be redistributed in the load balancing, False otherwise.
"""
return self._balance_inactive_sims
def initialize_sims_lazily(self):
"""
Check if simulations are to be created only when they are required to be active for the very first time.
Returns
-------
adaptivity : bool
True if micro simulations are created only when needed, False otherwise.
"""
return self._lazy_initialization
def get_micro_dt(self):
"""
Get the size of the micro time window.
Returns
-------
micro_time_window : float
Size of the micro time window.
"""
return self._micro_dt
def get_parameter_file_name(self):
"""
Get the name of the parameter file.
Returns
-------
parameter_file_name : string
Name of the hdf5 file containing the macro parameters.
"""
return self._parameter_file_name
def get_output_file_name(self):
"""
Get the name of the output file.
Returns
-------
output_file_name : string
Name of the hdf5 file containing the snapshot data.
"""
return self._output_file_name
def get_postprocessing_file_name(self):
"""
Depending on user input, snapshot computation will perform post-processing for every micro simulation before writing output to a file.
Returns
-------
postprocessing : str
Name of post-processing script.
"""
return self._postprocessing_file_name
def interpolate_crashed_micro_sim(self):
"""
Check if user wants crashed micro simulations to be interpolated.