So, I am solving the Euler equations (inviscid compressible flow) using discontinuous Galerkin method:<br><br>M (dQ/dt) = R,<br><br>R = nonlinear residual,<br>M = mass matrix,<br><br>Implicit procedure:<br>F = M*(Q^(n+1)-Q^n)/DT - R,<br>
dF/dQ=J=M/DT-dR/dQ,<br>Newton =&gt; Q^(n+1) = Q^n - (dF/dQ)^(-1) F ( with proper preconditioning )<br><br>The nonlinear residual and Jacobian matrix are evaluated with a face-based method. Two integrals are involved (the effect of element internal connections and face flux connections). All of my calculations of flow states are solved and stored in arrays of objects called elements.So my residual and Derivative of residual routines are developed based on the element (and face) objects. Then it is better for me to keep them when using petsc as a nonlinear solver.<br>
<br>Hope these make any help.<br>Thanks, <br>Behzad<br>