DOF (Degree-of-Freedom) Arrays¶
- class meshmode.dof_array.DOFArray(actx: ArrayContext | None, data: tuple[Any, ...])[source]¶
This array type holds degree-of-freedom arrays for use with
Discretization, with one entry in theDOFArrayfor eachElementGroupBase. The arrays contained within aDOFArrayare expected to be logically two-dimensional, with shape(nelements, ndofs_per_element), wherenelementsis the same asnelementsof the associated group.ndofs_per_elementis typically, but not necessarily, the same asnunit_dofsof the associated group. The entries in this array are further arrays managed byarray_context, i.e.DOFArrayis anArrayContainer.One main purpose of this class is to describe the data structure, i.e. when a
DOFArrayoccurs 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.dtypeof the group arrays contained in this instance.
The following methods and attributes are implemented to mimic the functionality of
ndarrays. They require theDOFArrayto bethaw()ed.- shape¶
- size¶
- real¶
- imag¶
Implements the usual set of arithmetic operations, including broadcasting of numbers and over numpy object arrays.
Note
DOFArrayinstances can be pickled and unpickled while the context managerarray_context_for_picklingis active. If, for an array to be pickled, theArrayContextgiven toarray_context_for_pickling()does not agree witharray_context, the array is frozen and rethawed. Ifarray_contextis None, theDOFArrayisthaw()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 onDOFArrays.
- meshmode.dof_array.rec_multimap_dof_array_container(f: Callable[[Any], Any], *args)[source]¶
Applies f recursively to multiple
ArrayContainers.Similar to
multimap_array_container(), but does not further recurse onDOFArrays.
- meshmode.dof_array.flat_norm(ary, ord: float | None = None) Any[source]¶
Return an element-wise \(\ell^{\text{ord}}\) norm of ary.
Unlike
arraycontext.ArrayContext.np, this function handlesDOFArrays 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
DOFArrayor anArrayContainercontaining them.
- meshmode.dof_array.array_context_for_pickling(actx: ArrayContext)[source]¶
A context manager that, for the current thread, sets the array context to be used for pickling and unpickling
DOFArrays to actx.Added in version 2021.1.
- meshmode.dof_array.check_dofarray_against_discr(discr: Discretization, dof_ary: DOFArray)[source]¶
Verify that the
DOFArraydof_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,InconsistentDOFArrayis raised.- Parameters:
discr – a
Discretizationagainst which dof_ary is to be checked.
Array Contexts¶
- class meshmode.array_context.PyOpenCLArrayContext(queue: cl.CommandQueue, allocator: cl_array.Allocator | None = None, wait_event_queue_length: int | None = None, force_device_scalars: bool | None = None)[source]¶
Extends
arraycontext.PyOpenCLArrayContextwith knowledge about program transformation for finite element programs.See
meshmode.transform_metadatafor relevant metadata.
- class meshmode.array_context.PytatoPyOpenCLArrayContext(queue: cl.CommandQueue, allocator: cl_array.Allocator | None = None, *, use_memory_pool: bool | None = None, compile_trace_callback: Callable[[Any, str, Any], None] | None = None, profile_kernels: bool = False, _force_svm_arg_limit: int | None = None)[source]¶
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.
- class meshmode.transform_metadata.DiscretizationEntityAxisTag[source]¶
A tag applicable to an array’s axis to describe which discretization entity the axis indexes over.
- class meshmode.transform_metadata.DiscretizationElementAxisTag[source]¶
Array dimensions tagged with this tag type describe an axis indexing over the discretization’s elements.
- class meshmode.transform_metadata.DiscretizationFaceAxisTag[source]¶
Array dimensions tagged with this tag type describe an axis indexing over the discretization’s faces.
- class meshmode.transform_metadata.DiscretizationDOFAxisTag[source]¶
Array dimensions tagged with this tag type describe an axis indexing over the discretization’s DoFs (nodal or modal).