17def demo(file_path: str, dimensions: int):
19 Demo: Read grid patch files, extract hardcoded split parameters, configure Hardcoded LB.
22 file_path: Directory containing Peano grid patch files (prefix 'grid-')
23 dimensions: 2 or 3 (must match input files)
25 if not os.path.isdir(file_path):
26 raise FileNotFoundError(f
"Input directory not found: {file_path}")
27 print(f
"Loading grid patch files from '{file_path}' (dimensions={dimensions})")
32 tree = split_strategy.reset_tree_to_single_subtree(tree)
34 destination_ranks = [1, 2]
35 hardcoded_config, hardcoded_mode = split_strategy.split_tree(
38 enable_propagate_bottom_up=
True,
39 enable_extract_split_instructions=
True,
40 destination_ranks=destination_ranks,
43 print(
"After split_tree():")
46 print(
"Hardcoded constructor arguments:")
47 print(
" destination_ranks =", destination_ranks)
48 print(
" mode =", hardcoded_mode)
49 print(
" config =", hardcoded_config)
52 project = exahype2.Project(
53 namespace=[
"toolbox",
"loadbalancing",
"demo"],
54 project_name=
"HardcodedLB",
56 executable=
"HardcodedLB.demo"
59 solver = exahype2.solvers.fv.rusanov.GlobalFixedTimeStep(
63 auxiliary_variables=0,
66 normalised_time_step_size=0.01,
67 flux=exahype2.solvers.PDETerms.User_Defined_Implementation,
68 eigenvalues=exahype2.solvers.PDETerms.User_Defined_Implementation,
69 source_term=exahype2.solvers.PDETerms.None_Implementation
71 project.add_solver(solver)
73 project.set_global_simulation_parameters(
74 dimensions=tree._dimension,
75 size=[1.0,1.0,1.0][0:tree._dimension],
76 offset=[0.0,0.0,0.0][0:tree._dimension],
79 first_plot_time_stamp=0.0,
80 time_in_between_plots=0.0,
81 periodic_BC=[
False,
False,
False]
85 project.set_load_balancing(
86 "toolbox::loadbalancing::strategies::Hardcoded",
91 project.set_Peano4_installation(
"../../../../", peano4.api.output.CompileMode.RELEASE)
94 peano4_project = project.generate_Peano4_project(verbose=
True)
95 peano4_project.generate()
96 print(
"Demo project generated with Hardcoded load balancing.")
97 peano4_project.build(make_clean_first=
True, number_of_parallel_builds=-1)
100 print(
"\n=== Hardcoded Load Balancing Summary ===")
101 print(f
"Subtrees: {tree._subtree_count}")
102 print(f
"Leaf count: {int(tree._leaf_count)}")
103 print(
"destination_ranks =", destination_ranks)
104 print(
"Hardcoded mode =", hardcoded_mode)
105 print(
"hardcoded_config =", hardcoded_config)
106 print(
"\nProject object:")
demo(str file_path, int dimensions)
Demo: Read grid patch files, extract hardcoded split parameters, configure Hardcoded LB.