Thank you very much! With that hint it works as expected.
Is it also possible to get a reference (pointer) to the Solid object within
the constructor of 'AnotherClass', so without passing a solid reference to
the latters constructor? 'this' would in this case refer to the instance of
'AnotherClass'.

The class 'AnotherClass' needs access to objects of type DoFHandler<dim>
and CellDataStorage<typename T>. As for the DoFHandler<dim> the copy
instructor, i.e something like 'dof_handler(dof_handler_from_solid)' will
delete 'dof_handler_from_solid'. It actually doesn't delete it but throws
an exception as it is also described in the documentation.
I checked a few source code files of the library how they manage the
storage of large objects, for instance the GridTools::Cache<dim> class
stores a triangulation like this:
SmartPointer<const Triangulation<dim>>      tria;
So I did this in the same way for the DoFHandler and the CellDataStorage
object:
SmartPointer<const DoFHandler<dim>>         dof_handler;
...
Is this a efficient way to do that or is there a more sophisticated way to
store the member variables? I asked myself why dealii did not just use the
SmartPointers of the c++ standard library, namely std::shared_ptr<...>,
std::unique_ptr<...>,....  I guess most of them also make sure that they
don't become dangling pointers.

Thanks again!



Am Di., 6. Juli 2021 um 05:20 Uhr schrieb Wolfgang Bangerth <
bange...@colostate.edu>:

> On 7/5/21 2:56 PM, Simon wrote:
> >
> > 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?
>
> No, but you need to provide a 'this' pointer for the object you want to
> work
> on. In the first case, this is pointer_M.get(). For a member function of
> the
> current object, it would probably be 'this'.
>
> Best
>   W.
>
>
> --
> ------------------------------------------------------------------------
> Wolfgang Bangerth          email:                 bange...@colostate.edu
>                             www: http://www.math.colostate.edu/~bangerth/
>
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dealii+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dealii/bd80797b-029d-a63e-1124-52a69237bab5%40colostate.edu
> .
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAM50jEuzLS3n2STSQJ_AdiMs9rpEd81O8USRZ4aEA7fhSaxnbw%40mail.gmail.com.

Reply via email to