removed unmaintained code to wait for better days

This commit is contained in:
Jukka Aho
2017-01-06 06:57:34 +02:00
parent a1c6c8753a
commit fc63ff1692
4 changed files with 0 additions and 613 deletions
-180
View File
@@ -1,180 +0,0 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
function add_boundary_condition!(case::Simulation, bc::NeumannBC)
push!(case.neumann_boundary_conditions, bc)
end
"""
Add node to model and renumber for output
"""
function add_node!(model::Model, index::Union{Int64, String},
coords::Vector{Float64})
node = Node(index, coords)
model.nodes[index] = node
node_number = length(model.nodes)
model.renum_nodes[index] = node_number
end
function add_boundary_condition!(case::Simulation, bc::DirichletBC)
push!(case.dirichlet_boundary_conditions, bc)
end
function add_solver!(case::Simulation, solver)
case.solver = solver
end
function add_material!(model::Model, set_name::String, material::Material)
element_set = model.elsets[set_name]
set_ids = element_set.elements
for each in set_ids
element = model.elements[each]
element.material = material
end
element_set.material = material
end
function add_element!(model::Model, idx::Union{Int64, String},
eltype::Symbol, node_ids::Vector{Int64})
element = Element(idx, node_ids, eltype)
model.elements[idx] = element
end
function add_element_set!(model::Model, elset::ElementSet)
name = elset.name
model.elsets[name] = elset
end
function add_element_set!(model::Model, name::String, ids::Vector{Int64})
elset = ElementSet(name, ids)
model.elsets[name] = elset
end
function add_node_set!(model::Model, name::String, ids::Vector{Int64})
nset = NodeSet(name, ids)
model.nsets[name] = nset
end
function add_element_set!(model::Model, name::String,
elements::Vector{Element})
elset = ElementSet(name, elements)
model.elsets[name] = elset
end
function add_element_set!(case::Simulation, name::String)
push!(case.sets, name)
end
function add_simulation!(model::Model, name::String, case::Simulation)
model.load_cases[name] = case
end
#function Base.convert{T<:AbstractFloat}(::Type{Node}, data::Vector{T})
# Node(data)
#end:q
#
#
#function set_material!{S <: AbstractString}(model::Model, material::Material, set_name::S)
# model.sets[set_name].material = material
#end
#
#
#function get_element_set(model::Model, set_name::String)
# get_set = model.sets[set_name]
# isa(get_set, ElementSet) ? get_set : err("Found set $(set_name)
# but it is not a ElementSet. Check if you have used
# dublicate set names.")
#end
#
#function add_boundary_condition!{B <: BoundaryCondition}(case::Simulation, bc::B)
# push!(case.boundary_conditions, bc)
#end
#
#function add_boundary_condition!{B <: BoundaryCondition}(case::Simulation, bc::Vector{B})
# map(x-> push!(case.boundary_conditions, x), bc)
#end
#
#function add_loadcase!(model::Model, case::Simulation)
# push!(model.load_cases, case)
#end
#
#function add_loadcase!{T<:Simulation}(model::Model, case::Vector{T})
# map(x-> push!(model.load_cases, x), case)
#end
#
#"""
#"""
#function build_core_elements()
#
#end
#
#"""
#"""
#function set_core_element_material()
#
#end
#
#"""
#element_has_type( ::Type{Val{:C3D4}}) = Tet4
#"""
#function create_problems()
#
#end
#
#"""
#"""
#function add_problems!()
#
#end
#
#"""
#Get set from model
#"""
#function get_set{S <: AbstractString}(model::Model, name::S)
# try
# return model.set[name]
# catch
# err("Given set: $(name) does not exist in Model")
# end
#end
#
#"""
#"""
#function push!(model::Model, element::Element)
# push!(model.elements, element...)
#end
#
#"""
#"""
#function push!(model::Model, elements::Vector{Element})
# push!(model.element, elements...)
#end
#
#"""
#"""
#function push!(model::Model, node::Node)
# push!(model.nodes, node)
#end
#
#function push!(model::Model, nodes::Vector{Node})
# push!(mode, nodes...)
#end
#
#"""
#"""
#function add_set!(model::Model, set::Union{NodeSet, ElementSet})
# model.sets[set.name] = set
#end
#
#function add_set!{S <: AbstractString}(model::Model, ::Type{Val{:NSET}},
# name::S, ids::Vector{Integer})
# new_set = NodeSet(name, ids)
# add_set!(model, new_set)
#end
#
#function add_set!{S <: AbstractString}(model::Model, ::Type{Val{:ELSET}},
# name::S, ids::Vector{Integer})
# new_set = ElementSet(name, ids)
# add_set!(model, new_set)
#end
-146
View File
@@ -1,146 +0,0 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
type NeumannBC
set_name :: String
value :: Any
end
type DirichletBC
set_name :: String
value :: Any
end
typealias DisplacementBC DirichletBC
typealias TemperatureBC DirichletBC
typealias ForceBC NeumannBC
typealias HeatFluxBC NeumannBC
"""
"""
type Material
name :: String
scalar_data :: Dict{String, Any}
end
#Material(name, data) = Material(name, Dict(data))
Material(name) = Material(name, Dict{String, Any}())
Material() = Material("", Dict{String, Any}())
function Base.setindex!{T <: AbstractString }(material::Material, val, name::T)
material.scalar_data[name] = val
end
type Node
id :: Union{Integer, String}
coords :: Array{Float64, 1}
end
type Element
id :: Union{Integer, String, Void}
connectivity :: Vector{Int64}
element_type :: Symbol
results :: Any # Dict{}
material :: Any
end
Element(a, b, c) = Element(a, b, c, nothing, Material())
type NodeSet
name :: String
nodes :: Vector{Int64}
end
"""
"""
type ElementSet
name :: String
elements :: Vector{Union{Int64, String}}
material :: Material
end
ElementSet(name::String, elements::Vector{Element}) =
ElementSet(name, map(x-> x.id, elements), Material())
ElementSet(name::String, ids::Vector{Int64}) =
ElementSet(name, ids, Material())
"""
Simulation
"""
type Simulation
problem :: Symbol
neumann_boundary_conditions :: Vector{NeumannBC}
dirichlet_boundary_conditions :: Vector{DirichletBC}
solver
sets :: Vector{String}
end
Simulation(a) = Simulation(a, NeumannBC[], DirichletBC[], nothing, String[])
"""
Model type
Used for constructing the calculation model
"""
type Model
name :: String
nodes :: Dict{Union{Int64, String}}
elements :: Dict{Union{String, Int64}, Element}
elsets :: Dict{String, ElementSet}
nsets :: Dict{String, NodeSet}
load_cases :: Dict{String, Simulation}
renum_nodes :: Dict{Union{Int64, String}, Int64}
#settings :: Dict{AbstractString, Real}
end
function Model(name::String, abq_input::Dict)
model = Model(name)
nodes = abq_input["nodes"]
elements = abq_input["elements"]
element_sets = abq_input["elsets"]
node_sets = abq_input["nsets"]
for id in keys(nodes)
coords = nodes[id]
add_node!(model, id, coords)
end
for id in keys(elements)
data = elements[id]
eltype = data["type"]
conn = data["connectivity"]
# println(eltype, " ", conn)
add_element!(model, id, eltype, conn)
end
for name in keys(node_sets)
ids = node_sets[name]
add_node_set!(model, name, ids)
end
for name in keys(element_sets)
ids = element_sets[name]
add_element_set!(model, name, ids)
end
model
end
Model(name::String) = Model(
name,
Dict{Union{Int64, String}, Node}(),
Dict{Union{Int64, String}, Element}(),
Dict{String, NodeSet}(),
Dict{String, ElementSet}(),
Dict{String, Simulation}(),
Dict{Union{Int64, String}, Int64}()
)
function Base.setindex!(dict::Dict{Union{String, Int64}, Node},
vals::Vector{Float64}, idx::Union{String, Int64})
dict[idx] = Node(idx, vals)
end
-160
View File
@@ -1,160 +0,0 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
# some preliminary code for constructing hierarchical elements
abstract Hierarchical <: Element
bin(n, k) = prod([(n + 1 - i)/i for i=1:k])
"""
Return Legendgre polynomial of order n to inverval ξ ∈ [-1, 1]
Parameters
----------
n :: Int
order of polynomial
Returns
-------
function
Legendgre polynomial of order n in interval ξ ∈ [-1, 1]
"""
function get_legendre_polynomial(n::Int)
P(xi) = 2^n*sum([xi.^k*bin(n, k)*bin(1/2*(n+k-1), n) for k=0:n])
P
end
"""
Return derivative of Legendgre polynomial of order n to inverval ξ ∈ [-1, 1]
"""
function get_legendre_polynomial_derivative(n::Int)
dP(xi) = 2^n*sum([k*xi.^(k-1)*bin(n, k)*bin(1/2*(n+k-1), n) for k=1:n])
dP
end
"""
Return Legendgre polynomial of order n to inverval ξ ∈ [1, 1].
Parameters
----------
n :: Int
order of polynomial
Returns
-------
function
Legendgre polynomial of order n in interval ξ ∈ [-1, 1]
Notes
-----
Uses Bonnet's recursion formula. See
https://en.wikipedia.org/wiki/Legendre_polynomials
"""
function get_legendre_polynomial_recursive(n)
if n == 0
P(xi) = 1
elseif n == 1
P(xi) = xi
else
Pm1 = get_legendre_polynomial(n-1)
Pm2 = get_legendre_polynomial(n-2)
P(xi) = 1/n*((2*n-1)*xi*Pm1(xi) - (n-1)*Pm2(xi))
end
return P
end
"""
Return derivative of Legendgre polynomial of order n to inverval ξ ∈ [-1, 1]
"""
function get_legendre_polynomial_derivative_recursive(n)
if n == 0
P(xi) = 0
elseif n == 1
P(xi) = 1
else
Pm1 = get_legendre_polynomial_derivative(n-1)
Pm2 = get_legendre_polynomial_derivative(n-2)
P(xi) = 1/(n-1)*( (2*(n-1)+1)*xi.*Pm1(xi) - (n+1-1)*Pm2(xi))
end
return P
end
"""
Return hierarchical shape function of order N
"""
function get_hierarchial_basis(n)
if n == 1
N(xi) = 1/2*(1 - xi)
elseif n == 2
N(xi) = 1/2*(1 + xi)
else
j = n-1
Pj = get_legendre_polynomial(j)
Pjm2 = get_legendre_polynomial(j-2)
N(xi) = 1/sqrt(2*(2*j-1))*(Pj(xi) - Pjm2(xi))
end
return N
end
"""
Return derivative of hierarchical shape function of order N
"""
function get_hierarchial_basis_derivative(n)
if n == 1
dN(xi) = -1/2
elseif n == 2
dN(xi) = 1/2
else
j = n-1
Pj = get_legendre_polynomial_derivative(j)
Pjm2 = get_legendre_polynomial_derivative(j-2)
dN(xi) = 1/sqrt(2*(2*j-1))*(Pj(xi) - Pjm2(xi))
end
return dN
end
"""
Set degree of hierarchical element
"""
function set_degree(el::Hierarchical, degree)
el.degree = degree
end
"""
Get degree of hierarchical element
"""
function get_degree(el::Hierarchical)
el.degree
end
"""
Hierarchical 1d segment element.
"""
type PSeg <: Hierarchical
connectivity :: Array{Int, 1}
fields :: Dict{Any, Any}
degree :: Int
end
PSeg(connectivity) = PSeg(connectivity, Dict{Any,Any}(), 1)
get_number_of_basis_functions(el::Type{PSeg}) = 2
get_number_of_basis_functions(el::PSeg) = 2 + el.degree - 1
get_element_dimension(el::Type{PSeg}) = 1
function get_basis(el::PSeg, xi)
m = get_number_of_basis_functions(el)
out = zeros(m)
for n=1:m
N = get_hierarchial_basis(n)
out[n] = N(xi[1])
end
return out
end
function get_dbasisdxi(el::PSeg, xi)
m = get_number_of_basis_functions(el)
out = zeros(m)
for n=1:m
dN = get_hierarchial_basis_derivative(n)
out[n] = dN(xi[1])
end
return out
end
-127
View File
@@ -1,127 +0,0 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
using JuliaFEM
using JuliaFEM.Core
using JuliaFEM.API: Model
"""
Function for creating solver and all the necessary components
for the calculation
"""
function get_solver(model::Model, case_name::String)
case = model.load_cases[case_name]
# Create core elements
core_elements = create_core_elements(model)
# Add Neumann boundary conditions to elements
add_neumann_bcs!(model, case, core_elements)
# Create Dirichlet boundary conditions
dirichlet_arr = create_dirichlet_bcs(model, case, core_elements)
# Create solver
solver = create_solver(model, case,
core_elements, dirichlet_arr)
return solver
end
"""
"""
function create_solver(model, case, core_elements, dirichlet_arr)
field_problem = JuliaFEM.Core.(case.problem)()
all_elsets = model.elsets
# Pushing all the defined element sets into the calculation
for element_set in case.sets
el_ids = all_elsets[element_set].elements
for each in el_ids
push!(field_problem, core_elements[each])
end
end
# Creating the solver and pushing problems and
solver = JuliaFEM.Core.(case.solver)()
push!(solver, field_problem)
push!(solver, dirichlet_arr...)
return solver
end
"""
"""
function create_dirichlet_bcs(model, case, core_elements)
dirichlet_arr = Any[]
dirichlet_bcs = case.dirichlet_boundary_conditions
elsets = model.elsets
field_problem = JuliaFEM.Core.(case.problem)()
for each in dirichlet_bcs
set_name = each.set_name
value = each.value
problem = JuliaFEM.Core.DirichletProblem(
JuliaFEM.Core.get_unknown_field_name(field_problem),
JuliaFEM.Core.get_unknown_field_dimension(field_problem))
set_for_bc = each.set_name
set_ids = elsets[set_for_bc]
bc = each.value
for el_id in set_ids.elements
core_element = core_elements[el_id]
core_element[bc[1]] = bc[2]
push!(problem, core_element)
end
push!(dirichlet_arr, problem)
end
return dirichlet_arr
end
"""
"""
function create_core_elements(model)
core_elements = Dict()
nodes = model.nodes
all_elements = model.elements
element_ids = keys(all_elements)
for el_id in element_ids
element = all_elements[el_id]
el_type = element.element_type
el_id = element.id
mat = element.material
conn = element.connectivity
core_element = JuliaFEM.Core.(el_type)(conn)
core_element["geometry"] = map(x->nodes[x].coords, conn)
for each in keys(mat.scalar_data)
core_element[each] = mat.scalar_data[each]
end
core_elements[el_id] = core_element
model.elements[el_id].results = core_element
end
return core_elements
end
"""
"""
function add_neumann_bcs!(model, case, core_elements)
neumann_bcs = case.neumann_boundary_conditions
elsets = model.elsets
for each in neumann_bcs
set_for_bc = each.set_name
set_ids = elsets[set_for_bc]
bc = each.value
for el_id in set_ids.elements
core_element = core_elements[el_id]
core_element[bc[1]] = bc[2]
end
if !(set_for_bc in case.sets)
push!(case.sets, set_for_bc)
end
end
end
"""
"""
function solve!(model::Model, case_name::String, time::Float64)
# Create solver
solver = get_solver(model, case_name)
# Solve problem at given time
solver(time)
end