Changeset 184d89 for src/Fragmentation


Ignore:
Timestamp:
May 5, 2017, 2:17:48 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph_documentation, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, Fix_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes
Children:
5fea7d
Parents:
dde50d
git-author:
Frederik Heber <heber@…> (04/05/17 17:19:49)
git-committer:
Frederik Heber <frederik.heber@…> (05/05/17 14:17:48)
Message:

FIX: MatrixContainer's serialize() was broken because default cstor initialized some members.

  • boost::serialization somehow changed its default behavior when deserializing vectors. Now, if the member variables are vectors and initialized with some initial elements, then these are kept and the new elements just added on top. Before, the vector was cleared and set equal to the serialized elements.
  • Now, we have split MatrixContainer serialize() into load()/save() where we clear the member variables in question first.
Location:
src/Fragmentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Fragmentation/MatrixContainer.cpp

    rdde50d r184d89  
    3232#include <config.h>
    3333#endif
     34
     35// include headers that implement a archive in simple text format
     36// otherwise BOOST_CLASS_EXPORT_IMPLEMENT has no effect
     37#include <boost/archive/text_oarchive.hpp>
     38#include <boost/archive/text_iarchive.hpp>
    3439
    3540//#include "CodePatterns/MemDebug.hpp"
  • src/Fragmentation/MatrixContainer.hpp

    rdde50d r184d89  
    1616#include <vector>
    1717
     18#include "boost/serialization/serialization.hpp"
     19#include <boost/serialization/split_member.hpp>
    1820#include "boost/serialization/vector.hpp"
    1921
     
    6466  friend class boost::serialization::access;
    6567  // serialization
    66   template<class Archive>
    67   void serialize(Archive & ar, const unsigned int version)
     68  template <typename Archive>
     69  void load(Archive& ar, const unsigned int version)
     70  {
     71    // default cstor resizes these three to 1, serialization will add more
     72    // members instead of starting new
     73    Header.clear();
     74    RowCounter.clear();
     75    ColumnCounter.clear();
     76    ar & Matrix;
     77    ar & Indices;
     78    ar & Header;
     79    ar & MatrixCounter;
     80    ar & RowCounter;
     81    ar & ColumnCounter;
     82  }
     83  template <typename Archive>
     84  void save(Archive& ar, const unsigned int version) const
    6885  {
    6986    ar & Matrix;
     
    7491    ar & ColumnCounter;
    7592  }
     93
     94  BOOST_SERIALIZATION_SPLIT_MEMBER()
    7695};
    7796
Note: See TracChangeset for help on using the changeset viewer.