[petsc-users] How to use class function in SNESSetFunction
Matthew Knepley
knepley at gmail.com
Mon Mar 20 14:29:04 CDT 2017
On Mon, Mar 20, 2017 at 7:01 PM, Ping He <friedenhe at gmail.com> wrote:
> Dear Matt,
>
> I know it is an old thread and your solution works well, but I still want
> to ask if there are any alternative instead of setting the member function
> "static". The issue is that I need to use multiple member functions (20+)
> in SNESSetFunction and numerous class variables. So changing all of them to
> static will need quite a lot of code/structure change. Thanks very much in
> advance.
>
1) Make a static member function that you pass in. That is the only way to
match the signature.
2) Pass your object as the user context
3) Inside your static function, use your object from the context argument
to call your member function with the other arguments.
Thanks,
Matt
> Regards,
> Ping
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170320/4cb33db6/attachment.html>
More information about the petsc-users
mailing list