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

Function create_interval

python/dolfinx/mesh.py:976–1022  ·  view source on GitHub ↗

Create an interval mesh. Args: comm: MPI communicator. nx: Number of cells. points: Coordinates of the end points. dtype: Float type for the mesh geometry(``numpy.float32`` or ``numpy.float64``). ghost_mode: Ghost mode used in the mesh partiti

(
    comm: _MPI.Comm,
    nx: int,
    points: npt.ArrayLike,
    dtype: npt.DTypeLike = default_real_type,
    ghost_mode=GhostMode.shared_facet,
    partitioner=None,
    gdim: int = 1,
)

Source from the content-addressed store, hash-verified

974
975
976def create_interval(
977 comm: _MPI.Comm,
978 nx: int,
979 points: npt.ArrayLike,
980 dtype: npt.DTypeLike = default_real_type,
981 ghost_mode=GhostMode.shared_facet,
982 partitioner=None,
983 gdim: int = 1,
984) -> Mesh:
985 """Create an interval mesh.
986
987 Args:
988 comm: MPI communicator.
989 nx: Number of cells.
990 points: Coordinates of the end points.
991 dtype: Float type for the mesh geometry(``numpy.float32``
992 or ``numpy.float64``).
993 ghost_mode: Ghost mode used in the mesh partitioning. Options
994 are ``GhostMode.none`` and ``GhostMode.shared_facet``.
995 partitioner: Partitioning function to use for determining the
996 parallel distribution of cells across MPI ranks.
997 gdim: Geometric dimension. The interval lies along the first
998 coordinate axis; remaining components are zero.
999
1000 Returns:
1001 An interval mesh.
1002 """
1003 if partitioner is None and comm.size > 1:
1004 partitioner = _cpp.mesh.create_cell_partitioner(ghost_mode, 2)
1005 domain = ufl.Mesh(
1006 basix.ufl.element(
1007 "Lagrange",
1008 "interval",
1009 1,
1010 lagrange_variant=basix.LagrangeVariant.unset,
1011 shape=(gdim,),
1012 dtype=dtype,
1013 )
1014 ) # type: ignore
1015 if np.issubdtype(dtype, np.float32):
1016 msh = _cpp.mesh.create_interval_float32(comm, nx, points, ghost_mode, partitioner, gdim)
1017 elif np.issubdtype(dtype, np.float64):
1018 msh = _cpp.mesh.create_interval_float64(comm, nx, points, ghost_mode, partitioner, gdim)
1019 else:
1020 raise RuntimeError(f"Unsupported mesh geometry float type: {dtype}")
1021
1022 return Mesh(msh, domain)
1023
1024
1025def create_unit_interval(

Callers 3

intervalFunction · 0.90
create_unit_intervalFunction · 0.70

Calls 4

MeshMethod · 0.80
MeshClass · 0.70
elementMethod · 0.45

Tested by 2

intervalFunction · 0.72