LCOV - code coverage report
Current view: top level - include/base - libmesh_base.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 6 6 100.0 %
Date: 2025-08-19 19:27:09 Functions: 3 3 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             : 
      20             : #ifndef LIBMESH_LIBMESH_BASE_H
      21             : #define LIBMESH_LIBMESH_BASE_H
      22             : 
      23             : #include "libmesh/id_types.h"
      24             : 
      25             : namespace libMesh {
      26             : 
      27             : /**
      28             :  * \returns The number of processors libMesh was initialized with.
      29             :  */
      30             : processor_id_type global_n_processors();
      31             : 
      32             : /**
      33             :  * \returns The index of the local processor with respect to the
      34             :  * original MPI pool libMesh was initialized with.
      35             :  */
      36             : processor_id_type global_processor_id();
      37             : 
      38             : /**
      39             :  * \returns The maximum number of threads used in the simulation.
      40             :  */
      41             : unsigned int n_threads();
      42             : 
      43             : /**
      44             :  * Namespaces don't provide private data,
      45             :  * so let's take the data we would like
      46             :  * private and put it in an obnoxious
      47             :  * namespace.  At least that way it is a
      48             :  * pain to use, thus discouraging errors.
      49             :  */
      50             : namespace libMeshPrivateData {
      51             : #ifdef LIBMESH_HAVE_MPI
      52             : /**
      53             :  * Total number of processors used.
      54             :  */
      55             : extern processor_id_type _n_processors;
      56             : 
      57             : /**
      58             :  * The local processor id.
      59             :  */
      60             : extern processor_id_type _processor_id;
      61             : #endif
      62             : 
      63             : /**
      64             :  * Total number of threads possible.
      65             :  */
      66             : extern int _n_threads;
      67             : }
      68             : }
      69             : 
      70             : 
      71             : 
      72             : // ------------------------------------------------------------
      73             : // libMesh inline member functions
      74             : inline
      75         907 : libMesh::processor_id_type libMesh::global_n_processors()
      76             : {
      77             : #ifdef LIBMESH_HAVE_MPI
      78        4837 :   return libMeshPrivateData::_n_processors;
      79             : #else
      80             :   return 1;
      81             : #endif
      82             : }
      83             : 
      84             : inline
      85         886 : libMesh::processor_id_type libMesh::global_processor_id()
      86             : {
      87             : #ifdef LIBMESH_HAVE_MPI
      88       19924 :   return libMeshPrivateData::_processor_id;
      89             : #else
      90             :   return 0;
      91             : #endif
      92             : }
      93             : 
      94             : 
      95             : inline
      96      191348 : unsigned int libMesh::n_threads()
      97             : {
      98     4548782 :   return static_cast<unsigned int>(libMeshPrivateData::_n_threads);
      99             : }
     100             : 
     101             : 
     102             : // We now put everything we can into a separate libMesh namespace;
     103             : // code which forward declares libMesh classes or which specializes
     104             : // libMesh templates may want to know whether it is compiling under
     105             : // such conditions, to be backward compatible with older libMesh
     106             : // versions:
     107             : #define LIBMESH_USE_SEPARATE_NAMESPACE 1
     108             : 
     109             : 
     110             : // Unless configured otherwise, we import all of namespace libMesh,
     111             : // for backwards compatibility with pre-namespaced codes.
     112             : 
     113             : #ifndef LIBMESH_REQUIRE_SEPARATE_NAMESPACE
     114             : using namespace libMesh;
     115             : #endif
     116             : 
     117             : 
     118             : #endif // LIBMESH_LIBMESH_BASE_H

Generated by: LCOV version 1.14