v0.14.0
sdf_hertz_2d_axisymm_sphere.py
Go to the documentation of this file.
1 import math
2 import numpy as np
3 
4 R = 100 # radius of the indenter
5 d = 0.01 # indentation depth
6 
7 xc = 0
8 yc = R
9 zc = 0
10 
11 def sdf(delta_t, t, x, y, z, tx, ty, tz, block_id):
12  return Sphere.sDF(R, xc, yc - d * t, zc, x, y, z)
13 
14 def grad_sdf(delta_t, t, x, y, z, tx, ty, tz, block_id):
15  return Sphere.gradSdf(xc, yc - d * t, zc, x, y, z)
16 
17 def hess_sdf(delta_t, t, x, y, z, tx, ty, tz, block_id):
18  return Sphere.hessSdf(xc, yc - d * t, zc, x, y, z)
19 
20 class Sphere:
21  def sDF(r, xc, yc, zc, x, y, z):
22  return np.sqrt((x - xc)**2 + (y - yc)**2 + (z - zc)**2) - r
23 
24  def gradSdf(xc, yc, zc, x, y, z):
25  c_val_A = 1./np.sqrt((x-xc)**2 + (y-yc)**2 + (z-zc)**2)
26  return np.hstack([(c_val_A * (x-xc)).reshape((-1,1)), (c_val_A * (y-yc)).reshape((-1,1)), (c_val_A * (z-zc)).reshape((-1,1))])
27 
28  def hessSdf(xc, yc, zc, x, y, z):
29  x, y, z = x-xc, y-yc, z-zc
30  denom = (x**2 + y**2 + z**2)**(3/2)
31  sqrt_denom = np.sqrt(x**2 + y**2 + z**2)
32  Hxx = -x**2/denom + 1/sqrt_denom
33  Hzx = -x*z/denom
34  Hxy = -x*y/denom
35  Hyy = -y**2/denom + 1/sqrt_denom
36  Hzy = -y*z/denom
37  Hzz = -z**2/denom + 1/sqrt_denom
38  # xx, yx, zx, yy, zy, zz
39  return np.hstack([Hxx.reshape((-1,1)), Hxy.reshape((-1,1)), Hzx.reshape((-1,1)), Hyy.reshape((-1,1)), Hzy.reshape((-1,1)), Hzz.reshape((-1,1))])
sdf_hertz_2d_axisymm_sphere.grad_sdf
def grad_sdf(delta_t, t, x, y, z, tx, ty, tz, block_id)
Definition: sdf_hertz_2d_axisymm_sphere.py:14
sdf_hertz_2d_axisymm_sphere.Sphere.sDF
def sDF(r, xc, yc, zc, x, y, z)
Definition: sdf_hertz_2d_axisymm_sphere.py:21
sdf_hertz_2d_axisymm_sphere.Sphere.hessSdf
def hessSdf(xc, yc, zc, x, y, z)
Definition: sdf_hertz_2d_axisymm_sphere.py:28
sdf_hertz_2d_axisymm_sphere.sdf
def sdf(delta_t, t, x, y, z, tx, ty, tz, block_id)
Definition: sdf_hertz_2d_axisymm_sphere.py:11
sdf_hertz_2d_axisymm_sphere.Sphere
Definition: sdf_hertz_2d_axisymm_sphere.py:20
sdf_hertz_2d_axisymm_sphere.Sphere.gradSdf
def gradSdf(xc, yc, zc, x, y, z)
Definition: sdf_hertz_2d_axisymm_sphere.py:24
sdf_hertz_2d_axisymm_sphere.hess_sdf
def hess_sdf(delta_t, t, x, y, z, tx, ty, tz, block_id)
Definition: sdf_hertz_2d_axisymm_sphere.py:17