If I understand correctly, if my initialization is expensive then it should
be coded directly into the component member of a class derived from
AnalyticFunction, as follows. Then simply use the project_solution and skip
the add_initial_function(...) and init() commands for the system. Is this
correct?

class AnalyticFunctionTest : public AnalyticFunction<Number>{
public:
AnalyticFunctionTest(){
                        _initialized = true;
                }

Number component(unsigned int i, const Point& p, Real time = 0){
if (i == 0){
return 1;
} else {
return 2;
}
}
};

I tried using this, but I get an error b/c I believe that AnalyticFunction
needs a default constructor (
http://www.cplusplus.com/doc/tutorial/inheritance/), but it doesn't have
one.

example3b.cpp:41:25: error: no matching function for call to
‘libMesh::AnalyticFunction<double>::AnalyticFunction()’

So, then how do you do what you propose?








On Wed, Jun 27, 2012 at 3:00 PM, John Peterson <[email protected]> wrote:

> On Wed, Jun 27, 2012 at 12:55 PM, Paul T. Bauman <[email protected]>
> wrote:
> >
> >
> > On Wed, Jun 27, 2012 at 1:44 PM, Andrew E Slaughter
> > <[email protected]> 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
>



-- 
Andrew E. Slaughter, PhD
[email protected]

Materials Process Design and Control Laboratory
Sibley School of Mechanical and Aerospace Engineering
169 Frank H. T. Rhodes Hall
Cornell University
Ithaca, NY 14853-3801
(607) 229-1829
http://aeslaughter.github.com/
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to