start = time.time() # create computational mesh mesh = foam_controlwrapper.create_block_mesh(tempfile.mkdtemp(), mesh_name, pipe_mesh.blockMeshDict) end = time.time() print "Time spend in blockmesh: ", end - start start = time.time() cuds.add([mesh]) end = time.time() print "Time spend in add mesh to cuds: ", end - start start = time.time() # boundary conditions vel_inlet = api.Dirichlet(foam, name='vel_inlet') vel_inlet.data[CUBA.VARIABLE] = CUBA.VELOCITY vel_inlet.data[CUBA.VELOCITY] = (0, 0, 0.53) pres_inlet = api.Neumann(foam, name='pres_inlet') pres_inlet.data[CUBA.VARIABLE] = CUBA.PRESSURE vel_outlet = api.Neumann(foam, name='vel_outlet') vel_outlet.data[CUBA.VARIABLE] = CUBA.VELOCITY pres_outlet = api.Dirichlet(foam, name='pres_outlet') pres_outlet.data[CUBA.VARIABLE] = CUBA.PRESSURE pres_outlet.data[CUBA.PRESSURE] = 0.0 vel_walls = api.ShearStressPowerLawSlipVelocity(foam, density=250.0, linear_constant=3.1e-3, power_law_index=1.16,
# water is Newtonian so no need to add that to rheology models cfd.rheology_model = bp cuds.add([cfd]) sm = api.StandardStressModel(name='standard_stress_model') cuds.add([sm]) rvm = api.MesoscopicRelativeVelocityModel(name='meso_rel_vel_model') cuds.add([rvm]) gm = api.GravityModel(name='gravitation') gm.acceleration = (0, -9.81, 0) cuds.add([gm]) vel_inlet = api.Dirichlet(water, name='vel_inlet') vel_inlet.data[CUBA.VARIABLE] = CUBA.VELOCITY vel_inlet.data[CUBA.VELOCITY] = (0.0191, 0, 0) pres_inlet = api.Neumann(water, name='pres_inlet') pres_inlet.data[CUBA.VARIABLE] = CUBA.DYNAMIC_PRESSURE vf_inlet = api.Dirichlet(water, name='vf_inlet') vf_inlet.data[CUBA.VARIABLE] = CUBA.VOLUME_FRACTION vf_inlet.data[CUBA.VOLUME_FRACTION] = 0.001 vel_outlet = api.InletOutletVelocity((0, 0, 0), name='vel_outlet') pres_outlet = api.Dirichlet(water, name='pres_outlet') pres_outlet.data[CUBA.VARIABLE] = CUBA.DYNAMIC_PRESSURE pres_outlet.data[CUBA.DYNAMIC_PRESSURE] = 0.0 vf_outlet = api.InletOutletVolumeFraction(0.001, name='vf_outlet') vel_walls = api.Dirichlet(water, name='vel_walls')
def setUp(self): case_name = "simplemeshIO" mesh_name = "simplemeshIO_mesh" cuds = CUDS(name=case_name) # physics model cfd = api.Cfd(name='default model') cuds.add([cfd]) self.sim_time = api.IntegrationTime(name='simulation_time', current=0.0, final=1.0, size=0.5) cuds.add([self.sim_time]) mat = api.Material(name='a_material') mat._data[CUBA.DENSITY] = 1.0 mat._data[CUBA.DYNAMIC_VISCOSITY] = 1.0 cuds.add([mat]) vel_inlet = api.Dirichlet(mat, name='vel_inlet') vel_inlet._data[CUBA.VARIABLE] = CUBA.VELOCITY vel_inlet._data[CUBA.VELOCITY] = (0.1, 0, 0) pres_inlet = api.Neumann(mat, name='pres_inlet') pres_inlet._data[CUBA.VARIABLE] = CUBA.PRESSURE vel_outlet = api.Neumann(mat, name='vel_outlet') vel_outlet._data[CUBA.VARIABLE] = CUBA.VELOCITY pres_outlet = api.Dirichlet(mat, name='pres_outlet') pres_outlet._data[CUBA.VARIABLE] = CUBA.PRESSURE pres_outlet._data[CUBA.PRESSURE] = 0.0 vel_walls = api.Dirichlet(mat, name='vel_walls') vel_walls._data[CUBA.VARIABLE] = CUBA.VELOCITY vel_walls._data[CUBA.VELOCITY] = (0, 0, 0) pres_walls = api.Neumann(mat, name='pres_walls') pres_walls._data[CUBA.VARIABLE] = CUBA.PRESSURE vel_frontAndBack = api.EmptyCondition(name='vel_frontAndBack') vel_frontAndBack._data[CUBA.VARIABLE] = CUBA.VELOCITY pres_frontAndBack = api.EmptyCondition(name='pres_frontAndBack') pres_frontAndBack._data[CUBA.VARIABLE] = CUBA.PRESSURE inlet = api.Boundary(name='inlet', condition=[vel_inlet, pres_inlet]) walls = api.Boundary(name='walls', condition=[vel_walls, pres_walls]) outlet = api.Boundary(name='outlet', condition=[vel_outlet, pres_outlet]) frontAndBack = api.Boundary( name='frontAndBack', condition=[vel_frontAndBack, pres_frontAndBack]) cuds.add([inlet, walls, outlet, frontAndBack]) corner_points = [(0.0, 0.0, 0.0), (5.0, 0.0, 0.0), (5.0, 5.0, 0.0), (0.0, 5.0, 0.0), (0.0, 0.0, 1.0), (5.0, 0.0, 1.0), (5.0, 5.0, 1.0), (0.0, 5.0, 1.0)] self.mesh_path = tempfile.mkdtemp() mesh = create_quad_mesh(self.mesh_path, mesh_name, corner_points, 5, 5, 5) cuds.add([mesh]) self.cuds = cuds self.sim = Simulation(cuds, 'OpenFOAM', engine_interface=EngineInterface.FileIO) self.mesh_in_cuds = self.cuds.get_by_name(mesh_name)
def test_Dirichlet(self): meta_class.Dirichlet(material=meta_class.Material())