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

Make deformation of wireframe work for superparametric elements #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KnutAM
Copy link
Member

@KnutAM KnutAM commented Feb 14, 2024

Supersedes 2nd part of #119

Minimum reproducer

using Ferrite, FerriteViz
import GLMakie as Plt

grid = generate_grid(Quadrilateral, (2, 2))

dh = DofHandler(grid)
add!(dh, :u, 2, Lagrange{2,RefCube,2}())
close!(dh)

a = zeros(ndofs(dh))

apply_analytical!(a, dh, :u, x -> rand(Vec{2})/5)

plotter = MakiePlotter(dh, a)

wireframe(plotter; deformation_field=:u)

On master gives the following error

ERROR: DimensionMismatch: parent has 18 elements, which is incompatible with size (2, 4)
Stacktrace:
  [1] _throw_dmrs(n::Int64, str::String, dims::Tuple{Int64, Int64})
    @ Base .\reshapedarray.jl:182
  [2] _reshape
    @ .\reshapedarray.jl:177 [inlined]
  [3] reshape
    @ .\reshapedarray.jl:112 [inlined]
  [4] dof_to_node(dh::DofHandler{2, Grid{2, Quadrilateral, Float64}}, u::Vector{Float64}; field_name::Symbol)
    @ FerriteViz C:\Users\meyer\.julia\dev\FerriteViz\src\utils.jl:582
  [5] dof_to_node
    @ C:\Users\meyer\.julia\dev\FerriteViz\src\utils.jl:573 [inlined]
  [6] (::FerriteViz.var"#53#69"{DataType, MakiePlotter{…}})(arg1#247::Vector{Float64}, arg2#248::Symbol)
    @ FerriteViz C:\Users\meyer\.julia\dev\FerriteViz\src\makieplotting.jl:192
  [7] #map#13
    @ Observables C:\Users\meyer\.julia\packages\Observables\YdEbO\src\Observables.jl:570 [inlined]
  [8] map(f::FerriteViz.var"#53#69"{…}, arg1::Observables.Observable{…}, args::Observables.Observable{…})
    @ Observables C:\Users\meyer\.julia\packages\Observables\YdEbO\src\Observables.jl:568
  [9] plot!(WF::MakieCore.Combined{FerriteViz.wireframe, Tuple{MakiePlotter{…}}})
    @ FerriteViz C:\Users\meyer\.julia\dev\FerriteViz\src\makieplotting.jl:188
 [10] plot!(scene::Makie.Scene, P::Type{…}, attributes::MakieCore.Attributes, input::Tuple{…}, args::Observables.Observable{…})
    @ Makie C:\Users\meyer\.julia\packages\Makie\RgxaV\src\interfaces.jl:398
 [11] plot!(scene::Makie.Scene, P::Type{…}, attributes::MakieCore.Attributes, args::MakiePlotter{…}; kw_attributes::@Kwargs{})
    @ Makie C:\Users\meyer\.julia\packages\Makie\RgxaV\src\interfaces.jl:310
 [12] plot!(scene::Makie.Scene, P::Type{…}, attributes::MakieCore.Attributes, args::MakiePlotter{…})
    @ Makie C:\Users\meyer\.julia\packages\Makie\RgxaV\src\interfaces.jl:275
 [13] get_axis(fig::Any, P::Any, axis_kw::Dict, plot_attr::Any, plot_args::Any)
    @ Makie C:\Users\meyer\.julia\packages\Makie\RgxaV\src\figureplotting.jl:46
 [14] plot(P::Type{…}, args::MakiePlotter{…}; axis::@NamedTuple{}, figure::@NamedTuple{}, kw_attributes::@Kwargs{…})
    @ Makie C:\Users\meyer\.julia\packages\Makie\RgxaV\src\figureplotting.jl:65
 [15] plot
    @ Makie C:\Users\meyer\.julia\packages\Makie\RgxaV\src\figureplotting.jl:58 [inlined]
 [16] #wireframe#49
    @ FerriteViz C:\Users\meyer\.julia\packages\MakieCore\tAY2U\src\recipes.jl:35 [inlined]
 [17] top-level scope
    @ C:\Users\meyer\.julia\dev\FerriteViz\mwe\PR121\mwe.jl:16
Some type information was truncated. Use `show(err)` to see complete types.

Added some draft code for how this could be adopted to Ferrite#master / v1.0

@termi-official termi-official changed the title Make wireframe work for non isoparametric elements Make deformation of wireframe work for superparametric elements Feb 14, 2024
return data
# reshape_to_nodes gives either [Nx1] or [Nx3] to match vtk expectations
# Makie doesn't support view in to_vertices, so we have to collect:
return collect(transpose(view(data, 1:field_dim, :)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thats annoying but seems like no other option than collecting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the comment below, looks like I haven't tested with reinterpreted array, but not sure if even a transposed array works... But if it does, I guess one could branch for 2d and collect only for that case. For master / v1 the vtk-style output ([Nx1] / [Nx3]) could also be used instead of Vector{Vec}, but that is using an internal Ferrite detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants