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 

[image: 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写道:
>
> 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
>
> Am Fr., 4. Okt. 2019 um 12:37 Uhr schrieb huyanzhuo <hu4ya...@gmail.com 
> <javascript:>>:
>
>>
>> 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
>>
>> [image: 456.png]
>>
>> [image: 123.png]
>> does anyone has the same problem?
>>
>> -- 
>> 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 dea...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/dealii/4b28379f-5d5f-4295-ace1-165b02d67947%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/dealii/4b28379f-5d5f-4295-ace1-165b02d67947%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/3b3009e7-9a7f-401c-b3c3-c829a19f2d95%40googlegroups.com.

Reply via email to