On Wed, 8 Oct 2008, John Peterson wrote: > On Wed, Oct 8, 2008 at 12:05 PM, Roy Stogner <[EMAIL PROTECTED]> wrote: >> >> How about a functor abstract base class? Anyone? We are using C++ >> still, right? ;-) > > I briefly considered this but MatShellSetOperation does required a > pointer to a void(void) function to be passed. > > http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatShellSetOperation.html
Oh, yeah, I wouldn't expect PETSc to take a C++ class. We'd have some behind-the-scenes trickery to make sure that PETSc got a C function that ended up calling the correct C++ functor. > With a function object or even just a non-static member function of > the class, can this be done with some mem_fun tricks, e.g. > > mem_fun(&Foo::the_function) If the C function takes a void*, everything's great - you have a global function which casts that argument to a pointer to your functor, and you call your functor. If the C function really took void, things would be nasty (since you'd need a separate C function for every shell matrix functor, but the former have to be defined at compile time and the latter ought to be createable at runtime), but it looks like the operator function ends up getting cast to something which takes the same arguments (e.g. Mat,Vec,Vec) as the corresponding PETSc matrix operation, and so we could use MatShellGetContext to grab a pointer to our functor. --- Roy ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Libmesh-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-users
