Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Praetorius, Simon
dune-dec
Commits
99634e60
Commit
99634e60
authored
Jun 11, 2017
by
Praetorius, Simon
Browse files
output for all or own rank only
parent
9cb1d1e2
Changes
4
Hide whitespace changes
Inline
Side-by-side
dune/dec/common/Common.hpp
View file @
99634e60
...
...
@@ -95,13 +95,6 @@ namespace Dec
template
<
class
T
>
using
Store_t
=
typename
aux
::
StoreType
<
Decay_t
<
T
>>::
type
;
/// Variadic type list
template
<
class
...
Ts
>
struct
Types
{};
template
<
class
...
Ts
>
using
Types_t
=
Types
<
Decay_t
<
Ts
>
...
>
;
/// Identity type wrapper, represents the type itself
template
<
class
T
>
struct
Type
...
...
@@ -109,6 +102,23 @@ namespace Dec
using
type
=
T
;
};
/// Variadic type list
template
<
class
...
Ts
>
struct
Types
{
template
<
bool
...>
struct
_bools
{};
template
<
class
T
>
static
constexpr
bool
contains
(
Type
<
T
>
=
{})
{
return
not
std
::
is_same
<
_bools
<
false
,
std
::
is_same
<
T
,
Ts
>::
value
...
>
,
_bools
<
std
::
is_same
<
T
,
Ts
>::
value
...,
false
>
>::
value
;
}
};
template
<
class
...
Ts
>
using
Types_t
=
Types
<
Decay_t
<
Ts
>
...
>
;
template
<
class
T
>
using
owner
=
T
;
...
...
dune/dec/common/Output.hpp
View file @
99634e60
...
...
@@ -5,6 +5,8 @@
#include <sstream>
#include <string>
#include <dune/dec/common/Common.hpp>
/**
* \def DEC_NO_THROW
* \brief The preprocessor constant sets whether to use c-asserts (if defined) or
...
...
@@ -40,6 +42,15 @@
namespace
Dec
{
namespace
tag
{
struct
own_rank
{};
struct
all_ranks
{};
template
<
class
OStream
>
OStream
&
operator
<<
(
OStream
&
out
,
own_rank
)
{
return
out
;
}
template
<
class
OStream
>
OStream
&
operator
<<
(
OStream
&
out
,
all_ranks
)
{
return
out
;
}
}
namespace
aux
{
template
<
class
OStream
>
...
...
@@ -67,9 +78,12 @@ namespace Dec
int
num_ranks
=
-
1
;
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
num_ranks
);
if
(
num_ranks
>
1
/* && rank == 0*/
)
{
concatImpl
(
out
,
"["
,
rank
,
"] "
,
std
::
forward
<
Args
>
(
args
)...);
}
else
if
(
num_ranks
==
1
)
{
bool
print
=
rank
==
0
||
Types
<
Decay_t
<
Args
>
...
>::
contains
(
Type
<
tag
::
all_ranks
>
{});
if
(
num_ranks
>
1
)
{
if
(
print
)
concatImpl
(
out
,
"["
,
rank
,
"] "
,
std
::
forward
<
Args
>
(
args
)...);
}
else
{
concatImpl
(
out
,
std
::
forward
<
Args
>
(
args
)...);
}
#else
...
...
dune/dec/utility/Timer.hpp
View file @
99634e60
...
...
@@ -22,9 +22,29 @@ namespace Dec
/// returns the elapsed time (from construction or last reset) to now in seconds
value_type
elapsed
()
const
;
pr
ivate
:
pr
otected
:
/// start time
TimePoint
t0
;
};
template
<
class
GridView
>
class
ParallelTimer
:
public
Timer
{
public:
ParallelTimer
(
GridView
const
&
gv
)
:
gv_
(
gv
)
{}
auto
elapsed
()
const
{
auto
e
=
Timer
::
elapsed
();
return
gv_
.
comm
().
max
(
e
);
}
protected:
GridView
gv_
;
};
}
// end namespace Dec
examples/alugrid.cpp
View file @
99634e60
...
...
@@ -64,7 +64,7 @@ int main(int argc, char** argv)
auto
&
mpihelper
=
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
assert_msg
(
argc
>
1
,
"usage: ./alugrid grid-filename [nSteps]"
);
Timer
t
;
Timer
t
0
;
using
GridBase
=
Dune
::
ALUGrid
<
2
,
2
,
Dune
::
simplex
,
Dune
::
conforming
>
;
#if 1
// Create ug grid from structured grid
...
...
@@ -81,30 +81,32 @@ int main(int argc, char** argv)
Dune::AlbertaReader<GridBase>().readGrid(argv[1], gridFactory);
std::unique_ptr<GridBase> gridBase( gridFactory.createGrid() );
#endif
msg
(
"time(create gridBase) = "
,
t
.
elapsed
(),
"sec"
);
msg
(
"time(create gridBase) = "
,
t
0
.
elapsed
(),
"sec"
);
t
.
reset
();
t
0
.
reset
();
LoadBalance
<
GridBase
>
lb
(
*
gridBase
,
mpihelper
);
gridBase
->
repartition
(
lb
);
msg
(
"#elements = "
,
gridBase
->
leafGridView
().
size
(
0
));
msg
(
"time(loadBalance) = "
,
t
.
elapsed
(),
"sec"
);
msg
(
"time(loadBalance) = "
,
t
0
.
elapsed
(),
"sec"
);
t
.
reset
();
t
0
.
reset
();
using
Grid
=
DecGrid
<
GridBase
>
;
Grid
grid
(
*
gridBase
);
msg
(
"time(create DECGrid) = "
,
t
.
elapsed
(),
"sec"
);
msg
(
"time(create DECGrid) = "
,
t
0
.
elapsed
(),
"sec"
);
if
(
argc
>
2
)
{
t
.
reset
();
t
0
.
reset
();
grid
.
globalRefine
(
std
::
atoi
(
argv
[
2
]));
msg
(
"#elements after global refinement = "
,
gridBase
->
leafGridView
().
size
(
0
));
msg
(
"time(global refine) = "
,
t
.
elapsed
(),
"sec"
);
msg
(
"time(global refine) = "
,
t
0
.
elapsed
(),
"sec"
);
}
using
GridView
=
Grid
::
LeafGridView
;
const
GridView
gv
=
grid
.
leafGridView
();
auto
const
&
indexSet
=
gv
.
indexSet
();
ParallelTimer
<
GridView
>
t
(
gv
);
// -----------------------------------------------------------------------------------------------
#if 0
for (auto const& v : vertices(gv, Dune::Partitions::All{}) ) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment