Simple usage examples

Simple usage examples

A simple example demonstrating the basic usage of package. Calculate a simple one element model. Add pressure load on top and support block symmetrically.

X = Dict(
    1 => [0.0, 0.0],
    2 => [1.0, 0.0],
    3 => [1.0, 1.0],
    4 => [0.0, 1.0])
Dict{Int64,Array{Float64,1}} with 4 entries:
  4 => [0.0, 1.0]
  2 => [1.0, 0.0]
  3 => [1.0, 1.0]
  1 => [0.0, 0.0]
element = Element(Quad4, [1, 2, 3, 4])
update!(element, "geometry", X)
update!(element, "youngs modulus", 288.0)
update!(element, "poissons ratio", 1/3)
DCTI{Float64}(0.3333333333333333)

First define a field problem and add element to it

body = Problem(Elasticity, "test problem", 2)
update!(body.properties,
    "formulation" => "plane_stress",
    "finite_strain" => "false",
    "geometric_stiffness" => "false")
body.elements = [element]
1-element Array{Element{Quad4},1}:
 Element{Quad4}(-1, [1, 2, 3, 4], FEMBase.Point{IntegrationPoint}[], Dict{String,AbstractField}("poissons ratio" => DCTI{Float64}(0.3333333333333333),"geometry" => DVTId{Array{Float64,1}}(Dict(4 => [0.0, 1.0],2 => [1.0, 0.0],3 => [1.0, 1.0],1 => [0.0, 0.0])),"youngs modulus" => DCTI{Float64}(288.0)), Quad4())

Then create element to carry on pressure

tr_el = Element(Seg2, [3, 4])
update!(tr_el, "geometry", X)
update!(tr_el, "displacement traction force 2", 288.0)
traction = Problem(Elasticity, "pressure on top of block", 2)
update!(traction.properties,
    "formulation" => "plane_stress",
    "finite_strain" => "false",
    "geometric_stiffness" => "false")
traction.elements = [tr_el]
1-element Array{Element{Seg2},1}:
 Element{Seg2}(-1, [3, 4], FEMBase.Point{IntegrationPoint}[], Dict{String,AbstractField}("geometry" => DVTId{Array{Float64,1}}(Dict(4 => [0.0, 1.0],2 => [1.0, 0.0],3 => [1.0, 1.0],1 => [0.0, 0.0])),"displacement traction force 2" => DCTI{Float64}(288.0)), Seg2())

Create boundary condition to support block at bottom and left

bc_el_1 = Element(Seg2, [1, 2])
bc_el_2 = Element(Seg2, [4, 1])
update!(bc_el_1, "displacement 2", 0.0)
update!(bc_el_2, "displacement 1", 0.0)
bc = Problem(Dirichlet, "add symmetry bc", 2, "displacement")
bc.elements = [bc_el_1, bc_el_2]
2-element Array{Element{Seg2},1}:
 Element{Seg2}(-1, [1, 2], FEMBase.Point{IntegrationPoint}[], Dict{String,AbstractField}("displacement 2" => DCTI{Float64}(0.0)), Seg2())
 Element{Seg2}(-1, [4, 1], FEMBase.Point{IntegrationPoint}[], Dict{String,AbstractField}("displacement 1" => DCTI{Float64}(0.0)), Seg2())

Last thing is to create a solver, push problem to solver and solve:

solver = Solver(Linear, body, traction, bc)
solver()
[ Info: Creating a new analysis of type Linear with name `LinearSolver`.
โ”Œ Warning: analysis(time) is deprecated. Instead, use run!(analysis)
โ”” @ JuliaFEM ~/build/JuliaFEM/JuliaFEM.jl/src/solvers.jl:678
[ Info: Running linear quasistatic analysis `LinearSolver` at time 0.0.
[ Info: Assembling 3 problems.
[ Info: Solving linear system.
[ Info: Solved linear system in 1.18 seconds using solver 1. Solution norms (||u||, ||la||): (1.49071198499986, 203.64675298172568).
[ Info:
[ Info: Postprocessing 3 problems.
[ Info: No result writers are attached to analysis, not writing output.
[ Info: To write results to Xdmf file, attach Xdmf to analysis, i.e.
[ Info: xdmf_output = Xdmf("simulation_results")
[ Info: add_results_writer!(analysis, xdmf_output)
[ Info: Quasistatic linear analysis ready.

Displacement in node 3 is

solver("displacement", 0.0)[3]
2-element Array{Float64,1}:
 -0.3333333333333334
  1.0000000000000002