some question about the move mesh function

57 views
Skip to first unread message

huyanzhuo

unread,
Oct 4, 2019, 12:36:59 PM10/4/19
to deal.II User Group

Dear All:
i use the move_mesh function just like step-42
template < int dim >
    void step<dim>::move_mesh(const TrilinosWrappers::MPI::Vector &state_change) const
    {
      pcout<<"moving the mesh ..." <<std::endl;
      std::vector<bool> vertex_touched(triangulation.n_vertices(), false);

      for (typename DoFHandler<dim>::active_cell_iterator cell =dof_handler.begin_active();cell != dof_handler.end(); ++cell)
        if (cell->is_locally_owned())                                                       
          for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)         
            {
              if(vertex_touched[cell->vertex_index(v)] == false)
              {
                vertex_touched[cell->vertex_index(v)] = true;

                Point<dim> vertex_displacement;
                for (unsigned int d = 0; d < dim; ++d)                                 
                  vertex_displacement[d] = state_change(cell->vertex_dof_index(v, d));
                cell->vertex(v) += vertex_displacement;
              }
            }
    }

it works well on my own computer. but when use the mpirun in a server, the result shows a departure on the boundry of mesh belongs to  different process

456.png

123.png

does anyone has the same problem?

Daniel Arndt

unread,
Oct 4, 2019, 1:07:13 PM10/4/19
to dea...@googlegroups.com
huyanzhou,

you might want to have a look at parallel::distributed::Triangulation::communicate_locally_moved_vertices (https://www.dealii.org/current/doxygen/deal.II/classparallel_1_1distributed_1_1Triangulation.html#a247598f1323a9f847832e60d6c840469).

Best,
Daniel

--
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/4b28379f-5d5f-4295-ace1-165b02d67947%40googlegroups.com.

huyanzhuo

unread,
Oct 5, 2019, 8:38:09 AM10/5/19
to deal.II User Group
thanks very much for your reply!

I try to use the communicate_locally_moved_vertices, it fixes the departure of mesh belongs to different mesh . but there still remains some problem 

789.png



you can see that the mesh is consistent on the boundry, but not smooth in the inner mesh ,there are some shallow hole  on the surface
my code is as follows
    template < int dim >
    void step<dim>::move_mesh(const TrilinosWrappers::MPI::Vector &state_change) 
    {
      pcout<<"moving the mesh ..." <<std::endl;
      std::vector<bool> vertex_touched(triangulation.n_vertices(), false);
      parallel::distributed::Triangulation< dim > *distributed_triangulation = &triangulation;

      const std::vector<bool> locally_owned_vertices = GridTools::get_locally_owned_vertices(triangulation);

      for (typename DoFHandler<dim>::active_cell_iterator cell =dof_handler.begin_active();cell != dof_handler.end(); ++cell)
        if (cell->is_locally_owned())                                                       
          for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)         
            {
              if(vertex_touched[cell->vertex_index(v)] == false)
              {
                vertex_touched[cell->vertex_index(v)] = true;

                Point<dim> vertex_displacement;
                for (unsigned int d = 0; d < dim; ++d)                                 
                  vertex_displacement[d] = state_change(cell->vertex_dof_index(v, d));
                cell->vertex(v) += vertex_displacement;
              }
            }
      distributed_triangulation->communicate_locally_moved_vertices(locally_owned_vertices);

      typename Triangulation<dim>::active_cell_iterator
      cell = triangulation.begin_active(),
      endc = triangulation.end();
      for (; cell!=endc; ++cell)
        if (!cell->is_artificial())
          for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
            if (cell->face(face)->has_children() && !cell->face(face)->at_boundary())
            {
              // this face has hanging nodes
              if (dim==2)
                cell->face(face)->child(0)->vertex(1) = (cell->face(face)->vertex(0) + cell->face(face)->vertex(1)) / 2;
              else if (dim==3)
              {
                cell->face(face)->child(0)->vertex(1) = .5*(cell->face(face)->vertex(0) +cell->face(face)->vertex(1));
                cell->face(face)->child(0)->vertex(2) = .5*(cell->face(face)->vertex(0) +cell->face(face)->vertex(2));
                cell->face(face)->child(1)->vertex(3) = .5*(cell->face(face)->vertex(1) +cell->face(face)->vertex(3));
                cell->face(face)->child(2)->vertex(3) = .5*(cell->face(face)->vertex(2) +cell->face(face)->vertex(3));
                // center of the face
                cell->face(face)->child(0)->vertex(3) = .25*(cell->face(face)->vertex(0)
                                                             +cell->face(face)->vertex(1)
                                                             +cell->face(face)->vertex(2)
                                                             +cell->face(face)->vertex(3));
              }
            }
    }

i follow the example in  GridTools::distort_random() 


在 2019年10月5日星期六 UTC+8上午1:07:13,Daniel Arndt写道:
To unsubscribe from this group and stop receiving emails from it, send an email to dea...@googlegroups.com.

Daniel Arndt

unread,
Oct 5, 2019, 11:34:18 AM10/5/19
to dea...@googlegroups.com
huyanzhou,

I try to use the communicate_locally_moved_vertices, it fixes the departure of mesh belongs to different mesh . but there still remains some problem
[...]

you can see that the mesh is consistent on the boundry, but not smooth in the inner mesh ,there are some shallow hole  on the surface
Can you explain more precisely what doesn't work as expected? Is this a problem you only see when running with multiple MPI processes?
What is the "inner mesh" for you? Do you refer to faces with children? Can you point out which vertices you think are set wrongly?
 
my code is as follows
[...]

It seems that your idea is to first move vertices according to some displacement function and then to "correct" hanging vertices to be placed inside the neighboring face.
That looks OK for standard orientation but might be problematic otherwise. You should be able to achieve the same effect when you only apply hanging node constraints to your
displacement vector.

Best,
Daniel

huyanzhuo

unread,
Oct 7, 2019, 10:40:15 PM10/7/19
to deal.II User Group
thanks for your reply!
 i got the problem solved. my fault is the misuse of communicate_locally_moved_vertices function. 
i got the "shallow hole" because i move the mesh when the mesh is deformed , the mpi processor does't know the right place of ghost layer cell.
i solve the problem by correct the whole move vector and return to the original mesh , which i refine and coarsen in the later step. after i finished the refinement , just add the whole move vector again the there is no "shallow hole" any more.


在 2019年10月5日星期六 UTC+8下午11:34:18,Daniel Arndt写道:
Reply all
Reply to author
Forward
0 new messages