MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / create_box

Function create_box

python/dolfinx/mesh.py:1158–1203  ·  view source on GitHub ↗

Create a box mesh. Args: comm: MPI communicator. points: Coordinates of the 'lower-left' and 'upper-right' corners of the box. n: List of cells in each direction cell_type: The cell type. dtype: Float type for the mesh geometry(``numpy.float32

(
    comm: _MPI.Comm,
    points: list[npt.ArrayLike],
    n: Sequence[int],
    cell_type=CellType.tetrahedron,
    dtype: npt.DTypeLike = default_real_type,
    ghost_mode=GhostMode.shared_facet,
    partitioner=None,
)

Source from the content-addressed store, hash-verified

1156
1157
1158def create_box(
1159 comm: _MPI.Comm,
1160 points: list[npt.ArrayLike],
1161 n: Sequence[int],
1162 cell_type=CellType.tetrahedron,
1163 dtype: npt.DTypeLike = default_real_type,
1164 ghost_mode=GhostMode.shared_facet,
1165 partitioner=None,
1166) -> Mesh:
1167 """Create a box mesh.
1168
1169 Args:
1170 comm: MPI communicator.
1171 points: Coordinates of the 'lower-left' and 'upper-right'
1172 corners of the box.
1173 n: List of cells in each direction
1174 cell_type: The cell type.
1175 dtype: Float type for the mesh geometry(``numpy.float32``
1176 or ``numpy.float64``).
1177 ghost_mode: The ghost mode used in the mesh partitioning.
1178 partitioner: Function that computes the parallel distribution of
1179 cells across MPI ranks.
1180
1181 Returns:
1182 A mesh of a box domain.
1183 """
1184 if partitioner is None and comm.size > 1:
1185 partitioner = _cpp.mesh.create_cell_partitioner(ghost_mode, 2)
1186 domain = ufl.Mesh(
1187 basix.ufl.element(
1188 "Lagrange",
1189 cell_type.name,
1190 1,
1191 lagrange_variant=basix.LagrangeVariant.unset,
1192 shape=(3,),
1193 dtype=dtype,
1194 )
1195 ) # type: ignore
1196 if np.issubdtype(dtype, np.float32):
1197 msh = _cpp.mesh.create_box_float32(comm, points, n, cell_type, partitioner)
1198 elif np.issubdtype(dtype, np.float64):
1199 msh = _cpp.mesh.create_box_float64(comm, points, n, cell_type, partitioner)
1200 else:
1201 raise RuntimeError(f"Unsupported mesh geometry float type: {dtype}")
1202
1203 return Mesh(msh, domain)
1204
1205
1206def create_unit_cube(

Callers 12

boxFunction · 0.90
test_create_box_prismFunction · 0.90
test_partition_box_meshFunction · 0.90
test_custom_partitionerFunction · 0.90
test_padded_bboxFunction · 0.90
test_nullspace_checkFunction · 0.90
poisson_problemFunction · 0.90
elasticity_problemFunction · 0.90
demo_elasticity.pyFile · 0.90
create_unit_cubeFunction · 0.70

Calls 4

MeshMethod · 0.80
MeshClass · 0.70
elementMethod · 0.45

Tested by 8

boxFunction · 0.72
test_create_box_prismFunction · 0.72
test_partition_box_meshFunction · 0.72
test_custom_partitionerFunction · 0.72
test_padded_bboxFunction · 0.72
test_nullspace_checkFunction · 0.72