Ferrite-FEM / FerriteViz.jl

Plot your Ferrite.jl data
https://ferrite-fem.github.io/FerriteViz.jl/
MIT License
28 stars 9 forks source link

1D Elements #41

Open koehlerson opened 2 years ago

koehlerson commented 2 years ago

How to triangulate Line, Line2D, Line3D ? Maybe just lines from Makie? How to incorporate this properly? https://makie.juliaplots.org/stable/examples/plotting_functions/lines/#example_11610848752349455524

termi-official commented 2 years ago

Related to this and if I remember correctly, then quads and triangles in 3D also do not work yet.

termi-official commented 11 months ago

Maybe we should rearrange the plotter struct to hold sets of triangles and additionally sets of lines for e.g 1D elements, wireframes, streamlines and so on. This way we only have one point where we need to update lines to fix e.g. deformed domains. Should also fix https://github.com/Ferrite-FEM/FerriteViz.jl/issues/26 .

asinghvi17 commented 2 weeks ago

I assume the MakiePlotter struct's definition is here,

https://github.com/Ferrite-FEM/FerriteViz.jl/blob/0eeec9a8bf5ff8a51b88cff3ec9c8de43e07b8bf/src/utils.jl#L34-L48

and it looks like cells are triangulated and assembled here,

https://github.com/Ferrite-FEM/FerriteViz.jl/blob/0eeec9a8bf5ff8a51b88cff3ec9c8de43e07b8bf/src/utils.jl#L63-L82

so maybe we could filter all line elements out of cells before they go into the triangulation loop, and apply some preprocessing? I'd be happy to do a first implementation (branched off from #103 of course) with some guidance from you all!

termi-official commented 2 weeks ago

Thanks for your interest on this Anshul! Happy to give you some guidance on this.

You are right, we have the plotter struct, which acts essentially as a cache. This cache contains some kind of remeshing of the Ferrite mesh that is comaptible with Makie (to overcome the issue that GeometryBasics has no sane way to handle nonlinear geometries yet).

My idea here was slightly different. In this loop we could just set ntriangles to 0 and also just do a no-op in the discretization function decompose! in utils.jl . The issue is that I am not sure if we can make decompose work on 1D elements with Makie right now, because we cannot dynamically generate screen-facing triangles.

To render the lines we can then add an additional fields to the struct to track 1D elements separately as Makie.lines, analogue to the way we handle triangles. An alternative idea is that we can also mesh line elements as cylinder geometries with some associated thickness. I am open to experiment here.

If 103 does not work, then I will find some time tomorrow to update it. This should be easy on my side.

Out of interest, what is your application? Do you "just" want to plot some solution in 1D with a 1D discretization or is this one more about beams, wires, ... in 2D/3D? If you want to make the former work, then we can get away with something much simpler by "just" adding specialized dispatches for dim=1.

asinghvi17 commented 2 weeks ago

Thanks for the advice! I'm primarily looking at 1D discretizations, but if I'm putting the effort in anyway, may as well write it for 2/3D too :D

I'd lean towards the lines proposal as an initial implementation, just because it seems simplest. Meshing as a cylinder would need UV support etc that seems like a pain at this point, but it can always be added later under this framework.

termi-official commented 2 weeks ago

I'd lean towards the lines proposal as an initial implementation [...]

Sure, let us start there. :)

[...] would need UV support [...]

Note that we have a different approach. Instead of providing textures directly we discretize the geometry manually on our end and map colors to the vertices of the triangles.