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
Backofen, Rainer
amdis
Commits
2497a645
Commit
2497a645
authored
May 12, 2014
by
Siqi Ling
Browse files
add function writeMetaData into Arh2Writer in parallel mode
parent
31edf520
Changes
5
Hide whitespace changes
Inline
Side-by-side
AMDiS/CMakeLists.txt
View file @
2497a645
...
...
@@ -163,6 +163,7 @@ SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc
${
SOURCE_DIR
}
/io/ArhReader.cc
${
SOURCE_DIR
}
/io/detail/ArhReader.cc
${
SOURCE_DIR
}
/io/Arh2Reader.cc
${
SOURCE_DIR
}
/io/Arh2Writer.cc
${
SOURCE_DIR
}
/io/detail/Arh2Reader.cc
${
SOURCE_DIR
}
/io/detail/ArhWriter.cc
${
SOURCE_DIR
}
/io/detail/Arh2Writer.cc
...
...
AMDiS/src/io/Arh2Writer.cc
0 → 100644
View file @
2497a645
/******************************************************************************
*
* AMDiS - Adaptive multidimensional simulations
*
* Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
* Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
*
* Authors:
* Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* This file is part of AMDiS
*
* See also license.opensource.txt in the distribution.
*
******************************************************************************/
#include
"Arh2Writer.h"
#include
"Mesh.h"
#include
"MeshStructure.h"
#include
"parallel/StdMpi.h"
namespace
AMDiS
{
namespace
io
{
using
namespace
std
;
using
namespace
AMDiS
::
Parallel
;
namespace
Arh2Writer
{
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
void
writeMetaData
(
Mesh
*
mesh
,
string
metaFilename
)
{
FUNCNAME
(
"Arh2Writer::writeMetaData()"
);
int
mpiSize
=
MPI
::
COMM_WORLD
.
Get_size
();
vector
<
std
::
set
<
pair
<
int
,
int
>
>
>
overallData
;
std
::
set
<
pair
<
int
,
int
>
>
data
;
// Calculate local data
MeshStructure
elementStructure
;
int
macroElIndex
=
-
1
;
TraverseStack
stack
;
ElInfo
*
elInfo
=
stack
.
traverseFirst
(
mesh
,
-
1
,
Mesh
::
CALL_EVERY_EL_PREORDER
);
while
(
elInfo
)
{
if
(
elInfo
->
getLevel
()
==
0
)
{
if
(
macroElIndex
!=
-
1
)
{
elementStructure
.
commit
();
data
.
insert
(
make_pair
(
macroElIndex
,
elementStructure
.
getNumElements
()));
}
elementStructure
.
clear
();
macroElIndex
=
elInfo
->
getElement
()
->
getIndex
();
}
elementStructure
.
insertElement
(
elInfo
->
getElement
()
->
isLeaf
());
elInfo
=
stack
.
traverseNext
(
elInfo
);
}
TEST_EXIT_DBG
(
macroElIndex
!=
-
1
)(
"Should not happen!
\n
"
);
elementStructure
.
commit
();
data
.
insert
(
make_pair
(
macroElIndex
,
elementStructure
.
getNumElements
()));
// Collect data from other processors
StdMpi
<
std
::
set
<
pair
<
int
,
int
>
>
>
stdMpi
(
MPI
::
COMM_WORLD
);
if
(
MPI
::
COMM_WORLD
.
Get_rank
()
==
0
)
{
for
(
int
rank
=
1
;
rank
<
mpiSize
;
rank
++
)
stdMpi
.
recv
(
rank
);
}
else
{
stdMpi
.
send
(
0
,
data
);
}
stdMpi
.
startCommunication
();
if
(
MPI
::
COMM_WORLD
.
Get_rank
()
==
0
)
{
overallData
.
push_back
(
data
);
for
(
int
rank
=
1
;
rank
<
mpiSize
;
rank
++
)
{
std
::
set
<
pair
<
int
,
int
>
>&
recvData
=
stdMpi
.
getRecvData
(
rank
);
overallData
.
push_back
(
recvData
);
}
// Write to meta file
ofstream
file
;
file
.
open
(
metaFilename
.
c_str
());
file
<<
"METAARH
\n
"
;
file
<<
""
<<
"
\n
"
;
file
<<
mpiSize
<<
"
\n
"
;
for
(
int
i
=
0
;
i
<
mpiSize
;
i
++
)
{
file
<<
i
<<
" "
<<
overallData
[
i
].
size
()
<<
"
\n
"
;
for
(
std
::
set
<
pair
<
int
,
int
>
>::
iterator
it
=
overallData
[
i
].
begin
();
it
!=
overallData
[
i
].
end
();
++
it
)
file
<<
it
->
first
<<
" "
<<
it
->
second
<<
"
\n
"
;
}
file
.
close
();
}
}
#endif
}
}
}
\ No newline at end of file
AMDiS/src/io/Arh2Writer.h
View file @
2497a645
...
...
@@ -97,7 +97,11 @@ namespace AMDiS { namespace io {
std
::
vector
<
DOFVector
<
double
>*>
vecs
;
detail
::
write
(
filename
,
mesh
,
vecs
,
writeParallel
);
}
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
void
writeMetaData
(
Mesh
*
mesh
,
std
::
string
filename
);
#endif
}
// end namespace Arh2Writer
}
}
// end namespace io, AMDiS
...
...
AMDiS/src/parallel/StdMpi.cc
View file @
2497a645
...
...
@@ -29,6 +29,7 @@ namespace AMDiS { namespace Parallel {
MPI_Datatype
StdMpiHelper
<
vector
<
int
>
>::
mpiDataType
=
MPI_INT
;
MPI_Datatype
StdMpiHelper
<
std
::
set
<
int
>
>::
mpiDataType
=
MPI_INT
;
MPI_Datatype
StdMpiHelper
<
vector
<
std
::
set
<
int
>
>
>::
mpiDataType
=
MPI_INT
;
MPI_Datatype
StdMpiHelper
<
std
::
set
<
std
::
pair
<
int
,
int
>
>
>::
mpiDataType
=
MPI_INT
;
MPI_Datatype
StdMpiHelper
<
vector
<
double
>
>::
mpiDataType
=
MPI_DOUBLE
;
MPI_Datatype
StdMpiHelper
<
vector
<
vector
<
double
>
>
>::
mpiDataType
=
MPI_DOUBLE
;
MPI_Datatype
StdMpiHelper
<
vector
<
MeshStructure
>
>::
mpiDataType
=
MPI_UNSIGNED_LONG_LONG
;
...
...
@@ -157,7 +158,35 @@ namespace AMDiS { namespace Parallel {
counter
,
bufSize
);
}
// T = std::set<std::pair<int, int> > >
int
StdMpiHelper
<
std
::
set
<
std
::
pair
<
int
,
int
>
>
>::
getBufferSize
(
std
::
set
<
std
::
pair
<
int
,
int
>
>
&
data
)
{
return
data
.
size
()
*
2
;
}
void
StdMpiHelper
<
std
::
set
<
std
::
pair
<
int
,
int
>
>
>::
createBuffer
(
std
::
set
<
std
::
pair
<
int
,
int
>
>
&
data
,
int
*
buf
)
{
int
i
=
0
;
for
(
std
::
set
<
std
::
pair
<
int
,
int
>
>::
iterator
it
=
data
.
begin
();
it
!=
data
.
end
();
++
it
)
{
buf
[
i
++
]
=
it
->
first
;
buf
[
i
++
]
=
it
->
second
;
}
}
void
StdMpiHelper
<
std
::
set
<
std
::
pair
<
int
,
int
>
>
>::
makeFromBuffer
(
std
::
set
<
std
::
pair
<
int
,
int
>
>
&
data
,
int
*
buf
,
int
bufSize
)
{
data
.
clear
();
for
(
int
i
=
0
;
i
<
bufSize
;
i
+=
2
)
data
.
insert
(
std
::
make_pair
(
buf
[
i
],
buf
[
i
+
1
]));
}
// T = vector<double>
...
...
AMDiS/src/parallel/StdMpi.h
View file @
2497a645
...
...
@@ -107,6 +107,20 @@ namespace AMDiS { namespace Parallel {
static
void
makeFromBuffer
(
std
::
vector
<
std
::
set
<
int
>
>
&
data
,
int
*
buf
,
int
bufSize
);
};
template
<
>
struct
StdMpiHelper
<
std
::
set
<
std
::
pair
<
int
,
int
>
>
>
{
static
MPI_Datatype
mpiDataType
;
typedef
int
cppDataType
;
static
int
getBufferSize
(
std
::
set
<
std
::
pair
<
int
,
int
>
>
&
data
);
static
void
createBuffer
(
std
::
set
<
std
::
pair
<
int
,
int
>
>
&
data
,
int
*
buf
);
static
void
makeFromBuffer
(
std
::
set
<
std
::
pair
<
int
,
int
>
>
&
data
,
int
*
buf
,
int
bufSize
);
};
template
<
>
...
...
Write
Preview
Supports
Markdown
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