@@ -602,7 +602,72 @@ namespace aspect
602602 return Output::EulerAngles;
603603 return Output::not_found;
604604 }
605+ template <int dim>
606+ template <class Archive >
607+ void CrystalPreferredOrientation<dim>::serialize (Archive &ar, const unsigned int )
608+ {
609+ ar &last_output_time
610+ & output_file_number
611+ & times_and_pvtu_file_names
612+ & output_file_names_by_timestep
613+ & xdmf_entries
614+ ;
615+ }
616+
617+
618+ template <int dim>
619+ void
620+ CrystalPreferredOrientation<dim>::save (std::map<std::string, std::string> &status_strings) const
621+ {
622+ for (unsigned int particle_manager = 0 ; particle_manager < this ->n_particle_managers (); ++particle_manager)
623+ {
624+ std::string particles_output_base_name = " Particles" ;
625+ if (particle_manager > 0 )
626+ {
627+ particles_output_base_name += " -" + Utilities::int_to_string (particle_manager+1 );
628+ }
629+
630+ // Serialize into a stringstream. Put the following into a code
631+ // block of its own to ensure the destruction of the 'oa'
632+ // archive triggers a flush() on the stringstream so we can
633+ // query the completed string below.
634+ std::ostringstream os;
635+ {
636+ aspect::oarchive oa (os);
637+
638+ this ->get_particle_manager (particle_manager).save (os);
639+ oa << (*this );
640+ }
605641
642+ status_strings[particles_output_base_name] = os.str ();
643+ }
644+ }
645+
646+
647+ template <int dim>
648+ void
649+ CrystalPreferredOrientation<dim>::load (const std::map<std::string, std::string> &status_strings)
650+ {
651+ for (unsigned int particle_manager = 0 ; particle_manager < this ->n_particle_managers (); ++particle_manager)
652+ {
653+ std::string particles_output_base_name = " Particles" ;
654+ if (particle_manager > 0 )
655+ {
656+ particles_output_base_name += " -" + Utilities::int_to_string (particle_manager+1 );
657+ }
658+ // see if something was saved
659+ if (status_strings.find (particles_output_base_name) != status_strings.end ())
660+ {
661+ std::istringstream is (status_strings.find (particles_output_base_name)->second );
662+ aspect::iarchive ia (is);
663+
664+ // Load the particle manager
665+ this ->get_particle_manager (particle_manager).load (is);
666+
667+ ia >> (*this );
668+ }
669+ }
670+ }
606671
607672
608673 template <int dim>
0 commit comments