From: John P. <jwp...@gm...> - 2012-06-27 19:01:01
|
On Wed, Jun 27, 2012 at 12:55 PM, Paul T. Bauman <ptb...@gm...> wrote: > > > On Wed, Jun 27, 2012 at 1:44 PM, Andrew E Slaughter > <and...@gm...> wrote: >> >> I was playing around with that, but the function still gets called for >> each >> variable. Essentially, doing the calculations twice or three times in 3D. >> This seems far to inefficient. Is there no way around this? > > > Internally, libMesh is calling the component method of AnalyticFunction. It > is virtual, so you can overload it to not compute the whole vector each > time. Paul's right. Here's the comment for component() from function_base.h * Subclasses are recommended to overload this, since the default * implementation is based on a vector evaluation, which is usually * unnecessarily inefficient. I guess if your initial condition is super simple (like return 1;) you can avoid implementing component() and just do extra work. On the other hand, you can implement component() with a big if-block if computing the initial condition is very expensive... if (i==0) return 1; else return 2; -- John |