LCOV - code coverage report
Current view: top level - src/parallel - parallel_ghost_sync.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 14 42 33.3 %
Date: 2025-08-19 19:27:09 Functions: 5 15 33.3 %
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             : 
      20             : #include "libmesh/parallel_ghost_sync.h"
      21             : #include "libmesh/int_range.h"
      22             : 
      23             : namespace libMesh
      24             : {
      25             : 
      26       24096 : SyncNodalPositions::SyncNodalPositions(MeshBase & m)
      27       24096 :   : mesh(m)
      28       24096 : {}
      29             : 
      30             : 
      31             : 
      32      180888 : void SyncNodalPositions::gather_data (const std::vector<dof_id_type> & ids,
      33             :                                       std::vector<datum> & data) const
      34             : {
      35      181488 :   data.resize(ids.size());
      36             : 
      37             :   // Gather (x,y,z) data for all node IDs in the ids vector
      38     5007721 :   for (auto i : index_range(ids))
      39             :     {
      40             :       // Look for this node in the mesh
      41     4914736 :       const Point & pt = mesh.point(ids[i]);
      42             : 
      43             :       // Store this node's position in the data array.
      44             :       // This should call Point::op=
      45     4914736 :       data[i] = pt;
      46             :     } // end for
      47      180888 : } // gather_data()
      48             : 
      49             : 
      50             : 
      51      180888 : void SyncNodalPositions::act_on_data (const std::vector<dof_id_type> & ids,
      52             :                                       const std::vector<datum> & data) const
      53             : {
      54     5007721 :   for (auto i : index_range(ids))
      55             :     {
      56             :       // Get a pointer to the node whose position is to be updated.
      57     4914736 :       Node & node = mesh.node_ref(ids[i]);
      58             : 
      59             :       // Update this node's position.  Should call Point::op=
      60      175806 :       node = data[i];
      61             :     } // end for
      62      180888 : } // act_on_data()
      63             : 
      64             : 
      65           0 : SyncSubdomainIds::SyncSubdomainIds(MeshBase & m)
      66           0 :   : mesh(m)
      67           0 : {}
      68             : 
      69           0 : void SyncSubdomainIds::gather_data (const std::vector<dof_id_type> & ids,
      70             :                                     std::vector<datum> & ids_out) const
      71             : {
      72           0 :   ids_out.reserve(ids.size());
      73             : 
      74           0 :   for (const auto & id : ids)
      75             :     {
      76           0 :       Elem & elem = mesh.elem_ref(id);
      77           0 :       ids_out.push_back(elem.subdomain_id());
      78             :     }
      79           0 : }
      80             : 
      81           0 : void SyncSubdomainIds::act_on_data (const std::vector<dof_id_type> & ids,
      82             :                                     const std::vector<datum> & subdomain_ids) const
      83             : {
      84           0 :   for (auto i : index_range(ids))
      85             :     {
      86           0 :       Elem & elem = mesh.elem_ref(ids[i]);
      87           0 :       elem.subdomain_id()=subdomain_ids[i];
      88             :     }
      89           0 : }
      90             : 
      91           0 : SyncElementIntegers::SyncElementIntegers(MeshBase & m, const std::string & integer_name)
      92           0 :   : mesh(m), ind(m.get_elem_integer_index(integer_name))
      93           0 : {}
      94             : 
      95           0 : void SyncElementIntegers::gather_data(const std::vector<dof_id_type> & ids,
      96             :                                       std::vector<dof_id_type> & ids_out) const
      97             : {
      98           0 :   ids_out.reserve(ids.size());
      99             : 
     100           0 :   for (const auto & id : ids)
     101             :     {
     102           0 :       Elem & elem = mesh.elem_ref(id);
     103           0 :       ids_out.push_back(elem.get_extra_integer(ind));
     104             :     }
     105           0 : }
     106             : 
     107           0 : void SyncElementIntegers::act_on_data(const std::vector<dof_id_type> & ids,
     108             :                                       const std::vector<dof_id_type> & integer_ids) const
     109             : {
     110           0 :   for (auto i : index_range(ids))
     111             :     {
     112           0 :       Elem & elem = mesh.elem_ref(ids[i]);
     113           0 :       elem.set_extra_integer(ind, integer_ids[i]);
     114             :     }
     115           0 : }
     116             : 
     117             : } // namespace

Generated by: LCOV version 1.14