def fromOriginAndSize(cls, origin, width, length, height, convertToMeters=1, nDivXYZ=None, grading=None, xAxis=None): """Create BlockMeshDict from BFBlockGeometries. Args: origin: Minimum point of bounding box as (x, y, z). width: Width in x direction. length: Length in y direction. height: Height in y direction. convertToMeters: Scaling factor for the vertex coordinates. nDivXYZ: Number of divisions in (x, y, z) as a tuple (default: 5, 5, 5). grading: A simpleGrading (default: simpleGrading(1, 1, 1)). xAxis: An optional tuple that indicates the xAxis direction (default: (1, 0)). """ _xAxis = vectormath.normalize((xAxis[0], xAxis[1], 0) if xAxis else (1, 0, 0)) _zAxis = (0, 0, 1) _yAxis = vectormath.crossProduct(_zAxis, _xAxis) vertices = tuple( vectormath.move(origin, vectormath.sums((vectormath.scale(_xAxis, i * width), vectormath.scale(_yAxis, j * length), vectormath.scale(_zAxis, k * height)) )) for i in range(2) for j in range(2) for k in range(2)) return cls.fromVertices(vertices, convertToMeters, nDivXYZ, grading, xAxis)
def fromMinMax(cls, minPt, maxPt, convertToMeters=1, nDivXYZ=None, grading=None, xAxis=None): """Create BlockMeshDict from minimum and maximum point. Args: minPt: Minimum point of bounding box as (x, y, z). maxPt: Maximum point of bounding box as (x, y, z). convertToMeters: Scaling factor for the vertex coordinates. nDivXYZ: Number of divisions in (x, y, z) as a tuple (default: 5, 5, 5). grading: A simpleGrading (default: simpleGrading(1, 1, 1)). xAxis: An optional tuple that indicates the xAxis direction (default: (1, 0)). """ _xAxis = vectormath.normalize((xAxis[0], xAxis[1], 0) if xAxis else (1, 0, 0)) _zAxis = (0, 0, 1) _yAxis = vectormath.crossProduct(_zAxis, _xAxis) diagonal2D = tuple(i - j for i, j in zip(maxPt, minPt))[:2] _angle = radians(vectormath.angleAnitclockwise(_xAxis[:2], diagonal2D)) width = cos(_angle) * vectormath.length(diagonal2D) length = sin(_angle) * vectormath.length(diagonal2D) height = maxPt[2] - minPt[2] vertices = tuple( vectormath.move(minPt, vectormath.sums((vectormath.scale(_xAxis, i * width), vectormath.scale(_yAxis, j * length), vectormath.scale(_zAxis, k * height)) )) for i in range(2) for j in range(2) for k in range(2)) return cls.fromVertices(vertices, convertToMeters, nDivXYZ, grading, xAxis)
def from_min_max(cls, min_pt, max_pt, convertToMeters=1, n_div_xyz=None, grading=None, x_axis=None): """Create BlockMeshDict from minimum and maximum point. Args: min_pt: Minimum point of bounding box as (x, y, z). max_pt: Maximum point of bounding box as (x, y, z). convertToMeters: Scaling factor for the vertex coordinates. n_div_xyz: Number of divisions in (x, y, z) as a tuple (default: 5, 5, 5). grading: A simpleGrading (default: simpleGrading(1, 1, 1)). x_axis: An optional tuple that indicates the x_axis direction (default: (1, 0)). """ _x_axis = vectormath.normalize((x_axis[0], x_axis[1], 0) if x_axis else (1, 0, 0)) _z_axis = (0, 0, 1) _y_axis = vectormath.cross_product(_z_axis, _x_axis) diagonal2_d = tuple(i - j for i, j in zip(max_pt, min_pt))[:2] _angle = radians( vectormath.angle_anitclockwise(_x_axis[:2], diagonal2_d)) width = cos(_angle) * vectormath.length(diagonal2_d) length = sin(_angle) * vectormath.length(diagonal2_d) height = max_pt[2] - min_pt[2] vertices = [ vectormath.move( min_pt, vectormath.sums((vectormath.scale(_x_axis, i * width), vectormath.scale(_y_axis, j * length), vectormath.scale(_z_axis, k * height)))) for i in range(2) for j in range(2) for k in range(2) ] return cls.from_vertices(vertices, convertToMeters, n_div_xyz, grading, x_axis)
def fromOriginAndSize(cls, origin, width, length, height, convertToMeters=1, nDivXYZ=None, grading=None, xAxis=None): """Create BlockMeshDict from BFBlockGeometries. Args: origin: Minimum point of bounding box as (x, y, z). width: Width in x direction. length: Length in y direction. height: Height in y direction. convertToMeters: Scaling factor for the vertex coordinates. nDivXYZ: Number of divisions in (x, y, z) as a tuple (default: 5, 5, 5). grading: A simpleGrading (default: simpleGrading(1, 1, 1)). xAxis: An optional tuple that indicates the xAxis direction (default: (1, 0)). """ _xAxis = vectormath.normalize((xAxis[0], xAxis[1], 0) if xAxis else (1, 0, 0)) _zAxis = (0, 0, 1) _yAxis = vectormath.crossProduct(_zAxis, _xAxis) vertices = [ vectormath.move( origin, vectormath.sums((vectormath.scale(_xAxis, i * width), vectormath.scale(_yAxis, j * length), vectormath.scale(_zAxis, k * height)))) for i in range(2) for j in range(2) for k in range(2) ] return cls.fromVertices(vertices, convertToMeters, nDivXYZ, grading, xAxis)