A mesh.
| 349 | |
| 350 | |
| 351 | class Mesh(typing.Generic[Real]): |
| 352 | """A mesh.""" |
| 353 | |
| 354 | _mesh: _cpp.mesh.Mesh_float32 | _cpp.mesh.Mesh_float64 |
| 355 | _topology: Topology |
| 356 | _geometry: Geometry[Real] |
| 357 | _ufl_domain: ufl.Mesh | None |
| 358 | |
| 359 | def __init__( |
| 360 | self, |
| 361 | msh: _cpp.mesh.Mesh_float32 | _cpp.mesh.Mesh_float64, |
| 362 | domain: ufl.Mesh | None, |
| 363 | ): |
| 364 | """Initialize mesh from a C++ mesh. |
| 365 | |
| 366 | Args: |
| 367 | msh: A C++ mesh object. |
| 368 | domain: A UFL domain. |
| 369 | |
| 370 | Note: |
| 371 | Mesh objects should usually be constructed using |
| 372 | :func:`create_mesh` and not using this class initializer. |
| 373 | This class is combined with different base classes that |
| 374 | depend on the scalar type used in the Mesh. |
| 375 | """ |
| 376 | self._cpp_object = msh |
| 377 | self._topology = Topology(self._cpp_object.topology) |
| 378 | self._geometry = Geometry(self._cpp_object.geometry) |
| 379 | self._ufl_domain = domain |
| 380 | if self._ufl_domain is not None: |
| 381 | self._ufl_domain._ufl_cargo = self._cpp_object # type: ignore |
| 382 | |
| 383 | @property |
| 384 | def comm(self): |
| 385 | """MPI communicator associated with the mesh.""" |
| 386 | return self._cpp_object.comm |
| 387 | |
| 388 | @property |
| 389 | def name(self): |
| 390 | """Name of the mesh.""" |
| 391 | return self._cpp_object.name |
| 392 | |
| 393 | @name.setter |
| 394 | def name(self, value): |
| 395 | self._cpp_object.name = value |
| 396 | |
| 397 | def ufl_cell(self) -> ufl.Cell: |
| 398 | """Return the UFL cell type. |
| 399 | |
| 400 | Note: |
| 401 | This method is required for UFL compatibility. |
| 402 | """ |
| 403 | return ufl.Cell(self.topology.cell_name()) |
| 404 | |
| 405 | def ufl_domain(self) -> ufl.Mesh | None: |
| 406 | """Return the ufl domain corresponding to the mesh. |
| 407 | |
| 408 | Returns: |
no outgoing calls