Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shape derivative #882

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
6 changes: 5 additions & 1 deletion src/Arrays/LazyArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ end

function _array_cache!(dict::Dict,a::LazyArray)
@boundscheck begin
@notimplementedif ! all(map(isconcretetype, map(eltype, a.args)))
if ! all(map(isconcretetype, map(eltype, a.args)))
for n in 1:length(a.args)
@notimplementedif ! all(map(isconcretetype, map(eltype, a.args[n])))
end
end
if ! (eltype(a.maps) <: Function)
@notimplementedif ! isconcretetype(eltype(a.maps))
end
Expand Down
35 changes: 31 additions & 4 deletions src/CellData/DomainContributions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,41 @@ get_domains(a::DomainContribution) = keys(a.dict)

function get_contribution(a::DomainContribution,trian::Triangulation)
if haskey(a.dict,trian)
return a.dict[trian]
return a.dict[trian]
else
@unreachable """\n
There is not contribution associated with the given mesh in this DomainContribution object.
"""
for trian_a in get_domains(a)
if get_cell_node_ids(trian_a) == get_cell_node_ids(trian)
if hasproperty(trian,:a)
if hasproperty(trian.a,:subcells)
if isequivtrian(trian,trian_a)
return get_contribution(a,trian_a)
end
end
elseif hasproperty(trian,:subfacets)
if isequivtrian_subfacet(trian,trian_a)
return get_contribution(a,trian_a)
end
end
end
end
@unreachable """\n
There is not contribution associated with the given mesh in this DomainContribution object.
"""
end
end

function isequivtrian(trian1::AppendedTriangulation,trian2::AppendedTriangulation)
sc1 = trian1.a.subcells
sc2 = trian2.a.subcells
return (sc1.cell_to_points == sc2.cell_to_points && sc1.cell_to_bgcell == sc2.cell_to_bgcell && sc1.point_to_coords == sc2.point_to_coords && sc1.point_to_rcoords == sc2.point_to_rcoords )
end

function isequivtrian_subfacet(trian1,trian2)
sf1 = trian1.subfacets
sf2 = trian2.subfacets
return (sf1.facet_to_points == sf2.facet_to_points && sf1.facet_to_normal == sf2.facet_to_normal && sf1.point_to_coords == sf2.point_to_coords && sf1.point_to_rcoords == sf2.point_to_rcoords )
end

Base.getindex(a::DomainContribution,trian::Triangulation) = get_contribution(a,trian)

function add_contribution!(a::DomainContribution,trian::Triangulation,b::AbstractArray,op=+)
Expand Down
2 changes: 1 addition & 1 deletion src/Polynomials/MonomialBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function _evaluate!(

f = fg.fa
r, v, c, g = cache
z = zero(Mutable(VectorValue{D,eltype(T)}))
z = zero(Mutable(eltype(x)))
np = length(x)
ndof = length(f.terms) * num_components(T)
n = 1 + _maximum(f.orders)
Expand Down
2 changes: 1 addition & 1 deletion test/PolynomialsTests/MonomialBasesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Gridap.TensorValues
using Gridap.Fields
using Gridap.Polynomials

xi = Point(2,3)
xi = Point(2.0,3.0)
np = 5
x = fill(xi,np)

Expand Down