Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/ComputationalModels/Drivers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand All @@ -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

Expand All @@ -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⁻))
Expand Down
Loading