Skip to content

Commit

Permalink
PERF: Add noexcept qualifiers to improve performance on Cython 3
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewturk authored and neutrinoceros committed Jul 19, 2023
1 parent 3927762 commit 0e9a1a5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 43 deletions.
20 changes: 10 additions & 10 deletions yt/frontends/gamer/cfields.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ cimport numpy as np
import numpy as np


cdef np.float64_t h_eos4(np.float64_t kT, np.float64_t g):
cdef np.float64_t h_eos4(np.float64_t kT, np.float64_t g) noexcept nogil:
cdef np.float64_t x
x = 2.25 * kT * kT
return 2.5 * kT + x / (1.0 + math.sqrt(x + 1.0))

cdef np.float64_t h_eos(np.float64_t kT, np.float64_t g):
cdef np.float64_t h_eos(np.float64_t kT, np.float64_t g) noexcept nogil:
return g * kT / (g - 1.0)

cdef np.float64_t gamma_eos(np.float64_t kT, np.float64_t g):
cdef np.float64_t gamma_eos(np.float64_t kT, np.float64_t g) noexcept nogil:
return g

cdef np.float64_t gamma_eos4(np.float64_t kT, np.float64_t g):
cdef np.float64_t gamma_eos4(np.float64_t kT, np.float64_t g) noexcept nogil:
cdef np.float64_t x, c_p, c_v
x = 2.25 * kT / math.sqrt(2.25 * kT * kT + 1.0)
c_p = 2.5 + x
c_v = 1.5 + x
return c_p / c_v

cdef np.float64_t cs_eos4(np.float64_t kT, np.float64_t c, np.float64_t g):
cdef np.float64_t cs_eos4(np.float64_t kT, np.float64_t c, np.float64_t g) noexcept nogil:
cdef np.float64_t hp, cs2
hp = h_eos4(kT, 0.0) + 1.0
cs2 = kT / (3.0 * hp)
cs2 *= (5.0 * hp - 8.0 * kT) / (hp - kT)
return c * math.sqrt(cs2)

cdef np.float64_t cs_eos(np.float64_t kT, np.float64_t c, np.float64_t g):
cdef np.float64_t cs_eos(np.float64_t kT, np.float64_t c, np.float64_t g) noexcept nogil:
cdef np.float64_t hp, cs2
hp = h_eos(kT, g) + 1.0
cs2 = g / hp * kT
return c * math.sqrt(cs2)

ctypedef np.float64_t (*f2_type)(np.float64_t, np.float64_t)
ctypedef np.float64_t (*f3_type)(np.float64_t, np.float64_t, np.float64_t)
ctypedef np.float64_t (*f2_type)(np.float64_t, np.float64_t) noexcept nogil
ctypedef np.float64_t (*f3_type)(np.float64_t, np.float64_t, np.float64_t) noexcept nogil

cdef class SRHDFields:
cdef f2_type h
Expand Down Expand Up @@ -68,7 +68,7 @@ cdef class SRHDFields:
np.float64_t my,
np.float64_t mz,
np.float64_t kT,
):
) noexcept nogil:
cdef np.float64_t u2
cdef np.float64_t fac

Expand All @@ -81,7 +81,7 @@ cdef class SRHDFields:
np.float64_t rho,
np.float64_t kT,
np.float64_t mi
):
) noexcept nogil:
return mi / (rho * (self.h(kT, self._gamma) + 1.0))

@cython.boundscheck(False)
Expand Down
16 changes: 8 additions & 8 deletions yt/geometry/particle_deposit.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cdef inline int gind(int i, int j, int k, int dims[3]):
# Standard SPH kernel for use with the Grid method #
####################################################

cdef inline np.float64_t sph_kernel_cubic(np.float64_t x) nogil:
cdef inline np.float64_t sph_kernel_cubic(np.float64_t x) noexcept nogil:
cdef np.float64_t kernel
# C is 8/pi
cdef np.float64_t C = 2.5464790894703255
Expand All @@ -53,7 +53,7 @@ cdef inline np.float64_t sph_kernel_cubic(np.float64_t x) nogil:
########################################################

# quartic spline
cdef inline np.float64_t sph_kernel_quartic(np.float64_t x) nogil:
cdef inline np.float64_t sph_kernel_quartic(np.float64_t x) noexcept nogil:
cdef np.float64_t kernel
cdef np.float64_t C = 9.71404681957369 # 5.**6/512/np.pi
if x < 1:
Expand All @@ -67,7 +67,7 @@ cdef inline np.float64_t sph_kernel_quartic(np.float64_t x) nogil:
return kernel * C

# quintic spline
cdef inline np.float64_t sph_kernel_quintic(np.float64_t x) nogil:
cdef inline np.float64_t sph_kernel_quintic(np.float64_t x) noexcept nogil:
cdef np.float64_t kernel
cdef np.float64_t C = 17.403593027098754 # 3.**7/40/np.pi
if x < 1:
Expand All @@ -81,7 +81,7 @@ cdef inline np.float64_t sph_kernel_quintic(np.float64_t x) nogil:
return kernel * C

# Wendland C2
cdef inline np.float64_t sph_kernel_wendland2(np.float64_t x) nogil:
cdef inline np.float64_t sph_kernel_wendland2(np.float64_t x) noexcept nogil:
cdef np.float64_t kernel
cdef np.float64_t C = 3.3422538049298023 # 21./2/np.pi
if x < 1:
Expand All @@ -91,7 +91,7 @@ cdef inline np.float64_t sph_kernel_wendland2(np.float64_t x) nogil:
return kernel * C

# Wendland C4
cdef inline np.float64_t sph_kernel_wendland4(np.float64_t x) nogil:
cdef inline np.float64_t sph_kernel_wendland4(np.float64_t x) noexcept nogil:
cdef np.float64_t kernel
cdef np.float64_t C = 4.923856051905513 # 495./32/np.pi
if x < 1:
Expand All @@ -101,7 +101,7 @@ cdef inline np.float64_t sph_kernel_wendland4(np.float64_t x) nogil:
return kernel * C

# Wendland C6
cdef inline np.float64_t sph_kernel_wendland6(np.float64_t x) nogil:
cdef inline np.float64_t sph_kernel_wendland6(np.float64_t x) noexcept nogil:
cdef np.float64_t kernel
cdef np.float64_t C = 6.78895304126366 # 1365./64/np.pi
if x < 1:
Expand All @@ -110,13 +110,13 @@ cdef inline np.float64_t sph_kernel_wendland6(np.float64_t x) nogil:
kernel = 0.
return kernel * C

cdef inline np.float64_t sph_kernel_dummy(np.float64_t x) nogil:
cdef inline np.float64_t sph_kernel_dummy(np.float64_t x) noexcept nogil:
return 0

# I don't know the way to use a dict in a cdef class.
# So in order to mimic a registry functionality,
# I manually created a function to lookup the kernel functions.
ctypedef np.float64_t (*kernel_func) (np.float64_t) nogil
ctypedef np.float64_t (*kernel_func) (np.float64_t) noexcept nogil
cdef inline kernel_func get_kernel_func(str kernel_name) nogil:
with gil:
if kernel_name == 'cubic':
Expand Down
24 changes: 12 additions & 12 deletions yt/utilities/lib/autogenerated_element_samplers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ from libc.math cimport pow
cdef void Q1Function3D(double* fx,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
fx[0] = 0.125*(1 - x[0])*(1 - x[1])*(1 - x[2])*vertices[0] + 0.125*(1 - x[0])*(1 - x[1])*(1 + x[2])*vertices[12] + 0.125*(1 - x[0])*(1 + x[1])*(1 - x[2])*vertices[9] + 0.125*(1 - x[0])*(1 + x[1])*(1 + x[2])*vertices[21] + 0.125*(1 + x[0])*(1 - x[1])*(1 - x[2])*vertices[3] + 0.125*(1 + x[0])*(1 - x[1])*(1 + x[2])*vertices[15] + 0.125*(1 + x[0])*(1 + x[1])*(1 - x[2])*vertices[6] + 0.125*(1 + x[0])*(1 + x[1])*(1 + x[2])*vertices[18] - phys_x[0]
fx[1] = 0.125*(1 - x[0])*(1 - x[1])*(1 - x[2])*vertices[1] + 0.125*(1 - x[0])*(1 - x[1])*(1 + x[2])*vertices[13] + 0.125*(1 - x[0])*(1 + x[1])*(1 - x[2])*vertices[10] + 0.125*(1 - x[0])*(1 + x[1])*(1 + x[2])*vertices[22] + 0.125*(1 + x[0])*(1 - x[1])*(1 - x[2])*vertices[4] + 0.125*(1 + x[0])*(1 - x[1])*(1 + x[2])*vertices[16] + 0.125*(1 + x[0])*(1 + x[1])*(1 - x[2])*vertices[7] + 0.125*(1 + x[0])*(1 + x[1])*(1 + x[2])*vertices[19] - phys_x[1]
fx[2] = 0.125*(1 - x[0])*(1 - x[1])*(1 - x[2])*vertices[2] + 0.125*(1 - x[0])*(1 - x[1])*(1 + x[2])*vertices[14] + 0.125*(1 - x[0])*(1 + x[1])*(1 - x[2])*vertices[11] + 0.125*(1 - x[0])*(1 + x[1])*(1 + x[2])*vertices[23] + 0.125*(1 + x[0])*(1 - x[1])*(1 - x[2])*vertices[5] + 0.125*(1 + x[0])*(1 - x[1])*(1 + x[2])*vertices[17] + 0.125*(1 + x[0])*(1 + x[1])*(1 - x[2])*vertices[8] + 0.125*(1 + x[0])*(1 + x[1])*(1 + x[2])*vertices[20] - phys_x[2]
Expand All @@ -28,7 +28,7 @@ cdef void Q1Jacobian3D(double* rcol,
double* tcol,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
rcol[0] = -0.125*(1 - x[1])*(1 - x[2])*vertices[0] + 0.125*(1 - x[1])*(1 - x[2])*vertices[3] - 0.125*(1 - x[1])*(1 + x[2])*vertices[12] + 0.125*(1 - x[1])*(1 + x[2])*vertices[15] + 0.125*(1 + x[1])*(1 - x[2])*vertices[6] - 0.125*(1 + x[1])*(1 - x[2])*vertices[9] + 0.125*(1 + x[1])*(1 + x[2])*vertices[18] - 0.125*(1 + x[1])*(1 + x[2])*vertices[21]
scol[0] = -0.125*(1 - x[0])*(1 - x[2])*vertices[0] + 0.125*(1 - x[0])*(1 - x[2])*vertices[9] - 0.125*(1 - x[0])*(1 + x[2])*vertices[12] + 0.125*(1 - x[0])*(1 + x[2])*vertices[21] - 0.125*(1 + x[0])*(1 - x[2])*vertices[3] + 0.125*(1 + x[0])*(1 - x[2])*vertices[6] - 0.125*(1 + x[0])*(1 + x[2])*vertices[15] + 0.125*(1 + x[0])*(1 + x[2])*vertices[18]
tcol[0] = -0.125*(1 - x[0])*(1 - x[1])*vertices[0] + 0.125*(1 - x[0])*(1 - x[1])*vertices[12] - 0.125*(1 - x[0])*(1 + x[1])*vertices[9] + 0.125*(1 - x[0])*(1 + x[1])*vertices[21] - 0.125*(1 + x[0])*(1 - x[1])*vertices[3] + 0.125*(1 + x[0])*(1 - x[1])*vertices[15] - 0.125*(1 + x[0])*(1 + x[1])*vertices[6] + 0.125*(1 + x[0])*(1 + x[1])*vertices[18]
Expand All @@ -46,7 +46,7 @@ cdef void Q1Jacobian3D(double* rcol,
cdef void Q1Function2D(double* fx,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
fx[0] = 0.25*(1 - x[0])*(1 - x[1])*vertices[0] + 0.25*(1 - x[0])*(1 + x[1])*vertices[6] + 0.25*(1 + x[0])*(1 - x[1])*vertices[2] + 0.25*(1 + x[0])*(1 + x[1])*vertices[4] - phys_x[0]
fx[1] = 0.25*(1 - x[0])*(1 - x[1])*vertices[1] + 0.25*(1 - x[0])*(1 + x[1])*vertices[7] + 0.25*(1 + x[0])*(1 - x[1])*vertices[3] + 0.25*(1 + x[0])*(1 + x[1])*vertices[5] - phys_x[1]

Expand All @@ -58,7 +58,7 @@ cdef void Q1Jacobian2D(double* rcol,
double* scol,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
rcol[0] = -0.25*(1 - x[1])*vertices[0] + 0.25*(1 - x[1])*vertices[2] + 0.25*(1 + x[1])*vertices[4] - 0.25*(1 + x[1])*vertices[6]
scol[0] = -0.25*(1 - x[0])*vertices[0] + 0.25*(1 - x[0])*vertices[6] - 0.25*(1 + x[0])*vertices[2] + 0.25*(1 + x[0])*vertices[4]
rcol[1] = -0.25*(1 - x[1])*vertices[1] + 0.25*(1 - x[1])*vertices[3] + 0.25*(1 + x[1])*vertices[5] - 0.25*(1 + x[1])*vertices[7]
Expand All @@ -71,7 +71,7 @@ cdef void Q1Jacobian2D(double* rcol,
cdef void Q2Function2D(double* fx,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
fx[0] = (1 + x[0])*(-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[16] - 0.5*(1 + x[0])*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[8] - 0.5*(1 + x[0])*(-1 + x[0])*x[1]*(1 + x[1])*vertices[12] - phys_x[0] - 0.5*x[0]*(-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[14] + 0.25*x[0]*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[0] + 0.25*x[0]*(-1 + x[0])*x[1]*(1 + x[1])*vertices[6] - 0.5*x[0]*(1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[10] + 0.25*x[0]*(1 + x[0])*x[1]*(-1 + x[1])*vertices[2] + 0.25*x[0]*(1 + x[0])*x[1]*(1 + x[1])*vertices[4]
fx[1] = (1 + x[0])*(-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[17] - 0.5*(1 + x[0])*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[9] - 0.5*(1 + x[0])*(-1 + x[0])*x[1]*(1 + x[1])*vertices[13] - phys_x[1] - 0.5*x[0]*(-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[15] + 0.25*x[0]*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[1] + 0.25*x[0]*(-1 + x[0])*x[1]*(1 + x[1])*vertices[7] - 0.5*x[0]*(1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[11] + 0.25*x[0]*(1 + x[0])*x[1]*(-1 + x[1])*vertices[3] + 0.25*x[0]*(1 + x[0])*x[1]*(1 + x[1])*vertices[5]

Expand All @@ -83,7 +83,7 @@ cdef void Q2Jacobian2D(double* rcol,
double* scol,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
rcol[0] = -0.5*(-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[14] + (-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[16] + 0.25*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[0] - 0.5*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[8] + 0.25*(-1 + x[0])*x[1]*(1 + x[1])*vertices[6] - 0.5*(-1 + x[0])*x[1]*(1 + x[1])*vertices[12] - 0.5*(1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[10] + (1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[16] + 0.25*(1 + x[0])*x[1]*(-1 + x[1])*vertices[2] - 0.5*(1 + x[0])*x[1]*(-1 + x[1])*vertices[8] + 0.25*(1 + x[0])*x[1]*(1 + x[1])*vertices[4] - 0.5*(1 + x[0])*x[1]*(1 + x[1])*vertices[12] - 0.5*x[0]*(1 + x[1])*(-1 + x[1])*vertices[10] - 0.5*x[0]*(1 + x[1])*(-1 + x[1])*vertices[14] + 0.25*x[0]*x[1]*(-1 + x[1])*vertices[0] + 0.25*x[0]*x[1]*(-1 + x[1])*vertices[2] + 0.25*x[0]*x[1]*(1 + x[1])*vertices[4] + 0.25*x[0]*x[1]*(1 + x[1])*vertices[6]
scol[0] = -0.5*(-1 + x[1])*(1 + x[0])*(-1 + x[0])*vertices[8] + (-1 + x[1])*(1 + x[0])*(-1 + x[0])*vertices[16] + 0.25*(-1 + x[1])*x[0]*(-1 + x[0])*vertices[0] - 0.5*(-1 + x[1])*x[0]*(-1 + x[0])*vertices[14] + 0.25*(-1 + x[1])*x[0]*(1 + x[0])*vertices[2] - 0.5*(-1 + x[1])*x[0]*(1 + x[0])*vertices[10] - 0.5*(1 + x[1])*(1 + x[0])*(-1 + x[0])*vertices[12] + (1 + x[1])*(1 + x[0])*(-1 + x[0])*vertices[16] + 0.25*(1 + x[1])*x[0]*(-1 + x[0])*vertices[6] - 0.5*(1 + x[1])*x[0]*(-1 + x[0])*vertices[14] + 0.25*(1 + x[1])*x[0]*(1 + x[0])*vertices[4] - 0.5*(1 + x[1])*x[0]*(1 + x[0])*vertices[10] - 0.5*x[1]*(1 + x[0])*(-1 + x[0])*vertices[8] - 0.5*x[1]*(1 + x[0])*(-1 + x[0])*vertices[12] + 0.25*x[1]*x[0]*(-1 + x[0])*vertices[0] + 0.25*x[1]*x[0]*(-1 + x[0])*vertices[6] + 0.25*x[1]*x[0]*(1 + x[0])*vertices[2] + 0.25*x[1]*x[0]*(1 + x[0])*vertices[4]
rcol[1] = -0.5*(-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[15] + (-1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[17] + 0.25*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[1] - 0.5*(-1 + x[0])*x[1]*(-1 + x[1])*vertices[9] + 0.25*(-1 + x[0])*x[1]*(1 + x[1])*vertices[7] - 0.5*(-1 + x[0])*x[1]*(1 + x[1])*vertices[13] - 0.5*(1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[11] + (1 + x[0])*(1 + x[1])*(-1 + x[1])*vertices[17] + 0.25*(1 + x[0])*x[1]*(-1 + x[1])*vertices[3] - 0.5*(1 + x[0])*x[1]*(-1 + x[1])*vertices[9] + 0.25*(1 + x[0])*x[1]*(1 + x[1])*vertices[5] - 0.5*(1 + x[0])*x[1]*(1 + x[1])*vertices[13] - 0.5*x[0]*(1 + x[1])*(-1 + x[1])*vertices[11] - 0.5*x[0]*(1 + x[1])*(-1 + x[1])*vertices[15] + 0.25*x[0]*x[1]*(-1 + x[1])*vertices[1] + 0.25*x[0]*x[1]*(-1 + x[1])*vertices[3] + 0.25*x[0]*x[1]*(1 + x[1])*vertices[5] + 0.25*x[0]*x[1]*(1 + x[1])*vertices[7]
Expand All @@ -96,7 +96,7 @@ cdef void Q2Jacobian2D(double* rcol,
cdef void Tet2Function3D(double* fx,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
fx[0] = (-x[0] + 2*pow(x[0], 2))*vertices[3] + (-x[1] + 2*pow(x[1], 2))*vertices[6] + (-x[2] + 2*pow(x[2], 2))*vertices[9] + (4*x[0] - 4*x[0]*x[1] - 4*x[0]*x[2] - 4*pow(x[0], 2))*vertices[12] + (4*x[1] - 4*x[1]*x[0] - 4*x[1]*x[2] - 4*pow(x[1], 2))*vertices[18] + (4*x[2] - 4*x[2]*x[0] - 4*x[2]*x[1] - 4*pow(x[2], 2))*vertices[21] + (1 - 3*x[0] + 4*x[0]*x[1] + 4*x[0]*x[2] + 2*pow(x[0], 2) - 3*x[1] + 4*x[1]*x[2] + 2*pow(x[1], 2) - 3*x[2] + 2*pow(x[2], 2))*vertices[0] - phys_x[0] + 4*x[0]*x[1]*vertices[15] + 4*x[0]*x[2]*vertices[24] + 4*x[1]*x[2]*vertices[27]
fx[1] = (-x[0] + 2*pow(x[0], 2))*vertices[4] + (-x[1] + 2*pow(x[1], 2))*vertices[7] + (-x[2] + 2*pow(x[2], 2))*vertices[10] + (4*x[0] - 4*x[0]*x[1] - 4*x[0]*x[2] - 4*pow(x[0], 2))*vertices[13] + (4*x[1] - 4*x[1]*x[0] - 4*x[1]*x[2] - 4*pow(x[1], 2))*vertices[19] + (4*x[2] - 4*x[2]*x[0] - 4*x[2]*x[1] - 4*pow(x[2], 2))*vertices[22] + (1 - 3*x[0] + 4*x[0]*x[1] + 4*x[0]*x[2] + 2*pow(x[0], 2) - 3*x[1] + 4*x[1]*x[2] + 2*pow(x[1], 2) - 3*x[2] + 2*pow(x[2], 2))*vertices[1] - phys_x[1] + 4*x[0]*x[1]*vertices[16] + 4*x[0]*x[2]*vertices[25] + 4*x[1]*x[2]*vertices[28]
fx[2] = (-x[0] + 2*pow(x[0], 2))*vertices[5] + (-x[1] + 2*pow(x[1], 2))*vertices[8] + (-x[2] + 2*pow(x[2], 2))*vertices[11] + (4*x[0] - 4*x[0]*x[1] - 4*x[0]*x[2] - 4*pow(x[0], 2))*vertices[14] + (4*x[1] - 4*x[1]*x[0] - 4*x[1]*x[2] - 4*pow(x[1], 2))*vertices[20] + (4*x[2] - 4*x[2]*x[0] - 4*x[2]*x[1] - 4*pow(x[2], 2))*vertices[23] + (1 - 3*x[0] + 4*x[0]*x[1] + 4*x[0]*x[2] + 2*pow(x[0], 2) - 3*x[1] + 4*x[1]*x[2] + 2*pow(x[1], 2) - 3*x[2] + 2*pow(x[2], 2))*vertices[2] - phys_x[2] + 4*x[0]*x[1]*vertices[17] + 4*x[0]*x[2]*vertices[26] + 4*x[1]*x[2]*vertices[29]
Expand All @@ -110,7 +110,7 @@ cdef void Tet2Jacobian3D(double* rcol,
double* tcol,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
rcol[0] = (-1 + 4*x[0])*vertices[3] + (-3 + 4*x[0] + 4*x[1] + 4*x[2])*vertices[0] + (4 - 8*x[0] - 4*x[1] - 4*x[2])*vertices[12] + 4*x[1]*vertices[15] - 4*x[1]*vertices[18] - 4*x[2]*vertices[21] + 4*x[2]*vertices[24]
scol[0] = (-1 + 4*x[1])*vertices[6] + (-3 + 4*x[0] + 4*x[1] + 4*x[2])*vertices[0] + (4 - 4*x[0] - 8*x[1] - 4*x[2])*vertices[18] - 4*x[0]*vertices[12] + 4*x[0]*vertices[15] - 4*x[2]*vertices[21] + 4*x[2]*vertices[27]
tcol[0] = (-1 + 4*x[2])*vertices[9] + (-3 + 4*x[0] + 4*x[1] + 4*x[2])*vertices[0] + (4 - 4*x[0] - 4*x[1] - 8*x[2])*vertices[21] - 4*x[0]*vertices[12] + 4*x[0]*vertices[24] - 4*x[1]*vertices[18] + 4*x[1]*vertices[27]
Expand All @@ -128,7 +128,7 @@ cdef void Tet2Jacobian3D(double* rcol,
cdef void T2Function2D(double* fx,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
fx[0] = (-x[0] + 2*pow(x[0], 2))*vertices[2] + (-x[1] + 2*pow(x[1], 2))*vertices[4] + (-4*x[0]*x[1] + 4*x[1] - 4*pow(x[1], 2))*vertices[10] + (4*x[0] - 4*x[0]*x[1] - 4*pow(x[0], 2))*vertices[6] + (1 - 3*x[0] + 4*x[0]*x[1] + 2*pow(x[0], 2) - 3*x[1] + 2*pow(x[1], 2))*vertices[0] - phys_x[0] + 4*x[0]*x[1]*vertices[8]
fx[1] = (-x[0] + 2*pow(x[0], 2))*vertices[3] + (-x[1] + 2*pow(x[1], 2))*vertices[5] + (-4*x[0]*x[1] + 4*x[1] - 4*pow(x[1], 2))*vertices[11] + (4*x[0] - 4*x[0]*x[1] - 4*pow(x[0], 2))*vertices[7] + (1 - 3*x[0] + 4*x[0]*x[1] + 2*pow(x[0], 2) - 3*x[1] + 2*pow(x[1], 2))*vertices[1] - phys_x[1] + 4*x[0]*x[1]*vertices[9]

Expand All @@ -140,7 +140,7 @@ cdef void T2Jacobian2D(double* rcol,
double* scol,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
rcol[0] = (-1 + 4*x[0])*vertices[2] + (-3 + 4*x[0] + 4*x[1])*vertices[0] + (4 - 8*x[0] - 4*x[1])*vertices[6] + 4*x[1]*vertices[8] - 4*x[1]*vertices[10]
scol[0] = (-1 + 4*x[1])*vertices[4] + (-3 + 4*x[0] + 4*x[1])*vertices[0] + (4 - 4*x[0] - 8*x[1])*vertices[10] - 4*x[0]*vertices[6] + 4*x[0]*vertices[8]
rcol[1] = (-1 + 4*x[0])*vertices[3] + (-3 + 4*x[0] + 4*x[1])*vertices[1] + (4 - 8*x[0] - 4*x[1])*vertices[7] + 4*x[1]*vertices[9] - 4*x[1]*vertices[11]
Expand All @@ -153,7 +153,7 @@ cdef void T2Jacobian2D(double* rcol,
cdef void W1Function3D(double* fx,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
fx[0] = 0.5*(1 - x[0] - x[1])*(1 - x[2])*vertices[0] + 0.5*(1 - x[0] - x[1])*(1 + x[2])*vertices[9] - phys_x[0] + 0.5*x[0]*(1 - x[2])*vertices[3] + 0.5*x[0]*(1 + x[2])*vertices[12] + 0.5*x[1]*(1 - x[2])*vertices[6] + 0.5*x[1]*(1 + x[2])*vertices[15]
fx[1] = 0.5*(1 - x[0] - x[1])*(1 - x[2])*vertices[1] + 0.5*(1 - x[0] - x[1])*(1 + x[2])*vertices[10] - phys_x[1] + 0.5*x[0]*(1 - x[2])*vertices[4] + 0.5*x[0]*(1 + x[2])*vertices[13] + 0.5*x[1]*(1 - x[2])*vertices[7] + 0.5*x[1]*(1 + x[2])*vertices[16]
fx[2] = 0.5*(1 - x[0] - x[1])*(1 - x[2])*vertices[2] + 0.5*(1 - x[0] - x[1])*(1 + x[2])*vertices[11] - phys_x[2] + 0.5*x[0]*(1 - x[2])*vertices[5] + 0.5*x[0]*(1 + x[2])*vertices[14] + 0.5*x[1]*(1 - x[2])*vertices[8] + 0.5*x[1]*(1 + x[2])*vertices[17]
Expand All @@ -167,7 +167,7 @@ cdef void W1Jacobian3D(double* rcol,
double* tcol,
double* x,
double* vertices,
double* phys_x) nogil:
double* phys_x) noexcept nogil:
rcol[0] = -0.5*(1 - x[2])*vertices[0] + 0.5*(1 - x[2])*vertices[3] - 0.5*(1 + x[2])*vertices[9] + 0.5*(1 + x[2])*vertices[12]
scol[0] = -0.5*(1 - x[2])*vertices[0] + 0.5*(1 - x[2])*vertices[6] - 0.5*(1 + x[2])*vertices[9] + 0.5*(1 + x[2])*vertices[15]
tcol[0] = -0.5*(1 - x[0] - x[1])*vertices[0] + 0.5*(1 - x[0] - x[1])*vertices[9] - 0.5*x[0]*vertices[3] + 0.5*x[0]*vertices[12] - 0.5*x[1]*vertices[6] + 0.5*x[1]*vertices[15]
Expand Down
Loading

0 comments on commit 0e9a1a5

Please sign in to comment.