Skip to content

Commit 2b571ff

Browse files
authored
Fix stress_tensor formulation (#175)
* Fix stress_tensor quadrature Fixes bug where all of quadrature points were not summed over properly for each basis function during the element-wise integration of the stress tensor. Also adds multiplication by relevant quadrature weights and the determinant of the jacobian. * Fixing stress_tensor kernel formuation Updated the stress tensor kernel to allign with Hooke's law for homogenous isotropic materials. * Add volume correction in stress_tensor.jl
1 parent a50f52a commit 2b571ff

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Functions/stress_tensor.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ function (f::ElementStressTensor)(u::DisplacementResult; element_dofs=false)
6262
n_basefuncs = getnbasefunctions(st.cellvalues)
6363
n_quad = getnquadpoints(st.cellvalues)
6464
dim = TopOptProblems.getdim(st.problem)
65-
return sum(
66-
map(1:n_basefuncs, 1:n_quad) do a, q_point
65+
V = sum(st.cellvalues.detJdV)
66+
return sum(map(1:n_quad) do q_point
67+
= getdetJdV(st.cellvalues, q_point)
68+
sum(map(1:n_basefuncs) do a
6769
_u = cellu[dim * (a - 1) .+ (1:dim)]
6870
return tensor_kernel(f, q_point, a)(DisplacementResult(_u))
69-
end,
70-
)
71+
end) *
72+
end) ./ V
7173
end
7274

7375
@params struct ElementStressTensorKernel{T} <: AbstractFunction{T}
@@ -82,8 +84,8 @@ function (f::ElementStressTensorKernel)(u::DisplacementResult)
8284
@unpack E, ν, q_point, a, cellvalues = f
8385
∇ϕ = Vector(shape_gradient(cellvalues, q_point, a))
8486
ϵ = (u.u .* ∇ϕ' .+ ∇ϕ .* u.u') ./ 2
85-
c1 = E * ν / (1 - ν^2) * sum(diag(ϵ))
86-
c2 = E * ν * (1 + ν)
87+
c1 = E * ν / ((1 + ν)*(1 - 2*ν)) * sum(diag(ϵ))
88+
c2 = E / (1 + ν)
8789
return c1 * I + c2 * ϵ
8890
end
8991
function ChainRulesCore.rrule(f::ElementStressTensorKernel, u::DisplacementResult)

0 commit comments

Comments
 (0)