dune-grid
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
grid
io
file
dgfparser
macrogrid.hh
Go to the documentation of this file.
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
11
#include <dune/common/parallel/mpihelper.hh>
12
#include <
dune/grid/io/file/dgfparser/parser.hh
>
13
14
15
namespace
Dune
16
{
17
// forward declarations
18
// --------------------
19
class
DuneGridFormatParser
;
20
21
class
MacroGrid
22
:
protected
DuneGridFormatParser
23
{
24
template
<
class
Gr
id
Type >
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
Gr
id
Type>
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
Gr
id
Type >
78
struct
Impl
79
{
80
static
GridType* generate(
MacroGrid
&
/*mg*/
,
81
const
char
*
/*filename*/
, [[maybe_unused]]
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
parser.hh
Dune
Include standard header files.
Definition
agrid.hh:60
Dune::MacroGrid::MacroGrid
MacroGrid(const char *filename, MPICommunicatorType MPICOMM=MPIHelper::getCommunicator())
constructor given the name of a DGF file
Definition
macrogrid.hh:32
Dune::MacroGrid::MacroGrid
MacroGrid(MPICommunicatorType MPICOMM=MPIHelper::getCommunicator())
constructor given the name of a DGF file
Definition
macrogrid.hh:38
Dune::MacroGrid::createGrid
GridType * createGrid()
returns pointer to a new instance of type GridType created from a DGF file
Definition
macrogrid.hh:45
Dune::MacroGrid::DGFGridFactory
friend struct DGFGridFactory
Definition
macrogrid.hh:25
Dune::MacroGrid::MPICommunicatorType
MPIHelper::MPICommunicator MPICommunicatorType
Definition
macrogrid.hh:28
Dune::DuneGridFormatParser
The DuneGridFormatParser class: reads a DGF file and stores build information in vector structures us...
Definition
parser.hh:47
Dune::DuneGridFormatParser::DuneGridFormatParser
DuneGridFormatParser(int rank, int size)
constructor
Definition
io/file/dgfparser/dgfparser.cc:97
Generated by
1.17.0