mirror of
https://github.com/JuliaFEM/JuliaFEM.jl.git
synced 2026-09-23 02:59:52 +00:00
fixed api test, modified linearsolver constructor, added possibility to add slow tests using prefix slow_test_...
This commit is contained in:
+6
-6
@@ -42,15 +42,15 @@ function create_solver(model, case, core_elements, dirichlet_arr)
|
||||
|
||||
# Creating the solver and pushing problems and
|
||||
# boundary conditions
|
||||
if case.solver == :LinearSolver
|
||||
solver = JuliaFEM.Core.(case.solver)(field_problem,
|
||||
dirichlet_arr...)
|
||||
else
|
||||
# if case.solver == :LinearSolver
|
||||
# solver = JuliaFEM.Core.(case.solver)(field_problem,
|
||||
# dirichlet_arr...)
|
||||
# else
|
||||
solver = JuliaFEM.Core.(case.solver)()
|
||||
push!(solver, field_problem)
|
||||
push!(solver, dirichlet_arr...)
|
||||
end
|
||||
solver
|
||||
# end
|
||||
return solver
|
||||
end
|
||||
|
||||
"""
|
||||
|
||||
+22
-7
@@ -56,8 +56,23 @@ end
|
||||
|
||||
""" Simple linear solver for educational purposes. """
|
||||
type LinearSolver <: Solver
|
||||
field_problem :: Problem
|
||||
boundary_problem :: BoundaryProblem
|
||||
name :: ASCIIString
|
||||
field_problems :: Vector{Problem}
|
||||
boundary_problems :: Vector{BoundaryProblem}
|
||||
end
|
||||
|
||||
function LinearSolver(name="LinearSolver")
|
||||
LinearSolver(name, [], [])
|
||||
end
|
||||
|
||||
function push!(solver::LinearSolver, problem::Problem)
|
||||
length(solver.field_problems) == 0 || error("Only one field problem allowed for LinearSolver")
|
||||
push!(solver.field_problems, problem)
|
||||
end
|
||||
|
||||
function push!(solver::LinearSolver, problem::BoundaryProblem)
|
||||
length(solver.boundary_problems) == 0 || error("Only one boundary problem allowed for LinearSolver")
|
||||
push!(solver.boundary_problems, problem)
|
||||
end
|
||||
|
||||
"""
|
||||
@@ -72,12 +87,12 @@ common situation, i.e., some main field problem and it's Dirichlet boundary.
|
||||
"""
|
||||
function call(solver::LinearSolver, time::Float64)
|
||||
|
||||
field_name = get_unknown_field_name(solver.field_problem)
|
||||
field_dim = get_unknown_field_dimension(solver.field_problem)
|
||||
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_problem, time)
|
||||
boundary_assembly = assemble(solver.boundary_problem, time)
|
||||
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)
|
||||
@@ -101,7 +116,7 @@ function call(solver::LinearSolver, time::Float64)
|
||||
la = x[dim+1:end]
|
||||
|
||||
# update field for elements in problem 1
|
||||
for element in get_elements(solver.field_problem)
|
||||
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
|
||||
|
||||
@@ -33,6 +33,11 @@ end
|
||||
""" Return all functions from module with name starting test """
|
||||
function get_test_functions(mod::Module)
|
||||
test_function_names = filter((k) -> startswith(string(k), "test_"), names(mod, true))
|
||||
if haskey(ENV, "JULIAFEM_TEST_SLOW")
|
||||
info("JULIAFEM_TEST_SLOW set, testing also tests that are taking a long time")
|
||||
slow_test_functions = filter((k) -> startswith(string(k), "slow_test_"), names(mod, true))
|
||||
append!(test_function_names, slow_test_functions)
|
||||
end
|
||||
test_function_expressions = map((k) -> :($mod.$k), test_function_names)
|
||||
test_functions = map(eval, test_function_expressions)
|
||||
return test_functions
|
||||
|
||||
Reference in New Issue
Block a user