copy_triangulation for a refined distributed Triangulation

70 views
Skip to first unread message

Ben Shields

unread,
Sep 21, 2015, 4:54:28 PM9/21/15
to deal.II User Group
Hi all,

I have an adaptively refined parallel::distributed::Triangulation. I'd like to create a copy of this Triangulation, add another refinement level, and solve the same problem on this new Triangulation. I want them both to exist at the same time so I can opt to return to the original mesh if the new solution is not significantly different.

My problem is, it looks like calling copy_triangulation on a distributed, refined triangulation is not allowed:


An error occurred in line <3637> of file </pub/builds/deal.II/source/distributed/tria.cc> in function
    void dealii::parallel::distributed::Triangulation<dim, spacedim>::copy_triangulation(const dealii::Triangulation<dim, spacedim>&) [with int dim = 2, int spacedim = 2]
The violated condition was:
    old_tria.n_levels() == 1
The name and call sequence of the exception was:
    ExcMessage ("Parallel distributed triangulations can only be copied, " "if they are not refined!")
Additional Information:
Parallel distributed triangulations can only be copied, if they are not refined!


Is there a workaround for this? Looking through previous topics here similar to this, the only suggestion I've seen is to save the triangulation to a file and import the file to generate a copy, but would that necessarily have the same partitioning?

Thanks,
Ben Shields

Sam Cox

unread,
Sep 22, 2015, 5:16:18 AM9/22/15
to deal.II User Group
Hi Ben,

it's my understanding that the mesh will be given the same partitioning after importing, as this is calculated only from the ordering of the cells. See https://groups.google.com/d/msg/dealii/94G5GU-flag/WEdBGil2WUoJ for Wolfgang's comment on this. (A caveat: I'd guess things would break if you have parallel::distributed:Triangulation::Settings::no_automatic_repartitioning set).

As a workaround, if you are happy to have two meshes existing throughout execution you could do similar to what I once did (in that same thread, for a different scenario, but it should work in your case) and generate two unrefined meshes then apply the same refine/coarsen flags to each at each stage.

Sam

Timo Heister

unread,
Sep 22, 2015, 8:00:39 AM9/22/15
to dea...@googlegroups.com
Hey Ben,

yes, unfortunately we haven't gotten around implementing this. It
actually shouldn't be too difficult, because there is p4est_copy that
one can use to clone the p4est (but the connectivity has to be
recreated). Sam's suggestions will work as a workaround...
> --
> 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.
> For more options, visit https://groups.google.com/d/optout.



--
Timo Heister
http://www.math.clemson.edu/~heister/

Katharina Jerg

unread,
Sep 29, 2022, 5:08:05 AM9/29/22
to deal.II User Group
Dear all,

I am trying to copy an adaptively refined triangulation (not even parallel::distributed::Triangulation) in order to change the refinement at some parts of the mesh, but still keep the original triangulation for futher calculations.
When I try to copy a simple (not adaptively refined yet) triangulation using " this->triangulation_coarse_.copy_triangulation(this->triangulation_);" I get the following error:

--------------------------------------------------------
An error occurred in line <11502> of file </home/dev/dealii/source/grid/tria.cc> in function
    void dealii::Triangulation<<anonymous>, <anonymous> >::copy_triangulation(const dealii::Triangulation<<anonymous>, <anonymous> >&) [with int dim = 3; int spacedim = 3]
The violated condition was:
    (vertices.size() == 0) && (levels.size() == 0) && (faces == nullptr)
Additional information:
    You are trying to perform an operation on a triangulation that is only
    allowed if the triangulation is currently empty. However, it currently
    stores 27 vertices and has cells on 2 levels.

Is there a way to copy adaptively refined triangulations by now? I was not able to find an answer to this question in the mailing list or the documentation. I would like to avoid the workaround suggested here, because I need a new copy of the triangulation multiple times during computation.

Thanks,
Katharina

Timo Heister

unread,
Sep 29, 2022, 9:40:27 AM9/29/22
to dea...@googlegroups.com
Is the destination ("triangulation_coarse_" in your case) empty when
you call the function? I think the error message says that it needs to
be empty.
> To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/963eeb1d-3e54-4d8d-8acb-2b58a813beb4n%40googlegroups.com.

Katharina Jerg

unread,
Sep 30, 2022, 4:50:25 AM9/30/22
to dea...@googlegroups.com
Thank you for the heads-up. That was actually the problem.
Best,
Katharina

You received this message because you are subscribed to a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/oPQ7KJ6zKjI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAMRj59GROBcupwgY7V9YZaF-Q3aM_J8zcGj8Mkb%2BS-TAsnXzEQ%40mail.gmail.com.

Katharina Jerg

unread,
Sep 30, 2022, 7:24:03 AM9/30/22
to dea...@googlegroups.com
Dear Timo,

I have another question still concerning the same task. I still want to coarsen the mesh and its solution at certain cells, but keep the old one (dof_handler, triangulation, solution) for further calculations.
In order to use the solution transfer, but not change the original dof_handler I created a new dof_handler_coarse_ and initialized it:
      this->dof_handler_coarse_.reinit(this->triangulation_coarse_);
      this->dof_handler_coarse_.distribute_dofs(this->fe_);
However, the numbering of this dof_handler_coarse_ does not correspond to the numbering of the original dof_handler_ and therefore the solution vector is senseless for this dof_handler_coarse_. The original dof_handler_ is renumbered with DoFRenumbering::Cuthill_McKee and different constraints are applied. Since the copy constructor of the dof_handler is deleted, I don't have a pretty solution for this. Do you have any suggestions?

Thank you in advance,
Katharina

Wolfgang Bangerth

unread,
Sep 30, 2022, 11:23:55 AM9/30/22
to dea...@googlegroups.com
On 9/30/22 05:23, Katharina Jerg wrote:
>
> I have another question still concerning the same task. I still want to
> coarsen the mesh and its solution at certain cells, but keep the old one
> (dof_handler, triangulation, solution) for further calculations.
> In order to use the solution transfer, but not change the original dof_handler
> I created a new dof_handler_coarse_ and initialized it:
>       this->dof_handler_coarse_.reinit(this->triangulation_coarse_);
>       this->dof_handler_coarse_.distribute_dofs(this->fe_);
> However, the numbering of this dof_handler_coarse_ does not correspond to the
> numbering of the original dof_handler_ and therefore the solution vector is
> senseless for this dof_handler_coarse_. The original dof_handler_ is
> renumbered with DoFRenumbering::Cuthill_McKee and different constraints are
> applied. Since the copy constructor of the dof_handler is deleted, I don't
> have a pretty solution for this. Do you have any suggestions?

If you perform the exact same renumbering steps as you did for the original
DoFHandler, you will get the exact same numbering on the copy as well.

Best
W.

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

Reply all
Reply to author
Forward
0 new messages