|
| 1 | +import importlib |
| 2 | + |
1 | 3 | from pyro.burgers import Simulation as burgers_sim |
2 | 4 | from pyro.burgers import burgers_interface |
3 | | -from pyro.mesh import reconstruction |
| 5 | +from pyro.mesh import patch, reconstruction |
| 6 | +from pyro.particles import particles |
| 7 | +from pyro.simulation_null import bc_setup, grid_setup |
4 | 8 | from pyro.viscous_burgers import interface |
5 | 9 |
|
6 | 10 |
|
7 | 11 | class Simulation(burgers_sim): |
8 | 12 |
|
| 13 | + def initialize(self): |
| 14 | + """ |
| 15 | + Initialize the grid and variables for advection and set the initial |
| 16 | + conditions for the chosen problem. |
| 17 | + """ |
| 18 | + |
| 19 | + # create grid, self.rp contains mesh.nx and mesh.ny |
| 20 | + my_grid = grid_setup(self.rp, ng=4) |
| 21 | + |
| 22 | + # create the variables |
| 23 | + my_data = patch.CellCenterData2d(my_grid) |
| 24 | + |
| 25 | + # outputs: bc, bc_xodd and bc_yodd for reflection boundary cond |
| 26 | + bc = bc_setup(self.rp)[0] |
| 27 | + |
| 28 | + # register variables in the data |
| 29 | + # burgers equation advects velocity |
| 30 | + |
| 31 | + my_data.register_var("x-velocity", bc) |
| 32 | + my_data.register_var("y-velocity", bc) |
| 33 | + my_data.create() |
| 34 | + |
| 35 | + # holds various data, like time and registered variable. |
| 36 | + self.cc_data = my_data |
| 37 | + |
| 38 | + if self.rp.get_param("particles.do_particles") == 1: |
| 39 | + n_particles = self.rp.get_param("particles.n_particles") |
| 40 | + particle_generator = self.rp.get_param("particles.particle_generator") |
| 41 | + self.particles = particles.Particles(self.cc_data, bc, n_particles, particle_generator) |
| 42 | + |
| 43 | + # now set the initial conditions for the problem |
| 44 | + problem = importlib.import_module(f"pyro.viscous_burgers.problems.{self.problem_name}") |
| 45 | + problem.init_data(self.cc_data, self.rp) |
| 46 | + |
9 | 47 | def evolve(self): |
10 | 48 | """ |
11 | 49 | Evolve the viscous burgers equation through one timestep. |
|
0 commit comments