@@ -145,20 +145,6 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify=false
145
145
# if var is like D(x)
146
146
isdiffvar (var) = invview (var_to_diff)[var] != = nothing && var_eq_matching[invview (var_to_diff)[var]] === SelectedState ()
147
147
148
- diffeqs = Equation[]
149
- # Solve solvable equations
150
- for (iv, ieq) in enumerate (var_eq_matching)
151
- is_solvable (ieq, iv) || continue
152
- # We don't solve differential equations, but we will need to try to
153
- # convert it into the mass matrix form.
154
- # We cannot solve the differential variable like D(x)
155
- if isdiffvar (iv)
156
- push! (diffeqs, solve_equation (neweqs[ieq], fullvars[iv], simplify))
157
- continue
158
- end
159
- push! (solved_equations, ieq); push! (solved_variables, iv)
160
- end
161
-
162
148
# Rewrite remaining equations in terms of solved variables
163
149
function to_mass_matrix_form (ieq)
164
150
eq = neweqs[ieq]
@@ -195,6 +181,22 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify=false
195
181
end
196
182
end
197
183
184
+ diffeq_idxs = BitSet ()
185
+ diffeqs = Equation[]
186
+ # Solve solvable equations
187
+ for (iv, ieq) in enumerate (var_eq_matching)
188
+ is_solvable (ieq, iv) || continue
189
+ # We don't solve differential equations, but we will need to try to
190
+ # convert it into the mass matrix form.
191
+ # We cannot solve the differential variable like D(x)
192
+ if isdiffvar (iv)
193
+ push! (diffeqs, to_mass_matrix_form (ieq))
194
+ push! (diffeq_idxs, ieq)
195
+ continue
196
+ end
197
+ push! (solved_equations, ieq); push! (solved_variables, iv)
198
+ end
199
+
198
200
if isempty (solved_equations)
199
201
subeqs = Equation[]
200
202
deps = Vector{Int}[]
@@ -214,7 +216,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching; simplify=false
214
216
# TODO : BLT sorting
215
217
# Rewrite remaining equations in terms of solved variables
216
218
solved_eq_set = BitSet (solved_equations)
217
- neweqs = Equation[to_mass_matrix_form (ieq) for ieq in 1 : length (neweqs) if ! (ieq in solved_eq_set)]
219
+ neweqs = Equation[to_mass_matrix_form (ieq) for ieq in 1 : length (neweqs) if ! (ieq in diffeq_idxs || ieq in solved_eq_set)]
218
220
filter! (! isnothing, neweqs)
219
221
prepend! (neweqs, diffeqs)
220
222
0 commit comments