Author Topic: [SOLVED] Serialization of the WeakPointerVector is missing  (Read 338 times)

Josep Maria

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 50
[SOLVED] Serialization of the WeakPointerVector is missing
« on: January 31, 2017, 04:21:30 PM »
Hello,

    The "restart" file saved / loaded  with the serializer is not working properly because the WeakPointerVector  is not serialized:

Code: [Select]
    template<class TDataType>
    void load(std::string const & rTag, WeakPointerVector<TDataType>& pValue)
    {
        // This is for testing. I have to change it. Pooyan.
        //KRATOS_THROW_ERROR(std::logic_error, "The serialization for weak_ptrs is not implemented yet", "")
//    read(*pValue);
    }
   
    //...................

   template<class TDataType>
    void save(std::string const & rTag, Kratos::WeakPointerVector<TDataType> pValue)
    {
        // This is for testing. I have to implement it. Pooyan.
        //KRATOS_THROW_ERROR(std::logic_error, "The serialization for weak_ptrs is not implemented yet", "")
//    write(*pValue);
    }


Can it be solved, or can you give some guide lines about how implement it correctly ?

Thank you in advance

Josep Maria
« Last Edit: February 03, 2017, 09:39:28 AM by Josep Maria »

pooyan

  • Global Moderator
  • Newbie
  • *****
  • Posts: 33
Re: Serialization of the WeakPointerVector is missing
« Reply #1 on: February 01, 2017, 04:16:45 PM »
The serialization of the weak pointers is omitted by purpose as it creates cyclic dependency. The idea is that user should regenerate such information (like neighbour nodes) after loading the model and not saving them.

Bests, 

Josep Maria

  • Global Moderator
  • Jr. Member
  • *****
  • Posts: 50
Re: Serialization of the WeakPointerVector is missing
« Reply #2 on: February 01, 2017, 11:55:49 PM »
Hi Pooyan,

   Ok I understand and I assume the argument.

I use to rebuild the WeakPointerVectors but I save and load them. This is because they are inserted in these DataValueContainer's (mData) of some of the core classes and is the DataValueContainer (mData) the serialized variable. One must be very careful to take into account that the reloaded WeakPointerVector from a restart file is empty.

Some extra rebuilds have to be done after reading a restart to have all working data coherent.

Thank you for your prompt response

Best regards

Josep Maria