triangulation save not working for 1D domain

62 views
Skip to first unread message

Amaresh B

unread,
Jun 6, 2020, 11:52:53 AM6/6/20
to deal.II User Group
  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
 

peterrum

unread,
Jun 6, 2020, 12:03:20 PM6/6/20
to deal.II User Group
What type of triangulation are you using?

Peter

Amaresh B

unread,
Jun 6, 2020, 1:55:03 PM6/6/20
to deal.II User Group
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

Amaresh B

unread,
Jun 7, 2020, 10:59:28 AM6/7/20
to deal.II User Group
I have even tried with subdivided_hyper_rectangle . The triangulation is not saved.

luca.heltai

unread,
Jun 7, 2020, 11:09:04 AM6/7/20
to Deal.II Users
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.
> --
> 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+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/816239ba-d993-4ae1-8772-77d920b946eeo%40googlegroups.com.

Amaresh B

unread,
Jun 7, 2020, 11:14:02 AM6/7/20
to dea...@googlegroups.com
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

luca.heltai

unread,
Jun 7, 2020, 11:33:39 AM6/7/20
to Deal.II Users
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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAE1SiMC7FgY6KdxsV5LNp4vePfYs136A%2BiXdLKjHc%3D%3D0pipgcQ%40mail.gmail.com.

Wolfgang Bangerth

unread,
Jun 7, 2020, 7:53:32 PM6/7/20
to dea...@googlegroups.com
On 6/7/20 9:12 AM, Amaresh B 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.

step-69 does checkpoint restart.

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Reply all
Reply to author
Forward
0 new messages