On Apr 26, 2011, at 6:50 AM, Nathan Collier wrote: > Good day, > > I am solving a linear problem using finite elements with PETSC and I > want to look at the H1 norm of my true error as a function of KSP > iterations. I registered my own monitor function with KSP which looks > something like the last function in this example: > > http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/src/ksp/ksp/examples/tutorials/ex9.c.html > > where I get the current state of the solution vector using > > KSPBuildSolution(kps,PETSC_NULL,&U)
Try using KSPBuildSolution(ksp,work,0); where you create the work vector in your monitor routine. There could be a bug in the usuage you are using. Let us know if this works. Barry > > Then I use U to compute the H1 norm. As per the documentation I do not > Destroy U after. When I have this monitor function registered, my H1 > norm diverges while the KSP residual converges. Also, I compute the > final H1 norm (outside of the monitor) and it is divergent, which > matches the last iteration. If I remove my monitor function, things > work well. > > What am I screwing up? How can I access the current solution vector in > a KSP monitor? Do I need to use a vector that I create from a DA since > my FEM matrix assembly is based in DAs? > > Thanks, > NAte > > -- > Nathan Collier > Postdoctoral Researcher > King Abdullah University of Science and Technology (KAUST) > nathaniel.collier at gmail.com > nathaniel.collier at kaust.edu.sa
