Skip to content

Commit

Permalink
rename convert_int_g_to_base -> rewrite_int_g_using_base_kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Nov 23, 2022
1 parent 106816f commit d34f787
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/symbolic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ Rewriting expressions with IntGs internals
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. automethod:: pytential.symbolic.pde.system_utils.convert_target_transformation_to_source
.. automethod:: pytential.symbolic.pde.system_utils.convert_int_g_to_base
.. automethod:: pytential.symbolic.pde.system_utils.rewrite_int_g_using_base_kernel

14 changes: 7 additions & 7 deletions pytential/symbolic/pde/system_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
as gnitstam)

from pytential.symbolic.primitives import (NodeCoordinateComponent,
hashable_kernel_args, IntG, as_dofdesc, TAG_WITH_DEFAULT_SOURCE)
hashable_kernel_args, IntG, TAG_WITH_DEFAULT_SOURCE)
from pytential.symbolic.mappers import IdentityMapper
from pytential.utils import chop, lu_with_post_division_callback
import pytential
Expand Down Expand Up @@ -103,7 +103,7 @@ def map_int_g(self, expr):
new_int_gs = convert_target_transformation_to_source(expr)
# Convert IntGs with different kernels to expressions containing
# IntGs with base_kernel or its derivatives
return sum(convert_int_g_to_base(new_int_g,
return sum(rewrite_int_g_using_base_kernel(new_int_g,
self.base_kernel) for new_int_g in new_int_gs)


Expand Down Expand Up @@ -273,22 +273,22 @@ def _multiply_int_g(int_g: IntG, expr_multiplier: sym.Basic,
return result


def convert_int_g_to_base(int_g: IntG, base_kernel: ExpressionKernel) \
def rewrite_int_g_using_base_kernel(int_g: IntG, base_kernel: ExpressionKernel) \
-> ExpressionT:
"""Converts an *IntG* to an expression with *IntG*s having the
"""Rewrite an *IntG* to an expression with *IntG*s having the
base kernel *base_kernel*.
"""
result = 0
for knl, density in zip(int_g.source_kernels, int_g.densities):
result += _convert_int_g_to_base(
result += _rewrite_int_g_using_base_kernel(
int_g.copy(source_kernels=(knl,), densities=(density,)),
base_kernel)
return result


def _convert_int_g_to_base(int_g: IntG, base_kernel: ExpressionKernel) \
def _rewrite_int_g_using_base_kernel(int_g: IntG, base_kernel: ExpressionKernel) \
-> ExpressionT:
"""Converts an *IntG* with only one source kernel to an expression with *IntG*s
"""Rewrites an *IntG* with only one source kernel to an expression with *IntG*s
having the base kernel *base_kernel*.
"""
target_kernel = int_g.target_kernel.replace_base_kernel(base_kernel)
Expand Down
11 changes: 7 additions & 4 deletions test/test_pde_system_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""

from pytential.symbolic.pde.system_utils import (
convert_target_transformation_to_source, convert_int_g_to_base)
convert_target_transformation_to_source, rewrite_int_g_using_base_kernel)
from pytential.symbolic.primitives import IntG
from pytential.symbolic.primitives import NodeCoordinateComponent
import pytential
Expand Down Expand Up @@ -130,7 +130,8 @@ def test_convert_int_g_base():
IntG(base_knl, [AxisSourceDerivative(d, AxisSourceDerivative(d, base_knl))],
[-1], qbx_forced_limit=1) for d in range(3))

assert expected_int_g == convert_int_g_to_base(int_g, base_kernel=base_knl)
assert expected_int_g == rewrite_int_g_using_base_kernel(int_g,
base_kernel=base_knl)


def test_convert_int_g_base_with_const():
Expand All @@ -147,7 +148,8 @@ def test_convert_int_g_base_with_const():
IntG(base_knl,
[AxisSourceDerivative(1, AxisSourceDerivative(1, base_knl))], [0.5],
qbx_forced_limit=1)
assert convert_int_g_to_base(int_g, base_kernel=base_knl) == expected_int_g
assert rewrite_int_g_using_base_kernel(int_g,
base_kernel=base_knl) == expected_int_g


def test_convert_int_g_base_with_const_and_deriv():
Expand All @@ -160,4 +162,5 @@ def test_convert_int_g_base_with_const_and_deriv():
[AxisSourceDerivative(1, AxisSourceDerivative(1,
AxisSourceDerivative(0, base_knl)))], [0.5],
qbx_forced_limit=1)
assert convert_int_g_to_base(int_g, base_kernel=base_knl) == expected_int_g
assert rewrite_int_g_using_base_kernel(int_g,
base_kernel=base_knl) == expected_int_g

0 comments on commit d34f787

Please sign in to comment.