Compare commits
No commits in common. "43cbf8a3a0c3e2152306876e8481fbcab797f7f8" and "a3f3f6a31bde0f28c01cb35c9ad18f7719232d90" have entirely different histories.
43cbf8a3a0
...
a3f3f6a31b
@ -72,21 +72,21 @@ const coordnames = IdDict{Symbol, Vector{Union{Symbol, Nothing}}}(
|
|||||||
nameof(Sphere) => [:rₛ, :sₛ, :xₛ, :yₛ, :zₛ]
|
nameof(Sphere) => [:rₛ, :sₛ, :xₛ, :yₛ, :zₛ]
|
||||||
)
|
)
|
||||||
|
|
||||||
coordname(elt::Element, index) = coordnames[nameof(typeof(elt))][index]
|
coordname(elem::Element, index) = coordnames[nameof(typeof(elem))][index]
|
||||||
|
|
||||||
function pushcoordname!(coordnamelist, indexed_elt::Tuple{Any, Element}, coordindex)
|
function pushcoordname!(coordnamelist, indexed_elem::Tuple{Any, Element}, coordindex)
|
||||||
eltindex, elt = indexed_elt
|
elemindex, elem = indexed_elem
|
||||||
name = coordname(elt, coordindex)
|
name = coordname(elem, coordindex)
|
||||||
if !isnothing(name)
|
if !isnothing(name)
|
||||||
subscript = Subscripts.sub(string(eltindex))
|
subscript = Subscripts.sub(string(elemindex))
|
||||||
push!(coordnamelist, Symbol(name, subscript))
|
push!(coordnamelist, Symbol(name, subscript))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function takecoord!(coordlist, indexed_elt::Tuple{Any, Element}, coordindex)
|
function takecoord!(coordlist, indexed_elem::Tuple{Any, Element}, coordindex)
|
||||||
elt = indexed_elt[2]
|
elem = indexed_elem[2]
|
||||||
if !isnothing(coordname(elt, coordindex))
|
if !isnothing(coordname(elem, coordindex))
|
||||||
push!(elt.coords, popfirst!(coordlist))
|
push!(elem.coords, popfirst!(coordlist))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -132,12 +132,12 @@ mutable struct Construction{T}
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.push!(ctx::Construction{T}, elt::Point{T}) where T
|
function Base.push!(ctx::Construction{T}, elem::Point{T}) where T
|
||||||
push!(ctx.points, elt)
|
push!(ctx.points, elem)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.push!(ctx::Construction{T}, elt::Sphere{T}) where T
|
function Base.push!(ctx::Construction{T}, elem::Sphere{T}) where T
|
||||||
push!(ctx.spheres, elt)
|
push!(ctx.spheres, elem)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Base.push!(ctx::Construction{T}, rel::Relation{T}) where T
|
function Base.push!(ctx::Construction{T}, rel::Relation{T}) where T
|
||||||
@ -150,10 +150,10 @@ end
|
|||||||
function realize(ctx::Construction{T}) where T
|
function realize(ctx::Construction{T}) where T
|
||||||
# collect coordinate names
|
# collect coordinate names
|
||||||
coordnamelist = Symbol[]
|
coordnamelist = Symbol[]
|
||||||
eltenum = enumerate(Iterators.flatten((ctx.spheres, ctx.points)))
|
elemenum = enumerate(Iterators.flatten((ctx.spheres, ctx.points)))
|
||||||
for coordindex in 1:5
|
for coordindex in 1:5
|
||||||
for indexed_elt in eltenum
|
for indexed_elem in elemenum
|
||||||
pushcoordname!(coordnamelist, indexed_elt, coordindex)
|
pushcoordname!(coordnamelist, indexed_elem, coordindex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -161,34 +161,25 @@ function realize(ctx::Construction{T}) where T
|
|||||||
coordring, coordqueue = polynomial_ring(parent_type(T)(), coordnamelist, ordering = :degrevlex)
|
coordring, coordqueue = polynomial_ring(parent_type(T)(), coordnamelist, ordering = :degrevlex)
|
||||||
|
|
||||||
# retrieve coordinates
|
# retrieve coordinates
|
||||||
for (_, elt) in eltenum
|
for (_, elem) in elemenum
|
||||||
empty!(elt.coords)
|
empty!(elem.coords)
|
||||||
end
|
end
|
||||||
for coordindex in 1:5
|
for coordindex in 1:5
|
||||||
for indexed_elt in eltenum
|
for indexed_elem in elemenum
|
||||||
takecoord!(coordqueue, indexed_elt, coordindex)
|
takecoord!(coordqueue, indexed_elem, coordindex)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# construct coordinate vectors
|
# construct coordinate vectors
|
||||||
for (_, elt) in eltenum
|
for (_, elem) in elemenum
|
||||||
buildvec!(elt)
|
buildvec!(elem)
|
||||||
end
|
end
|
||||||
|
|
||||||
# turn relations into equations
|
# turn relations into equations
|
||||||
eqns = vcat(
|
eqns = vcat(
|
||||||
equation.(ctx.relations),
|
equation.(ctx.relations),
|
||||||
[elt.rel for (_, elt) in eltenum if !isnothing(elt.rel)]
|
[elem.rel for (_, elem) in elemenum if !isnothing(elem.rel)]
|
||||||
)
|
)
|
||||||
|
|
||||||
# add relations to center and orient the construction
|
|
||||||
if !isempty(ctx.points)
|
|
||||||
append!(eqns, [sum(pt.coords[k] for pt in ctx.points) for k in 1:3])
|
|
||||||
end
|
|
||||||
if !isempty(ctx.spheres)
|
|
||||||
append!(eqns, [sum(sph.coords[k] for sph in ctx.spheres) for k in 3:4])
|
|
||||||
end
|
|
||||||
|
|
||||||
Generic.Ideal(coordring, eqns)
|
Generic.Ideal(coordring, eqns)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user