LCOV - code coverage report
Current view: top level - src/base - dof_map_base.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4256 (26f7e2) with base d735cc Lines: 24 24 100.0 %
Date: 2025-10-01 13:47:18 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      239196 : DofMapBase::DofMapBase(const Parallel::Communicator & comm)
      24             :   : ParallelObject(comm),
      25      225544 :     _n_dfs(0)
      26             : #ifdef LIBMESH_ENABLE_AMR
      27             :     ,
      28      246022 :     _n_old_dfs(0)
      29             : #endif
      30             : {
      31      239196 : }
      32             : 
      33      264390 : std::size_t DofMapBase::compute_dof_info(const dof_id_type n_local_dofs)
      34             : {
      35             :   // Get DOF counts on all processors
      36       15312 :   const auto n_proc = this->n_processors();
      37             : 
      38      272046 :   std::vector<dof_id_type> dofs_on_proc(n_proc, 0);
      39      264390 :   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      264390 :   _first_old_df = _first_df;
      44      264390 :   _end_old_df = _end_df;
      45             : #endif
      46             : 
      47      264390 :   _first_df.resize(n_proc);
      48      264390 :   _end_df.resize(n_proc);
      49             : 
      50             :   // Get DOF offsets
      51      264390 :   _first_df[0] = 0;
      52     2577470 :   for (processor_id_type i = 1; i < n_proc; ++i)
      53     2343704 :     _first_df[i] = _end_df[i - 1] = _first_df[i - 1] + dofs_on_proc[i - 1];
      54      279702 :   _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      264390 :   _n_old_dfs = _n_dfs;
      59             : #endif
      60      264390 :   _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      272046 :   return std::accumulate(dofs_on_proc.begin(), dofs_on_proc.end(), static_cast<std::size_t>(0));
      69             : }
      70             : 
      71      240185 : void DofMapBase::clear()
      72             : {
      73        6856 :   _first_df.clear();
      74        6856 :   _end_df.clear();
      75      240185 :   _n_dfs = 0;
      76      240185 : }
      77             : }

Generated by: LCOV version 1.14