U.V[i_cell][0] = -1.
    U.V[i_cell][1] =  1.

for patch_ in myMesh.patches:
    patch_length = len(patch_.faces)
    temp_vector = numpy.zeros((patch_length,3))
    for face_i,face_ in enumerate(patch_.faces):
        face_x = face_.C[0]
        face_y = face_.C[1]
        temp_vector[face_i][0] = -1.
        temp_vector[face_i][1] =  1.
    U.get_patch(patch_.name).set_patch_distributed(temp_vector, "fixedValue")
U.update_boundary_values()

# create rho field
rho = fields.ScalarField(myMesh, "rho", 1.0)

# create massflux field
m_dot = calcfield.MassFlux(U, rho)

# create vector field with boundary conditions
phi = fields.VectorField(myMesh, "phi_vec", [1., 10., 100.])
phi.get_patch("phi0"        ).set_patch_uniform([0., 9., 90.], "fixedValue"   )
phi.get_patch("phi1"        ).set_patch_uniform([1., 10., 100.], "fixedValue"   )
phi.get_patch("outlet"      ).set_patch_uniform(0., "fixedGradient")
phi.get_patch("frontAndBack").set_patch_uniform(0., "fixedGradient")

# create time loop
save_fields = [U,phi]

start_time = 0.
Exemplo n.º 2
0
# create mesh object and read mesh data from MESHES directory
myMesh = readers.FoamMesh("2dChannel_wide")
cell_volumes = myMesh.get_volumes()[:, 0]
face_areas = myMesh.get_areas()

# create and initialize field U, V and W
U = fields.VectorField(myMesh, "U", numpy.array([1., 0., 0.]))
U.get_patch("inlet").set_patch_uniform([1., 0., 0.], "fixedValue")
U.get_patch("outlet").set_patch_uniform(0., "fixedGradient")
U.get_patch("frontAndRear").set_patch_uniform(0., "fixedGradient")
U_old = fields.VectorField(myMesh, "U_old")
U_old.copy_field(U_old)

# create and initialize field p
p = fields.ScalarField(myMesh, "p", 0.)
p.get_patch("inlet").set_patch_uniform(0., "fixedGradient")
p.get_patch("walls").set_patch_uniform(0., "fixedGradient")
p.get_patch("frontAndRear").set_patch_uniform(0., "fixedGradient")
p_old = fields.ScalarField(myMesh, "p_old")
p_old.copy_field(p)
######################################
p_bef = fields.ScalarField(myMesh, "p_bef")
p_bef.copy_field(p)
######################################

# create and initialize field p_corr
p_corr = fields.ScalarField(myMesh, "p_corr", 0.)
p_corr.get_patch("inlet").set_patch_uniform(0., "fixedGradient")
p_corr.get_patch("walls").set_patch_uniform(0., "fixedGradient")
p_corr.get_patch("frontAndRear").set_patch_uniform(0., "fixedGradient")
import pyCFD_output.output as output
import pyCFD_fields.fields as fields
#import pyCFD_fields.calculated_fields as calcfield
import pyCFD_calculation.time_loop as time_loop
import pyCFD_operators.generic_equation as generic_equation
#import pyCFD_operators.explicit_operators as explicit_operators
import pyCFD_operators.implicit_operators as implicit_operators

# clear output dirs
output.clean_output_dirs()

# create mesh object and read mesh data from MESHES directory
myMesh = readers.FoamMesh("inclinedBlock")

# create scalar field with boundary conditions
phi = fields.ScalarField(myMesh, "phi", 273.)
phi.get_patch("phi0"        ).set_patch_uniform(273., "fixedValue"   )
phi.get_patch("phi1"        ).set_patch_uniform(300., "fixedValue"   )
phi.get_patch("frontAndRear").set_patch_uniform(0., "fixedGradient")

# create time loop
save_fields = [phi]

start_time = 0.
stop_time  = 3.
time_step  = 0.1
save_step  = 1.

myLoop = time_loop.TimeLoop(save_fields, start_time, stop_time, time_step)
myLoop.uniform_save_times(save_step)
Exemplo n.º 4
0
import pyCFD_output.output as output
import pyCFD_fields.fields as fields
#import pyCFD_fields.calculated_fields as calcfield
import pyCFD_calculation.time_loop as time_loop
import pyCFD_operators.generic_equation as generic_equation
import pyCFD_operators.explicit_operators as explicit_operators
import pyCFD_operators.implicit_operators as implicit_operators

# clear output dirs
output.clean_output_dirs()

# create mesh object and read mesh data from MESHES directory
myMesh = readers.FoamMesh()

# create scalar field with boundary conditions
phi = fields.ScalarField(myMesh, "phi", 0.)
phi.get_patch("left").set_patch_uniform(1., "fixedValue")
phi.get_patch("right").set_patch_uniform(2., "fixedValue")
phi.get_patch("bottom").set_patch_uniform(2., "fixedGradient")

# create time loop
save_fields = []
save_fields.append(phi)

start_time = 0.
stop_time = 2.
time_step = 1.
save_step = 1.

myLoop = time_loop.TimeLoop(save_fields, start_time, stop_time, time_step)
myLoop.uniform_save_times(save_step)
Exemplo n.º 5
0
    cell_x = myMesh.cells[i_cell].C[0]
    cell_y = myMesh.cells[i_cell].C[1]
    U.V[i_cell][0] = -1.
    U.V[i_cell][1] = 1.

for patch_ in myMesh.patches:
    patch_length = len(patch_.faces)
    temp_vector = numpy.zeros((patch_length, 3))
    for face_i, face_ in enumerate(patch_.faces):
        temp_vector[face_i][0] = -1.
        temp_vector[face_i][1] = 1.
    U.get_patch(patch_.name).set_patch_distributed(temp_vector, "fixedValue")
U.update_boundary_values()

# create rho field
rho = fields.ScalarField(myMesh, "rho", 1.0)

# create massflux field
m_dot = calcfield.MassFlux(U, rho)

# create scalar field with boundary conditions
phi = fields.ScalarField(myMesh, "phi", 1.0)
phi.get_patch("phi0").set_patch_uniform(0., "fixedValue")
phi.get_patch("phi1").set_patch_uniform(1., "fixedValue")
phi.get_patch("outlet").set_patch_uniform(0., "fixedGradient")
phi.get_patch("frontAndBack").set_patch_uniform(0., "fixedGradient")

# create time loop
save_fields = [U, phi]

start_time = 0.