diff --git a/src/ComputationalModels/Drivers.jl b/src/ComputationalModels/Drivers.jl index 50b1c88..7626684 100644 --- a/src/ComputationalModels/Drivers.jl +++ b/src/ComputationalModels/Drivers.jl @@ -283,6 +283,13 @@ get_spaces(m::DynamicNonlinearModel) = m.spaces get_assemblers(m::DynamicNonlinearModel) = (m.caches[4]) +function midpoint_update!(v, x⁺, x⁻, Δt) + v .*= -1.0 + v .-= (2.0 / Δt) * x⁻ + v .+= (2.0 / Δt) * x⁺ +end + + """ update_velocity! @@ -291,10 +298,9 @@ and the previous displacement `xh⁻` using a midpoint time-stepping scheme. The velocity is updated in place. """ function update_velocity!(vh, xh⁺, xh⁻, Δt) - v = get_free_dof_values(vh) - v .*= -1.0 - v .-= (2.0 / Δt) * get_free_dof_values(xh⁻) - v .+= (2.0 / Δt) * get_free_dof_values(xh⁺) + # TODO: Once moved to Gridap 0.20, a dispatch get_dirichlet_dof_values(::CellField) will be available + midpoint_update!(get_free_dof_values(vh), get_free_dof_values(xh⁺), get_free_dof_values(xh⁻), Δt) + midpoint_update!(get_dirichlet_dof_values(get_fe_space(vh)), get_dirichlet_dof_values(get_fe_space(xh⁺)), get_dirichlet_dof_values(get_fe_space(xh⁻)), Δt) return vh end @@ -307,6 +313,7 @@ The update is performed in place, modifying `xh⁻` to match both the free dof v and the dirichlet dof values of `xh⁺`. """ function update_displacements!(xh⁻, xh⁺) + # TODO: Once moved to Gridap 0.20, a dispatch get_dirichlet_dof_values(::CellField) will be available x = get_free_dof_values(xh⁻) x .= get_free_dof_values(xh⁺) x_dir = get_dirichlet_dof_values(get_fe_space(xh⁻))