Skip to content
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

How-to: Calculate reaction forces #1072

Open
KnutAM opened this issue Sep 26, 2024 · 2 comments
Open

How-to: Calculate reaction forces #1072

KnutAM opened this issue Sep 26, 2024 · 2 comments
Labels
docs good first issue Something to work on as a new contributor!

Comments

@KnutAM
Copy link
Member

KnutAM commented Sep 26, 2024

Having a how-to on calculating reaction forces and comparing the accuracy would probably be nice.

Is a good first issue, so providing some details from Slack:

Calculating the reaction forces can be done in two ways in Ferrite,

  1. Calculate the traction at the boundary using the solution field to get the correct strains (and thus stresses), and then integrate to get the total reaction on the boundary.
  2. Get the residual vector on the boundary by assembling the internal force vector considering the solution field, and extracting the constrained degrees of freedom (I usually use a dummy constraint handler to do this).

The second option is more accurate (specifically it will give the exact result if the loading was a body load), but the first option is a bit easier to implement. Both are mathematically correct and will converge to eachother assuming a sufficiently fine mesh.

@KnutAM KnutAM added docs good first issue Something to work on as a new contributor! labels Sep 26, 2024
@fredrikekre
Copy link
Member

For 2 something like 17c9ef2 would help a lot

@zkk960317
Copy link

zkk960317 commented Oct 8, 2024

I had a similar problem before and it was solved in the second way as @KnutAM said. The code is below:

ch = ConstraintHandler(dh)
add!(ch, Dirichlet(:u, getfaceset(grid, "left"), Returns(zeros(2))))
add!(ch, Dirichlet(:u, getfaceset(grid, "right"), Returns(0.0), [2]))
close!(ch)

function FESolvers.postprocess!(p::PlasticityProblem, solver)
    buf = p.buf
    def = p.def
    post = p.post
    doassemble!(buf.cv, buf.fv, buf.K, buf.r,
        def.dh.grid, def.dh, def.material, def.damage, buf.u, buf.states, buf.states_old, true)
    dbc_force = sum(FESolvers.getresidual(p)[get_dbc_dofs(p.def,2)])
end;

function get_dbc_dofs(def,dbc_num::Int)
    dbc = def.ch.dbcs[dbc_num]
    bcfaces = dbc.faces
    constrained_dofs = Int[]
    cc = CellCache(def.ch.dh, UpdateFlags(; nodes=false, coords=false, dofs=true))
    for (cellidx, faceidx) in bcfaces
        reinit!(cc, cellidx)
        r = dbc.local_face_dofs_offset[faceidx]:(dbc.local_face_dofs_offset[faceidx+1]-1)
        append!(constrained_dofs, cc.dofs[dbc.local_face_dofs[r]])
    end
    return unique!(constrained_dofs)
end

If the query global_dofs can be added to each dbc of ch.dbcs, there is no need to write the above get_dbc_dofs function, and calculating reaction force will be much simpler. Then the only thing the user has to do is to add the focused dbc into the ch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs good first issue Something to work on as a new contributor!
Projects
None yet
Development

No branches or pull requests

3 participants