On 3/5/24 07:46, Paras Kumar wrote:

Within the context of an MPI parallel code, I need to broadcast the ConstitutiveParameters struct which contains std::unique pointer to the base class StrainEnergyFuncParameters; cf. MWE file.

Using the ideasĀ  discussed in the post https://groups.google.com/g/dealii/c/bmqTbs4ofHQ/m/aCuDpUekBAAJ, the code works fine if the members are concrete derived classes since there the serialize function is enough. However, I get segmentation fault during the unpack() call since the deserialize() function is not called.

Running the attached MWE would explain the issue.

Could someone please help in understanding how I could solve this issue?

Yes, this can't work :-) In essence, you are packing up a pointer (=an address into memory space) on machine A, and unpack it on machine B. But on machine B, nothing useful is likely going to be stored at the location of the memory address at which there was a useful object on machine A, and so when you access the data stored at that location, you should not expect anything good to happen.

You need to find a way to serialize/deserialize the data pointed to, not the pointer itself.

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/e7423abb-b213-4575-b407-12d3a2d7d0f8%40colostate.edu.

Reply via email to