Skip to content
Snippets Groups Projects
Commit a2967d8f authored by Thomas Gibson's avatar Thomas Gibson
Browse files

Implement numerical integration in grudge.op

parent 315d4b96
No related branches found
No related tags found
No related merge requests found
...@@ -508,7 +508,7 @@ def _apply_mass_operator(dcoll, dd_out, dd_in, vec): ...@@ -508,7 +508,7 @@ def _apply_mass_operator(dcoll, dd_out, dd_in, vec):
def mass(dcoll, *args): def mass(dcoll, *args):
if len(args) == 1: if len(args) == 1:
vec, = args vec, = args
dd = dof_desc.DOFDesc("vol", dof_desc.QTAG_NONE) dd = dof_desc.DOFDesc("vol", dof_desc.DISCR_TAG_BASE)
elif len(args) == 2: elif len(args) == 2:
dd, vec = args dd, vec = args
else: else:
...@@ -863,6 +863,26 @@ def nodal_max(dcoll, dd, vec): ...@@ -863,6 +863,26 @@ def nodal_max(dcoll, dd, vec):
return np.max([actx.np.max(vec_i) for vec_i in vec]) return np.max([actx.np.max(vec_i) for vec_i in vec])
def integral(dcoll, vec, dd=None):
if dd is None:
dd = dof_desc.DD_VOLUME
dd = dof_desc.as_dofdesc(dd)
actx = vec.array_context
discr = dcoll.discr_from_dd(dd)
ones = discr.zeros(actx) + 1
# TODO: Use actx.np.dot once it's added to the array context
flattened_mass_weights = actx.to_numpy(
flatten(_apply_mass_operator(dcoll, dd, dd, ones))
)
flattened_vec = actx.to_numpy(flatten(vec))
return np.dot(flattened_vec, flattened_mass_weights)
# }}} # }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment