Skip to content

Instantly share code, notes, and snippets.

@fredrikekre
Last active March 8, 2016 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredrikekre/04dba1aaf6295c29ddd7 to your computer and use it in GitHub Desktop.
Save fredrikekre/04dba1aaf6295c29ddd7 to your computer and use it in GitHub Desktop.
using JuAFEM
# Test of mesh functions in JuAFEM
function test_mesh()
# Set up nodal coordinates
coords = [0.0 1.0 2.0 0.0 1.0 2.0 0.0 1.0 2.0;
0.0 0.0 0.0 1.0 1.0 1.0 2.0 2.0 2.0]
coords_tens = reinterpret(Vec{2, Float64}, coords, (div(length(coords),2),))
# Topology matrix
topology = [1 2 4 5;
2 3 5 6;
5 6 8 9;
4 5 7 8]
# How should boundary information be gathered?
boundary = Vector{Int}[[1,2,3],[3,6,9],[9,8,7],[7,4,1]]
# Create a mesh object
fe_m = FEMesh(coords_tens,topology,boundary)
# Set up two fields to add to the mesh
u_field = FEField("displacement",2)
p_field = FEField("pressure",1)
fields = [u_field,p_field]
# Create a FEDofs object
fe_d = FEDofs(fe_m,fields)
# Access nodal coordinates for element #1
x = get_element_coords(fe_d,1)
println("Nodal coordinates for element #1: $x")
# or from the mesh object
x2 = get_element_coords(fe_m,1)
# Access element dofs for element #1
edof = get_element_dofs(fe_d,1)
println("Element dofs for element 1: $edof")
end
test_mesh()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment