I developed a copy of libMesh::AnalyticFunction that uses boost::functions
as inputs. This allows for some additional flexibility when boost::bind is
used over the function pointer inputs of AnalyticFunction. Below is a
non-working code snippet of me using it to attach the Parameters class to
an initialization function (func2), similar to Example 9, but in this case
two variables are considered.

I have found this to be very useful, so I thought I would post the code in
case anyone is interested in using it. Note, I have placed the class in my
own namespace. I have successfully tested the use of this class for
attaching initialization and boundary conditions functions that are members
of a class.

- Andrew


--- CODE SNIPPET ---------------

void func2(DenseVector<Number>& output, const Point& p, const Real, const
Parameters& parameters){
 /* return output(0) and output(1) */
}


// Generate the boost::function pointers
boost::function< void (DenseVector<Number>&, const Point&, const Real,
const Parameters&)> fptr_full;
boost::function< void (DenseVector<Number>&, const Point&, const Real)>
fptr_shrt;

// Link function to the full pointer
fptr_full = func2;

// Bind the parameters
fptr_shrt = boost::bind(fptr_full, _1, _2, _3, eq_sys.parameters);

// Create a MyAnalyticFuction and use this to project the solution
MyAnalyticFunction<Number> fobj2(fptr_shrt);
eq_sys.get_system("data").project_solution(&fobj2);
ExodusII_IO(mesh).write_equation_systems("example3_2.ex2", eq_sys);






-- 
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