From 267b1f8f0dbf7512c1336327fe8eb7ded9c41219 Mon Sep 17 00:00:00 2001 From: miguelmaso Date: Fri, 28 Aug 2026 16:18:24 +0200 Subject: [PATCH 1/2] Update velocity also on dirichlet dofs --- src/ComputationalModels/Drivers.jl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ComputationalModels/Drivers.jl b/src/ComputationalModels/Drivers.jl index 50b1c88..6407a9e 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!(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!(get_free_dof_values(vh), get_free_dof_values(xh⁺), get_free_dof_values(xh⁻), Δt) + midpoint!(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⁻)) From d564bfed4591e6d6561d058dd61a1c3ceebe932d Mon Sep 17 00:00:00 2001 From: miguelmaso Date: Fri, 28 Aug 2026 19:09:09 +0200 Subject: [PATCH 2/2] minor --- src/ComputationalModels/Drivers.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ComputationalModels/Drivers.jl b/src/ComputationalModels/Drivers.jl index 6407a9e..7626684 100644 --- a/src/ComputationalModels/Drivers.jl +++ b/src/ComputationalModels/Drivers.jl @@ -283,7 +283,7 @@ get_spaces(m::DynamicNonlinearModel) = m.spaces get_assemblers(m::DynamicNonlinearModel) = (m.caches[4]) -function midpoint!(v, x⁺, x⁻, Δt) +function midpoint_update!(v, x⁺, x⁻, Δt) v .*= -1.0 v .-= (2.0 / Δt) * x⁻ v .+= (2.0 / Δt) * x⁺ @@ -299,8 +299,8 @@ The velocity is updated in place. """ function update_velocity!(vh, xh⁺, xh⁻, Δt) # TODO: Once moved to Gridap 0.20, a dispatch get_dirichlet_dof_values(::CellField) will be available - midpoint!(get_free_dof_values(vh), get_free_dof_values(xh⁺), get_free_dof_values(xh⁻), Δt) - midpoint!(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) + 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