Fix return types for fields not defined

Problem arises typically when boundary condition is created using
"nodal" elements of type Poi1, but forget to define geometry and
```solvers("geometry", 0.0)``` fails in Xdmf update function. Fixed.
This commit is contained in:
Jukka Aho
2017-06-28 13:54:04 +03:00
committed by Jukka Aho
parent 1505205dcd
commit 7efa5aa01e
2 changed files with 18 additions and 3 deletions
+1 -1
View File
@@ -313,7 +313,7 @@ function getindex(problem::Problem, field_name::AbstractString)
end
""" Return field calculated to nodal points for elements in problem p. """
function (problem::Problem)(field_name::AbstractString, time::Float64=0.0)
function (problem::Problem)(field_name::AbstractString, time::AbstractFloat=0.0)
#if haskey(problem, field_name)
# return problem[field_name](time)
#end
+17 -2
View File
@@ -468,15 +468,30 @@ function get_all_elements(solver::Solver)
return [elements...;]
end
"""
Return nodal field from all problems defined in solver.
Examples
--------
To return e.g. geometry defined in nodal points at time t=0.0, one can write:
julia> solver("geometry", 0.0)
"""
function (solver::Solver)(field_name::String, time::Float64)
fields = []
for problem in get_problems(solver)
field = problem(field_name, time)
if field == nothing
continue
end
if length(field) == 0
warn("no field $field_name found for problem $(problem.name)")
else
push!(fields, field)
continue
end
push!(fields, field)
end
if length(fields) == 0
return Dict{Integer, Vector{Float64}}()
end
return merge(fields...)
end