def test_copy(self): with struct.unsafe(): fluid = Fluid(Domain([4]), density='Density', velocity='Velocity') v = fluid.copied_with(velocity='V2') self.assertEqual(v.velocity, 'V2') self.assertEqual(v.density, 'Density') try: fluid.copied_with(velocity='D2') self.fail() except AssertionError: pass
def test_fluid_tf(self): world = World() fluid = Fluid(Domain([16, 16])) world.add(fluid) world.add(Inflow(Sphere((8, 8), radius=4))) world.add(Obstacle(box[4:16, 0:8])) fluid_in = fluid.copied_with(density=placeholder, velocity=placeholder) fluid_out = world.step(fluid_in) self.assertIsInstance(fluid_out, Fluid) session = Session(Scene.create('data', copy_calling_script=False)) fluid = session.run(fluid_out, {fluid_in: fluid}) fluid = session.run(fluid_out, {fluid_in: fluid}) self.assertIsInstance(fluid, Fluid)