Dear all,
I am trying to modify my program in a way such that certain quantities are only updated if the underlying triangulation object changes during runtime (due to adaptivity). I want to call a specific member function of my Main Class 'Solid' if this happens. (Solid is the class which calls the typical functions like make_grid(), system_setup(),...)
The Triangulation<dim,spacedim> class offers a interface to the boost::signals2 library. I guess that is predestinated for my purpose.
Here is a snippet of my code:
//constructor of 'Solid'
:
dof_handler(triangulation),
/*many_more*/
qf_cell(degree+1),
n_q_points(qf_cell.size())
{
pointer_M = boost::make_shared<AnotherClass<dim>>(/*constructor of
AnotherClass */);
boost::signals2::connection tria_signal =
triangulation.signals.post_refinement.connect( boost::signals2::signal<void()>::slot_type(&AnotherClass<dim>::mark_for_update,
pointer_M
.get()).track(
pointer_M
) );
}
So the constructor of Solid initializes "pointer_M" which points to an object of "AnotherClass". The variable "tria_signal" in the line below is the one which causes the call of the member function
&AnotherClass<dim>::mark_for_update.
The above code compiles and actually calls
mark_for_update from
AnotherClass<dim>
.
But what I'd like to achieve is that the signal triggers a member function of 'Solid', i.e. something like
&Solid<dim>::call_this_function. So a naive approach is to simply replace
&AnotherClass<dim>::mark_for_update by
&Solid<dim>::call_this_function
. (Both functions take no parameters and return void).
Unfortunately this change produces two error messages.
(i) error: pointer to member type ‘void (Solid<2>::)()’ incompatible with object type ‘AnotherClass<2>’
(ii) error: return-statement with a value, in function returning 'void' [-fpermissive]
My understanding of the error message is that only member functions of 'AnotherClass' can be connected to the signal.
Is this true?
And can I modify the parameters of the connect function somehow to actually connect a member function of Solid?
As always, any input is appreciated! :-)
Best
Simon