Skip to content

Commit

Permalink
clean ups; check that nodes match
Browse files Browse the repository at this point in the history
  • Loading branch information
a-alveyblanc committed Oct 11, 2024
1 parent ac6708c commit 946f9bc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions meshmode/discretization/poly_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,27 +525,30 @@ def basis_obj(self):

@memoize_method
def quadrature_rule(self):
from modepy.tools import reshape_array_for_tensor_product_space as fold
from modepy.tools import reshape_array_for_tensor_product_space

quads = []

if self.dim != 1:
nodes_tp = fold(self.space, self._nodes)
nodes_tp = reshape_array_for_tensor_product_space(self.space,
self._nodes)
else:
nodes_tp = self._nodes

for idim, (nodes, basis) in enumerate(zip(nodes_tp, self._basis.bases)):
# get current dimension's nodes from fastest varying axis
if self.dim != 1:
nodes = np.swapaxes(nodes, 0, idim)[:, *(0,)*(self.dim-1)]
nodes = nodes[*(0,)*idim, :, *(0,)*(self.dim-idim-1)]

nodes_1d = nodes.reshape(1, -1)
mass_matrix = mp.mass_matrix(basis, nodes_1d)
weights = np.dot(mass_matrix, np.ones(len(basis.functions)))

quads.append(mp.Quadrature(nodes_1d, weights, exact_to=self.order))

return mp.TensorProductQuadrature(quads)
tp_quad = mp.TensorProductQuadrature(quads)
assert np.allclose(tp_quad.nodes, self._nodes)

return tp_quad

@property
@memoize_method
Expand Down

0 comments on commit 946f9bc

Please sign in to comment.