LCOV - code coverage report
Current view: top level - include/partitioning - parmetis_helper.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 3 3 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             : #ifndef LIBMESH_PARMETIS_HELPER_H
      19             : #define LIBMESH_PARMETIS_HELPER_H
      20             : 
      21             : // Local Includes
      22             : #include "libmesh/libmesh_config.h"
      23             : 
      24             : // C++ Includes
      25             : #include <vector>
      26             : 
      27             : #ifdef LIBMESH_HAVE_PARMETIS
      28             : 
      29             : #include "libmesh/id_types.h"
      30             : 
      31             : // Before we include a header wrapped in a namespace, we'd better make
      32             : // sure none of its dependencies end up in that namespace
      33             : #include <mpi.h>
      34             : 
      35             : // Include the ParMETIS header files.  We need this so we can use
      36             : // ParMetis' idx_t and real_t types directly.
      37             : namespace Parmetis {
      38             : extern "C" {
      39             : #     include "libmesh/ignore_warnings.h"
      40             : #     include "parmetis.h"
      41             : #     include "libmesh/restore_warnings.h"
      42             : }
      43             : }
      44             : #endif // LIBMESH_HAVE_PARMETIS
      45             : 
      46             : 
      47             : namespace libMesh
      48             : {
      49             : 
      50             : /**
      51             :  * The \p ParmetisHelper class allows us to use a 'pimpl' strategy in
      52             :  * the ParmetisPartitioner class.  Since we don't include the
      53             :  * parmetis.h header file here, we don't have to install it, either.
      54             :  * This class is empty when Parmetis is not available, otherwise it is
      55             :  * simply a data container.
      56             :  *
      57             :  * \author John W. Peterson
      58             :  * \date 2015
      59             :  * \brief Pointer-to-implementation class used by ParmetisPartitioner.
      60             :  */
      61             : class ParmetisHelper
      62             : {
      63             : public:
      64             :   /**
      65             :    * Defaulted constructors, assignment operators, and destructor.
      66             :    */
      67      253959 :   ParmetisHelper () = default;
      68       16674 :   ParmetisHelper (const ParmetisHelper &) = default;
      69             :   ParmetisHelper (ParmetisHelper &&) = default;
      70             :   ParmetisHelper & operator= (const ParmetisHelper &) = default;
      71             :   ParmetisHelper & operator= (ParmetisHelper &&) = default;
      72      270887 :   ~ParmetisHelper () = default;
      73             : 
      74             : #ifdef LIBMESH_HAVE_PARMETIS
      75             : 
      76             :   /**
      77             :    * Data structures used by ParMETIS to describe the connectivity graph
      78             :    * of the mesh. Consult the ParMETIS documentation.
      79             :    */
      80             :   std::vector<Parmetis::idx_t>  vtxdist;
      81             :   std::vector<Parmetis::idx_t>  xadj;
      82             :   std::vector<Parmetis::idx_t>  adjncy;
      83             : 
      84             :   // We use dof_id_type for part so we can pass it directly to
      85             :   // Partitioner:: methods expecting that type.
      86             :   std::vector<dof_id_type>  part;
      87             : 
      88             :   // But we plan to pass a pointer to part as a buffer to ParMETIS, so
      89             :   // it had better be using a simply reinterpretable type!
      90             :   static_assert(sizeof(Parmetis::idx_t) == sizeof(dof_id_type),
      91             :                 "ParMETIS and libMesh ID sizes must match!");
      92             : 
      93             :   std::vector<Parmetis::real_t> tpwgts;
      94             :   std::vector<Parmetis::real_t> ubvec;
      95             :   std::vector<Parmetis::idx_t>  options;
      96             :   std::vector<Parmetis::idx_t>  vwgt;
      97             : 
      98             :   Parmetis::idx_t wgtflag;
      99             :   Parmetis::idx_t ncon;
     100             :   Parmetis::idx_t numflag;
     101             :   Parmetis::idx_t nparts;
     102             :   Parmetis::idx_t edgecut;
     103             : 
     104             : #endif // LIBMESH_HAVE_PARMETIS
     105             : };
     106             : 
     107             : } // namespace libMesh
     108             : 
     109             : #endif // LIBMESH_PARMETIS_HELPER_H

Generated by: LCOV version 1.14