Skip to content

Commit c166b2f

Browse files
authored
Merge branch 'main' into pytato-array-context-transforms
2 parents bd964da + 877b89d commit c166b2f

File tree

9 files changed

+54
-48
lines changed

9 files changed

+54
-48
lines changed

meshmode/discretization/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def num_reference_derivative(
632632
isinstance(grp, InterpolatoryElementGroupBase) for grp in discr.groups
633633
]):
634634
raise NoninterpolatoryElementGroupError(
635-
"Element groups must be usuable for differentiation and interpolation.")
635+
"Element groups must be usable for differentiation and interpolation.")
636636

637637
if not ref_axes:
638638
return vec

meshmode/discretization/connection/modal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def __call__(self, ary):
347347
actx = ary.array_context
348348

349349
# Evaluates the action of the Vandermonde matrix on the
350-
# vector of modal coefficeints to obtain nodal values
350+
# vector of modal coefficients to obtain nodal values
351351
@memoize_in(actx, (ModalToNodalDiscretizationConnection,
352352
"evaluation_knl"))
353353
def keval():

meshmode/dof_array.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ class DOFArray:
127127
"""
128128

129129
def __init__(self, actx: Optional[ArrayContext], data: Tuple[Any]):
130-
if not (actx is None or isinstance(actx, ArrayContext)):
131-
raise TypeError("actx must be of type ArrayContext")
130+
if __debug__:
131+
if not (actx is None or isinstance(actx, ArrayContext)):
132+
raise TypeError("actx must be of type ArrayContext")
132133

133-
if not isinstance(data, tuple):
134-
raise TypeError("'data' argument must be a tuple")
134+
if not isinstance(data, tuple):
135+
raise TypeError("'data' argument must be a tuple")
135136

136137
self._array_context = actx
137138
self._data = data
@@ -165,13 +166,18 @@ def from_list(cls, actx: Optional[ArrayContext], res_list) -> "DOFArray":
165166
return cls(actx, tuple(res_list))
166167

167168
def __str__(self):
168-
return str(self._data)
169+
return f"DOFArray({str(self._data)})"
169170

170171
def __repr__(self):
171172
return f"DOFArray({repr(self._data)})"
172173

173174
# {{{ sequence protocol
174175

176+
def __bool__(self):
177+
raise ValueError(
178+
"The truth value of a DOFArray is not well-defined. "
179+
"Use actx.np.any(x) or actx.np.all(x)")
180+
175181
def __len__(self):
176182
return len(self._data)
177183

meshmode/interop/firedrake/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def build_connection_to_firedrake(discr, group_nr=None, comm=None):
759759
by resampling at the nodes.
760760
761761
:param discr: A :class:`~meshmode.discretization.Discretization`
762-
to intialize the connection with
762+
to initialize the connection with
763763
:param group_nr: The group number of the discretization to convert.
764764
If *None* there must be only one group. The selected group
765765
must be of type
@@ -789,7 +789,7 @@ def build_connection_to_firedrake(discr, group_nr=None, comm=None):
789789
# **_cell_node holds the node nrs in shape *(ncells, nunit_nodes)*
790790
fd_cell_node = fspace.cell_node_list
791791

792-
# To get the meshmode to firedrake node assocation, we need to handle
792+
# To get the meshmode to firedrake node association, we need to handle
793793
# local vertex reordering and cell reordering.
794794
from pyop2.datatypes import IntType
795795
mm2fd_node_mapping = np.ndarray((el_group.nelements, el_group.nunit_dofs),

meshmode/mesh/processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def partition_mesh(mesh, part_per_element, part_num):
554554
global_elem_to_part_elem = _compute_global_elem_to_part_elem(part_per_element,
555555
{part_num}, mesh.element_id_dtype)
556556

557-
# Create new mesh groups that mimick the original mesh's groups but only contain
557+
# Create new mesh groups that mimic the original mesh's groups but only contain
558558
# the local partition's elements
559559
part_mesh_groups, global_group_to_part_group, required_vertex_indices =\
560560
_filter_mesh_groups(mesh.groups, queried_elems, mesh.vertex_id_dtype)

meshmode/mesh/refinement/__init__.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
import numpy as np
2727

2828
from meshmode.mesh.refinement.no_adjacency import RefinerWithoutAdjacency
29-
from meshmode.mesh.refinement.tesselate import \
30-
ElementTesselationInfo, GroupRefinementRecord
29+
from meshmode.mesh.refinement.tessellate import \
30+
ElementTessellationInfo, GroupRefinementRecord
3131

3232
import logging
3333
logger = logging.getLogger(__name__)
@@ -56,16 +56,16 @@ def get_vertex_pair_to_midpoint_order(dim):
5656

5757
@staticmethod
5858
def get_midpoints(group, el_tess_info, elements):
59-
import meshmode.mesh.refinement.tesselate as tess
59+
import meshmode.mesh.refinement.tessellate as tess
6060
return tess.get_group_midpoints(group, el_tess_info, elements)
6161

6262
@staticmethod
63-
def get_tesselated_nodes(group, el_tess_info, elements):
64-
import meshmode.mesh.refinement.tesselate as tess
65-
return tess.get_group_tesselated_nodes(group, el_tess_info, elements)
63+
def get_tessellated_nodes(group, el_tess_info, elements):
64+
import meshmode.mesh.refinement.tessellate as tess
65+
return tess.get_group_tessellated_nodes(group, el_tess_info, elements)
6666

6767

68-
def tesselate_simplex(dim):
68+
def tessellate_simplex(dim):
6969
import modepy as mp
7070
shape = mp.Simplex(dim)
7171
space = mp.space_for_shape(shape, 2)
@@ -136,17 +136,17 @@ def __init__(self, mesh):
136136
self.lazy = False
137137
self.seen_tuple = {}
138138
self.group_refinement_records = []
139-
seg_node_tuples, seg_result = tesselate_simplex(1)
140-
tri_node_tuples, tri_result = tesselate_simplex(2)
141-
tet_node_tuples, tet_result = tesselate_simplex(3)
139+
seg_node_tuples, seg_result = tessellate_simplex(1)
140+
tri_node_tuples, tri_result = tessellate_simplex(2)
141+
tet_node_tuples, tet_result = tessellate_simplex(3)
142142
#quadrilateral_node_tuples = [
143143
#print tri_result, tet_result
144144
self.simplex_node_tuples = [
145145
None, seg_node_tuples, tri_node_tuples, tet_node_tuples]
146-
# Dimension-parameterized tesselations for refinement
146+
# Dimension-parameterized tessellations for refinement
147147
self.simplex_result = [None, seg_result, tri_result, tet_result]
148148
#print tri_node_tuples, tri_result
149-
#self.simplex_node_tuples, self.simplex_result = tesselatetet()
149+
#self.simplex_node_tuples, self.simplex_result = tessellatetet()
150150
self.last_mesh = mesh
151151
self.last_split_elements = None
152152

@@ -646,7 +646,7 @@ def check_adjacent_elements(groups, new_hanging_vertex_elements, nelements_in_gr
646646
midpoints_to_find.append(iel_grp)
647647
if not resampler:
648648
resampler = SimplexResampler()
649-
el_tess_info = ElementTesselationInfo(
649+
el_tess_info = ElementTessellationInfo(
650650
children=self.simplex_result[grp.dim],
651651
ref_vertices=self.simplex_node_tuples[grp.dim])
652652
else:
@@ -794,7 +794,7 @@ def check_adjacent_elements(groups, new_hanging_vertex_elements, nelements_in_gr
794794
# if simplex
795795
if is_simplex:
796796
resampler = SimplexResampler()
797-
new_nodes = resampler.get_tesselated_nodes(
797+
new_nodes = resampler.get_tessellated_nodes(
798798
prev_group, refinement_record.el_tess_info, to_resample)
799799
else:
800800
raise NotImplementedError(

meshmode/mesh/refinement/no_adjacency.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ def refine(self, refine_flags):
8484
if perform_vertex_updates:
8585
inew_vertex = mesh.nvertices
8686

87-
from meshmode.mesh.refinement.tesselate import (
88-
get_group_tesselation_info,
87+
from meshmode.mesh.refinement.tessellate import (
88+
get_group_tessellation_info,
8989
get_group_midpoints,
90-
get_group_tesselated_nodes)
90+
get_group_tessellated_nodes)
9191

9292
for group in mesh.groups:
93-
el_tess_info = get_group_tesselation_info(group)
93+
el_tess_info = get_group_tessellation_info(group)
9494

9595
# {{{ compute counts and index arrays
9696

@@ -114,7 +114,7 @@ def refine(self, refine_flags):
114114

115115
# }}}
116116

117-
from meshmode.mesh.refinement.tesselate import GroupRefinementRecord
117+
from meshmode.mesh.refinement.tessellate import GroupRefinementRecord
118118
group_refinement_records.append(
119119
GroupRefinementRecord(
120120
el_tess_info=el_tess_info,
@@ -195,13 +195,13 @@ def refine(self, refine_flags):
195195
# copy over unchanged nodes
196196
new_nodes[:, unrefined_el_new_indices] = group.nodes[:, ~grp_flags]
197197

198-
tesselated_nodes = get_group_tesselated_nodes(
198+
tessellated_nodes = get_group_tessellated_nodes(
199199
group, el_tess_info, refining_el_old_indices)
200200

201201
for old_iel in refining_el_old_indices:
202202
new_iel_base = child_el_indices[old_iel]
203203
new_nodes[:, new_iel_base:new_iel_base+nchildren, :] = \
204-
tesselated_nodes[old_iel]
204+
tessellated_nodes[old_iel]
205205

206206
assert (~np.isnan(new_nodes)).all()
207207

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# {{{ interface
4242

4343
@dataclass(frozen=True)
44-
class ElementTesselationInfo:
44+
class ElementTessellationInfo:
4545
"""Describes how one element is split into multiple child elements.
4646
4747
.. attribute:: children
@@ -84,15 +84,15 @@ class GroupRefinementRecord:
8484
"""
8585
.. attribute:: el_tess_info
8686
87-
An instance of :class:`ElementTesselationInfo` that describes the
88-
tesselation of a single element into multiple child elements.
87+
An instance of :class:`ElementTessellationInfo` that describes the
88+
tessellation of a single element into multiple child elements.
8989
9090
.. attribute:: element_mapping
9191
9292
A mapping from the original elements to the refined child elements.
9393
"""
9494

95-
el_tess_info: ElementTesselationInfo
95+
el_tess_info: ElementTessellationInfo
9696
# FIXME: This should really be a CSR data structure.
9797
element_mapping: List[List[int]]
9898

@@ -102,23 +102,23 @@ def get_group_midpoints(meg: MeshElementGroup, el_tess_info, elements):
102102
"""Compute the midpoints of the vertices of the specified elements.
103103
104104
:arg group: an instance of :class:`meshmode.mesh.MeshElementGroup`.
105-
:arg el_tess_info: a :class:`ElementTesselationInfo`.
105+
:arg el_tess_info: a :class:`ElementTessellationInfo`.
106106
:arg elements: a list of (group-relative) element numbers.
107107
108108
:return: A :class:`dict` mapping element numbers to midpoint
109109
coordinates, with each value in the map having shape
110110
``(ambient_dim, nmidpoints)``. The ordering of the midpoints
111-
follows their ordering in the tesselation.
111+
follows their ordering in the tessellation.
112112
"""
113113
raise NotImplementedError(type(meg).__name__)
114114

115115

116116
@singledispatch
117-
def get_group_tesselated_nodes(meg: MeshElementGroup, el_tess_info, elements):
118-
"""Compute the nodes of the child elements according to the tesselation.
117+
def get_group_tessellated_nodes(meg: MeshElementGroup, el_tess_info, elements):
118+
"""Compute the nodes of the child elements according to the tessellation.
119119
120120
:arg group: An instance of :class:`meshmode.mesh.MeshElementGroup`.
121-
:arg el_tess_info: a :class:`ElementTesselationInfo`.
121+
:arg el_tess_info: a :class:`ElementTessellationInfo`.
122122
:arg elements: A list of (group-relative) element numbers.
123123
124124
:return: A :class:`dict` mapping element numbers to node
@@ -131,9 +131,9 @@ def get_group_tesselated_nodes(meg: MeshElementGroup, el_tess_info, elements):
131131

132132

133133
@singledispatch
134-
def get_group_tesselation_info(meg: MeshElementGroup):
134+
def get_group_tessellation_info(meg: MeshElementGroup):
135135
"""
136-
:returns: a :class:`ElementTesselationInfo` for the element group *meg*.
136+
:returns: a :class:`ElementTessellationInfo` for the element group *meg*.
137137
"""
138138
raise NotImplementedError(type(meg).__name__)
139139

@@ -181,7 +181,7 @@ def _get_ref_midpoints(shape, ref_vertices):
181181
# }}}
182182

183183

184-
# {{{ modepy.shape tesselation and resampling
184+
# {{{ modepy.shape tessellation and resampling
185185

186186
@get_group_midpoints.register(_ModepyElementGroup)
187187
def _(meg: _ModepyElementGroup, el_tess_info, elements):
@@ -203,7 +203,7 @@ def _(meg: _ModepyElementGroup, el_tess_info, elements):
203203
return dict(zip(elements, resampled_midpoints))
204204

205205

206-
@get_group_tesselated_nodes.register(_ModepyElementGroup)
206+
@get_group_tessellated_nodes.register(_ModepyElementGroup)
207207
def _(meg: _ModepyElementGroup, el_tess_info, elements):
208208
shape = meg._modepy_shape
209209
space = meg._modepy_space
@@ -232,7 +232,7 @@ def _(meg: _ModepyElementGroup, el_tess_info, elements):
232232
}
233233

234234

235-
@get_group_tesselation_info.register(_ModepyElementGroup)
235+
@get_group_tessellation_info.register(_ModepyElementGroup)
236236
def _(meg: _ModepyElementGroup):
237237
shape = meg._modepy_shape
238238
space = type(meg._modepy_space)(meg.dim, 2)
@@ -260,7 +260,7 @@ def _(meg: _ModepyElementGroup):
260260
# ensure order matches the one in midpoint_indices
261261
midpoint_vertex_pairs = [midpoint_to_vertex_pairs[m] for m in midpoints]
262262

263-
return ElementTesselationInfo(
263+
return ElementTessellationInfo(
264264
ref_vertices=ref_vertices,
265265
children=np.array(mp.submesh_for_shape(shape, ref_vertices)),
266266
orig_vertex_indices=np.array(orig_vertex_indices),

meshmode/mesh/refinement/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def map_unit_nodes_to_children(meg: MeshElementGroup,
4242
:arg unit_nodes: an :class:`~numpy.ndarray` of unit nodes on the
4343
element type described by *meg*.
4444
:arg el_tess_info: a
45-
:class:`~meshmode.mesh.refinement.tesselate.ElementTesselationInfo`.
45+
:class:`~meshmode.mesh.refinement.tessellate.ElementTessellationInfo`.
4646
:returns: an :class:`~numpy.ndarray` of mapped unit nodes for each
47-
child in the tesselation.
47+
child in the tessellation.
4848
"""
4949
raise NotImplementedError(type(meg).__name__)
5050

0 commit comments

Comments
 (0)