# create voronoi mesh mesh = phd.Mesh(relax_iterations=10) # computation integrator = phd.MovingMeshMUSCLHancock() integrator.set_mesh(mesh) integrator.set_riemann(phd.HLLC()) integrator.set_particles(particles) integrator.set_domain_manager(domain_manager) integrator.set_boundary_condition(phd.Reflective()) integrator.set_reconstruction(phd.PieceWiseLinear()) integrator.set_equation_state(phd.IdealGas(gamma=gamma)) sim_name = "sod" if phd._in_parallel: integrator.set_load_balance(phd.LoadBalance()) sim_name = "mpi_sod" # add finish criteria simulation_time_manager = phd.SimulationTimeManager() simulation_time_manager.add_finish(phd.Time(time_max=0.15)) # output last step output = phd.FinalOutput() output.set_writer(phd.Hdf5()) simulation_time_manager.add_output(output) # Create simulator simulation = phd.Simulation(simulation_name=sim_name) simulation.set_integrator(integrator) simulation.set_simulation_time_manager(simulation_time_manager)
# tell each processor how many particles it will hold send = comm.scatter(send, root=0) # allocate local particle container pc = phd.ParticleContainer(send) # import particles from root fields = ['position-x', 'position-y', 'density', 'pressure', 'ids'] for field in fields: comm.Scatterv([pc_root[field], (lengths, disp)], pc[field]) pc['process'][:] = rank pc['tag'][:] = phd.ParticleTAGS.Real pc['type'][:] = phd.ParticleTAGS.Undefined domain = phd.DomainLimits(dim=2, xmin=0., xmax=1.) # spatial size of problem load_bal = phd.LoadBalance(domain, comm, order=21) # tree load balance scheme boundary = phd.BoundaryParallel(domain, # periodic boundary condition boundary_type=phd.BoundaryType.Periodic, load_bal, comm) mesh = phd.Mesh(boundary) # tesselation algorithm reconstruction = phd.PieceWiseConstant() # constant reconstruction riemann = phd.HLLC(reconstruction, gamma=1.4, cfl=0.5) # riemann solver integrator = phd.MovingMesh(pc, mesh, riemann, regularize=1) # integrator solver = phd.SolverParallel(integrator, # simulation driver cfl=0.5, tf=2.5, pfreq=25, relax_num_iterations=0, output_relax=False, fname='kh_2d_cartesian') solver.solve()
for field in fields: phd._comm.Scatterv([particles_root[field], (lengths, disp)], particles[field]) particles["tag"][:] = phd.ParticleTAGS.Real particles["type"][:] = phd.ParticleTAGS.Undefined # computation related to boundaries domain_manager = phd.DomainManager(xmin=[0., 0., 0.], xmax=[100., 100., 100.], initial_radius=0.1, dim=3) # load balance load_balance = phd.LoadBalance(factor=0.1, min_in_leaf=0, order=18) # setup gravity gravity_tree = phd.GravityTree(barnes_angle=0.4, smoothing_length=0.03) # computation integrator = phd.Nbody(dt=0.005) integrator.set_particles(particles) integrator.set_domain_manager(domain_manager) integrator.set_gravity_tree(gravity_tree) integrator.set_load_balance(load_balance) # add finish criteria simulation_time_manager = phd.SimulationTimeManager() simulation_time_manager.add_finish(phd.Time(time_max=1.0))
pc['velocity-x'][:] = 0.0 pc['velocity-y'][:] = 0.0 pc['process'][:] = rank pc['tag'][:] = phd.ParticleTAGS.Real pc['type'][:] = phd.ParticleTAGS.Undefined # simulation driver sim = phd.SimulationParallel(cfl=0.5, tf=0.1, pfreq=1, relax_num_iterations=10, output_relax=False, fname='sedov_2d_uniform') sim.add_component(pc) # create inital state of the simulation sim.add_component(comm) # create inital state of the simulation sim.add_component(phd.LoadBalance(order=21)) # tree load balance scheme sim.add_component(phd.DomainLimits(dim=2, xmin=0., xmax=1.)) # spatial size of problem sim.add_component( phd.BoundaryParallel( # reflective boundary condition boundary_type=phd.BoundaryType.Reflective)) sim.add_component(phd.Mesh()) # tesselation algorithm sim.add_component(phd.PieceWiseLinear()) # Linear reconstruction sim.add_component(phd.HLLC(gamma=1.4)) # riemann solver sim.add_component(phd.MovingMesh(regularize=1)) # Integrator # run the simulation sim.solve()