Skip to content

Commit a178c97

Browse files
committed
merge structures
1 parent d77fa2f commit a178c97

File tree

3 files changed

+94
-93
lines changed

3 files changed

+94
-93
lines changed

mcdc/code_factory.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,22 +123,6 @@ def generate_numba_objects(object_list):
123123
# Numbafy!
124124
numbafy_object(object_, structures, records, data)
125125

126-
# Set the global structure
127-
global_structure = []
128-
for key in structures.keys():
129-
if isinstance(records[key], list):
130-
global_structure += [(f"{key}s", structures[key], (len(records[key]),))]
131-
else:
132-
global_structure += [(f"{key}", structures[key])]
133-
134-
# Initialize the global structure
135-
mcdc = np.zeros((), dtype=global_structure)
136-
for key in structures.keys():
137-
if isinstance(records[key], list):
138-
mcdc[f"{key}s"] = np.array(records[key], dtype=structures[key])
139-
else:
140-
mcdc[f"{key}"] = np.array(records[key], dtype=structures[key])
141-
142126
data = np.array(data, dtype=np.float64)
143127

144-
return data, mcdc
128+
return data, structures, records

mcdc/main.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def run():
7878
# Timer: preparation
7979
time_prep_start = MPI.Wtime()
8080

81-
data_tally, mcdc_arr, data, mcdc_new = prepare()
81+
data_tally, mcdc_arr, data = prepare()
8282
mcdc = mcdc_arr[0]
8383

8484
# Print headers
@@ -505,7 +505,7 @@ def prepare():
505505
"""
506506

507507
# Generate Numba-supported "Objects"
508-
data_new, mcdc_new = code_factory.generate_numba_objects(
508+
data, structures, records = code_factory.generate_numba_objects(
509509
objects.materials + objects.nuclides + objects.reactions + [objects.settings]
510510
)
511511

@@ -579,7 +579,7 @@ def prepare():
579579
type_.make_type_domain_decomp(input_deck)
580580
type_.make_type_dd_turnstile_event(input_deck)
581581
type_.make_type_technique(input_deck)
582-
type_.make_type_global(input_deck)
582+
type_.make_type_global(input_deck, structures, records)
583583
type_.make_size_rpn(input_deck)
584584
kernel.adapt_rng(nb.config.DISABLE_JIT)
585585

@@ -598,6 +598,16 @@ def prepare():
598598
# Get modes
599599
mode_MG = settings.multigroup_mode
600600
mode_CE = not mode_MG
601+
602+
# ==================================================================================
603+
# Set with records
604+
# ==================================================================================
605+
606+
for key in structures.keys():
607+
if isinstance(records[key], list):
608+
mcdc[f"{key}s"] = np.array(records[key], dtype=structures[key])
609+
else:
610+
mcdc[f"{key}"] = np.array(records[key], dtype=structures[key])
601611

602612
# =========================================================================
603613
# Surfaces
@@ -1519,7 +1529,7 @@ def prepare():
15191529
# Finalize data: wrapping into a tuple
15201530
# =========================================================================
15211531

1522-
return data_tally, mcdc_arr, data_new, mcdc_new
1532+
return data_tally, mcdc_arr, data
15231533

15241534

15251535
def cardlist_to_h5group(dictlist, input_group, name):

mcdc/type_.py

Lines changed: 79 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ def make_type_domain_decomp(input_deck):
11871187
# ==============================================================================
11881188

11891189

1190-
def make_type_global(input_deck):
1190+
def make_type_global(input_deck, structures, records):
11911191
global global_
11921192

11931193
# Get modes
@@ -1266,78 +1266,85 @@ def make_type_global(input_deck):
12661266
) or input_deck.technique["iQMC"]:
12671267
bank_source = particle_bank(N_work)
12681268

1269+
# Set the global structure
1270+
global_structure = []
1271+
for key in structures.keys():
1272+
if isinstance(records[key], list):
1273+
global_structure += [(f"{key}s", structures[key], (len(records[key]),))]
1274+
else:
1275+
global_structure += [(f"{key}", structures[key])]
1276+
global_structure += [
1277+
("surfaces", surface, (N_surface,)),
1278+
# Cells
1279+
("cells", cell, (N_cell,)),
1280+
("cells_data_surface", int64, (N_cell_surface,)),
1281+
("cells_data_region", int64, (N_cell_region,)),
1282+
# Universes
1283+
("universes", universe, (N_universe,)),
1284+
("universes_data_cell", int64, (N_universe_cell,)),
1285+
("lattices", lattice, (N_lattice,)),
1286+
("sources", source, (N_source,)),
1287+
("mesh_tallies", mesh_tally, (N_mesh_tally,)),
1288+
("surface_tallies", surface_tally, (N_surface_tally,)),
1289+
("cell_tallies", cell_tally, (N_cell_tally,)),
1290+
("cs_tallies", cs_tally, (N_cs_tally,)),
1291+
("technique", technique),
1292+
("domain_decomp", domain_decomp),
1293+
("bank_active", bank_active),
1294+
("bank_census", bank_census),
1295+
("bank_source", bank_source),
1296+
("bank_future", bank_future),
1297+
("bank_precursor", bank_precursor),
1298+
("rng_seed_base", uint64),
1299+
("rng_seed", uint64),
1300+
("rng_stride", int64),
1301+
("dd_idx", int64),
1302+
("dd_N_local_source", int64),
1303+
("dd_local_rank", int64),
1304+
("k_eff", float64),
1305+
("k_cycle", float64, (N_cycle,)),
1306+
("k_avg", float64),
1307+
("k_sdv", float64),
1308+
("n_avg", float64), # Neutron density
1309+
("n_sdv", float64),
1310+
("n_max", float64),
1311+
("C_avg", float64), # Precursor density
1312+
("C_sdv", float64),
1313+
("C_max", float64),
1314+
("k_avg_running", float64),
1315+
("k_sdv_running", float64),
1316+
("gyration_radius", float64, (N_cycle,)),
1317+
("idx_cycle", int64),
1318+
("cycle_active", bool_),
1319+
("eigenvalue_tally_nuSigmaF", float64, (1,)),
1320+
("eigenvalue_tally_n", float64, (1,)),
1321+
("eigenvalue_tally_C", float64, (1,)),
1322+
("idx_census", int64),
1323+
("idx_batch", int64),
1324+
("mpi_size", int64),
1325+
("mpi_rank", int64),
1326+
("mpi_master", bool_),
1327+
("mpi_work_start", int64),
1328+
("mpi_work_size", int64),
1329+
("mpi_work_size_total", int64),
1330+
("mpi_work_start_precursor", int64),
1331+
("mpi_work_size_precursor", int64),
1332+
("mpi_work_size_total_precursor", int64),
1333+
("runtime_total", float64),
1334+
("runtime_preparation", float64),
1335+
("runtime_simulation", float64),
1336+
("runtime_output", float64),
1337+
("runtime_bank_management", float64),
1338+
("precursor_strength", float64),
1339+
("mpi_work_iter", int64, (1,)),
1340+
("gpu_state_pointer", uintp),
1341+
("source_program_pointer", uintp),
1342+
("precursor_program_pointer", uintp),
1343+
("source_seed", uint64),
1344+
]
1345+
12691346
# GLobal type
1270-
global_ = into_dtype(
1271-
[
1272-
("surfaces", surface, (N_surface,)),
1273-
# Cells
1274-
("cells", cell, (N_cell,)),
1275-
("cells_data_surface", int64, (N_cell_surface,)),
1276-
("cells_data_region", int64, (N_cell_region,)),
1277-
# Universes
1278-
("universes", universe, (N_universe,)),
1279-
("universes_data_cell", int64, (N_universe_cell,)),
1280-
("lattices", lattice, (N_lattice,)),
1281-
("sources", source, (N_source,)),
1282-
("mesh_tallies", mesh_tally, (N_mesh_tally,)),
1283-
("surface_tallies", surface_tally, (N_surface_tally,)),
1284-
("cell_tallies", cell_tally, (N_cell_tally,)),
1285-
("cs_tallies", cs_tally, (N_cs_tally,)),
1286-
("technique", technique),
1287-
("domain_decomp", domain_decomp),
1288-
("bank_active", bank_active),
1289-
("bank_census", bank_census),
1290-
("bank_source", bank_source),
1291-
("bank_future", bank_future),
1292-
("bank_precursor", bank_precursor),
1293-
("rng_seed_base", uint64),
1294-
("rng_seed", uint64),
1295-
("rng_stride", int64),
1296-
("dd_idx", int64),
1297-
("dd_N_local_source", int64),
1298-
("dd_local_rank", int64),
1299-
("k_eff", float64),
1300-
("k_cycle", float64, (N_cycle,)),
1301-
("k_avg", float64),
1302-
("k_sdv", float64),
1303-
("n_avg", float64), # Neutron density
1304-
("n_sdv", float64),
1305-
("n_max", float64),
1306-
("C_avg", float64), # Precursor density
1307-
("C_sdv", float64),
1308-
("C_max", float64),
1309-
("k_avg_running", float64),
1310-
("k_sdv_running", float64),
1311-
("gyration_radius", float64, (N_cycle,)),
1312-
("idx_cycle", int64),
1313-
("cycle_active", bool_),
1314-
("eigenvalue_tally_nuSigmaF", float64, (1,)),
1315-
("eigenvalue_tally_n", float64, (1,)),
1316-
("eigenvalue_tally_C", float64, (1,)),
1317-
("idx_census", int64),
1318-
("idx_batch", int64),
1319-
("mpi_size", int64),
1320-
("mpi_rank", int64),
1321-
("mpi_master", bool_),
1322-
("mpi_work_start", int64),
1323-
("mpi_work_size", int64),
1324-
("mpi_work_size_total", int64),
1325-
("mpi_work_start_precursor", int64),
1326-
("mpi_work_size_precursor", int64),
1327-
("mpi_work_size_total_precursor", int64),
1328-
("runtime_total", float64),
1329-
("runtime_preparation", float64),
1330-
("runtime_simulation", float64),
1331-
("runtime_output", float64),
1332-
("runtime_bank_management", float64),
1333-
("precursor_strength", float64),
1334-
("mpi_work_iter", int64, (1,)),
1335-
("gpu_state_pointer", uintp),
1336-
("source_program_pointer", uintp),
1337-
("precursor_program_pointer", uintp),
1338-
("source_seed", uint64),
1339-
]
1340-
)
1347+
global_ = into_dtype(global_structure)
13411348

13421349

13431350
# ==============================================================================

0 commit comments

Comments
 (0)