DUNE PDELab (git)

macrogrid.hh
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_DGF_MACROGRID_HH
6#define DUNE_DGF_MACROGRID_HH
7
8
9#include <iostream>
10
12#include <dune/grid/io/file/dgfparser/parser.hh>
13
14
15namespace Dune
16{
17 // forward declarations
18 // --------------------
19 class DuneGridFormatParser;
20
21 class MacroGrid
22 : protected DuneGridFormatParser
23 {
24 template< class GridType >
25 friend struct DGFGridFactory;
26
27 public:
28 typedef MPIHelper::MPICommunicator MPICommunicatorType;
29
30 protected:
32 MacroGrid(const char* filename, MPICommunicatorType MPICOMM = MPIHelper::getCommunicator())
33 : DuneGridFormatParser( rank(MPICOMM), size(MPICOMM) )
34 , filename_(filename)
35 , MPICOMM_(MPICOMM) {}
36
38 MacroGrid(MPICommunicatorType MPICOMM = MPIHelper::getCommunicator())
39 : DuneGridFormatParser( rank(MPICOMM), size(MPICOMM) )
40 , filename_(0)
41 , MPICOMM_(MPICOMM) {}
42
44 template <class GridType>
45 inline GridType * createGrid ()
46 {
47 return Impl<GridType>::generate(*this,filename_,MPICOMM_);
48 }
49 private:
50 static int rank( [[maybe_unused]] MPICommunicatorType MPICOMM )
51 {
52 int rank = 0;
53#if HAVE_MPI
54 MPI_Comm_rank( MPICOMM, &rank );
55#endif
56 return rank;
57 }
58 static int size( [[maybe_unused]] MPICommunicatorType MPICOMM )
59 {
60 int size = 1;
61#if HAVE_MPI
62 MPI_Comm_size( MPICOMM, &size );
63#endif
64 return size;
65 }
77 template< class GridType >
78 struct Impl
79 {
80 static GridType* generate(MacroGrid& mg,
81 const char* filename, MPICommunicatorType MPICOMM = MPIHelper::getCommunicator() )
82 {
83 // make assertion depend on the template argument but always evaluate to false
84 static_assert( GridType::dimension<0,"DGF grid factory missing. Did you forget to add the corresponding dgf header?");
85 }
86 };
87
88 const char* filename_;
89 MPICommunicatorType MPICOMM_;
90 };
91
92} // end namespace Dune
93
94#endif
DuneGridFormatParser(int rank, int size)
constructor
Definition: dgfparser.cc:97
MPI_Comm MPICommunicator
The type of the mpi communicator.
Definition: mpihelper.hh:192
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:200
Helpers for dealing with MPI.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)