/usr/include/dune/grid/io/file/dgfparser/macrogrid.hh is in libdune-grid-dev 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_DGF_MACROGRID_HH
#define DUNE_DGF_MACROGRID_HH
#include <iostream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/grid/io/file/dgfparser/parser.hh>
namespace Dune
{
// forward declarations
// --------------------
class DuneGridFormatParser;
class MacroGrid
: protected DuneGridFormatParser
{
template< class GridType >
friend struct DGFGridFactory;
public:
typedef MPIHelper::MPICommunicator MPICommunicatorType;
protected:
//! constructor given the name of a DGF file
MacroGrid(const char* filename, MPICommunicatorType MPICOMM = MPIHelper::getCommunicator())
: DuneGridFormatParser( rank(MPICOMM), size(MPICOMM) )
, filename_(filename)
, MPICOMM_(MPICOMM) {}
//! constructor given the name of a DGF file
MacroGrid(MPICommunicatorType MPICOMM = MPIHelper::getCommunicator())
: DuneGridFormatParser( rank(MPICOMM), size(MPICOMM) )
, filename_(0)
, MPICOMM_(MPICOMM) {}
//! returns pointer to a new instance of type GridType created from a DGF file
template <class GridType>
inline GridType * createGrid ()
{
return Impl<GridType>::generate(*this,filename_,MPICOMM_);
}
private:
static int rank( MPICommunicatorType MPICOMM )
{
int rank = 0;
#if HAVE_MPI
MPI_Comm_rank( MPICOMM, &rank );
#endif
return rank;
}
static int size( MPICommunicatorType MPICOMM )
{
int size = 1;
#if HAVE_MPI
MPI_Comm_size( MPICOMM, &size );
#endif
return size;
}
/** \brief container for the actual grid generation method
*
* For each grid implementation to be used with the DGF parser, this class
* has to be specialized. It has to contain one static method of the
* following prototype:
* \code
* static GridType *
* generate ( MacroGrid ¯oGrid, const char *filename,
* MPIHelper :: MPICommunicator comm = MPIHelper :: getCommunicator() );
* \endcode
*/
template< class GridType >
struct Impl
{
static GridType* generate(MacroGrid& mg,
const char* filename, MPICommunicatorType MPICOMM = MPIHelper::getCommunicator() )
{
// make assertion depend on the template argument but always evaluate to false
static_assert( GridType::dimension<0,"DGF grid factory missing. Did you forget to add the corresponding dgf header or config.h?");
}
};
const char* filename_;
MPICommunicatorType MPICOMM_;
};
} // end namespace Dune
#endif
|