JuliaFEM / FEMBase.jl

JuliaFEM base package (core functionality)
http://juliafem.org/
MIT License
16 stars 9 forks source link

Update fields with dictionaries is not consistent #56

Open ahojukka5 opened 5 years ago

ahojukka5 commented 5 years ago

I just realized that we have two kinds of results when updating fields with dictionaries. First one, when we already have a DVTV field, and then update with dictionary:

using FEMBase
T = Dict(1 => 1.0, 2 => 2.0)
element = Element(Seg2, (1, 2))
update!(element, "temperature", 0.0 => (0.0, 0.0))
update!(element, "temperature", 1.0 => T)
element.fields["temperature"]

# output

DVTV{2,Float64}(Pair{Float64,Tuple{Float64,Float64}}[0.0=>(0.0, 0.0), 1.0=>(1.0, 2.0)])

However, if we create a a new field:

update!(element, "temperature2", 0.0 => T)
element.fields["temperature2"]

# output

DVTVd{Float64}(Pair{Float64,Dict{Int64,Float64}}[0.0=>Dict(2=>2.0,1=>1.0)])

It cannot be like this. For sure this is causing confusion. Because it is very unlikely that the user actually wants to create DVTVd, we should always have DVTV and creating DVTVd should need some special attention, maybe

temp_field = field(0.0 => T)
update!(element, "temperature", temp_field)