Skip to content

Commit

Permalink
use all 1d bases and 1d nodes to create quadrature
Browse files Browse the repository at this point in the history
  • Loading branch information
a-alveyblanc committed Oct 11, 2024
1 parent 4c66332 commit e09ac74
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions meshmode/discretization/poly_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,27 @@ def basis_obj(self):

@memoize_method
def quadrature_rule(self):
basis = self._basis.bases[0]
nodes = self.unit_nodes_1d
mass_matrix = mp.mass_matrix(basis, nodes)
weights = np.dot(mass_matrix,
np.ones(len(basis.functions)))
quads = (mp.Quadrature(nodes, weights, exact_to=self.order),)*self.dim
from modepy.tools import reshape_array_for_tensor_product_space as fold

quads = []

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

for idim, zipped in enumerate(zip(nodes_tp, self._basis.bases)):
nodes, basis = zipped

# get current dimension's nodes from fastest varying axis
if self.dim != 1:
nodes = np.swapaxes(nodes, 0, idim)[:,*(0,)*(self.dim-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)

Expand Down

0 comments on commit e09ac74

Please sign in to comment.