def create_cube(shape, width, height, depth): """ Creates a cube-shaped single-zone structured domain. """ imax, jmax, kmax = shape delta_x = float(width) / (imax - 1) delta_y = float(height) / (jmax - 1) delta_z = float(depth) / (kmax - 1) dtype = numpy.float32 # Default single-precision. x = numpy.zeros(shape, dtype=dtype) y = numpy.zeros(shape, dtype=dtype) z = numpy.zeros(shape, dtype=dtype) q1 = numpy.zeros(shape, dtype=dtype) q2 = numpy.zeros(shape, dtype=dtype) q3 = numpy.zeros(shape, dtype=dtype) q4 = numpy.zeros(shape, dtype=dtype) q5 = numpy.zeros(shape, dtype=dtype) for i in range(imax): for j in range(jmax): for k in range(kmax): x.itemset(i, j, k, delta_x * i) y.itemset(i, j, k, delta_y * j) z.itemset(i, j, k, delta_z * k) q1.itemset(i, j, k, delta_x * i) q2.itemset(i, j, k, delta_x * i) q3.itemset(i, j, k, delta_y * j) q4.itemset(i, j, k, delta_z * k) q5.itemset(i, j, k, delta_z * k) momentum = Vector() momentum.x = q2 momentum.y = q3 momentum.z = q4 zone = Zone() zone.grid_coordinates.x = x zone.grid_coordinates.y = y zone.grid_coordinates.z = z zone.flow_solution.mach = 0.5 zone.flow_solution.alpha = 0. zone.flow_solution.reynolds = 100000. zone.flow_solution.time = 42. zone.flow_solution.add_array('density', q1) zone.flow_solution.add_vector('momentum', momentum) zone.flow_solution.add_array('energy_stagnation_density', q5) domain = DomainObj() domain.reference_state = dict(length_reference=PhysicalQuantity(1., 'ft')) domain.add_zone('xyzzy', zone) return domain
def create_wedge_2d(shape, inner, outer, angle): """ Creates a 2D wedge-shaped single-zone structured domain. """ imax, jmax = shape delta_radius = float(outer - inner) / (imax - 1) if imax > 1 else 1. delta_theta = float(angle * _DEG2RAD) / (jmax - 1) if jmax > 1 else 1. dtype = numpy.float32 # Default single-precision. x = numpy.zeros(shape, dtype=dtype) y = numpy.zeros(shape, dtype=dtype) q1 = numpy.zeros(shape, dtype=dtype) q2 = numpy.zeros(shape, dtype=dtype) q3 = numpy.zeros(shape, dtype=dtype) q4 = numpy.zeros(shape, dtype=dtype) for i in range(imax): radial = inner + delta_radius * i for j in range(jmax): tangential = delta_theta * j x.itemset(i, j, radial * cos(tangential)) y.itemset(i, j, radial * sin(tangential)) q1.itemset(i, j, radial) q2.itemset(i, j, radial) q3.itemset(i, j, tangential) q4.itemset(i, j, tangential) momentum = Vector() momentum.x = q2 momentum.y = q3 zone = Zone() zone.grid_coordinates.x = x zone.grid_coordinates.y = y zone.flow_solution.mach = 0.5 zone.flow_solution.alpha = 0. zone.flow_solution.reynolds = 100000. zone.flow_solution.time = 42. zone.flow_solution.add_array('density', q1) zone.flow_solution.add_vector('momentum', momentum) zone.flow_solution.add_array('energy_stagnation_density', q4) domain = DomainObj() domain.reference_state = dict(length_reference=PhysicalQuantity(1., 'ft')) domain.add_zone('xyzzy', zone) return domain
def create_curve_2d(npoints, radius, angle): """ Creates a curve (arc) of `npoints` at `radius` through `angle`. """ delta_theta = float(angle * _DEG2RAD) / (npoints - 1) dtype = numpy.float32 # Default single-precision. shape = (npoints,) x = numpy.zeros(shape, dtype=dtype) y = numpy.zeros(shape, dtype=dtype) q1 = numpy.zeros(shape, dtype=dtype) q2 = numpy.zeros(shape, dtype=dtype) q3 = numpy.zeros(shape, dtype=dtype) q4 = numpy.zeros(shape, dtype=dtype) for i in range(npoints): tangential = delta_theta * i x.itemset(i, radius * cos(tangential)) y.itemset(i, radius * sin(tangential)) q1.itemset(i, radius) q2.itemset(i, radius) q3.itemset(i, tangential) q4.itemset(i, tangential) momentum = Vector() momentum.x = q2 momentum.y = q3 zone = Zone() zone.grid_coordinates.x = x zone.grid_coordinates.y = y zone.flow_solution.mach = 0.5 zone.flow_solution.alpha = 0. zone.flow_solution.reynolds = 100000. zone.flow_solution.time = 42. zone.flow_solution.add_array('density', q1) zone.flow_solution.add_vector('momentum', momentum) zone.flow_solution.add_array('energy_stagnation_density', q4) domain = DomainObj() domain.reference_state = dict(length_reference=PhysicalQuantity(1., 'ft')) domain.add_zone('xyzzy', zone) return domain
def create_curve_2d(npoints, radius, angle): """ Creates a curve (arc) of `npoints` at `radius` through `angle`. """ delta_theta = float(angle * _DEG2RAD) / (npoints - 1) dtype = numpy.float32 # Default single-precision. shape = (npoints, ) x = numpy.zeros(shape, dtype=dtype) y = numpy.zeros(shape, dtype=dtype) q1 = numpy.zeros(shape, dtype=dtype) q2 = numpy.zeros(shape, dtype=dtype) q3 = numpy.zeros(shape, dtype=dtype) q4 = numpy.zeros(shape, dtype=dtype) for i in range(npoints): tangential = delta_theta * i x.itemset(i, radius * cos(tangential)) y.itemset(i, radius * sin(tangential)) q1.itemset(i, radius) q2.itemset(i, radius) q3.itemset(i, tangential) q4.itemset(i, tangential) momentum = Vector() momentum.x = q2 momentum.y = q3 zone = Zone() zone.grid_coordinates.x = x zone.grid_coordinates.y = y zone.flow_solution.mach = 0.5 zone.flow_solution.alpha = 0. zone.flow_solution.reynolds = 100000. zone.flow_solution.time = 42. zone.flow_solution.add_array('density', q1) zone.flow_solution.add_vector('momentum', momentum) zone.flow_solution.add_array('energy_stagnation_density', q4) domain = DomainObj() domain.reference_state = dict(length_reference=PhysicalQuantity(1., 'ft')) domain.add_zone('xyzzy', zone) return domain