DiscretizationsΒΆ
Abstract interfaceΒΆ
Error handlingΒΆ

exception
meshmode.discretization.
ElementGroupTypeError
ΒΆ A
TypeError
specific for handling element groups. This exception may be raised to indicate whenever an improper operation or function is applied to a particular subclass ofElementGroupBase
.

exception
meshmode.discretization.
NoninterpolatoryElementGroupError
ΒΆ A specialized
ElementGroupTypeError
that may be raised whenever noninterpolatory element groups are being used for interpolation.
Base classesΒΆ

class
meshmode.discretization.
ElementGroupBase
(mesh_el_group, order, index)ΒΆ Defines a discrete function space on a homogeneous (in terms of element type and order) subset of a
Discretization
. These correspond onetoone withmeshmode.mesh.MeshElementGroup
. Responsible for all bulk data handling inDiscretization
.
mesh_el_group
ΒΆ

order
ΒΆ

index
ΒΆ

is_affine
ΒΆ A
bool
flag that is True if the localtoglobal parametrization of all the elements in the group is affine. Based onmeshmode.mesh.MeshElementGroup.is_affine
.

nelements
ΒΆ The total number of polygonal elements in the
meshmode.mesh.MeshElementGroup
.

nunit_dofs
ΒΆ The number of degrees of freedom (βDOFsβ) associated with a single element.

ndofs
ΒΆ The total number of degrees of freedom (βDOFsβ) associated with the entire element group.

shape
ΒΆ Returns a subclass of
modepy.Shape
representing the reference element defining the element group.

space
ΒΆ Returns a
modepy.FunctionSpace
representing the underlying polynomial space defined on the element groupβs reference element.

discretization_key
()ΒΆ Return a hashable, equalitycomparable object that fully describes the perelement discretization used by this element group. (This should cover all parts of the Ciarlet Triple: reference element, shape functions, and the linear functionals defining the degrees of freedom.) The object should be independent, however, of the (global) elements that make up the group.
The structure of the element is not specified, but it must be globally unique to this element group.


class
meshmode.discretization.
NodalElementGroupBase
(mesh_el_group, order, index)ΒΆ Base class for nodal element groups, defined as finite elements equipped with nodes. Nodes are specific locations defined on the reference element (
shape
) defining a degree of freedom by point evaluation at that location. Such element groups can have an associated quadrature rule to perform numerical integration, but are not necessarily usable (unisolvent) for interpolation.Inherits from
ElementGroupBase
.
unit_nodes
ΒΆ Returns a
numpy.ndarray
of shape(dim, nunit_dofs)
of reference coordinates of interpolation nodes.

weights
ΒΆ Returns a
numpy.ndarray
of shape(nunit_dofs,)
containing quadrature weights applicable on the reference element.


class
meshmode.discretization.
ElementGroupWithBasis
(mesh_el_group, order, index)ΒΆ Base class for element groups which possess an explicit basis for the underlying function space
space
.Inherits from
ElementGroupBase
.

class
meshmode.discretization.
InterpolatoryElementGroupBase
(mesh_el_group, order, index)ΒΆ An element group equipped with both an explicit basis for the underlying
space
, and a set of nodal locations on theshape
. These element groups are unisolvent in the Ciarlet sense, meaning the dimension ofspace
matches the number of interpolatory nodal locations. These element groups are therefore suitable for interpolation and differentiation.Inherits from
NodalElementGroupBase
andElementGroupWithBasis
.
abstract
mass_matrix
()ΒΆ Return a
numpy.ndarray
of shape(nunit_nodes, nunit_nodes)
, which is defined as the operator \(M\), with\[M_{ij} = \int_{K} \phi_i \cdot \phi_j \mathrm{d}x,\]where \(K\) denotes a cell and \(\phi_i\) is the basis spanning the underlying
space
.

abstract
diff_matrices
()ΒΆ Return a
dim
longtuple
ofnumpy.ndarray
of shape(nunit_nodes, nunit_nodes)
, each of which, when applied to an array of nodal values, take derivatives in the reference \((r, s, t)\) directions.

abstract

class
meshmode.discretization.
ModalElementGroupBase
(mesh_el_group, order, index)ΒΆ An element group equipped with a function space and a hierarchical basis that is orthonormal with respect to the \(L^2\) inner product.
Inherits from
ElementGroupWithBasis
.
Discretization classΒΆ

meshmode.discretization.
num_reference_derivative
(discr, ref_axes, vec)ΒΆ  Parameters
ref_axes (Iterable[int]) β an
Iterable
of indices that define the sequence of derivatives to vec. For example,(0, 1, 1)
would take a third partial derivative, one in the first axis and two in the second axis.discr (meshmode.discretization.Discretization) β
vec (meshmode.dof_array.DOFArray) β
 Return type

class
meshmode.discretization.
Discretization
(actx, mesh, group_factory, real_dtype=<class 'numpy.float64'>)ΒΆ An unstructured composite discretization.

real_dtype
ΒΆ

complex_dtype
ΒΆ

mesh
ΒΆ

dim
ΒΆ

ambient_dim
ΒΆ

ndofs
ΒΆ

groups
ΒΆ

is_nodal
ΒΆ A
bool
indicating whether theDiscretization
is defined over element groups subclasses ofNodalElementGroupBase
.

is_modal
ΒΆ A
bool
indicating whether theDiscretization
is defined over element groups subclasses ofModalElementGroupBase
.

copy
(actx=None, mesh=None, group_factory=None, real_dtype=None)ΒΆ Creates a new object of the same type with all arguments that are not None replaced. The copy is not recursive (e.g. it does not call
meshmode.mesh.Mesh.copy()
).

empty
(actx, dtype=None)ΒΆ Return an empty
DOFArray
. Parameters
dtype β type special value βcβ will result in a vector of dtype
complex_dtype
. If None (the default), a real vector will be returned.actx (meshmode.array_context.ArrayContext) β

zeros
(actx, dtype=None)ΒΆ Return a zeroinitialized
DOFArray
. Parameters
dtype β type special value βcβ will result in a vector of dtype
complex_dtype
. If None (the default), a real vector will be returned.actx (meshmode.array_context.ArrayContext) β

empty_like
(array)ΒΆ  Parameters
array (meshmode.dof_array.DOFArray) β

zeros_like
(array)ΒΆ  Parameters
array (meshmode.dof_array.DOFArray) β

nodes
()ΒΆ

num_reference_derivative
(ref_axes, vec)ΒΆ

Element Groups for Composite Polynomial DiscretizationΒΆ
Group typesΒΆ

meshmode.discretization.poly_element.
mass_matrix
(grp)ΒΆ  Parameters
grp (meshmode.discretization.InterpolatoryElementGroupBase) β
 Return type

meshmode.discretization.poly_element.
diff_matrices
(grp)ΒΆ  Parameters
grp (meshmode.discretization.InterpolatoryElementGroupBase) β
 Return type
Tuple[numpy.ndarray]
Simplicial group typesΒΆ

class
meshmode.discretization.poly_element.
ModalSimplexElementGroup
(mesh_el_group, order, index)ΒΆ

class
meshmode.discretization.poly_element.
InterpolatoryQuadratureSimplexElementGroup
(mesh_el_group, order, index)ΒΆ Elemental discretization supplying a highorder quadrature rule with a number of nodes matching the number of polynomials in \(P^k\), hence usable for differentiation and interpolation.
No interpolation nodes are present on the boundary of the simplex.

class
meshmode.discretization.poly_element.
QuadratureSimplexElementGroup
(mesh_el_group, order, index)ΒΆ Elemental discretization supplying a highorder quadrature rule with a number of nodes which does not necessarily match the number of polynomials in \(P^k\). This discretization therefore excels at quadarature, but is not necessarily usable for interpolation.
No interpolation nodes are present on the boundary of the simplex.

class
meshmode.discretization.poly_element.
PolynomialWarpAndBlendElementGroup
(mesh_el_group, order, index)ΒΆ Elemental discretization with a number of nodes matching the number of polynomials in \(P^k\), hence usable for differentiation and interpolation. Interpolation nodes edgeclustered for avoidance of Runge phenomena. Nodes are present on the boundary of the simplex.

class
meshmode.discretization.poly_element.
PolynomialRecursiveNodesElementGroup
(mesh_el_group, order, family, index)ΒΆ Elemental discretization with a number of nodes matching the number of polynomials in \(P^k\), hence usable for differentiation and interpolation. Interpolation nodes edgeclustered for avoidance of Runge phenomena. Depending on the family argument, nodes may be present on the boundary of the simplex. See [Isaac20] for details.
Supports a choice of the base family of 1D nodes, see the documentation of the family argument to
recursivenodes.recursive_nodes()
.Requires
recursivenodes
to be installed. Isaac20
Tobin Isaac. Recursive, parameterfree, explicitly defined interpolation nodes for simplices. Arxiv preprint.
New in version 2020.2.

class
meshmode.discretization.poly_element.
PolynomialEquidistantSimplexElementGroup
(mesh_el_group, order, index)ΒΆ Elemental discretization with a number of nodes matching the number of polynomials in \(P^k\), hence usable for differentiation and interpolation. Interpolation nodes are present on the boundary of the simplex.
New in version 2016.1.

class
meshmode.discretization.poly_element.
PolynomialGivenNodesElementGroup
(mesh_el_group, order, unit_nodes, index)ΒΆ Elemental discretization with a number of nodes matching the number of polynomials in \(P^k\), hence usable for differentiation and interpolation. Uses nodes given by the user.
Tensor product group typesΒΆ

class
meshmode.discretization.poly_element.
ModalTensorProductElementGroup
(mesh_el_group, order, index)ΒΆ

class
meshmode.discretization.poly_element.
GaussLegendreTensorProductElementGroup
(mesh_el_group, order, index)ΒΆ Elemental discretization supplying a highorder quadrature rule with a number of nodes matching the number of polynomials in the tensor product basis, hence usable for differentiation and interpolation.
No interpolation nodes are present on the boundary of the hypercube.

class
meshmode.discretization.poly_element.
LegendreGaussLobattoTensorProductElementGroup
(mesh_el_group, order, index)ΒΆ Elemental discretization supplying a highorder quadrature rule with a number of nodes matching the number of polynomials in the tensor product basis, hence usable for differentiation and interpolation. Nodes sufficient for unisolvency are present on the boundary of the hypercube.

class
meshmode.discretization.poly_element.
EquidistantTensorProductElementGroup
(mesh_el_group, order, index)ΒΆ Elemental discretization supplying a highorder quadrature rule with a number of nodes matching the number of polynomials in the tensor product basis, hence usable for differentiation and interpolation. Nodes sufficient for unisolvency are present on the boundary of the hypercube.
Uses
equidistant_nodes()
.
Group factoriesΒΆ

class
meshmode.discretization.poly_element.
ElementGroupFactory
ΒΆ 
__call__
(mesh_ele_group, dof_nr_base)ΒΆ


class
meshmode.discretization.poly_element.
OrderAndTypeBasedGroupFactory
(order, simplex_group_class, tensor_product_group_class)ΒΆ
Simplicial group factoriesΒΆ

class
meshmode.discretization.poly_element.
ModalSimplexGroupFactory
(order)ΒΆ

class
meshmode.discretization.poly_element.
InterpolatoryQuadratureSimplexGroupFactory
(order)ΒΆ

class
meshmode.discretization.poly_element.
QuadratureSimplexGroupFactory
(order)ΒΆ

class
meshmode.discretization.poly_element.
PolynomialWarpAndBlendGroupFactory
(order)ΒΆ

class
meshmode.discretization.poly_element.
PolynomialRecursiveNodesGroupFactory
(order, family)ΒΆ

class
meshmode.discretization.poly_element.
PolynomialEquidistantSimplexGroupFactory
(order)ΒΆ New in version 2016.1.

class
meshmode.discretization.poly_element.
PolynomialGivenNodesGroupFactory
(order, unit_nodes)ΒΆ
Tensor product group factoriesΒΆ

class
meshmode.discretization.poly_element.
ModalTensorProductGroupFactory
(order)ΒΆ

class
meshmode.discretization.poly_element.
GaussLegendreTensorProductGroupFactory
(order)ΒΆ

class
meshmode.discretization.poly_element.
LegendreGaussLobattoTensorProductGroupFactory
(order)ΒΆ
VisualizationΒΆ

meshmode.discretization.visualization.
make_visualizer
(actx, discr, vis_order, element_shrink_factor=None, force_equidistant=False)ΒΆ  Parameters
vis_order β order of the visualization DOFs.
element_shrink_factor β number in \((0, 1]\).
force_equidistant β if True, the visualization is done on equidistant nodes. If plotting highorder Lagrange VTK elements, this needs to be set to True.

class
meshmode.discretization.visualization.
Visualizer
(connection, element_shrink_factor=None, is_equidistant=False, _vtk_connectivity=None, _vtk_lagrange_connectivity=None)ΒΆ 
show_scalar_in_mayavi
(field, **kwargs)ΒΆ

show_scalar_in_matplotlib_3d
(field, **kwargs)ΒΆ

write_vtk_file
(file_name, names_and_fields, compressor=None, real_only=False, overwrite=False, use_high_order=None, par_manifest_filename=None, par_file_names=None)ΒΆ Write a Vtk XML file (typical extension
.vtu
) containing the visualization data in names_and_fields. Can optionally also write manifests for distributed memory simulation (typical extension.pvtu
). See alsowrite_parallel_vtk_file()
for a convenience wrapper. Parameters
names_and_fields β A list of tuples
(name, value)
, where name is a string and value is aDOFArray
or a constant, or an object array of those. value may also be a data class (seedataclasses
), whose attributes will be inserted into the visualization with their names prefixed by name. If value is None, then there is no data to write and the corresponding name will not appear in the data file. If value is None, it should be None collectively across all ranks for parallel writes; otherwise the behavior of this routine is undefined.overwrite β If True, silently overwrite existing files.
use_high_order β Writes arbitrary order Lagrange VTK elements. These elements are described in this blog post and are available in VTK 8.1 and newer.
par_manifest_filename β If not None write a distributedmemory manifest with this file name if file_name matches the first entry in par_file_names.
par_file_names β A list of file names of visualization files to include in the distributedmemory manifest.

Changed in version 2020.2:
Added par_manifest_filename and par_file_names.
Added use_high_order.

write_parallel_vtk_file
(mpi_comm, file_name_pattern, names_and_fields, compressor=None, real_only=False, overwrite=False, use_high_order=None, par_manifest_filename=None)ΒΆ A convenience wrapper around
write_vtk_file()
for distributedmemory visualization. Parameters
mpi_comm β An object that supports
mpi_comm.Get_rank()
andmpi_comm.Get_size()
method calls, typically (but not necessarily) an instance ofmpi4py.Comm
. This is used to determine the current rank as well as the total number of files being written. May also be None in which case a unitsize communicator is assumed.file_name_pattern β A file name pattern (required to end in
.vtu
) that will be used withstr.format()
with an (integer) argument ofrank
to obtain the perrank file name.par_manifest_filename β as in
write_vtk_file()
. If not given, par_manifest_filename is synthesized by substituting rank 0 into file_name_pattern and replacing the file extension with.pvtu
.
See
write_vtk_file()
for the meaning of the remainder of the arguments.New in version 2020.2.

write_xdmf_file
(file_name, names_and_fields, attrs=None, h5_file_options=None, dataset_options=None, real_only=False, overwrite=False)ΒΆ Write an XDMF file (with an
.xmf
extension) containing the arrays in names_and_fields. The heavy data is written to binary HDF5 files, which requires installing h5py. Distributed memory visualization is not yet supported. Parameters
names_and_fields β a list of
(name, array)
, where array is an arraylike object (seeVisualizer.write_vtk_file()
).attrs β a
dict
of scalar attributes that will be saved in the root HDF5 group.h5_file_options β a
dict
passed directly toh5py.File
that allows controlling chunking, compatibility, etc.dataset_options β a
dict
passed directly toh5py.Group.create_dataset()
.

copy_with_same_connectivity
(actx, discr, skip_tests=False)ΒΆ Makes a copy of the visualizer for a
Discretization
with the same group structure as the original discretization. This can be useful when the geometry is mapped (e.g. usingaffine_map()
) and the connectivity can be reused.The βsame group structureβ here means that the two discretizations should have the same group types, number of elements, degrees of freedom, etc.
 Parameters
skip_tests β If True, no checks in the group structure of the discretizations are performed.


meshmode.discretization.visualization.
write_nodal_adjacency_vtk_file
(file_name, mesh, compressor=None, overwrite=False)ΒΆ