Open mohamed82008 opened 6 years ago
cc @Kevin-Mattheus-Moerman
This script requires a couple of preparations to run. Firstly, you need JuAFEM
and StaticArrays
installed. Then you need to checkout this PR/branch https://github.com/KristofferC/JuAFEM.jl/pull/216. Then you should clone https://github.com/mohamed82008/LinearElasticity.jl. Then I believe you should be ready to go:
using LinearElasticity
# Define problem
nels = (60,20,4)
sizes = (1.0,1.0,1.0)
E = 1.0;
ν = 0.3;
force = -1.0;
problem = PointLoadCantilever(nels, sizes, E, ν, force)
# Build element stiffness matrices and force vectors
einfo = ElementFEAInfo(problem);
# Assemble global stiffness matrix and force vector
ginfo = assemble(problem, einfo);
# Solve for node displacements
u = ginfo.K \ ginfo.f
mesh = problem.ch.dh.grid
node_dofs = problem.metadata.node_dofs
node_displacements = reshape(u[node_dofs], 3, JuAFEM.getnnodes(mesh))
# visualize(mesh, node_displacements)
Please let me know if you run into difficulties or need more details on the internal representation of the mesh.
The desired visualization here is to transform the nodes of the mesh by the corresponding displacements and bonus points if the color of the mesh changes proportionally to the norm of the displacement at that part of the mesh.
Duplicate of https://github.com/JuliaPlots/Makie.jl/issues/64 ? We'd (@ysimillides) would like to use this with FEniCS.jl as well, so it makes sense to have a standard trisurf tie-in that both JuliaFEM and FEniCS (and then whoever else comes in the future as well) build package-specific recipes on top of.
The approach Simon used to visualize juafem cells using the above script is here https://github.com/JuliaPlots/Makie.jl/blob/sd/abstract/examples/fem.jl. I don't know how the fenics wrapper works but if you can sneak behind Python's back and reinterpret the (hopefully contiguous) data into a juafem-like unstructured grid then the same script above can be used. All I needed to generalize this script to other cell types was to define to_triangle
for different cell types. If you want to trisurf the whole mesh yourself, e.g. in case of structured meshes, and then pass it to Makie, then you may want to try overloading to_gl_indices
. You will also probably need to pass the Cells
struct to Makie.mesh
and mesh!
instead of mesh.cells
in the script above. There may be more to the story though that only Simon can tell us.
The api with to_triangle
and to_gl_indices
is not set in stone yet ;) Ideally I wanted to just have convert_arguments
work for this in a standard way, but this was the easiest right now.
I just opened an issue at GeometryTypes to talk more about it:
https://github.com/JuliaGeometry/GeometryTypes.jl/issues/131
Following the brief discussion on slack, I am opening this issue to host relevant discussions. Here is the text of my question:
@SimonDanisch's response was:
A script to showcase the mesh representation, expected visualization and desired API is coming up next...