diff --git a/doc/symbolic.rst b/doc/symbolic.rst index 1e667a6a2..cd61348bf 100644 --- a/doc/symbolic.rst +++ b/doc/symbolic.rst @@ -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 diff --git a/pytential/symbolic/pde/system_utils.py b/pytential/symbolic/pde/system_utils.py index 2a8cda438..bd63e44ff 100644 --- a/pytential/symbolic/pde/system_utils.py +++ b/pytential/symbolic/pde/system_utils.py @@ -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 @@ -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) @@ -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) diff --git a/test/test_pde_system_utils.py b/test/test_pde_system_utils.py index 037f375a1..44b016354 100644 --- a/test/test_pde_system_utils.py +++ b/test/test_pde_system_utils.py @@ -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 @@ -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(): @@ -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(): @@ -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