LCOV - code coverage report
Current view: top level - src/mesh - mesh_serializer.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 20 20 100.0 %
Date: 2025-08-19 19:27:09 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : 
      19             : // Local includes
      20             : #include "libmesh/mesh_serializer.h"
      21             : #include "libmesh/mesh_base.h"
      22             : #include "libmesh/parallel_only.h"
      23             : 
      24             : namespace libMesh
      25             : {
      26             : 
      27      346808 : MeshSerializer::MeshSerializer(MeshBase & mesh, bool need_serial, bool serial_only_needed_on_proc_0) :
      28      336804 :   _mesh(mesh),
      29      336804 :   reparallelize(false),
      30      346808 :   resume_allow_remote_element_removal(false)
      31             : {
      32        5002 :   libmesh_parallel_only(mesh.comm());
      33      346808 :   if (need_serial && !_mesh.is_serial() && !serial_only_needed_on_proc_0) {
      34       77345 :     reparallelize = true;
      35       77345 :     _mesh.allgather();
      36             :   }
      37      269463 :   else if (need_serial && !_mesh.is_serial() && serial_only_needed_on_proc_0) {
      38             :     // Note: NOT reparallelizing on purpose.
      39             :     // Just waste a bit of space on processor 0 to speed things up
      40       18032 :     _mesh.gather_to_zero();
      41             :   }
      42             : 
      43      346808 :   if (_mesh.allow_remote_element_removal())
      44             :     {
      45      309249 :       resume_allow_remote_element_removal = true;
      46        3888 :       _mesh.allow_remote_element_removal(false);
      47             :     }
      48      346808 : }
      49             : 
      50             : 
      51             : 
      52      356812 : MeshSerializer::~MeshSerializer()
      53             : {
      54      346808 :   if (reparallelize)
      55       77345 :     _mesh.delete_remote_elements();
      56             : 
      57      346808 :   if (resume_allow_remote_element_removal)
      58      309249 :     _mesh.allow_remote_element_removal(true);
      59      346808 : }
      60             : 
      61             : } // namespace libMesh

Generated by: LCOV version 1.14