From: Roy S. <ro...@st...> - 2008-08-15 20:30:37
|
On Fri, 15 Aug 2008, Adam C Powell IV wrote: > I'd like to calculate the integral of (grad u)^2 over my domain, after a > calculation. > > Currently, I assign two new variables, and set up new equations for > them: Jx-du/dx=0, Jy-du/dy=0. Then I just square and add the results of > calculate_norm (Jx and Jy, L2). It seems to work. But this adds two > extra field variables and equations to the calculation, multiplying the > memory usage and slowing things down a good bit. > > Alternatively, is it possible to calculate the L2 norm of the field > derivative or gradient directly, through a method I've missed? Well, for future reference in general: it's possible to calculate the L2 norm of the arctangent cubed of the field gradient directly, if that's what you want. Just loop over all the elements the same way you would for a residual assembly, calculate whatever function you need at each quadrature point, and sum the weighted values to numerically integrate the result. Helper methods like calculate_norm() are intended to simplify common code, not to be a straitjacket if you need to do something out of the ordinary. Hmm... I didn't mean that last paragraph to sound condescending, but did it anyway? Apparently karma thinks I deserve to be embarrassed now. You see, the next thing I was going to say is that you can (in the SVN and soon 0.6.3+ libMesh versions) just pass H1_SEMINORM to calculate_norm() to get the square root of the integral of the gradient squared, and then square that to get the number you want... but glancing at the calculate_norm() implementation, I see I never finished adding that feature; the code currently would give you an inaccurate result. I'll go fix that now. > Or if there's nothing quite that convenient, is there a way of > calculating the derivatives and putting them into a separate vector > in the system, decoupled from the original calculation? All variables in a system are coupled by definition; if you really needed to keep some post-processed data around, the way to do it efficiently would be to add an additional ExplicitSystem to your EquationSystems object, then put the decoupled variables there. --- Roy |