Skip to content

Stokes biharmonic #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 222 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
222 commits
Select commit Hold shift + click to select a range
32faae1
Experimental Stokes wrapper with Biharmonic Kernel
isuruf Jul 11, 2019
f418fe7
Fix formatting
isuruf Jul 12, 2019
51cbf53
Merge branch 'stokes_experiment' of gitlab.tiker.net:isuruf/pytential…
isuruf Sep 9, 2020
498c1cb
Use BiharmonicKernel directly
isuruf Sep 9, 2020
9a4a1bc
Merge branch 'master' of github.com:inducer/pytential into pytential2
isuruf Sep 9, 2020
958d578
Fixes for stokes
isuruf Sep 9, 2020
0c9b129
Revert "Fixes for stokes"
isuruf Sep 9, 2020
ea80c5a
Fix adding the constant
isuruf Sep 9, 2020
55b1430
Fix deriv_dirs
isuruf Sep 11, 2020
33c8722
remove slow test marker
isuruf Sep 11, 2020
90b507d
Add a comment and fix IntG
isuruf Sep 11, 2020
30a73a9
Use sym.integral
isuruf Sep 12, 2020
8fb6142
Pass source as dofdesc
isuruf Sep 15, 2020
3d18a3f
tag the mean with DEFUALT_SOURCE
isuruf Sep 23, 2020
d534088
Fix formatting
isuruf Sep 23, 2020
764e18e
Automatically figure out the derivative relation
isuruf Sep 29, 2020
05e1d9d
fix formatting
isuruf Sep 29, 2020
edf000c
convert in get_deriv_relation
isuruf Sep 29, 2020
ee2fb45
increase fmm_order
isuruf Sep 29, 2020
d1c53e0
Clean up stressletwrapper and use biharmonic
isuruf Sep 29, 2020
07067ca
refator and make use_biharmonic default
isuruf Sep 29, 2020
5efcba9
Fix stokes stresslet
isuruf Dec 6, 2020
b404b02
make pylint happy
isuruf Dec 6, 2020
44d29be
make flake8 happy
isuruf Dec 6, 2020
ad6ce49
Merge remote-tracking branch 'github/stokes_biharmonic' into check_su…
isuruf Dec 6, 2020
2db10c6
update creating IntGs in stokes
isuruf Dec 7, 2020
d1d8bb0
pass through timing_data in BoundExpression.__call__
isuruf Dec 7, 2020
6f45882
print timing
isuruf Dec 9, 2020
995c7b1
fix for using new P2M
isuruf Jan 7, 2021
bff0a7c
Use source derivative and add a function to merge IntGs
isuruf Jan 20, 2021
8ed8214
biharmonic stokes test
isuruf Jan 20, 2021
4aef2ad
Merge master and update tests
isuruf Jan 20, 2021
f7c3ace
working biharmonic now
isuruf Jan 21, 2021
6898f24
Refactor StokesletWrapper
isuruf Apr 29, 2021
2dc482d
use itgt instead of icenter_tgt for TargetPointMultiplier
isuruf Apr 29, 2021
31717da
Use transformation remover
isuruf Apr 29, 2021
8233ce6
Add Tornberg algorithm
isuruf May 2, 2021
64ee9a4
Revert "print timing"
isuruf May 2, 2021
0c40dc1
Remove debug print
isuruf May 2, 2021
3ef69fe
Add a test for biharmonic stokes as well
isuruf May 2, 2021
762f239
Merge branch 'main' of gitlab.tiker.net:inducer/pytential into check_…
isuruf May 4, 2021
2b20fd8
Use LineTaylor even for target derivatives
isuruf May 6, 2021
861d596
Initial support for ElasticityKernel
isuruf May 9, 2021
9207519
Support nu fully
isuruf May 10, 2021
bfeb4f1
Support Quotient in merge_int_g_exprs
isuruf May 10, 2021
1f1f7c6
refactor and fix missing division by 2*(1-nu)
isuruf May 10, 2021
cb5b692
expose laplace int g
isuruf May 20, 2021
5b434b2
automatically convert IntGs to base kernel if given
isuruf May 21, 2021
cd8195b
Add MindlinOperator
isuruf May 22, 2021
326d5b3
Fix free space elasticity
isuruf May 22, 2021
2b77a34
degree -> order
isuruf May 22, 2021
e11a894
Implement Yoshida et al algorithm
isuruf May 26, 2021
dd937fb
Add 9 harmonic implementation
isuruf May 26, 2021
850a71f
Remove 9 FMM implementationa in favour of 4 FMMs
isuruf May 26, 2021
1ebcd51
Add references
isuruf May 26, 2021
9b14abc
Fix names
isuruf May 27, 2021
4285e84
Revert "Remove 9 FMM implementationa in favour of 4 FMMs"
isuruf May 27, 2021
07e0159
Revert "Revert "Remove 9 FMM implementationa in favour of 4 FMMs""
isuruf May 27, 2021
f193f09
Finish free space elasticity and add testing
isuruf May 28, 2021
50a2ee6
Merge branch 'elasticity' of github.com:isuruf/pytential into main
isuruf Jun 8, 2021
11ae160
Make free space elasticity faster with Laplace
isuruf Jun 9, 2021
4061ba8
Merge branch 'elasticity' of github.com:isuruf/pytential into check_s…
isuruf Jun 10, 2021
880b3b6
Make method=laplace the default
isuruf Jun 10, 2021
2c0359e
Make apply_derivative and apply_pressure fast
isuruf Jun 10, 2021
dc14594
Add StokesletWrapperTornberg
isuruf Jun 10, 2021
4852ff4
Keep stokeslet object
isuruf Jun 10, 2021
eccf212
update experiments/stokes-2d-interior.py to use biharmonic
isuruf Jun 10, 2021
fb319ba
use method in StokesletWrapper too
isuruf Jun 10, 2021
30a176d
Fix laplace
isuruf Jun 10, 2021
25b0b95
Don't use the kernel_arguments from kernel for base_kernel
isuruf Jun 10, 2021
1419415
WIP
isuruf Jun 11, 2021
09699dc
fix tests
isuruf Jun 11, 2021
299c8bb
Fix 2D tests
isuruf Jun 18, 2021
123cd79
WIP reduce number of fmms
isuruf Jun 20, 2021
7ee639c
Fix source_expr typo and fix formatting
isuruf Jun 21, 2021
3f38175
pass translation_classes_data
isuruf Jun 21, 2021
e343a6e
Merge equal source_kernels in IntG
isuruf Jun 21, 2021
7f008b1
Merge branch 'main' into stokes_biharmonic
isuruf Jul 4, 2021
3cc6d8f
remove half space elasticity for now
isuruf Jul 4, 2021
e095e6c
Fix formatting
isuruf Jul 4, 2021
b7fb387
Fix translation_classes_data for fmmlib
isuruf Aug 23, 2021
e44bee7
Fix B008 Do not perform function calls in argument defaults
isuruf Aug 23, 2021
c0d8ce8
Reduce diff and convert list to tuple
isuruf Aug 25, 2021
119a1df
Merge branch 'main' of github.com:inducer/pytential into stokes_bihar…
isuruf Aug 25, 2021
f68613d
Fix typo and fix test
isuruf Aug 25, 2021
f9c6808
use pyopencl-deprecated
isuruf Aug 25, 2021
023a2ff
reduce diff
isuruf Aug 25, 2021
0b967e1
fix for interactive tests
isuruf Aug 25, 2021
ca514b4
Fix pylint and flake8 issues
isuruf Aug 25, 2021
b85c9ec
make sure both operands are tuples before adding them
isuruf Aug 26, 2021
c8ff6e1
Fix apply_derivative for Stresslet
isuruf Aug 26, 2021
8877c1a
document merge_int_g_exprs
isuruf Aug 26, 2021
6374375
Split off reduce_fmms to a new file
isuruf Aug 26, 2021
fefa563
document more functions in reduce_fmms
isuruf Aug 26, 2021
4391a9e
move chop and lu_solve_with_expand to utils
isuruf Aug 27, 2021
71d1540
Use coefficientcollector from pymbolic
isuruf Sep 2, 2021
5d3a22d
improve the docstring of reduce_number_of_fmms
isuruf Sep 2, 2021
7d15830
create new helper function for creating the matrix
isuruf Sep 2, 2021
c4068e9
Docs for data types of int_gs and source_dependent_variables
isuruf Sep 2, 2021
391eec6
Fix flake8 failures
isuruf Sep 2, 2021
86e5882
write a mapper for substitution
isuruf Sep 2, 2021
5fef79e
use ValueError instead of asserts
isuruf Sep 2, 2021
c695e02
fix typos
isuruf Sep 2, 2021
30697eb
docs for evalf
isuruf Sep 2, 2021
eeadafd
more docs
isuruf Sep 2, 2021
c794ad0
Fix return of IntGs
isuruf Sep 2, 2021
78d9234
use a mapper instead of _merge_int_g_expr
isuruf Sep 8, 2021
37a7941
Fix extra_deriv_dirs for tornberg
alexfikl Sep 8, 2021
d2d9348
remove unused imports
isuruf Sep 8, 2021
5ea14e2
fix when syzygy module can't be computed
isuruf Sep 8, 2021
afe3be8
Add some tests for system_utils
isuruf Sep 8, 2021
566ae5b
Fix f-strings. (No need of $)
isuruf Sep 8, 2021
e441b52
Improve docstrings
isuruf Sep 8, 2021
053c085
gens -> generators
isuruf Sep 8, 2021
801e5fb
_convert_kernel_to_poly -> _kernel_target_derivs_as_poly
isuruf Sep 8, 2021
e7a4afb
Use functools.reduce
isuruf Sep 8, 2021
93aad17
Fix coefficient collector
isuruf Sep 8, 2021
bf4adb1
describe matrix rows and columns
isuruf Sep 8, 2021
b937a9d
explain what _groebner_vec returns
isuruf Sep 8, 2021
3e1f76f
Group IntGs by base_kernel, source, target, qbx_forced_limit
isuruf Sep 9, 2021
1155dd7
treat different kernel arguments as different
isuruf Sep 12, 2021
92ccd69
separately handle target groups and source groups
isuruf Sep 12, 2021
8676359
Add comments and docstrings
isuruf Sep 12, 2021
f794300
remove unnecessary functions and refactor
isuruf Sep 12, 2021
89ffcf6
fix example in docstrings
isuruf Sep 12, 2021
c0d1b9c
test different qbx_forced_limit
isuruf Sep 13, 2021
b189a27
Support DirectionalSourceDerivatives
isuruf Sep 13, 2021
b3e5092
Handle unsupported expression in IntGCoefficientCollector
isuruf Sep 13, 2021
a12d6b7
Add a test
isuruf Sep 13, 2021
d385529
fix map_algebraic_leaf
isuruf Sep 13, 2021
afb3e08
explain sympy.EX
isuruf Sep 14, 2021
4ed556e
explain syzygy_module
isuruf Sep 14, 2021
6ef9fd8
explain syzygy
isuruf Sep 14, 2021
35d63f5
explain target dependent variables and common properties
isuruf Sep 20, 2021
d87a0ba
rhs_mat -> right_factor and fix docs
isuruf Sep 20, 2021
cf38f70
_convert_target_poly_to_int_g -> _convert_target_poly_to_int_g_derivs…
isuruf Sep 20, 2021
2d659b0
explain why (-1)
isuruf Sep 20, 2021
bf065ec
reorganize functions and add vim markers
isuruf Sep 20, 2021
8e58d39
explain difference between pymbolic's coefficientcollector and pytent…
isuruf Sep 20, 2021
0994482
explain map_product
isuruf Sep 20, 2021
0117804
rename some variables
isuruf Sep 20, 2021
e03e230
use dict comprehension
isuruf Sep 20, 2021
4d94b64
use python argument unpacking
isuruf Sep 20, 2021
269fe81
clarify that syzygy is a left nullspace
isuruf Sep 20, 2021
fd636b2
fix bad refactor
isuruf Sep 20, 2021
05e2541
Use LUsolve
isuruf Sep 20, 2021
9ea9b33
explain that we are working in a polynomial ring
isuruf Sep 26, 2021
75dea2b
Explain why we are using LUsolve
isuruf Sep 26, 2021
0d0082d
Add reduce_fmms to private docs
isuruf Sep 26, 2021
c4b569f
Improve docs
isuruf Sep 26, 2021
8e2d31a
Add reduce_fmms to private docs
isuruf Sep 26, 2021
bb246db
Add system utils to docs and fix doc warnings
isuruf Sep 26, 2021
5d198f0
Use a logger
isuruf Sep 26, 2021
3c05eab
Fix comment about source dependent variables to reflect code
isuruf Sep 26, 2021
ef0497d
Use one pass substitutor
isuruf Sep 26, 2021
b32e4ff
Allow converting IntGs with more than one source_kernels
isuruf Sep 26, 2021
90fd5b0
make normal vector names unique
isuruf Sep 27, 2021
d030a8a
Fix flake8 and bring back IntGSubstitutor
isuruf Sep 27, 2021
bed0598
insn_to_idx_mapping -> targetless_int_g_to_idx_mapping
isuruf Sep 27, 2021
447759c
Merge branch 'stokes_biharmonic' of github.com:isuruf/pytential into …
isuruf Sep 27, 2021
f2860ab
Merge branch 'main' into stokes_biharmonic
isuruf Sep 27, 2021
2723c15
Fix passing base_kernel
isuruf Sep 27, 2021
a3c35f9
Fix making normal vector names unique
isuruf Sep 27, 2021
3d50ac8
Use {} instead of dict()
isuruf Sep 27, 2021
c12b016
Merge branch 'main' of github.com:inducer/pytential into stokes_bihar…
isuruf Sep 29, 2021
9133bda
pymbolic has __iter__ that throws
isuruf Sep 29, 2021
896e2d1
Add a comment about folding duplicates in IntG
isuruf Sep 29, 2021
d547d7d
document extra_deriv_dirs
isuruf Sep 29, 2021
f948fc3
Use ABC for base classes
isuruf Sep 29, 2021
585bd34
note that apply_pressure doesn't depend on implementation
isuruf Sep 29, 2021
8d43a95
S -> int_g_vec as it's not a single layer kernel
isuruf Sep 29, 2021
85a9e4f
move stokeslet to the top
isuruf Sep 29, 2021
6075c88
update vim section comment
isuruf Sep 29, 2021
1bd3232
refactor base classes
isuruf Sep 29, 2021
302c5fb
simplify logic
isuruf Sep 29, 2021
61b7180
fix calling __init__
isuruf Sep 30, 2021
d899cdd
fix passing nu and method
isuruf Sep 30, 2021
e14b3d4
use double quotes
isuruf Sep 30, 2021
f7cdf14
Fix lints from pylint
isuruf Sep 30, 2021
24aedd8
revert setting stresslet obj
isuruf Sep 30, 2021
0c03e0a
Fix bad merge
isuruf Sep 30, 2021
fb13205
fix processing source[i] in densities
isuruf Sep 30, 2021
1b59ffc
Fix restoring target attributes
isuruf Sep 30, 2021
4561c26
Add test for restoring target attributes
isuruf Sep 30, 2021
26fa31b
Fix another bad merge with sending mu
isuruf Oct 1, 2021
78287b6
add some debug logging
isuruf Oct 3, 2021
e3391d8
Fix when there are non linear expressions
isuruf Oct 3, 2021
2c1ca38
don't check with np.array
isuruf Oct 3, 2021
33376f1
Increase randomint range and retry if that also fails
isuruf Oct 7, 2021
423c029
Allow target dependent variables
isuruf Oct 7, 2021
8a2779a
Fix formatting
isuruf Oct 7, 2021
e89d96f
revert maxwell test changes
isuruf Oct 8, 2021
81d3162
use retries exclusively
isuruf Oct 8, 2021
21a0ab7
Go back to 10**15 and fix rand matrix
isuruf Oct 8, 2021
c3dc80e
Support IntGs with IntGs in the densities
isuruf Oct 8, 2021
38d4018
pull out base kernel finder to a new function
isuruf Oct 9, 2021
00b0441
Fix IntGs within IntGs and add a test
isuruf Oct 9, 2021
78bbd1a
Mark all variables as source dependent if not given
isuruf Oct 10, 2021
85df49d
Fix handling DirectionalSourceDerivative
isuruf Oct 10, 2021
3be0da2
Run merge_int_g_exprs by default
isuruf Oct 10, 2021
e4f9fb0
Remove unused imports
isuruf Oct 10, 2021
4d079c9
remove unused variables
isuruf Oct 10, 2021
8a8a601
use get_args and get_source_args for target vs source
isuruf Oct 10, 2021
62e4dd2
remove making normal vector names unique
isuruf Oct 10, 2021
4056a33
handle directionaltargetderivative
isuruf Oct 10, 2021
f3a1660
WIP: inner
isuruf Oct 12, 2021
4d8bfb1
Revert "WIP: inner"
isuruf Oct 12, 2021
4159530
Don't change mu, nu names
isuruf Oct 12, 2021
33143c4
Fixes for change viscosity name
isuruf Oct 13, 2021
bddf4dc
change viscosity name in test to see if it works
isuruf Oct 13, 2021
f93c494
point sumpy to spatial constant branch
isuruf Oct 13, 2021
0928d79
make rewrite_using_base_kernel accept None as base_kernel
isuruf Oct 13, 2021
1e25c86
Fix formatting
isuruf Oct 13, 2021
e349803
sympy 1.9 compatibility
isuruf Oct 13, 2021
979f8f4
fix formatting
isuruf Oct 13, 2021
4d4fceb
Fix pylint lints
isuruf Oct 13, 2021
5f7904d
use sympy/sympy#22273
isuruf Oct 14, 2021
103a889
Support AxisTargetDerivative(TargetPointMultiplier)
isuruf Nov 15, 2021
878974b
Merge branch 'main' of github.com:inducer/pytential into stokes_bihar…
isuruf Jun 26, 2022
09da9ad
Fix lint
isuruf Jun 26, 2022
d81e16c
Fix pylint
isuruf Jun 26, 2022
feec35e
Reduce order expectation for new tests
isuruf Jun 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Contents
tools
misc
qbx
merge
🚀 Github <https://github.com/inducer/pytential>
💾 Download Releases <https://pypi.org/project/pytential>

Expand Down
4 changes: 4 additions & 0 deletions doc/merge.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Utilities to merge and reduce IntG expressions
==============================================

.. automodule:: pytential.symbolic.pde.system_utils
14 changes: 14 additions & 0 deletions doc/private.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:orphan:

Internal APIs
=============

These are private API that are documented for developers
and should not be used by end users.

Reduce Number of FMMs
---------------------

.. automodule:: pytential.symbolic.pde.reduce_fmms


18 changes: 10 additions & 8 deletions experiments/stokes-2d-interior.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
qbx_order = 2
fmm_order = 7
mu = 3
# method has to be one of biharmonic/naive for 2D
method = "biharmonic"

# Test solution type -- either 'fundamental' or 'couette' (default is couette)
soln_type = 'couette'
Expand Down Expand Up @@ -87,10 +89,10 @@ def get_obj_array(obj_array):
loc_sign = -1

# Create stresslet object
stresslet_obj = StressletWrapper(dim=2)
stresslet_obj = StressletWrapper(dim=2, mu_sym=mu_sym, method=method)

# Describe boundary operator
bdry_op_sym = loc_sign * 0.5 * sigma_sym + sqrt_w * stresslet_obj.apply(inv_sqrt_w_sigma, nvec_sym, mu_sym, qbx_forced_limit='avg')
bdry_op_sym = loc_sign * 0.5 * sigma_sym + sqrt_w * stresslet_obj.apply(inv_sqrt_w_sigma, nvec_sym, qbx_forced_limit='avg')

# Bind to the qbx discretization
bound_op = bind(qbx, bdry_op_sym)
Expand Down Expand Up @@ -140,7 +142,7 @@ def couette_soln(x, y, dp, h):
sigma = gmres_result.solution

# Describe representation of solution for evaluation in domain
representation_sym = stresslet_obj.apply(inv_sqrt_w_sigma, nvec_sym, mu_sym, qbx_forced_limit=-2)
representation_sym = stresslet_obj.apply(inv_sqrt_w_sigma, nvec_sym, qbx_forced_limit=-2)

from sumpy.visualization import FieldPlotter
nsamp = 10
Expand Down Expand Up @@ -194,11 +196,11 @@ def stride_hack(arr):
print("exact velocity at max error points: x -> ", err[0][max_error_loc[0]], ", y -> ", err[1][max_error_loc[1]])

from pytential.symbolic.mappers import DerivativeTaker
rep_pressure = stresslet_obj.apply_pressure(inv_sqrt_w_sigma, nvec_sym, mu_sym, qbx_forced_limit=-2)
rep_pressure = stresslet_obj.apply_pressure(inv_sqrt_w_sigma, nvec_sym, qbx_forced_limit=-2)
pressure = bind((qbx, PointsTarget(eval_points_dev)),
rep_pressure)(queue, sigma=sigma, mu=mu, normal=normal)
pressure = pressure.get()
print "pressure = ", pressure
print(f"pressure = {pressure}")

x_dir_vecs = np.zeros((2,len(eval_points[0])))
x_dir_vecs[0,:] = 1.0
Expand All @@ -207,7 +209,7 @@ def stride_hack(arr):
x_dir_vecs = cl.array.to_device(queue, x_dir_vecs)
y_dir_vecs = cl.array.to_device(queue, y_dir_vecs)
dir_vec_sym = sym.make_sym_vector("force_direction", dim)
rep_stress = stresslet_obj.apply_stress(inv_sqrt_w_sigma, nvec_sym, dir_vec_sym, mu_sym, qbx_forced_limit=-2)
rep_stress = stresslet_obj.apply_stress(inv_sqrt_w_sigma, nvec_sym, dir_vec_sym, qbx_forced_limit=-2)

applied_stress_x = bind((qbx, PointsTarget(eval_points_dev)),
rep_stress)(queue, sigma=sigma, normal=normal, force_direction=x_dir_vecs, mu=mu)
Expand All @@ -216,8 +218,8 @@ def stride_hack(arr):
rep_stress)(queue, sigma=sigma, normal=normal, force_direction=y_dir_vecs, mu=mu)
applied_stress_y = get_obj_array(applied_stress_y)

print "stress applied to x direction: ", applied_stress_x
print "stress applied to y direction: ", applied_stress_y
print(f"stress applied to x direction: {applied_stress_x}")
print(f"stress applied to y direction: {applied_stress_y}")


import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion pytential/qbx/fmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class QBXExpansionWrangler(SumpyExpansionWrangler):
def __init__(self, tree_indep, geo_data, dtype,
qbx_order, fmm_level_to_order,
source_extra_kwargs, kernel_extra_kwargs,
_use_target_specific_qbx=None):
*, translation_classes_data=None, _use_target_specific_qbx=None):
if _use_target_specific_qbx:
raise ValueError("TSQBX is not implemented in sumpy")

Expand Down
3 changes: 2 additions & 1 deletion pytential/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def ambient_dim(self):
return self._nodes.shape[0]

def op_group_features(self, expr):
from sumpy.kernel import TargetTransformationRemover
from pytential.utils import sort_arrays_together
# since IntGs with the same source kernels and densities calculations
# for P2E and E2E are the same and only differs in E2P depending on the
Expand All @@ -152,7 +153,7 @@ def op_group_features(self, expr):
result = (
expr.source,
*sort_arrays_together(expr.source_kernels, expr.densities, key=str),
expr.target_kernel,
TargetTransformationRemover()(expr.target_kernel),
)

return result
Expand Down
166 changes: 166 additions & 0 deletions pytential/symbolic/elasticity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
__copyright__ = "Copyright (C) 2021 Isuru Fernando"

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

import numpy as np

from pytential import sym
from sumpy.kernel import (AxisTargetDerivative, AxisSourceDerivative,
TargetPointMultiplier, LaplaceKernel)
from pytential.symbolic.stokes import (StressletWrapperBase, StokesletWrapperBase,
_MU_SYM_DEFAULT)


class StressletWrapperYoshida(StressletWrapperBase):
"""Stresslet Wrapper using Yoshida et al's method [1] which uses Laplace
derivatives.

[1] Yoshida, K. I., Nishimura, N., & Kobayashi, S. (2001). Application of
fast multipole Galerkin boundary integral equation method to elastostatic
crack problems in 3D.
International Journal for Numerical Methods in Engineering, 50(3), 525-547.
"""

def __init__(self, dim=None, mu_sym=_MU_SYM_DEFAULT, nu_sym=0.5):
self.dim = dim
if dim != 3:
raise ValueError("unsupported dimension given to "
"StressletWrapperYoshida")
self.kernel = LaplaceKernel(dim=3)
self.mu = mu_sym
self.nu = nu_sym

def apply(self, density_vec_sym, dir_vec_sym, qbx_forced_limit,
extra_deriv_dirs=()):
return self.apply_stokeslet_and_stresslet([0]*self.dim,
density_vec_sym, dir_vec_sym, qbx_forced_limit, 0, 1,
extra_deriv_dirs)

def apply_stokeslet_and_stresslet(self, stokeslet_density_vec_sym,
stresslet_density_vec_sym, dir_vec_sym,
qbx_forced_limit, stokeslet_weight, stresslet_weight,
extra_deriv_dirs=()):

mu = self.mu
nu = self.nu
lam = 2*nu*mu/(1-2*nu)
stokeslet_weight *= -1

def C(i, j, k, l): # noqa: E741
res = 0
if i == j and k == l:
res += lam
if i == k and j == l:
res += mu
if i == l and j == k:
res += mu
return res * stresslet_weight

def add_extra_deriv_dirs(target_kernel):
for deriv_dir in extra_deriv_dirs:
target_kernel = AxisTargetDerivative(deriv_dir, target_kernel)
return target_kernel

def P(i, j, int_g):
int_g = int_g.copy(target_kernel=add_extra_deriv_dirs(
int_g.target_kernel))
res = -int_g.copy(target_kernel=TargetPointMultiplier(j,
AxisTargetDerivative(i, int_g.target_kernel)))
if i == j:
res += (3 - 4*nu)*int_g
return res / (4*mu*(1 - nu))

def Q(i, int_g):
res = int_g.copy(target_kernel=add_extra_deriv_dirs(
AxisTargetDerivative(i, int_g.target_kernel)))
return res / (4*mu*(1 - nu))

sym_expr = np.zeros((3,), dtype=object)

kernel = self.kernel
source = [sym.NodeCoordinateComponent(d) for d in range(3)]
normal = dir_vec_sym
sigma = stresslet_density_vec_sym

source_kernels = [None]*4
for i in range(3):
source_kernels[i] = AxisSourceDerivative(i, kernel)
source_kernels[3] = kernel

for i in range(3):
for k in range(3):
densities = [0]*4
for l in range(3): # noqa: E741
for j in range(3):
for m in range(3):
densities[l] += C(k, l, m, j)*normal[m]*sigma[j]
densities[3] += stokeslet_weight * stokeslet_density_vec_sym[k]
int_g = sym.IntG(target_kernel=kernel,
source_kernels=tuple(source_kernels),
densities=tuple(densities),
qbx_forced_limit=qbx_forced_limit)
sym_expr[i] += P(i, k, int_g)

densities = [0]*4
for k in range(3):
for m in range(3):
for j in range(3):
for l in range(3): # noqa: E741
densities[l] += \
C(k, l, m, j)*normal[m]*sigma[j]*source[k]
if k == l:
densities[3] += \
C(k, l, m, j)*normal[m]*sigma[j]
densities[3] += stokeslet_weight * source[k] \
* stokeslet_density_vec_sym[k]
int_g = sym.IntG(target_kernel=kernel,
source_kernels=tuple(source_kernels),
densities=tuple(densities),
qbx_forced_limit=qbx_forced_limit)
sym_expr[i] += Q(i, int_g)

return sym_expr


class StokesletWrapperYoshida(StokesletWrapperBase):
"""Stokeslet Wrapper using Yoshida et al's method [1] which uses Laplace
derivatives.

[1] Yoshida, K. I., Nishimura, N., & Kobayashi, S. (2001). Application of
fast multipole Galerkin boundary integral equation method to elastostatic
crack problems in 3D.
International Journal for Numerical Methods in Engineering, 50(3), 525-547.
"""

def __init__(self, dim=None, mu_sym=_MU_SYM_DEFAULT, nu_sym=0.5):
self.dim = dim
if dim != 3:
raise ValueError("unsupported dimension given to "
"StokesletWrapperYoshida")
self.kernel = LaplaceKernel(dim=3)
self.mu = mu_sym
self.nu = nu_sym

def apply(self, density_vec_sym, qbx_forced_limit, extra_deriv_dirs=()):
stresslet = StressletWrapperYoshida(3, self.mu, self.nu)
return stresslet.apply_stokeslet_and_stresslet(density_vec_sym,
[0]*self.dim, [0]*self.dim, qbx_forced_limit, 1, 0,
extra_deriv_dirs)
18 changes: 16 additions & 2 deletions pytential/symbolic/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,12 @@ def __call__(self, *args, **kwargs):
raise TypeError("More than one positional argument supplied. "
"None or an PyOpenCLArrayContext expected.")

return self.eval(kwargs, array_context=array_context)
timing_data = kwargs.pop("timing_data", None)
return self.eval(kwargs, array_context=array_context,
timing_data=timing_data)


def bind(places, expr, auto_where=None):
def bind(places, expr, auto_where=None, _merge_exprs=True):
"""
:arg places: a :class:`pytential.collection.GeometryCollection`.
Alternatively, any list or mapping that is a valid argument for its
Expand All @@ -865,6 +867,18 @@ def bind(places, expr, auto_where=None):
auto_where = places.auto_where

expr = _prepare_expr(places, expr, auto_where=auto_where)
if _merge_exprs:
from pytential.symbolic.pde.system_utils import merge_int_g_exprs
from pymbolic.primitives import Expression
from pytential.qbx import QBXLayerPotentialSource
fmmlib = any(value.fmm_backend == "fmmlib" for value
in places.places.values() if isinstance(value, QBXLayerPotentialSource))
if not fmmlib:
if isinstance(expr, (np.ndarray, list, tuple)):
expr = np.array(merge_int_g_exprs(list(expr)), dtype=object)
elif isinstance(expr, Expression):
expr = merge_int_g_exprs([expr])[0]

return BoundExpression(places, expr)

# }}}
Expand Down
Loading