Skip to content

Commit f78caa9

Browse files
committed
Add but_ordered_incidence
1 parent 61b2207 commit f78caa9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/structural_transformation/utils.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,38 @@ function find_solvables!(state::TearingState; allow_symbolic=false)
208208
return nothing
209209
end
210210

211+
highest_order_variable_mask(ts) = let v2d = ts.structure.var_to_diff
212+
v->isempty(outneighbors(v2d, v))
213+
end
214+
215+
lowest_order_variable_mask(ts) = let v2d = ts.structure.var_to_diff
216+
v->isempty(outneighbors(v2d, v))
217+
end
218+
219+
function but_ordered_incidence(ts::TearingState, varmask=highest_order_variable_mask(ts))
220+
graph = complete(ts.structure.graph)
221+
var_eq_matching = complete(maximal_matching(graph, _->true, varmask))
222+
scc = find_var_sccs(graph, var_eq_matching)
223+
vordering = Vector{Int}(undef, 0)
224+
bb = Int[1]
225+
sizehint!(vordering, ndsts(graph))
226+
sizehint!(bb, ndsts(graph))
227+
l = 1
228+
for c in scc
229+
isemptyc = true
230+
for v in c
231+
if varmask(v)
232+
push!(vordering, v)
233+
l += 1
234+
isemptyc = false
235+
end
236+
end
237+
isemptyc || push!(bb, l)
238+
end
239+
mm = incidence_matrix(graph)
240+
mm[[var_eq_matching[v] for v in vordering if var_eq_matching[v] isa Int], vordering], bb
241+
end
242+
211243
# debugging use
212244
function reordered_matrix(sys, torn_matching)
213245
s = TearingState(sys)

0 commit comments

Comments
 (0)