import numpy
import pyCFD_mesh.readers as readers
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 and initialize field U
U = fields.VectorField(myMesh, "U")

for i_cell in range(len(U.V)):
    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):
        face_x = face_.C[0]
Example #2
0
import numpy
import pyCFD_mesh.readers as readers
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
import pyCFD_monitors.monitors as monitors
import pyCFD_linear_solvers.linear_solvers as mylin
#import pyCFD_fields.initialization as init

# 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")
Example #3
0
import numpy
import pyCFD_mesh.readers as readers
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("cavity")
cell_volumes = myMesh.get_volumes()[:, 0]
face_areas = myMesh.get_areas()

# create and initialize field U, V and W
U = fields.VectorField(myMesh, "U")
U.get_patch("movingWall").set_patch_uniform([1., 0., 0.], "fixedValue")
U.get_patch("frontAndBack").set_patch_uniform(0., "fixedGradient")
U_old = fields.VectorField(myMesh, "U_old")

# create and initialize field p
p = fields.ScalarField(myMesh, "p", 0.)
p.get_patch("movingWall").set_patch_uniform(0., "fixedGradient")
p.get_patch("fixedWalls").set_patch_uniform(0., "fixedGradient")
p.get_patch("frontAndBack").set_patch_uniform(0., "fixedGradient")
Config_.__OUTITERDIRREL__   = 'ITERATIONS/'

import pyCFD_mesh.readers as readers
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.
Example #5
0
Config_.__OUTDIR__ = '_OUTPUT/'
Config_.__OUTITERDIR__ = '_OUTPUT/ITERATIONS/'
Config_.__OUTITERDIRREL__ = 'ITERATIONS/'

import numpy
import pyCFD_mesh.readers as readers
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

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

# create and initialize field U
U = fields.VectorField(myMesh, "U")

for i_cell in range(len(U.V)):
    cell_x = myMesh.cells[i_cell].C[0]
    cell_y = myMesh.cells[i_cell].C[1]
    U.V[i_cell][0] = 2. * cell_y * (1. - pow(cell_x, 2))
    U.V[i_cell][1] = -2. * cell_x * (1. - pow(cell_y, 2))

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]