Esempio n. 1
0
    def _create_scene(self):
        # from reset
        self.sources = []
        self.density.setConst(0)
        self.vel.setConst(vec3(0))
        is3d = (self.dimension > 2)

        # TODO , needed?
        # dont reset! multiple sims written into single file with increasing index...
        #self.file_num = 0

        source_count = randint(1, 2)  #  from scene_setup.scene_selection
        for i in range(source_count):
            print("_create_scene rand box ")
            box = volumes.random_box(center_min=[0.2, 0.1, 0.2],
                                     center_max=[0.8, 0.6, 0.8],
                                     size_min=[0.005, 0.005, 0.005],
                                     size_max=[0.2, 0.2, 0.2],
                                     is3d=is3d)

        super(SimpleScene, self)._create_scene()
        self.flags.initDomain(boundaryWidth=self.boundary)
        self.flags.fillGrid()
        if self.open_bound:
            setOpenBound(self.flags, self.boundary, 'yY',
                         16 | 4)  # FlagOutflow|FlagEmpty)

        print("_create_scene done")
Esempio n. 2
0
def initialize_simple_scene(scene):
    source_count = randint(1, 2)
    for i in range(source_count):
        box = v.random_box(center_min=[0.2, 0.1, 0.2],
                           center_max=[0.8, 0.6, 0.8],
                           size_min=[0.005, 0.005, 0.005],
                           size_max=[0.2, 0.2, 0.2])
Esempio n. 3
0
def initialize_smoke_scene(scene):
    source_count = randint(4, 10)
    for i in range(source_count):
        box = v.random_box(center_min=[0.2, 0.1, 0.2],
                           center_max=[0.8, 0.6, 0.8],
                           size_min=[0.005, 0.005, 0.005],
                           size_max=[0.2, 0.2, 0.2])
        scene.add_source(box)
Esempio n. 4
0
def spawn_drop(scene):
    box = v.random_box(center_min=[0, 0.7, 0],
                       center_max=[1, 0.9, 1],
                       size_min=[0.005, 0.005, 0.005],
                       size_max=[0.25, 0.25, 0.25])
    scene.add_fluid(box)
    drop_velo = v.random_velocity(vel_min=[-2.5, -2.5, -2.5],
                                  vel_max=[2.5, 0, 2.5])
    scene.set_velocity(box, drop_velo)
Esempio n. 5
0
def initialize_scene(scene, simple=False, obstacles=False, meshes=False):
    if simple:
        # low basin is the large volume of liquid at the bottom of the scene. in general adds most of the liquid in the scene
        low_basin = v.random_box(center_min=[0.5, 0.0, 0.5], center_max=[0.5, 0.0, 0.5], size_min=[1, 0.3, 1], size_max=[1, 0.5, 1])
        scene.add_fluid(low_basin)
        scene.set_velocity(low_basin, v.random_velocity(vel_min=[-0.5, 0, -0.5], vel_max=[0.5, 0, 0.5]))
        # the high basin is a tall but narrow block of liquid, adding motion to the scene
        high_basin = v.random_box(center_min=[0.1, 0.3, 0.1], center_max=[0.9, 0.4, 0.9], size_min=[0.1, 0.2, 0.1], size_max=[0.3, 0.4, 0.3])
        scene.add_fluid(high_basin)
        scene.set_velocity(high_basin, v.random_velocity(vel_min=[-2.0, -2.0, -2.0], vel_max=[2.0, 0, 2.0]))
    else:
        # low basin is the large volume of liquid at the bottom of the scene. in general adds most of the liquid in the scene
        low_basin = v.random_box(center_min=[0.5, 0.0, 0.5], center_max=[0.5, 0.0, 0.5], size_min=[1, 0.3, 1], size_max=[1, 0.6, 1])
        scene.add_fluid(low_basin)
        low_basin_velo = v.random_velocity(vel_min=[-1.5, 0, -1.5], vel_max=[1.5, 0, 1.5])
        scene.set_velocity(low_basin, low_basin_velo)
        # print("Low:\n\t{},{},{}\n\t{},{},{}\n\t{},{},{}".format(low_basin._center.x, low_basin._center.y, low_basin._center.z,
        #                                                         low_basin._size.x, low_basin._size.y, low_basin._size.z,
        #                                                         low_basin_velo.x, low_basin_velo.y, low_basin_velo.z))

        # the high basin is a tall but narrow block of liquid, adding motion to the scene
        high_basin = v.random_box(center_min=[0.0, 0.3, 0.0], center_max=[1.0, .3, 1.0], size_min=[0.1, 0.2, 0.1], size_max=[0.4, 0.5, 0.4])
        scene.add_fluid(high_basin)
        high_basin_velo =  v.random_velocity(vel_min=[-2.5, -2.5, -2.5], vel_max=[2.5, 0, 2.5])
        scene.set_velocity(high_basin, high_basin_velo)
        # print("High:\n\t{},{},{}\n\t{},{},{}\n\t{},{},{}".format(high_basin._center.x, high_basin._center.y, high_basin._center.z,
        #                                                         high_basin._size.x, high_basin._size.y, high_basin._size.z,
        #                                                         high_basin_velo.x, high_basin_velo.y, high_basin_velo.z))

        # drops: spawn at most 3 drops or meshes
        drop_count = randint(0, 3)
        for i in range(drop_count):
            if meshes and bool(getrandbits(1)):
                spawn_mesh(mesh_path, scene)
            else:
                spawn_drop(scene)

    # optional: add solid boxes to scene. more realistic, harder to learn
    if obstacles:
        obstacle = v.random_box(center_min=[0.1,0.1,0.1], center_max=[1.0,0.5,1.0], size_min=[0.2,0.2,0.2], size_max=[0.3,1.0,0.3])
        print("Added obstacle to the scene")
        scene.add_obstacle(obstacle)