Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Backofen, Rainer
amdis
Commits
13ed7ef9
Commit
13ed7ef9
authored
Sep 23, 2009
by
Thomas Witkowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parallel paraview output.
parent
103fc4b6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
63 deletions
+112
-63
AMDiS/src/FileWriter.cc
AMDiS/src/FileWriter.cc
+53
-32
AMDiS/src/FileWriter.h
AMDiS/src/FileWriter.h
+8
-15
AMDiS/src/VtkWriter.cc
AMDiS/src/VtkWriter.cc
+46
-0
AMDiS/src/VtkWriter.h
AMDiS/src/VtkWriter.h
+4
-0
AMDiS/src/VtkWriter.hh
AMDiS/src/VtkWriter.hh
+1
-16
No files found.
AMDiS/src/FileWriter.cc
View file @
13ed7ef9
...
...
@@ -29,8 +29,8 @@ namespace AMDiS {
feSpace
=
vec
->
getFESpace
();
solutionVecs
_
.
resize
(
1
);
solutionVecs
_
[
0
]
=
vec
;
solutionVecs
.
resize
(
1
);
solutionVecs
[
0
]
=
vec
;
}
...
...
@@ -49,7 +49,7 @@ namespace AMDiS {
(
"All FESpace have to be equal!
\n
"
);
feSpace
=
vecs
[
0
]
->
getFESpace
();
solutionVecs
_
=
vecs
;
solutionVecs
=
vecs
;
}
...
...
@@ -64,21 +64,18 @@ namespace AMDiS {
initialize
();
// Create the temporal DOFVectors for all components of WorldVector.
nTmpSolutions_
=
(
*
vec
)[
0
].
getSize
();
solutionVecs_
.
resize
(
nTmpSolutions_
);
for
(
int
i
=
0
;
i
<
nTmpSolutions_
;
i
++
)
{
solutionVecs_
[
i
]
=
new
DOFVector
<
double
>
(
vec
->
getFESpace
(),
""
);
}
nTmpSolutions
=
(
*
vec
)[
0
].
getSize
();
solutionVecs
.
resize
(
nTmpSolutions
);
for
(
int
i
=
0
;
i
<
nTmpSolutions
;
i
++
)
solutionVecs
[
i
]
=
new
DOFVector
<
double
>
(
vec
->
getFESpace
(),
""
);
// Copy the components of the WorldVectors to different DOFVectors
// of double values.
DOFVector
<
WorldVector
<
double
>
>::
Iterator
it
(
vec
,
USED_DOFS
);
int
counter
=
0
;
for
(
it
.
reset
();
!
it
.
end
();
++
it
,
counter
++
)
{
for
(
int
i
=
0
;
i
<
nTmpSolutions_
;
i
++
)
{
(
*
solutionVecs_
[
i
])[
counter
]
=
(
*
it
)[
i
];
}
}
for
(
it
.
reset
();
!
it
.
end
();
++
it
,
counter
++
)
for
(
int
i
=
0
;
i
<
nTmpSolutions
;
i
++
)
(
*
solutionVecs
[
i
])[
counter
]
=
(
*
it
)[
i
];
feSpace
=
vec
->
getFESpace
();
}
...
...
@@ -88,9 +85,9 @@ namespace AMDiS {
{
// Do not forget to delete temporal solution vector, if there have been
// some created in the constructor.
if
(
nTmpSolutions
_
>
0
)
for
(
int
i
=
0
;
i
<
nTmpSolutions
_
;
i
++
)
delete
solutionVecs
_
[
i
];
if
(
nTmpSolutions
>
0
)
for
(
int
i
=
0
;
i
<
nTmpSolutions
;
i
++
)
delete
solutionVecs
[
i
];
}
...
...
@@ -99,7 +96,8 @@ namespace AMDiS {
tecplotExt
=
".tec"
;
amdisMeshExt
=
".mesh"
;
amdisDataExt
=
".dat"
;
paraViewFileExt
=
".vtu"
;
paraviewFileExt
=
".vtu"
;
paraviewParallelFileExt
=
".pvtu"
;
periodicFileExt
=
".per"
;
writeTecPlotFormat
=
0
;
writeAMDiSFormat
=
0
;
...
...
@@ -112,8 +110,8 @@ namespace AMDiS {
indexLength
=
5
;
indexDecimals
=
3
;
tsModulo
=
1
;
nTmpSolutions
_
=
0
;
para
V
iewAnimationFrames
_
.
resize
(
0
),
nTmpSolutions
=
0
;
para
v
iewAnimationFrames
.
resize
(
0
),
compression
=
NONE
;
readParameters
();
...
...
@@ -131,7 +129,7 @@ namespace AMDiS {
GET_PARAMETER
(
0
,
name
+
"->AMDiS data ext"
,
&
amdisDataExt
);
GET_PARAMETER
(
0
,
name
+
"->ParaView format"
,
"%d"
,
&
writeParaViewFormat
);
GET_PARAMETER
(
0
,
name
+
"->ParaView animation"
,
"%d"
,
&
writeParaViewAnimation
);
GET_PARAMETER
(
0
,
name
+
"->ParaView ext"
,
&
para
V
iewFileExt
);
GET_PARAMETER
(
0
,
name
+
"->ParaView ext"
,
&
para
v
iewFileExt
);
GET_PARAMETER
(
0
,
name
+
"->Periodic format"
,
"%d"
,
&
writePeriodicFormat
);
GET_PARAMETER
(
0
,
name
+
"->Periodic ext"
,
&
periodicFileExt
);
GET_PARAMETER
(
0
,
name
+
"->PNG format"
,
"%d"
,
&
writePngFormat
);
...
...
@@ -162,15 +160,15 @@ namespace AMDiS {
return
;
// Containers, which store the data to be written;
std
::
vector
<
DataCollector
*
>
dataCollectors
(
solutionVecs
_
.
size
());
std
::
vector
<
DataCollector
*
>
dataCollectors
(
solutionVecs
.
size
());
if
(
writeElem
)
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
dataCollectors
.
size
());
i
++
)
dataCollectors
[
i
]
=
new
DataCollector
(
feSpace
,
solutionVecs
_
[
i
],
dataCollectors
[
i
]
=
new
DataCollector
(
feSpace
,
solutionVecs
[
i
],
level
,
flag
,
writeElem
);
}
else
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
dataCollectors
.
size
());
i
++
)
dataCollectors
[
i
]
=
new
DataCollector
(
feSpace
,
solutionVecs
_
[
i
],
dataCollectors
[
i
]
=
new
DataCollector
(
feSpace
,
solutionVecs
[
i
],
traverseLevel
,
flag
|
traverseFlag
,
writeElement
);
...
...
@@ -179,7 +177,9 @@ namespace AMDiS {
std
::
string
fn
=
filename
;
#if HAVE_PARALLEL_DOMAIN_AMDIS
char
f
[
10
];
std
::
string
paraFilename
=
fn
;
std
::
string
postfix
=
""
;
char
f
[
15
];
sprintf
(
f
,
"-p%d-"
,
MPI
::
COMM_WORLD
.
Get_rank
());
fn
+=
f
;
#endif
...
...
@@ -196,12 +196,17 @@ namespace AMDiS {
sprintf
(
timeStr
,
formatStr
,
adaptInfo
?
adaptInfo
->
getTime
()
:
0.0
);
fn
+=
timeStr
;
#if HAVE_PARALLEL_DOMAIN_AMDIS
paraFilename
+=
timeStr
;
postfix
+=
timeStr
;
postfix
+=
paraviewFileExt
;
#endif
}
if
(
writeTecPlotFormat
)
{
TecPlotWriter
<
DOFVector
<
double
>
>::
writeValues
(
solutionVecs
_
[
0
],
TecPlotWriter
<
DOFVector
<
double
>
>::
writeValues
(
solutionVecs
[
0
],
const_cast
<
char
*>
((
fn
+
tecplotExt
).
c_str
()),
solutionVecs
_
[
0
]
->
getName
().
c_str
());
solutionVecs
[
0
]
->
getName
().
c_str
());
MSG
(
"TecPlot file written to %s
\n
"
,
(
fn
+
tecplotExt
).
c_str
());
}
...
...
@@ -229,16 +234,33 @@ namespace AMDiS {
if
(
writeParaViewFormat
)
{
VtkWriter
vtkWriter
(
&
dataCollectors
);
vtkWriter
.
setCompression
(
compression
);
vtkWriter
.
writeFile
(
fn
+
paraViewFileExt
);
vtkWriter
.
writeFile
(
fn
+
paraviewFileExt
);
#if HAVE_PARALLEL_DOMAIN_AMDIS
if
(
MPI
::
COMM_WORLD
.
Get_rank
()
==
0
)
vtkWriter
.
writeParallelFile
(
paraFilename
+
paraviewParallelFileExt
,
MPI
::
COMM_WORLD
.
Get_size
(),
filename
,
postfix
);
#endif
MSG
(
"ParaView file written to %s
\n
"
,
(
fn
+
para
V
iewFileExt
).
c_str
());
MSG
(
"ParaView file written to %s
\n
"
,
(
fn
+
para
v
iewFileExt
).
c_str
());
}
if
(
writeParaViewAnimation
)
{
#if HAVE_PARALLEL_DOMAIN_AMDIS
if
(
MPI
::
COMM_WORLD
.
Get_rank
()
==
0
)
{
VtkWriter
vtkWriter
(
&
dataCollectors
);
vtkWriter
.
updateAnimationFile
(
paraFilename
+
paraviewParallelFileExt
,
&
paraviewAnimationFrames
,
filename
+
".pvd"
);
}
#else
VtkWriter
vtkWriter
(
&
dataCollectors
);
vtkWriter
.
updateAnimationFile
(
fn
+
para
V
iewFileExt
,
&
para
V
iewAnimationFrames
_
,
vtkWriter
.
updateAnimationFile
(
fn
+
para
v
iewFileExt
,
&
para
v
iewAnimationFrames
,
filename
+
".pvd"
);
#endif
}
if
(
writePngFormat
)
{
...
...
@@ -249,9 +271,8 @@ namespace AMDiS {
}
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
dataCollectors
.
size
());
i
++
)
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
dataCollectors
.
size
());
i
++
)
delete
dataCollectors
[
i
];
}
}
}
AMDiS/src/FileWriter.h
View file @
13ed7ef9
...
...
@@ -28,22 +28,12 @@
#include <vector>
#include <string>
#include "
MatrixVector
.h"
#include "
AMDiS_fwd
.h"
#include "Mesh.h"
#include "DataCollector.h"
namespace
AMDiS
{
class
ProblemScal
;
class
ProblemInstat
;
class
Mesh
;
class
SystemVector
;
class
FiniteElemSpace
;
class
AdaptInfo
;
template
<
typename
T
>
class
DOFVector
;
typedef
enum
{
NONE
=
0
,
GZIP
=
1
,
...
...
@@ -158,7 +148,10 @@ namespace AMDiS {
std
::
string
amdisDataExt
;
/// VTK file extension.
std
::
string
paraViewFileExt
;
std
::
string
paraviewFileExt
;
/// Parallel VTK file extension.
std
::
string
paraviewParallelFileExt
;
/// Periodic file extension.
std
::
string
periodicFileExt
;
...
...
@@ -200,7 +193,7 @@ namespace AMDiS {
int
tsModulo
;
/// Stores all writen filename to a ParaView animation file.
std
::
vector
<
std
::
string
>
para
V
iewAnimationFrames
_
;
std
::
vector
<
std
::
string
>
para
v
iewAnimationFrames
;
///
int
timestepNumber
;
...
...
@@ -212,14 +205,14 @@ namespace AMDiS {
const
FiniteElemSpace
*
feSpace
;
/// Pointers to the vectors which store the solution.
std
::
vector
<
DOFVector
<
double
>*
>
solutionVecs
_
;
std
::
vector
<
DOFVector
<
double
>*
>
solutionVecs
;
/** \brief
* Stores the number of temporal solutions vectors, which have been created
* in the constructor. If this number is greater than zero, the vectors
* stored in solutionVecs_ must be deleted in the destructor.
*/
int
nTmpSolutions
_
;
int
nTmpSolutions
;
/** \brief
* Defines if, and with what kind of compression, the file should be compressed
...
...
AMDiS/src/VtkWriter.cc
View file @
13ed7ef9
#include <stdio.h>
#include <string>
#include <fstream>
#include <sstream>
#include <cmath>
#include "boost/filesystem.hpp"
#include "VtkWriter.h"
#include "DataCollector.h"
#include "DOFVector.h"
...
...
@@ -44,6 +47,49 @@ namespace AMDiS {
return
0
;
}
void
VtkWriter
::
writeParallelFile
(
std
::
string
name
,
int
nRanks
,
std
::
string
fnPrefix
,
std
::
string
fnPostfix
)
{
std
::
ofstream
file
;
file
.
open
(
name
.
c_str
());
file
<<
"<?xml version=
\"
1.0
\"
?>
\n
"
;
file
<<
"<VTKFile type=
\"
PUnstructuredGrid
\"
>
\n
"
;
file
<<
" <PUnstructuredGrid GhostLevel=
\"
0
\"
>
\n
"
;
file
<<
" <PPoints>
\n
"
<<
" <PDataArray type=
\"
Float32
\"
NumberOfComponents=
\"
3
\"
format=
\"
ascii
\"
/>
\n
"
<<
" </PPoints>
\n
"
;
file
<<
" <PCells>
\n
"
<<
" <PDataArray type=
\"
Int32
\"
Name=
\"
offsets
\"
/>
\n
"
<<
" <PDataArray type=
\"
UInt8
\"
Name=
\"
types
\"
/>
\n
"
<<
" <PDataArray type=
\"
Int32
\"
Name=
\"
connectivity
\"
/>
\n
"
<<
" </PCells>
\n
"
;
file
<<
" <PPointData>
\n
"
;
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
dataCollector
->
size
());
i
++
)
file
<<
" <PDataArray type=
\"
Float32
\"
Name=
\"
value"
<<
i
<<
"
\"
format=
\"
ascii
\"
/>
\n
"
;
file
<<
" </PPointData>
\n
"
;
for
(
int
i
=
0
;
i
<
nRanks
;
i
++
)
{
std
::
stringstream
oss
;
oss
<<
fnPrefix
<<
"-p"
<<
i
<<
"-"
<<
fnPostfix
;
boost
::
filesystem
::
path
filepath
(
oss
.
str
());
file
<<
" <Piece Source=
\"
"
<<
boost
::
filesystem
::
basename
(
filepath
)
<<
boost
::
filesystem
::
extension
(
filepath
)
<<
"
\"
/>
\n
"
;
}
file
<<
" </PUnstructuredGrid>
\n
"
;
file
<<
"</VTKFile>
\n
"
;
file
.
close
();
}
int
VtkWriter
::
updateAnimationFile
(
std
::
string
valueFilename
,
std
::
vector
<
std
::
string
>
*
paraViewAnimationFrames
,
std
::
string
animationFilename
)
...
...
AMDiS/src/VtkWriter.h
View file @
13ed7ef9
...
...
@@ -50,6 +50,10 @@ namespace AMDiS {
/// Writes a ParaView-VTK file.
int
writeFile
(
std
::
string
name
);
/// Writes a pvtu file, which contains the links to all the rank files.
void
writeParallelFile
(
std
::
string
name
,
int
nRanks
,
std
::
string
fnPrefix
,
std
::
string
fnPostfix
);
/// May be used to simply write ParaView files.
static
void
writeFile
(
DOFVector
<
double
>
*
values
,
std
::
string
filename
);
...
...
AMDiS/src/VtkWriter.hh
View file @
13ed7ef9
...
...
@@ -36,9 +36,8 @@ namespace AMDiS {
file
<<
" <Cells>
\n
"
;
file
<<
" <DataArray type=
\"
Int32
\"
Name=
\"
offsets
\"
>
\n
"
;
for
(
int
i
=
0
;
i
<
nElements
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nElements
;
i
++
)
file
<<
" "
<<
(
i
+
1
)
*
vertices
<<
"
\n
"
;
}
file
<<
" </DataArray>
\n
"
;
file
<<
" <DataArray type=
\"
UInt8
\"
Name=
\"
types
\"
>
\n
"
;
...
...
@@ -119,24 +118,10 @@ namespace AMDiS {
template
<
typename
T
>
void
VtkWriter
::
writeVertexValues
(
T
&
file
,
int
componentNo
)
{
// DOFVector<int> *interpPointInd;
// DOFVector<double> *values;
// DOFVector< std::list<WorldVector<double> > > *dofCoords;
DOFVector
<
int
>
*
interpPointInd
=
(
*
dataCollector
)[
componentNo
]
->
getInterpPointInd
();
DOFVector
<
double
>
*
values
=
(
*
dataCollector
)[
componentNo
]
->
getValues
();
DOFVector
<
std
::
list
<
WorldVector
<
double
>
>
>
*
dofCoords
=
(
*
dataCollector
)[
componentNo
]
->
getDofCoords
();
/*
#ifdef _OPENMP
#pragma omp critical
#endif
{
interpPointInd = (*dataCollector)[componentNo]->getInterpPointInd();
values = (*dataCollector)[componentNo]->getValues();
dofCoords = (*dataCollector)[componentNo]->getDofCoords();
}
*/
DOFVector
<
int
>::
Iterator
intPointIt
(
interpPointInd
,
USED_DOFS
);
DOFVector
<
double
>::
Iterator
valueIt
(
values
,
USED_DOFS
);
DOFVector
<
std
::
list
<
WorldVector
<
double
>
>
>::
Iterator
coordIt
(
dofCoords
,
USED_DOFS
);
...
...
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