Dune Core Modules (2.3.1)

macrogrid.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_DGF_MACROGRID_HH
4#define DUNE_DGF_MACROGRID_HH
5
6
7#include <iostream>
8
10#include <dune/grid/io/file/dgfparser/parser.hh>
11
12
13namespace Dune
14{
15 // forward declarations
16 // --------------------
17 class DuneGridFormatParser;
18
19 class MacroGrid
20 : protected DuneGridFormatParser
21 {
22 template< class GridType >
23 friend struct DGFGridFactory;
24
25 public:
26 typedef MPIHelper::MPICommunicator MPICommunicatorType;
27
28 protected:
30 MacroGrid(const char* filename, MPICommunicatorType MPICOMM = MPIHelper::getCommunicator())
31 : DuneGridFormatParser( rank(MPICOMM), size(MPICOMM) )
32 , filename_(filename)
33 , MPICOMM_(MPICOMM) {}
34
36 MacroGrid(MPICommunicatorType MPICOMM = MPIHelper::getCommunicator())
37 : DuneGridFormatParser( rank(MPICOMM), size(MPICOMM) )
38 , filename_(0)
39 , MPICOMM_(MPICOMM) {}
40
42 template <class GridType>
43 inline GridType * createGrid ()
44 {
45 return Impl<GridType>::generate(*this,filename_,MPICOMM_);
46 }
47 private:
48 static int rank( MPICommunicatorType MPICOMM )
49 {
50 int rank = 0;
51#if HAVE_MPI
52 MPI_Comm_rank( MPICOMM, &rank );
53#endif
54 return rank;
55 }
56 static int size( MPICommunicatorType MPICOMM )
57 {
58 int size = 1;
59#if HAVE_MPI
60 MPI_Comm_size( MPICOMM, &size );
61#endif
62 return size;
63 }
75 template< class GridType >
76 struct Impl
77 {
78 static GridType* generate(MacroGrid& mg,
79 const char* filename, MPICommunicatorType MPICOMM = MPIHelper::getCommunicator() )
80 {
81 // make assertion depend on the template argument but always evaluate to false
82 dune_static_assert( GridType::dimension<0,"DGF grid factory missing. Did you forget to add the corresponding dgf header or config.h?");
83 }
84 };
85
86 const char* filename_;
87 MPICommunicatorType MPICOMM_;
88 };
89
90} // end namespace Dune
91
92#endif
DuneGridFormatParser(int rank, int size)
constructor
Definition: dgfparser.cc:90
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:174
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:182
#define dune_static_assert(COND, MSG)
Helper template so that compilation fails if condition is not true.
Definition: static_assert.hh:79
Dune namespace.
Definition: alignment.hh:14
Helpers for dealing with MPI.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)