@ti.kernel def mvp(v: ti.template(), mv: ti.template()): for p in x: gradc_scp[p] = 0…
- User
@ti.kernel def mvp(v: ti.template(), mv: ti.template()): for p in x: gradc_scp[p] = 0 # matrix-vector product for p in x: Xp = x[p] / dx base = (Xp - 0.5).cast(int) fx = Xp - base
# Weight functions w = [0.5 * (1.5 - fx)**2, 0.75 - (fx - 1)**2, 0.5 * (fx - 0.5)**2] dw = [-1.5 + fx, 2 * (fx - 1), 1.5 * (fx - 0.5)] # Derivative of shape functions for i, j in ti.static(ti.ndrange(3, 3)): offset = ti.Vector([i, j]) grid_idx = base + offset weight = w[i].x * w[j].y grad_c = ti.Vector([dw[i].x * w[j].y, w[i].x * dw[j].y]) gradc_scp[p] += p_vol * F[p].determinant() *grad_c*l0**2*parabolic_M*4* v[base + offset] # matrix-vector product for p in x: Xp = x[p] / dx base = (Xp - 0.5).cast(int) fx = Xp - base # Weight functions w = [0.5 * (1.5 - fx)**2, 0.75 - (fx - 1)**2, 0.5 * (fx - 0.5)**2] dw = [-1.5 + fx, 2 * (fx - 1), 1.5 * (fx - 0.5)] # Derivative of shape functions for i, j in ti.static(ti.ndrange(3, 3)): offset = ti.Vector([i, j]) grid_idx = base + offset weight = w[i].x * w[j].y grad_c = ti.Vector([dw[i].x * w[j].y, w[i].x * dw[j].y]) Fp = (4 * l0 * parabolic_M * psi_max[p] * 0.999 / G- parabolic_M + 1/dt) # Original MVP term mv[base + offset] += p_vol * F[p].determinant() * weight * (1/dt)* v[base + offset] mv[base + offset] += gradc_scp[p].dot(grad_c) Values don't evolve as expected for the heat equation, fix that
- Assistant
The issue with your heat equation implementation arises from incorrect calculations of the derivatives of the shape functions (
dw). Specifically, the signs and coefficients in your derivatives are not accurate, which leads to incorrect gradient computations and, consequently, incorrect evolution of your values.Here's how you can fix it:
-
Correct the Derivatives of the Shape Functions: The weight functions (
w) and their gradients () are crucial in finite element methods like MPM. The derivatives should be calculated correctly to ensure accurate gradient computations.
-