Skip to content

Instantly share code, notes, and snippets.

@fredrikekre fredrikekre/test_mesh.jl
Last active Mar 8, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.