removed obsolete solver code

This commit is contained in:
Jukka Aho
2016-05-24 08:34:39 +03:00
parent 292a97620c
commit 2057bc9c44
-87
View File
@@ -1,93 +1,6 @@
# This file is a part of JuliaFEM.
# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md
""" Simple linear solver for educational purposes. """
type LinearSolver
name :: ASCIIString
field_problems :: Vector{Problem}
boundary_problems :: Vector{Problem}
end
function LinearSolver(name="LinearSolver")
LinearSolver(name, [], [])
end
function push!{P<:FieldProblem}(solver::LinearSolver, problem::Problem{P})
length(solver.field_problems) == 0 || error("Only one field problem allowed for LinearSolver")
push!(solver.field_problems, problem)
end
function push!{P<:BoundaryProblem}(solver::LinearSolver, problem::Problem{P})
length(solver.boundary_problems) == 0 || error("Only one boundary problem allowed for LinearSolver")
push!(solver.boundary_problems, problem)
end
"""
Call solver to solve a set of problems.
This is a simple direct solver for demonstration purposes. It handles the
common situation, i.e., some main field problem and it's Dirichlet boundary.
Ku + C'λ = f
Cu = g
"""
function call(solver::LinearSolver, time::Float64)
t0 = Base.time()
field_name = get_unknown_field_name(solver.field_problems[1])
field_dim = get_unknown_field_dimension(solver.field_problems[1])
info("solving $field_name problem, $field_dim dofs / nodes")
field_assembly = assemble(solver.field_problems[1], time)
boundary_assembly = assemble(solver.boundary_problems[1], time)
#info("Creating sparse matrices")
K = sparse(field_assembly.stiffness_matrix)
dim = size(K, 1)
f = sparse(field_assembly.force_vector, dim, 1)
C = sparse(boundary_assembly.stiffness_matrix, dim, dim)
g = sparse(boundary_assembly.force_vector, dim, 1)
# create a saddle point problem
A = [K C'; C' zeros(C)]
b = [f; g]
# solve problem
nz = unique(rowvals(A)) # take only non-zero rows
x = zeros(b)
x[nz] = lufact(A[nz,nz]) \ full(b[nz])
# get "problem-wise" solution vectors
u = x[1:dim]
la = x[dim+1:end]
# update field for elements in problem 1
for element in get_elements(solver.field_problems[1])
gdofs = get_gdofs(element, field_dim)
local_sol = vec(full(u[gdofs]))
# if solving vector field, modify local solution vector
# to array of vectors
if field_dim != 1
local_sol = reshape(local_sol, field_dim, length(element))
local_sol = [local_sol[:,i] for i=1:size(local_sol,2)]
end
if haskey(element, field_name)
push!(element[field_name], time => local_sol)
else
element[field_name] = (time => local_sol)
end
end
t1 = round(Base.time()-t0, 2)
info("solved problem in $t1 seconds.")
return norm(u)
end
# Tuple{Symbol,Any,Any} or Function
type Solver
name :: ASCIIString # some descriptive name for problem
time :: Real # current time