Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Aland, Sebastian
amdis
Commits
7acfe3ad
Commit
7acfe3ad
authored
Oct 20, 2015
by
Siqi Ling
Browse files
add write tarh
parent
96d0b4bc
Changes
7
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/io/Arh3Reader.h
View file @
7acfe3ad
...
...
@@ -25,6 +25,10 @@ namespace AMDiS { namespace io {
{
const
uint8_t
MAJOR
=
3
;
const
uint8_t
MINOR
=
0
;
const
uint8_t
PARH_MAJOR
=
1
;
const
uint8_t
PARH_MINOR
=
0
;
const
uint8_t
TARH_MAJOR
=
1
;
const
uint8_t
TARH_MINOR
=
0
;
/**
* \brief Read MeshStructure, refine the mesh and read dof values to sysVec by order.
...
...
AMDiS/src/io/FileWriter.cc
View file @
7acfe3ad
...
...
@@ -197,6 +197,20 @@ namespace AMDiS
filename
+
".pvd"
);
}
}
if
(
writeArhAnimation
)
{
#if HAVE_PARALLEL_DOMAIN_AMDIS
if
(
MPI
::
COMM_WORLD
.
Get_rank
()
==
0
)
#endif
{
Arh3Writer
::
detail
::
updateAnimationFile
(
adaptInfo
,
&
arhAnimationFrames
,
createSubDir
>
0
,
indexLength
,
indexDecimals
,
filename
+
".tarh"
);
}
}
if
(
writeDofFormat
)
{
...
...
AMDiS/src/io/FileWriter.h
View file @
7acfe3ad
...
...
@@ -83,6 +83,11 @@ namespace AMDiS {
{
return
paraviewAnimationFrames
;
}
std
::
vector
<
double
>&
getArhAnimationFrames
()
{
return
arhAnimationFrames
;
}
bool
getWriteParaViewFormat
()
const
{
...
...
@@ -177,6 +182,9 @@ namespace AMDiS {
/// write Arh2 version 3.0, prior to writeArhFormat
int
writeArh3
;
/// 0: Don't write Arh animation file; 1: Write Arh animation file.
int
writeArhAnimation
;
/// camera position for povray script files
std
::
string
povrayCameraLocation
;
...
...
@@ -191,6 +199,9 @@ namespace AMDiS {
/// Stores a set of std::pairs of timepoint and filename to write a ParaView
/// animation file.
std
::
vector
<
std
::
pair
<
double
,
std
::
string
>
>
paraviewAnimationFrames
;
/// Stores a set of timepoint to write a ParaView animation file.
std
::
vector
<
double
>
arhAnimationFrames
;
///
int
timestepNumber
;
...
...
AMDiS/src/io/FileWriter.hh
View file @
7acfe3ad
...
...
@@ -142,9 +142,11 @@ namespace AMDiS
writeArh1
=
0
;
writeArh2
=
0
;
writeArh3
=
0
;
writeArhAnimation
=
0
;
pngType
=
0
;
nTmpSolutions
=
0
;
paraviewAnimationFrames
.
resize
(
0
),
paraviewAnimationFrames
.
resize
(
0
);
arhAnimationFrames
.
resize
(
0
);
compression
=
NONE
;
readParameters
(
name
);
...
...
@@ -181,6 +183,7 @@ namespace AMDiS
Parameters
::
get
(
name
+
"->ARH1 format"
,
writeArh1
);
Parameters
::
get
(
name
+
"->ARH2 format"
,
writeArh2
);
Parameters
::
get
(
name
+
"->ARH3 format"
,
writeArh3
);
Parameters
::
get
(
name
+
"->Arh animation"
,
writeArhAnimation
);
std
::
string
compressionStr
=
""
;
Parameters
::
get
(
name
+
"->compression"
,
compressionStr
);
...
...
AMDiS/src/io/detail/Arh3Reader.cc
View file @
7acfe3ad
...
...
@@ -573,7 +573,7 @@ namespace AMDiS { namespace io {
sPos
=
file_onlyname
.
string
().
find
(
".arh"
);
string
onlynameWithoutExt
=
file_onlyname
.
string
().
substr
(
0
,
sPos
);
string
parh
=
filenameWithoutExt
+
".parh"
;
string
basedir
=
""
;
string
basedir
=
"
./
"
;
path
file_path
=
file_name
.
remove_filename
();
int
nProcs_
=
0
,
nMacros_
=
0
,
nMacros
=
0
;
...
...
@@ -583,8 +583,7 @@ namespace AMDiS { namespace io {
if
(
parhExists
)
basedir
=
readParallelFile
(
parh
,
partition
,
nProcs_
,
nMacros_
);
if
(
basedir
!=
""
)
filenameWithoutExt
=
file_path
.
string
()
+
'/'
+
basedir
+
onlynameWithoutExt
;
filenameWithoutExt
=
file_path
.
string
()
+
'/'
+
basedir
+
onlynameWithoutExt
;
if
(
nProcs
==
-
1
)
{
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
...
...
@@ -848,7 +847,7 @@ namespace AMDiS { namespace io {
string
Id
=
fd
.
substr
(
0
,
4
);
int
major
=
boost
::
lexical_cast
<
int
>
(
fd
.
substr
(
5
,
1
));
int
minor
=
boost
::
lexical_cast
<
int
>
(
fd
.
substr
(
7
,
1
));
firstRead
(
Id
,
major
,
minor
,
"parh"
,
1
,
0
);
firstRead
(
Id
,
major
,
minor
,
"parh"
,
PARH_MAJOR
,
PARH_MINOR
);
uint32_t
baseDirLen
=
0
,
macroFile_nl
=
0
;
string
baseDir
,
macroFilename
;
...
...
AMDiS/src/io/detail/Arh3Writer.cc
View file @
7acfe3ad
...
...
@@ -10,7 +10,9 @@
#include
"DOFVector.h"
#include
"../Arh3Reader.h"
#include
<boost/iostreams/filtering_stream.hpp>
#include
<boost/iostreams/filtering_streambuf.hpp>
#include
<boost/iostreams/device/file_descriptor.hpp>
#include
<boost/iostreams/copy.hpp>
#ifdef HAVE_COMPRESSION
#include
<boost/iostreams/filter/zlib.hpp>
...
...
@@ -44,6 +46,55 @@ namespace AMDiS { namespace io {
write
(
filename
,
NULL
,
vecs
,
writeParallel
,
cps
,
dataformat
,
writeMacro
);
}
void
updateAnimationFile
(
AdaptInfo
*
adaptInfo
,
std
::
vector
<
double
>*
arhAnimationFrames
,
bool
createSubDir
,
int
indexLength
,
int
indexDecimals
,
std
::
string
animationFilename
)
{
FUNCNAME
(
"updateAnimationFile()"
);
arhAnimationFrames
->
push_back
(
adaptInfo
->
getTime
());
boost
::
iostreams
::
filtering_ostream
file
;
{
ofstream
swapfile
(
animationFilename
.
c_str
(),
ios
::
out
|
ios
::
trunc
|
ios
::
binary
);
TEST_EXIT
(
swapfile
.
is_open
())
(
"Cannot open file %s for writing!
\n
"
,
animationFilename
.
c_str
());
swapfile
.
close
();
}
file
.
push
(
boost
::
iostreams
::
file_descriptor_sink
(
animationFilename
,
ios
::
trunc
|
ios
::
binary
));
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
string
typeId
=
"tparh"
;
#else
string
typeId
=
"tarh"
;
#endif
string
baseDir
=
createSubDir
?
"./data/"
:
"./"
;
uint32_t
baseDirLen
=
baseDir
.
length
();
int
major
=
AMDiS
::
io
::
Arh3Reader
::
TARH_MAJOR
;
int
minor
=
AMDiS
::
io
::
Arh3Reader
::
TARH_MINOR
;
typeId
+=
'_'
+
boost
::
lexical_cast
<
string
>
(
major
)
+
'.'
+
boost
::
lexical_cast
<
string
>
(
minor
);
if
(
typeId
.
length
()
<=
16
)
{
// 16 is the Id size
string
rest
(
16
-
typeId
.
length
(),
' '
);
typeId
.
append
(
rest
);
}
uint32_t
indexLength_
=
indexLength
;
uint32_t
indexDecimals_
=
indexDecimals
;
file
.
write
(
typeId
.
c_str
(),
16
);
file
.
write
(
reinterpret_cast
<
char
*>
(
&
baseDirLen
),
4
);
file
.
write
(
baseDir
.
c_str
(),
baseDirLen
);
file
.
write
(
reinterpret_cast
<
char
*>
(
&
indexLength_
),
4
);
file
.
write
(
reinterpret_cast
<
char
*>
(
&
indexDecimals_
),
4
);
for
(
size_t
i
=
0
;
i
<
arhAnimationFrames
->
size
();
i
++
)
file
.
write
(
reinterpret_cast
<
char
*>
(
&
arhAnimationFrames
[
i
]),
8
);
}
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
void
writeParallelFile
(
string
filename
,
Mesh
*
mesh
,
bool
createSubDir
,
bool
writeMacro
)
...
...
@@ -52,13 +103,14 @@ namespace AMDiS { namespace io {
file
.
open
(
filename
.
c_str
(),
ios
::
out
|
ios
::
binary
|
ios
::
trunc
);
string
typeId
=
"parh"
,
macroFilename
=
""
,
perFilename
=
""
;
string
baseDir
=
createSubDir
?
"./data/"
:
""
;
string
baseDir
=
createSubDir
?
"./data/"
:
"
./
"
;
string
macroData
=
""
,
periodicData
=
""
;
uint32_t
baseDirLen
=
baseDir
.
length
();
Parameters
::
get
(
mesh
->
getName
()
+
"->macro file name"
,
macroFilename
);
Parameters
::
get
(
mesh
->
getName
()
+
"->periodic file"
,
perFilename
);
int
major
=
1
,
minor
=
0
;
int
major
=
AMDiS
::
io
::
Arh3Reader
::
PARH_MAJOR
;
int
minor
=
AMDiS
::
io
::
Arh3Reader
::
PARH_MINOR
;
uint32_t
nFiles
=
MPI
::
COMM_WORLD
.
Get_size
();
uint32_t
macroFile_nl
=
0
;
map
<
int
,
int
>
partitionMap
=
...
...
AMDiS/src/io/detail/Arh3Writer.h
View file @
7acfe3ad
...
...
@@ -6,6 +6,7 @@
#include
"MeshStructure.h"
#include
"DOFVector.h"
#include
"SystemVector.h"
#include
"AdaptInfo.h"
#include
"boost/assign.hpp"
namespace
AMDiS
{
namespace
io
{
...
...
@@ -111,6 +112,13 @@ namespace AMDiS { namespace io {
void
readFileToString
(
std
::
string
filename
,
std
::
string
&
data
);
void
updateAnimationFile
(
AdaptInfo
*
adaptInfo
,
std
::
vector
<
double
>*
arhAnimationFrames
,
bool
createSubDir
,
int
indexLength
,
int
indexDecimals
,
std
::
string
animationFilename
);
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
void
writeParallelFile
(
std
::
string
filename
,
Mesh
*
mesh
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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