# JuAFEM difference between apply! and apply\_zero!

**URL:** <https://discourse.julialang.org/t/juafem-difference-between-apply-and-apply-zero/39072>\
**Category:** Modelling & Simulations\
**Tags:** question\
**Created:** [May 8, 2020, 10:43am UTC](https://discourse.julialang.org/t/juafem-difference-between-apply-and-apply-zero/39072 "2020-05-08T10:43:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrootLoops](https://avatars.discourse-cdn.com/v4/letter/f/c4cdca/32.png) [@FrootLoops](https://discourse.julialang.org/u/FrootLoops)\
**Post date:** [May 8, 2020, 10:43am UTC](https://discourse.julialang.org/t/juafem-difference-between-apply-and-apply-zero/39072/1 "2020-05-08T10:43:56Z")

</div>

In some examples for JuAFEM I often see people using either “apply!()” or “apply\_zero!()” to apply the boundary conditions. Can someone explain me the difference:

```julia
        apply!(K, f, dbc)
        apply_zero!(K, f, dbc)

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 8, 2020, 12:01pm UTC](https://discourse.julialang.org/t/juafem-difference-between-apply-and-apply-zero/39072/2 "2020-05-08T12:01:07Z")

</div>

`apply_zero!` is for when you want to have zeros for the constrained degrees of freedom in the solution of `K \ f`. One example when this is required is when iterating on a solution for a nonlinear system of equations. The solution to `K \ f` is the increments to your trial solution and those should be zero for constrained dofs.
