Mesh Data Structure

Tags

class hedge.mesh.TAG_NONE

A boundary or volume tag representing an empty boundary or volume.

class hedge.mesh.TAG_ALL

A boundary or volume tag representing the entire boundary or volume.

In the case of the boundary, TAG_ALL does not include rank boundaries, or, more generally, anything tagged with TAG_NO_BOUNDARY.

class hedge.mesh.TAG_REALLY_ALL

A boundary tag representing the entire boundary.

Unlike TAG_ALL, this includes rank boundaries, or, more generally, everything tagged with TAG_NO_BOUNDARY.

class hedge.mesh.TAG_NO_BOUNDARY

A boundary tag indicating that this edge should not fall under TAG_ALL.

class hedge.mesh.TAG_RANK_BOUNDARY(rank)

A boundary tag indicating the boundary with a neighboring rank.

rank

Element Types

class hedge.mesh.Element
id
vertex_indices
bounding_box(vertices)
centroid(vertices)
map
inverse_map
face_normals
face_jacobians

Meshes

class hedge.mesh.Mesh(valuedict=None, exclude=['self'], **kwargs)

Information about the geometry and connectivity of a finite element mesh. (Note: no information about the discretization is stored here.)

Variables:
  • points – list of Pylinear vectors of node coordinates
  • elements – list of Element instances
  • interfaces

    a list of pairs:

    ((element instance 1, face index 1), (element instance 2, face index 2))

    enumerating elements bordering one another. The relation “element 1 touches element 2” is always reflexive, but this list will only contain one entry per element pair.

  • tag_to_boundary
    a mapping of the form:
    boundary_tag -> [(element instance, face index)])

    The boundary tag TAG_NONE always refers to an empty boundary. The boundary tag TAG_ALL always refers to the entire boundary.

  • tag_to_elements

    a mapping of the form element_tag -> [element instances]

    The element tag TAG_NONE always refers to an empty domain. The element tag TAG_ALL always refers to the entire domain.

  • periodicity – A list of tuples (minus_tag, plus_tag) or None indicating the tags of the boundaries to be matched together as periodic. There is one tuple per axis, so that for example a 3D mesh has three tuples.
  • periodic_opposite_faces
    a mapping of the form:
    (face_vertex_indices) ->
    (opposite_face_vertex_indices), axis

    This maps a face to its periodicity-induced opposite.

  • periodic_opposite_vertices
    a mapping of the form:
    vertex_index -> [(opposite_vertex_index, axis), ...]

    This maps one vertex to a list of its periodicity-induced opposites.

both_interfaces()
bounding_box()
dimensions
element_adjacency_graph()

Return a dictionary mapping each element id to a list of adjacent element ids.

class hedge.mesh.ConformalMesh

Bases: hedge.mesh.Mesh

A mesh whose elements’ faces exactly match up with one another.

See Mesh for attributes provided by this class.

__init__()
reordered_by()
reordered()
hedge.mesh.make_conformal_mesh(points, elements, boundary_tagger=None, volume_tagger=None, periodicity=None, _is_rankbdry_face=None)

Construct a simplical mesh.

Face indices follow the convention for the respective element, such as Triangle or Tetrahedron, in this module.

Parameters:
  • points – an iterable of vertex coordinates, given as vectors.
  • elements – an iterable of tuples of indices into points, giving element endpoints.
  • boundary_tagger – a function that takes the arguments (set_of_face_vertex_indices, element, face_number, all_vertices) It returns a list of tags that apply to this surface.
  • volume_tagger – a function that takes the arguments (element, all_vertices) and returns the a list of tags that apply to that element.
  • periodicity – either None or is a list of tuples just like the one documented for the periodicity member of class Mesh.
  • _is_rankbdry_face – an implementation detail, should not be used from user code. It is a function returning whether a given face identified by (element instance, face_nr) is cut by a parallel mesh partition.
hedge.mesh.check_bc_coverage(mesh, bc_tags, incomplete_ok=False)

Verify boundary condition coverage.

Given a list of boundary tags as bc_tags, this function verifies that

1. the union of all these boundaries gives the complete boundary, 1. all these boundaries are disjoint.
Parameters:incomplete_ok – Do not report an error if some faces are not covered by the boundary conditions.

Mesh Helpers

hedge.mesh.tools.cuthill_mckee(graph)

Return a Cuthill-McKee ordering for the given graph.

See (for example) Y. Saad, Iterative Methods for Sparse Linear System, 2nd edition, p. 76.

graph is given as an adjacency mapping, i.e. each node is mapped to a list of its neighbors.

Mesh Generation

1D Meshes

hedge.mesh.generator.make_1d_mesh(points, left_tag=None, right_tag=None, periodic=False, boundary_tagger=None, volume_tagger=None)
hedge.mesh.generator.make_uniform_1d_mesh(a, b, el_count, left_tag=None, right_tag=None, periodic=False, boundary_tagger=None)

2D Meshes

hedge.mesh.generator.make_regular_rect_mesh(a=(0, 0), b=(1, 1), n=(5, 5), periodicity=None, boundary_tagger=function)

Create a semi-structured rectangular mesh.

Parameters:
  • a – the lower left hand point of the rectangle
  • b – the upper right hand point of the rectangle
  • n – a tuple of integers indicating the total number of points on [a,b].
  • periodicity – either None, or a tuple of bools specifying whether the mesh is to be periodic in x and y.
hedge.mesh.generator.make_centered_regular_rect_mesh(a=(0, 0), b=(1, 1), n=(5, 5), periodicity=None, post_refine_factor=1, boundary_tagger=function)

Create a semi-structured rectangular mesh.

Parameters:
  • a – the lower left hand point of the rectangle
  • b – the upper right hand point of the rectangle
  • n – a tuple of integers indicating the total number of points on [a,b].
  • periodicity – either None, or a tuple of bools specifying whether the mesh is to be periodic in x and y.
hedge.mesh.generator.make_regular_square_mesh(a=-0.5, b=0.5, n=5, periodicity=None, boundary_tagger=function)

Create a semi-structured square mesh.

Parameters:
  • a – the lower x and y coordinate of the square
  • b – the upper x and y coordinate of the square
  • n – integer indicating the total number of points on [a,b].
  • periodicity – either None, or a tuple of bools specifying whether the mesh is to be periodic in x and y.
hedge.mesh.generator.make_rect_mesh(a=(0, 0), b=(1, 1), max_area=None, boundary_tagger=function, periodicity=None, subdivisions=None, refine_func=None)

Create an unstructured rectangular mesh.

Parameters:
  • a – the lower left hand point of the rectangle
  • b – the upper right hand point of the rectangle
  • max_area – maximum area of each triangle.
  • periodicity – either None, or a tuple of bools specifying whether the mesh is to be periodic in x and y.
  • subdivisions – If not None, this is a 2-tuple specifying the number of facet subdivisions in X and Y.
  • refine_func – A refinement function as taken by meshpy.triangle.build().
hedge.mesh.generator.make_regular_rect_mesh(a=(0, 0), b=(1, 1), n=(5, 5), periodicity=None, boundary_tagger=function)

Create a semi-structured rectangular mesh.

Parameters:
  • a – the lower left hand point of the rectangle
  • b – the upper right hand point of the rectangle
  • n – a tuple of integers indicating the total number of points on [a,b].
  • periodicity – either None, or a tuple of bools specifying whether the mesh is to be periodic in x and y.
hedge.mesh.generator.make_square_mesh(a=-0.5, b=0.5, max_area=0.004, boundary_tagger=function)

Create an unstructured square mesh.

Parameters:
  • a – the lower x and y coordinate of the square
  • b – the upper x and y coordinate of the square
  • max_area – maximum area of each triangle
hedge.mesh.generator.make_disk_mesh(r=0.5, faces=50, max_area=0.004, boundary_tagger=function)

3D Meshes

hedge.mesh.generator.make_ball_mesh(r=0.5, subdivisions=10, max_volume=None, boundary_tagger=function)
hedge.mesh.generator.make_cylinder_mesh(radius=0.5, height=1, radial_subdivisions=10, height_subdivisions=1, max_volume=None, periodic=False, boundary_tagger=function)
hedge.mesh.generator.make_box_mesh(a=(0, 0, 0), b=(1, 1, 1), max_volume=None, periodicity=None, boundary_tagger=function, return_meshpy_mesh=False)

Return a mesh for a brick from the origin to dimensions.

max_volume specifies the maximum volume for each tetrahedron. periodicity is either None, or a triple of bools, indicating whether periodic BCs are to be applied along that axis. See make_conformal_mesh() for the meaning of boundary_tagger.

A few stock boundary tags are provided for easy application of boundary conditions, namely plus_[xyz] and minus_[xyz] tag the appropriate faces of the brick.