Module Classes¶
The autodocumentation for the hexapy module is provided below.
-
class
hexapy.Mesher¶ This class provides functionality for creating hexahedral meshes of primitives.
-
__dict__= dict_proxy({'makeCylinder': <function makeCylinder>, '__module__': 'hexapy.hexapy', '_findProjectionDirection': <function _findProjectionDirection>, 'defineElementSet': <function defineElementSet>, 'defineNodeSet': <function defineNodeSet>, 'makeQuarterCylinder': <function makeQuarterCylinder>, '__dict__': <attribute '__dict__' of 'Mesher' objects>, '_makeBlock': <function _makeBlock>, '_faceSetFromNodeSet': <function _faceSetFromNodeSet>, 'makeQuarterEllipsoid': <function makeQuarterEllipsoid>, 'applyRigidTransform': <function applyRigidTransform>, 'makeBox': <function makeBox>, '_mergeBlocks': <function _mergeBlocks>, 'makeEllipsoid': <function makeEllipsoid>, '__init__': <function __init__>, 'makeHalfCylinder': <function makeHalfCylinder>, 'makeHalfEllipsoid': <function makeHalfEllipsoid>, '__weakref__': <attribute '__weakref__' of 'Mesher' objects>, '_interpSpherical': <function _interpSpherical>, 'writeToFile': <function writeToFile>, 'defineSurfaceSet': <function defineSurfaceSet>, '_interpCylindrical': <function _interpCylindrical>, '__doc__': '\n This class provides functionality for creating hexahedral meshes of primitives.\n ', 'makeEighthEllipsoid': <function makeEighthEllipsoid>})¶
-
__init__()¶ -
meshes¶ [, dict, ...] – List of meshes stored as dictionaries. Dictionary fields are as follows: * ‘Name’ – str, optional
Name assigned to mesh - defaults to “Part_i” as appended- ‘Nodes’ – ndarray((N, 3), dtype=float)
Array of node ids and coordinates
‘Node IDs’ – ndarray(N, dtype=int)
- ‘Elements’ – ndarray((N, 8), dtype=(int, ...) )
Array of element ids [:,0] and nodal connectivity [:,1:]
‘Element IDs’ – ndarray(N, dtype=int)
- ‘Element Sets’ – dict(‘name’, ndarray((N,1), dtype=int))
Each dictionary key is the set name and the value is an array of element ids in the set. Default key:
“all”: all elements in the mesh
- ‘Node Sets’ – dict(‘name’, ndarray((N,1), dtype=int))
Each dictionary key is the set name and the value is an array of node ids in the set. Default key:
“all”: all nodes in the mesh
‘Surface Sets’ – dict(‘name’, ndarray((N,4))) Each dictionary key is the set name and the value is an array of faces (rows) indicated by nodal connectivity
-
_coordinates¶ [, ndarray(N, 3), ...] – List of x, y, and z coordinate ranges in undeformed block for mesh in same index.
-
-
__module__= 'hexapy.hexapy'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
_faceSetFromNodeSet(nset, elements, eids)¶
-
_findProjectionDirection(points, case, sym)¶
-
_interpCylindrical(block, a, b, t, case, sym)¶ Map nodal coordinates of passed block to cylinder defined in polar.
Parameters: - block (dict) – The block to map.
- a (float) – The major radius of the elliptical cross-section
- b (float) – The minor radius of the elliptical cross-section
- t ([float, float]) – The domain of angles to interpolate between (specified in radians)
- case (str) – Side of block to project to arc. Options - ‘left’, ‘right’, ‘top’, ‘bottom’
- sym (str) – Symmetry case. Options - ‘none’, ‘half’, ‘quarter’
Returns: Return type: The block with mapped nodal coordinates.
-
_interpSpherical(block, a, b, c, case, sym)¶ Map nodal coordinates of passed block to cylinder defined in polar.
Parameters: - block (dict) – The block to map.
- a (float) – The major radius of the ellipsoid
- b (float) – The middle radius of the ellipsoid
- c (float) – The minor radius of the ellipsoid
- case (str) – Side of block to project to arc. Options - ‘left’, ‘right’, ‘top’, ‘bottom’, ‘back’, ‘front’
- sym (str) – Symmetry case. Options - ‘none’, ‘half’, ‘quarter’, ‘eighth’
Returns: Return type: The block with mapped nodal coordinates.
-
_makeBlock(x_origin, y_origin, z_origin, x_length, y_length, z_length, x_div, y_div, z_div)¶
-
_mergeBlocks(blockList, tol=1e-14)¶ Merges a list of blocks into one mesh. Nodes within a tolerance are merged.
Parameters: - blockList ([dict,]) – list of block dictionaries
- tol (float 1e-14, optional) – merge nodes within this distance
Returns: Return type: Mesh with coincident nodes of blocks in list merged.
-
applyRigidTransform(mesh_index=None, translation=[0.0, 0.0, 0.0], method='angles', q=<Mock name='mock()' id='140112003070736'>, rx=0.0, ry=0.0, rz=0.0)¶ Applies a rigid transformation to the mesh indicated by its index. Specify rotations either by a matrix or as x, y, and z rotation angles (degrees).
Note: When using angles, the order of application is x then y then z.
Parameters: - translation ([float=0.0, float=0.0, float=0.0], optional) –
- method (str="angles", optional) – “angles” : use rotation angles “matrix” : use rotation matrix
- q (ndarray((3,3), dtype=float), optional) – The rotation matrix. If unspecified defaults to identity.
- rx (float=0.0) – x rotation angle (degrees)
- ry (float=0.0) – y rotation angle (degrees)
- rz (float=0.0) – z rotation angle (degrees)
Returns: Return type: Modifies mesh nodal coordinates for specified meshes item.
-
defineElementSet(mesh_index=None, **kwargs)¶ Define an additonal element set for mesh indicated by mesh_index.
Parameters: - name (str, required) – Name to assign to the set. WARNING: If the name already exists either it will be overwritten or be replaced by the union depending on value of overwrite.
- element_ids (ndarray((n,1), dtype=int)) –
- overwrite (bool=True, optional) – If a set with the indicated name exists overwrite is True. Otherwise, take the union of new set with old.
Returns: Appends mesh dictionary key
Return type: “Element Sets” the key (name, element_ids)
-
defineNodeSet(mesh_index=None, **kwargs)¶ Define an additonal node set for mesh indicated by mesh_index.
Parameters: - name (str, required) – Name to assign to the set. WARNING: If the name already exists either it will be overwritten or be replaced by the union depending on value of overwrite.
- node_ids (ndarray((n,1), dtype=int)) –
- overwrite (bool=True, optional) – If a set with the indicated name exists overwrite is True. Otherwise, take the union of new set with old.
Returns: Appends mesh dictionary key
Return type: “Node Sets” the key (name, node_ids)
-
defineSurfaceSet(mesh_index=None, **kwargs)¶ Define an additonal surface set for mesh indicated by mesh_index.
Parameters: - name (str, required) – Name to assign to the set. WARNING: If the name already exists either it will be overwritten or be replaced by the union depending on value of overwrite.
- faces (ndarray((n,4), dtype=int)) – Each row is a nodal connectivity list for a face.
- overwrite (bool=True, optional) – If a set with the indicated name exists overwrite is True. Otherwise, take the union of new set with old.
Returns: Appends mesh dictionary key
Return type: “Face Sets” the key (name, faces)
-
makeBox(name=None, x_origin=None, y_origin=None, z_origin=None, x_length=1.0, y_length=1.0, z_length=1.0, x_div=10, y_div=10, z_div=10, x_edge=-1.0, y_edge=-1.0, z_edge=-1.0)¶ Create a box.
Parameters: - name (str, optional) – Name identifier for mesh. Defaults to “Part_{:s}”.format(index in meshes)
- x_length (float=1.0, optional) – The box x-length
- y_length (float=1.0, optional) – The box y-length
- z_length (float=1.0, optional) – The box z-length
- x_div (int=10, optional) – Number of element divisions in the x-direction
- y_div (int=10, optional) – Number of element divisions in the y-direction
- z_div (int=10, optional) – Number of element divisions in the z-direction
- x_edge (float=-1.0, optional) – Overrides x_div with absolute edge length (ignored if non-positive)
- y_edge (float=-1.0, optional) – Overrides y_div with absolute edge length (ignored if non-positive)
- z_edge (float=-1.0, optional) – Overrides z_div with absolute edge length (ignored if non-positive)
Returns: Return type: Appends a box mesh definition to meshes.
-
makeCylinder(name=None, r_major=1.0, r_minor=1.0, z_length=1.0, r_major_div=10, r_minor_div=10, z_div=10, r_major_edge=-1.0, r_minor_edge=-1.0, z_edge=-1.0)¶ Create an elliptic cylinder.
Parameters: - name (str, optional) – Name identifier for mesh. Defaults to “Part_{:s}”.format(index in meshes)
- r_major (float 1.0, optional) – Major radius of the elliptical z-slices
- r_minor (float 1.0, optional) – Minor radius of the elliptical z-slices
- z_length (float 1.0, optional) – Cylinder height.
- r_major_div (int=10, optional) – Number of element divisions in the major radius direction
- r_minor_div (int=10, optional) – Number of element divisions in the minor radius direction
- z_div (int=10, optional) – Number of element divisions in the z-direction
- r_major_edge (float=-1.0, optional) – Overrides r_major_div with absolute edge length (ignored if non-positive)
- r_minor_edge (float=-1.0, optional) – Overrides r_minor_div with absolute edge length (ignored if non-positive)
- z_edge (float=-1.0, optional) – Overrides z_div with absolute edge length (ignored if non-positive)
Returns: Return type: Appends an elliptic cylinder mesh definition to meshes.
-
makeEighthEllipsoid(name=None, r_major=1.0, r_middle=1.0, r_minor=1.0, r_major_div=10, r_middle_div=10, r_minor_div=10, r_major_edge=-1.0, r_middle_edge=-1.0, r_minor_edge=-1.0)¶ Create a half-ellipsoid.
Parameters: - name (str, optional) – Name identifier for mesh. Defaults to “Part {:s}”.format(index in meshes)
- r_major (float 1.0, optional) – Major radius of ellipsoid
- r_middle (float 1.0, optional) – Middle radius of ellipsoid
- r_minor (float 1.0, optional) – Minor radius of ellipsoid
- r_major_div (int 10, optional) – Number of element divisions in the major radial direction
- r_middle_div (int 10, optional) – Number of element divisions in the middle radial direction
- r_minor_div (int 10, optional) – Number of element divisions in the minor radial direction
- r_major_edge (float=-1.0, optional) – Overrides r_major_div with absolute radial edge length (ignored if non-positive)
- r_middle_edge (float=-1.0, optional) – Overrides r_middle_div with absolute radial edge length (ignored if non-positive)
- r_minor_edge (float=-1.0, optional) – Overrides r_minor_div with absolute radial edge length (ignored if non-positive)
Returns: Return type: Appends an ellipsoidal mesh definition to meshes.
-
makeEllipsoid(name=None, r_major=1.0, r_middle=1.0, r_minor=1.0, r_major_div=10, r_middle_div=10, r_minor_div=10, r_major_edge=-1.0, r_middle_edge=-1.0, r_minor_edge=-1.0)¶ Create a ellipsoid.
- name : str, optional
- Name identifier for mesh. Defaults to “Part {:s}”.format(index in meshes)
- r_major : float 1.0, optional
- Major radius of ellipsoid
- r_middle : float 1.0, optional
- Middle radius of ellipsoid
- r_minor : float 1.0, optional
- Minor radius of ellipsoid
- prop = np.sqrt(np.pi / 4.0)
- r_major_div : int 10, optional
- Number of element divisions in the major radial direction
- r_middle_div : int 10, optional
- Number of element divisions in the middle radial direction
- r_minor_div : int 10, optional
- Number of element divisions in the minor radial direction
- r_major_edge : float=-1.0, optional
- Overrides r_major_div with absolute radial edge length (ignored if non-positive)
- r_middle_edge : float=-1.0, optional
- Overrides r_middle_div with absolute radial edge length (ignored if non-positive)
- r_minor_edge : float=-1.0, optional
- Overrides r_minor_div with absolute radial edge length (ignored if non-positive)
Appends an ellipsoidal mesh definition to meshes.
-
makeHalfCylinder(name=None, r_major=1.0, r_minor=1.0, z_length=1.0, r_major_div=10, r_minor_div=10, z_div=10, r_major_edge=-1.0, r_minor_edge=-1.0, z_edge=-1.0)¶ Create a half-elliptic cylinder.
Parameters: - name (str, optional) – Name identifier for mesh. Defaults to “Part {:s}”.format(index in meshes)
- r_major (float 1.0, optional) – Major radius of the elliptical z-slices
- r_minor (float 1.0, optional) – Minor radius of the elliptical z-slices
- z_length (float 1.0, optional) – Cylinder height.
- r_major_div (int=10, optional) – Number of element divisions in the major radius direction
- r_minor_div (int=10, optional) – Number of element divisions in the minor radius direction
- z_div (int=10, optional) – Number of element divisions in the z-direction
- r_major_edge (float=-1.0, optional) – Overrides r_major_div with absolute edge length (ignored if non-positive)
- r_minor_edge (float=-1.0, optional) – Overrides r_minor_div with absolute edge length (ignored if non-positive)
- z_edge (float=-1.0, optional) – Overrides z_div with absolute edge length (ignored if non-positive)
Returns: Return type: Appends a half elliptic cylinder mesh definition to meshes.
-
makeHalfEllipsoid(name=None, r_major=1.0, r_middle=1.0, r_minor=1.0, r_major_div=10, r_middle_div=10, r_minor_div=10, r_major_edge=-1.0, r_middle_edge=-1.0, r_minor_edge=-1.0)¶ Create a half-ellipsoid.
Parameters: - name (str, optional) – Name identifier for mesh. Defaults to “Part {:s}”.format(index in meshes)
- r_major (float 1.0, optional) – Major radius of ellipsoid
- r_middle (float 1.0, optional) – Middle radius of ellipsoid
- r_minor (float 1.0, optional) – Minor radius of ellipsoid
- r_major_div (int 10, optional) – Number of element divisions in the major radial direction
- r_middle_div (int 10, optional) – Number of element divisions in the middle radial direction
- r_minor_div (int 10, optional) – Number of element divisions in the minor radial direction
- r_major_edge (float=-1.0, optional) – Overrides r_major_div with absolute radial edge length (ignored if non-positive)
- r_middle_edge (float=-1.0, optional) – Overrides r_middle_div with absolute radial edge length (ignored if non-positive)
- r_minor_edge (float=-1.0, optional) – Overrides r_minor_div with absolute radial edge length (ignored if non-positive)
Returns: Return type: Appends an ellipsoidal mesh definition to meshes.
-
makeQuarterCylinder(name=None, r_major=1.0, r_minor=1.0, z_length=1.0, r_major_div=10, r_minor_div=10, z_div=10, r_major_edge=-1.0, r_minor_edge=-1.0, z_edge=-1.0)¶ Create a quarter-elliptic cylinder.
Parameters: - name (str, optional) – Name identifier for mesh. Defaults to “Part {:s}”.format(index in meshes)
- r_major (float 1.0, optional) – Major radius of the elliptical z-slices
- r_minor (float 1.0, optional) – Minor radius of the elliptical z-slices
- z_length (float 1.0, optional) – Cylinder height.
- r_major_div (int=10, optional) – Number of element divisions in the major radius direction
- r_minor_div (int=10, optional) – Number of element divisions in the minor radius direction
- z_div (int=10, optional) – Number of element divisions in the z-direction
- r_major_edge (float=-1.0, optional) – Overrides r_major_div with absolute edge length (ignored if non-positive)
- r_minor_edge (float=-1.0, optional) – Overrides r_minor_div with absolute edge length (ignored if non-positive)
- z_edge (float=-1.0, optional) – Overrides z_div with absolute edge length (ignored if non-positive)
Returns: Return type: Appends an elliptic cylinder mesh definition to meshes.
-
makeQuarterEllipsoid(name=None, r_major=1.0, r_middle=1.0, r_minor=1.0, r_major_div=10, r_middle_div=10, r_minor_div=10, r_major_edge=-1.0, r_middle_edge=-1.0, r_minor_edge=-1.0)¶ Create a half-ellipsoid.
Parameters: - name (str, optional) – Name identifier for mesh. Defaults to “Part {:s}”.format(index in meshes)
- r_major (float 1.0, optional) – Major radius of ellipsoid
- r_middle (float 1.0, optional) – Middle radius of ellipsoid
- r_minor (float 1.0, optional) – Minor radius of ellipsoid
- r_major_div (int 10, optional) – Number of element divisions in the major radial direction
- r_middle_div (int 10, optional) – Number of element divisions in the middle radial direction
- r_minor_div (int 10, optional) – Number of element divisions in the minor radial direction
- r_major_edge (float=-1.0, optional) – Overrides r_major_div with absolute radial edge length (ignored if non-positive)
- r_middle_edge (float=-1.0, optional) – Overrides r_middle_div with absolute radial edge length (ignored if non-positive)
- r_minor_edge (float=-1.0, optional) – Overrides r_minor_div with absolute radial edge length (ignored if non-positive)
Returns: Return type: Appends an ellipsoidal mesh definition to meshes.
-
writeToFile(filename='mesh.inp', file_format='abaqus')¶ Parameters: - filename (str, optional) – If provided, this will write the mesh to file. Currently, Abaqus (.inp) and VTK (.vtu) formats are supported. The format will be deduced by the file extension unless overridden by format parameter. If no filename is specified the mesh will be stored in memory.
- file_format (str="abaqus", optional) –
- File format to save mesh in.
- “vtk”: use VTK format
- “abaqus”: use Abaqus format
-