Introduced the concept of element and equation.

This commit is contained in:
Jukka Aho
2015-08-26 01:39:04 +03:00
parent 18394347dd
commit 8369e508b5
3 changed files with 353 additions and 333 deletions
+6 -5
View File
@@ -99,15 +99,16 @@ This version returns another function which can be then evaluated against field
"""
function linearize(f::Function, field::ASCIIString)
function jacobian(el::Element, args...)
dim, nnodes = size(el.attributes[field])
fld = get_field(el, field)
dim, nnodes = size(fld)
function helper!(x, y)
orig = copy(el.attributes[field])
el.attributes[field] = reshape(x, dim, nnodes)
orig = copy(fld)
set_field(el, field, reshape(x, dim, nnodes))
y[:] = f(el, args...)
el.attributes[field] = copy(orig)
set_field(el, field, copy(orig))
end
jac = ForwardDiff.forwarddiff_jacobian(helper!, Float64, fadtype=:dual, n=dim*nnodes, m=dim*nnodes)
return jac(el.attributes[field][:])
return jac(fld[:])
end
return jacobian
end
+1 -1
View File
@@ -19,7 +19,7 @@ type IntegrationPoint
weight :: Float64
attributes :: Dict{ASCIIString, Any}
end
IntegrationPoint(xi, weight) = IntegrationPoint(xi, weight, Dict{AsciiString, Any}())
IntegrationPoint(xi, weight) = IntegrationPoint(xi, weight, Dict{ASCIIString, Any}())
type Assembly
# LHS