You could use a boost archive, and save the triangulation to a binary file using operator << (and >> to load it), i.e.:
#include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_oarchive.hpp> ... std::ofstream file(filename, std::ios::binary | std::ios::trunc); boost::archive::binary_oarchive oa(file); oa << tria; and then restore it with std::ifstream file(filename, std::ios::binary); boost::archive::binary_iarchive ia(file); ia >> tria; Alternatively, use the method GridOut::write_vtu and GridIn::read_vtu. Best, Luca. > On 7 Jun 2020, at 17:12, Amaresh B <[email protected]> wrote: > > Thank you Luca for your reply. I can avoid > parallel::distributed::Triangulation and use serial code. Can you suggest a > method to save the solutions along with the triangulation which can be used > for restarting code? Also please let me know if any example code is available. > > Thanks > > Sincerely > Amaresh > > On Sun, Jun 7, 2020 at 8:39 PM luca.heltai <[email protected]> wrote: > Amaresh, > > as the documentation states, parallel::distributed::Triangulation is not > implemented in 1d. Consequently, parallel::distributed::SolutionTransfer will > not work in 1d. > > Are you running your code in debug mode? In debug mode several assertions are > throw when you try to instantiate a 1d parallel::distributed::Triangulation. > > L. > > > On 7 Jun 2020, at 16:59, Amaresh B <[email protected]> wrote: > > > > I have even tried with subdivided_hyper_rectangle . The triangulation is > > not saved. > > > > > > > > On Saturday, June 6, 2020 at 11:25:03 PM UTC+5:30, Amaresh B wrote: > > Thank you peterrum for your reply. > > > > I have tried the following commands. In both the cases, the triangulation > > was not saved. Please let me know if you have any suggestions. > > > > 1. GridGenerator::hyper_cube (triangulation, 0., 40.0); > > > > > > 2. GridGenerator::hyper_rectangle(triangulation, > > Point<dim>(0.0), > > Point<dim>(40.0), > > true); > > > > > > Thanks, > > Amaresh > > > > > > On Saturday, June 6, 2020 at 9:33:20 PM UTC+5:30, peterrum wrote: > > What type of triangulation are you using? > > > > Peter > > > > On Saturday, 6 June 2020 17:52:53 UTC+2, Amaresh B wrote: > > Dear all, > > > > I am trying to save my triangulation and using the lines below. > > 'triangulation.save' commands works and saves the mesh if my domain is > > either 2D or 3D (i.e. dim=2 or 3). However, it does not save the > > triangulation if dim=1, nor it gives any error message. I will be thankful > > if someone can comment on it and give suggestions. > > > > > > > > std::vector<const PETScWrappers::MPI::Vector *> sol_transfer_vectors; > > > > sol_transfer_vectors.push_back(&solution0); > > > > > > parallel::distributed::SolutionTransfer<dim,PETScWrappers::MPI::Vector> > > sol_transfer(dof_handler); > > sol_transfer.prepare_for_serialization > > (sol_transfer_vectors); > > > > triangulation.save("restart.mesh"); > > > > Thank you, > > > > Regards > > Amaresh > > > > > > -- > > 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 [email protected]. > > To view this discussion on the web visit > > https://groups.google.com/d/msgid/dealii/816239ba-d993-4ae1-8772-77d920b946eeo%40googlegroups.com. > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/618C643B-C88D-4BFF-B82D-A2B2675C467A%40gmail.com. > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/CAE1SiMC7FgY6KdxsV5LNp4vePfYs136A%2BiXdLKjHc%3D%3D0pipgcQ%40mail.gmail.com. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CA3C5668-1AD5-473C-A5D6-6AF6E6DE1452%40gmail.com.
