Exemplo n.º 1
0
                                                         vf_walls])
end_wall = api.Boundary(name='endWall', condition=[vel_walls, pres_walls,
                                                   vf_walls])
top = api.Boundary(name='top', condition=[vel_top, pres_top, vf_top])
outlet = api.Boundary(name='outlet', condition=[vel_outlet, pres_outlet,
                                                vf_outlet])
frontAndBack = api.Boundary(name='frontAndBack', condition=[vel_frontAndBack,
                                                            pres_frontAndBack,
                                                            vf_frontAndBack])

cuds.add([inlet, bottom_wall, end_wall, top, outlet, frontAndBack])

mesh_in_cuds = cuds.get_by_name(mesh_name)

updated_cells = []
vf_sludge = api.PhaseVolumeFraction(sludge, 0.001)
vf_water = api.PhaseVolumeFraction(water, 1 - 0.001)

for cell in mesh_in_cuds.iter(item_type=CUBA.CELL):
    cell.data[CUBA.VOLUME_FRACTION] = [vf_sludge, vf_water]
    cell.data[CUBA.DYNAMIC_PRESSURE] = 0.0
    cell.data[CUBA.VELOCITY] = [0.0191, 0.0, 0.0]
    updated_cells.append(cell)

mesh_in_cuds._update_cells(updated_cells)

sim = Simulation(cuds, 'OpenFOAM', engine_interface=EngineInterface.Internal)

sim.run()

mesh_in_engine = cuds.get_by_name(mesh_name)
Exemplo n.º 2
0
                                                            pres_frontAndBack,
                                                            vf_frontAndBack])

cuds.add([inlet, walls, atm, frontAndBack])

# create mesh
mesh = foam_controlwrapper.create_block_mesh(tempfile.mkdtemp(), mesh_name,
                                             tube_mesh.blockMeshDict)
cuds.add([mesh])

mesh_in_cuds = cuds.get_by_name(mesh_name)

start = time.time()

updated_cells = []
zero_water = api.PhaseVolumeFraction(water, 0)
zero_air = api.PhaseVolumeFraction(air, 0)
one_water = api.PhaseVolumeFraction(water, 1)
one_air = api.PhaseVolumeFraction(air, 1)

# initial state. In VOF only one velocity and pressure field
# for cell in mesh_in_cuds._iter_cells_parallell():
for cell in mesh_in_cuds.iter(item_type=CUBA.CELL):
    ymid = sum(mesh_in_cuds._get_point(puid).coordinates[1]
               for puid in cell.points)
    ymid /= sum(1.0 for _ in cell.points)
    if ymid < 8e-3:
        cell.data[CUBA.VOLUME_FRACTION] = [one_water, zero_air]
    else:
        cell.data[CUBA.VOLUME_FRACTION] = [zero_water, one_air]