DOF (Degree-of-Freedom) ArraysÂ¶
- class meshmode.dof_array.DOFArray(actx: Optional[arraycontext.context.ArrayContext], data: Tuple[Any])[source]Â¶
This array type holds degree-of-freedom arrays for use with
Discretization
, with one entry in theDOFArray
for eachElementGroupBase
. The arrays contained within aDOFArray
are expected to be logically two-dimensional, with shape(nelements, ndofs_per_element)
, wherenelements
is the same asnelements
of the associated group.ndofs_per_element
is typically, but not necessarily, the same asnunit_dofs
of the associated group. The entries in this array are further arrays managed byarray_context
.One main purpose of this class is to describe the data structure, i.e. when a
DOFArray
occurs inside of further numpy object array, the level representing the array of element groups can be recognized (by people and programs).- array_contextÂ¶
An
ArrayContext
.
- entry_dtypeÂ¶
The (assumed uniform)
numpy.dtype
of the group arrays contained in this instance.
The following methods and attributes are implemented to mimic the functionality of
ndarray
s. They require theDOFArray
to bethaw()
ed.- shapeÂ¶
- sizeÂ¶
- realÂ¶
- imagÂ¶
Implements the usual set of arithmetic operations, including broadcasting of numbers and over numpy object arrays.
Note
DOFArray
instances can be pickled and unpickled while the context managerarray_context_for_pickling
is active. If, for an array to be pickled, theArrayContext
given toarray_context_for_pickling()
does not agree witharray_context
, the array is frozen and rethawed. Ifarray_context
is None, theDOFArray
isthaw()
ed into the array context given toarray_context_for_pickling()
.
- meshmode.dof_array.rec_map_dof_array_container(f: Callable[[Any], Any], ary)[source]Â¶
Applies f recursively to an
ArrayContainer
.Similar to
map_array_container()
, but does not further recurse onDOFArray
s.
- meshmode.dof_array.rec_multimap_dof_array_container(f: Callable[[Any], Any], *args)[source]Â¶
Applies f recursively to multiple
ArrayContainer
s.Similar to
multimap_array_container()
, but does not further recurse onDOFArray
s.
- meshmode.dof_array.flat_norm(ary, ord=None) Any [source]Â¶
Return an element-wise \(\ell^{\text{ord}}\) norm of ary.
Unlike
arraycontext.ArrayContext.np
, this function handlesDOFArray
s by taking a norm of their flattened values (in the sense ofarraycontext.flatten()
) regardless of how the group arrays are stored.- Parameters
ary â€“ may be a
DOFArray
or anArrayContainer
containing them.
- meshmode.dof_array.array_context_for_pickling(actx: arraycontext.context.ArrayContext)[source]Â¶
A context manager that, for the current thread, sets the array context to be used for pickling and unpickling
DOFArray
s to actx.New in version 2021.1.
- meshmode.dof_array.check_dofarray_against_discr(discr, dof_ary: meshmode.dof_array.DOFArray)[source]Â¶
Verify that the
DOFArray
dof_ary is consistent with the discretization discr, in terms of things like group count, number of elements, and number of DOFs per element. If a discrepancy is detected,InconsistentDOFArray
is raised.- Parameters
discr â€“ a
Discretization
against which dof_ary is to be checked.
Array ContextsÂ¶
- class meshmode.array_context.PyOpenCLArrayContext(queue: pyopencl.CommandQueue, allocator: Optional[pyopencl.tools.AllocatorInterface] = None, wait_event_queue_length: Optional[int] = None, force_device_scalars: bool = False)[source]Â¶
Extends
arraycontext.PyOpenCLArrayContext
with knowledge about program transformation for finite element programs.See
meshmode.transform_metadata
for relevant metadata.
Metadata for Program TransformationÂ¶
- class meshmode.transform_metadata.FirstAxisIsElementsTag[source]Â¶
A tag that is applicable to array outputs indicating that the first index corresponds to element indices. This suggests that the implementation should set element indices as the outermost loop extent.
For convenience, this tag may also be applied to a kernel if that kernel contains exactly one assignment, in which case the tag is considered equivalent to being applied to the (single) output array argument.
- class meshmode.transform_metadata.ConcurrentElementInameTag[source]Â¶
A tag applicable to an iname indicating that this iname is used to iterate over elements in a discretization. States that no dependencies exist between elements, i.e. that computations for all elements may be performed concurrently.
- class meshmode.transform_metadata.ConcurrentDOFInameTag[source]Â¶
A tag applicable to an iname indicating that this iname is used to iterate over degrees of freedom (DOFs) within an element in a discretization. States that no dependencies exist between output DOFs, i.e. that computations for all DOFs within each element may be performed concurrently.