Add cache-based solve test for multiple right-hand sides#185
Conversation
|
I think we need to invent a good public API call signature for this. eval_and_assemble is not the right one. Could this be sometinh like this ? or And what tools do you need for assembling your rhs ? |
That'd already be quite helpful. Currently, what I settled on is to define a system that discretizes a convection-diffusion operator for some solution F=unknowns(rbssys.basis_system;inival=0.)
state=VoronoiFVM.SystemState(rbssys.basis_system)
VoronoiFVM.evaluate_residual_and_jacobian!(state, unknowns(rbssys.basis_system, inival=0))
mtx = SparseMatrixCSC(state.matrix)
p = LinearProblem(mtx, VoronoiFVM.dofs(F))
linear_cache = init(p,LinearSolve.UMFPACKFactorization())
for (i, ireg) in enumerate(rbssys.breaction_face_regions)
ibasis=basis[i]
for (k,inode) in enumerate(Nodes[i])
# extract bfacenodefactors for inode
# to write into RHS
# 1. get bfaces for inode
faceindices=findall(bfacenodes.==inode)
# 2. calculate contributions of bfaces to inode
γ=0.
for faceind in faceindices
# if the bface is in ireg
# (violated e.g. in inodes on very left or right of regions)
if grid[BFaceRegions][faceind[2]] == ireg
γ+=bfacenodefactors[faceind[1],faceind[2]]
end
end
# 3. iterate through reactions and build a basis element per reaction
for jreac in 1:nreac
for ispec in 1:nspecies
idof=dof(F,ispec,inode)
if chemtest
F[idof]+=data.S[jreac,ispec]*data.molar_weights[ispec]*γ
else
F[idof]+=γ
end
end
# reuse LU factorization
linear_cache.b=VoronoiFVM.dofs(F)
sol=LinearSolve.solve!(linear_cache)
VoronoiFVM.dofs(ibasis[k,jreac]).=sol.u
F.=0
end
end
endSince the assembly machinery of |
|
Ah we already have This indeed lacks a test. May be you can update the test to this API ? |
|
Also see #187: I want to downgrade |
|
I also removed the |
|
I also incorporated your suggestion to make And I took the liberty to bump the |
|
Concerning the constantly failing tests, it looks to me that Similarly, I think we should open a separate PR to fix the testing environment. |
|
AMG seems to be held back by ExtendableSparse which gets a new version soon... As for ModelingToolkit I'll have a look... Could you design your project code in a branch of your project such that it works an we can see that the changes in this PR are sufficient for your project ? |
That's already available. I rebased the branch The changes from this PR probably won't have much of an impact, but I'll check the downstream ramifications nonetheless. The only thing that'd be useful would be some assembly method for only the residuals without going through the effort of computing the linearization
Oh, yes, that definitely seems correct. But then I'm confused as to why this is not actually displayed by checking the (test) pkg> st --outdated -m
Status `.../VoronoiFVM.jl/test/Manifest.toml`
⌃ [2169fc97] AlgebraicMultigrid v0.6.0 (<v1.0.0)
[...]
⌃ [961ee093] ModelingToolkit v9.32.0 (<v9.69.0)I would have expected here an output like |
|
I think after Chris' intervention we also should move test dependencies to [extras] @pjaap . |
|
I incorporated some changes suggested by your review.
I opened #188 to address this, but wasn't sure which I'd suggest to rebase this branch onto the version of #188 once we're done with that one to get a CI check for the changes here. |
5fe3ec9 to
b7692d4
Compare
|
Tests seem fine now. Since we patched a buggy function, I'd propose a patch version bump and release once someone has had a look at the current state. |
|
looks good to me |
vectorize using dofs added cache-based solve test for multiple right-hand sides
95d9de8 to
ea325e6
Compare
For my application, I need to extract the state matrix for a linear convection-diffusion system, factorize it, and solve the system for multiple right-hand sides.
It'd be nice to have a test case for this that checks for regressions in the interface. It seems to me that such a regression has been introduced some time after the move to
VoronoiFVM v2as it used to be that I could simply feed theExtendableSparseMatrixto theLinearSolvepackage to repeatedlysolve!with updated right-hand sides in the cache.This seems to not be possible anymore as of the latest version of
LinearSolve v3.7.0- is that intended?Furthermore, the test environment of
VoronoiFVMis again somehow broken and outdated, partly due to a related issue forExtendableSparseand also becauseLinearSolveis fixed tov2.39.xby some compatibility constraints I have been unable to figure out so far.Thus, to reproduce the regression in this test, one has to run it within an environment that includes
LinearSolve v3.7.0which will produce a similar error as in the related issue fromExtendableSparse.I could also live with having to extract the sparse matrix directly. It'd just be nice to settle on some interface and have a test included to guard against downstream breakage.