LCOV - code coverage report
Current view: top level - src/base - dof_map_base.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4232 (290bfc) with base 82cc40 Lines: 24 24 100.0 %
Date: 2025-08-27 15:46:53 Functions: 4 4 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             : #include "libmesh/dof_map_base.h"
      19             : #include "libmesh/parallel_implementation.h"
      20             : 
      21             : namespace libMesh
      22             : {
      23      238202 : DofMapBase::DofMapBase(const Parallel::Communicator & comm)
      24             :   : ParallelObject(comm),
      25      224606 :     _n_dfs(0)
      26             : #ifdef LIBMESH_ENABLE_AMR
      27             :     ,
      28      245000 :     _n_old_dfs(0)
      29             : #endif
      30             : {
      31      238202 : }
      32             : 
      33      263396 : std::size_t DofMapBase::compute_dof_info(const dof_id_type n_local_dofs)
      34             : {
      35             :   // Get DOF counts on all processors
      36       15256 :   const auto n_proc = this->n_processors();
      37             : 
      38      271024 :   std::vector<dof_id_type> dofs_on_proc(n_proc, 0);
      39      263396 :   this->comm().allgather(n_local_dofs, dofs_on_proc);
      40             : 
      41             : #ifdef LIBMESH_ENABLE_AMR
      42             :   // Resize and fill the _first_df and _end_df arrays
      43      263396 :   _first_old_df = _first_df;
      44      263396 :   _end_old_df = _end_df;
      45             : #endif
      46             : 
      47      263396 :   _first_df.resize(n_proc);
      48      263396 :   _end_df.resize(n_proc);
      49             : 
      50             :   // Get DOF offsets
      51      263396 :   _first_df[0] = 0;
      52     2567768 :   for (processor_id_type i = 1; i < n_proc; ++i)
      53     2334884 :     _first_df[i] = _end_df[i - 1] = _first_df[i - 1] + dofs_on_proc[i - 1];
      54      278652 :   _end_df[n_proc - 1] = _first_df[n_proc - 1] + dofs_on_proc[n_proc - 1];
      55             : 
      56             : // Set the total number of degrees of freedom
      57             : #ifdef LIBMESH_ENABLE_AMR
      58      263396 :   _n_old_dfs = _n_dfs;
      59             : #endif
      60      263396 :   _n_dfs = _end_df[n_proc - 1];
      61             : 
      62             :   // Return total number of DOFs across all procs. We compute and
      63             :   // return this as a std::size_t so that we can detect situations in
      64             :   // which the total number of DOFs across all procs would exceed the
      65             :   // capability of the underlying NumericVector representation to
      66             :   // index into it correctly (std::size_t is the largest unsigned
      67             :   // type, so no NumericVector representation can exceed it).
      68      271024 :   return std::accumulate(dofs_on_proc.begin(), dofs_on_proc.end(), static_cast<std::size_t>(0));
      69             : }
      70             : 
      71      239191 : void DofMapBase::clear()
      72             : {
      73        6828 :   _first_df.clear();
      74        6828 :   _end_df.clear();
      75      239191 :   _n_dfs = 0;
      76      239191 : }
      77             : }

Generated by: LCOV version 1.14