residual calculation needs to be done when boundary degrees of freedom have not been removed (since their removal takes place in the Mult step in order to introduce the proper restoring force). Whereas jacobian calculation needs to always work from the boundary aware operators (these are sparse matrices)
The other thing to note here is that this seems contrary to a matrix free design. While true it is common practive to assemble linear terms since they are cheap. We still never assemble the non linear matrix form.
In order to maintain memory efficienty I have implimented a matrix free SchurComplement operator as well as an operator which uses a few iterations of GMRES to approxinate the inverse of any general operator.
A custom integrator is required to handle the theta^n term in the lane emden equation, that is written as NonlinearPowerIntegrator which is a mfem::NonlinearFormIntegrator and defines methods to assemble its element vector (function value) and element gradient matrix (jacobian). This is then, along with built in mfem vectors for M Q and D, incorporated into the PolytropeOperator which defines methods for Mult (calculate the residuals of the variational form) and GetGradient (find the jacobian of the system)
the preconditioner must be built once before the solver begins to iterater, by putting the logic for this in a dedicated method it becomes cleaner to call
approxJacobiInvert now only preforms a reallocation if the result buffer is non null. If it is non null it will preform validation to confirm that the result buffer is the correct size to recive the inverted matrix
working on a "smart" schur compliment preconditioner for the block form of the lane emden equation. Currently this is stub and should not be considered usable
essential dofs can be applied to both theta and phi (grad theta) if we move to a block form. I have done this derivation and made that change so that we can properly apply the central boundary condition to the slope
The default gamma value has been upped to 1e4 which is enough to strongly constrain the solution to have zero slope at the core region. Further, the initial guess has been changed from a series expansion of theta to a simple quadratic that is one at origin and zero at the polytrope radius. This is faster to evaluate and seems to work just as well.
In order to constrain the central slope we find all the elements connected to the central vertex. The slope will be approximated over these using the finite difference method