LCOV - code coverage report
Current view: top level - src/ghosting - non_manifold_coupling.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 15 26 57.7 %
Date: 2025-08-19 19:27:09 Functions: 2 6 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             : // libMesh includes
      19             : #include "libmesh/elem.h"
      20             : #include "libmesh/non_manifold_coupling.h"
      21             : #include "libmesh/simple_range.h" // as_range()
      22             : 
      23             : namespace libMesh
      24             : {
      25             : 
      26         284 : NonManifoldGhostingFunctor::
      27         284 : NonManifoldGhostingFunctor(const MeshBase & mesh) :
      28             :   GhostingFunctor(mesh),
      29         284 :   _stem(MeshTools::SidesToElemMap::build(mesh))
      30             : {
      31             :   // We call MeshBase::reinit_ghosting_functors() in MeshBase::prepare_for_use(),
      32             :   // so it _should_ be safe to omit this call to SidesToElemMap::build() here,
      33             :   // but to be on the safe side, we'll construct it both here and during any call
      34             :   // to mesh_reinit().
      35         284 : }
      36             : 
      37             : std::unique_ptr<GhostingFunctor>
      38           0 : NonManifoldGhostingFunctor::clone () const
      39             : {
      40           0 :   return std::make_unique<NonManifoldGhostingFunctor>(*this);
      41             : }
      42             : 
      43             : void
      44           0 : NonManifoldGhostingFunctor::mesh_reinit ()
      45             : {
      46           0 :   _stem = MeshTools::SidesToElemMap::build(*_mesh);
      47           0 : }
      48             : 
      49             : void
      50           0 : NonManifoldGhostingFunctor::redistribute ()
      51             : {
      52           0 :   this->mesh_reinit();
      53           0 : }
      54             : 
      55             : void
      56           0 : NonManifoldGhostingFunctor::delete_remote_elements()
      57             : {
      58           0 :   this->mesh_reinit();
      59           0 : }
      60             : 
      61             : void
      62        1140 : NonManifoldGhostingFunctor::operator() (
      63             :   const MeshBase::const_element_iterator & range_begin,
      64             :   const MeshBase::const_element_iterator & range_end,
      65             :   processor_id_type p,
      66             :   map_type & coupled_elements)
      67             : {
      68             :   // This code is just for geometric coupling, so we use a null
      69             :   // CouplingMatrix pointer.  We'll declare that here so as to avoid
      70             :   // confusing the emplace() calls later.
      71        1140 :   CouplingMatrix * nullcm = nullptr;
      72             : 
      73        5080 :   for (const auto & elem : as_range(range_begin, range_end))
      74             :     {
      75             :       // The idea here is that the input range [range_begin,
      76             :       // range_end] is a list of Elems whose DOFs we already know we
      77             :       // want to ghost (if they aren't already owned by processor p,
      78             :       // we don't need to worry about ghosting "local" Elem DOFs)
      79             :       // Therefore, we always put *all* the non-local Elems in the
      80             :       // input range into the output "coupled_elements" map.  The
      81             :       // purpose of the rest of this of this function is then to
      82             :       // determine which *additional* elements should be ghosted,
      83             :       // given that we care about the entire input range.
      84        1584 :       if (elem->processor_id() != p)
      85         792 :         coupled_elements.emplace(elem, nullcm);
      86             : 
      87             :       // For each side of "elem", look up that (elem, side) pair in
      88             :       // the SidesToElemMap and then add all the Elem pointers from
      89             :       // that list to the coupled_elements map.
      90        8064 :       for (auto s : elem->side_index_range())
      91       19360 :         for (const auto & neigh : as_range(_stem.get_connected_elems(elem, s)))
      92       13024 :           if (neigh->processor_id() != p)
      93        8602 :             coupled_elements.emplace(neigh, nullcm);
      94         980 :     }
      95        1140 : }
      96             : 
      97             : } // namespace libMesh

Generated by: LCOV version 1.14