hb.relaxation_time = 0.0148 * foam.data[CUBA.DENSITY]
hb.linear_constant = 0.00268 * foam.data[CUBA.DENSITY]
hb.power_law_index = 0.5
hb.material = cuds.get_by_name('foam').uid
cfd.rheology_model = hb

cuds.add([cfd])

# time setting
sim_time = api.IntegrationTime(name='simulation_time',
                               current=0.0,
                               final=1000,
                               size=1)
cuds.add([sim_time])

sol_par = api.SolverParameter(name='steady_state')
sol_par.data[CUBA.STEADY_STATE] = True
cuds.add([sol_par])

end = time.time()
print "Time spend in initialization: ", end-start

start = time.time()
# create computational mesh
mesh = 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])
예제 #2
0
# material
mat = api.Material(name='a_material')
mat.data[CUBA.DENSITY] = 1.0
mat.data[CUBA.DYNAMIC_VISCOSITY] = 1.0
cuds.add([mat])

# time setting
sim_time = api.IntegrationTime(name='simulation_time',
                               current=0.0,
                               final=1.0,
                               size=0.01)
cuds.add([sim_time])

# solver parameter to write data
sp = api.SolverParameter(name='solver_parameters')
sp.data[CUBA.NUMBER_OF_PHYSICS_STATES] = 5
cuds.add([sp])

# create computational mesh

corner_points = [(0.0, 0.0, 0.0), (20.0e-3, 0.0, 0.0), (20.0e-3, 1.0e-3, 0.0),
                 (0.0, 1.0e-3, 0.0), (0.0, 0.0, 0.1e-3),
                 (20.0e-3, 0.0, 0.1e-3), (20.0e-3, 1.0e-3, 0.1e-3),
                 (0.0, 1.0e-3, 0.1e-3)]
# elements in x -direction
nex = 8
# elements in y -direction
ney = 4
# this routine creates one block quad mesh
#  - boundaries have predescribed names (inlet, walls, outlet, frontAndBack)
    def setUp(self):

        case_name = "simplemesh_parallel"
        mesh_name = "simplemesh_parallel_mesh"
        cuds = CUDS(name=case_name)
        # physics model
        cfd = api.Cfd(name='default model')
        cuds.add([cfd])

        self.sp = api.SolverParameter(name='solver_parameters')
        self.sp._data[CUBA.NUMBER_OF_CORES] = 4

        cuds.add([self.sp])

        sim_time = api.IntegrationTime(name='simulation_time',
                                       current=0.0,
                                       final=1.0,
                                       size=1.0)
        cuds.add([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)