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
aeadcd83
Commit
aeadcd83
authored
Feb 01, 2014
by
Siqi Ling
Browse files
fix arh2file version backward compatibility problem
parent
81146d61
Changes
4
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/io/Arh2Reader.h
View file @
aeadcd83
...
...
@@ -24,7 +24,7 @@ namespace AMDiS { namespace io {
namespace
Arh2Reader
{
const
uint8_t
MAJOR
=
2
;
const
uint8_t
MINOR
=
0
;
const
uint8_t
MINOR
=
1
;
/**
* \brief Read MeshStructure, refine the mesh and read dof values to sysVec by order.
...
...
AMDiS/src/io/Arh2Writer.h
View file @
aeadcd83
...
...
@@ -16,7 +16,7 @@ namespace AMDiS { namespace io {
namespace
Arh2Writer
{
const
uint8_t
MAJOR
=
2
;
const
uint8_t
MINOR
=
0
;
const
uint8_t
MINOR
=
1
;
/**
* \brief write the meshstructure and the dof values of DOFVectors in sysVec
...
...
AMDiS/src/io/detail/Arh2Reader.cc
View file @
aeadcd83
...
...
@@ -22,7 +22,7 @@ namespace AMDiS { namespace io {
namespace
detail
{
void
firstRead
(
ifstream
&
file
)
uint8_t
firstRead
(
ifstream
&
file
)
{
FUNCNAME
(
"Arh2Reader::detail::firstRead"
);
...
...
@@ -42,6 +42,7 @@ namespace AMDiS { namespace io {
TEST_EXIT
(
minor
<=
AMDiS
::
io
::
Arh2Reader
::
MINOR
)
(
"Cannot read Arh2 format: Arh2Reader minor version is %i is smaller than the file minor version %i.
\n
"
,
AMDiS
::
io
::
Arh2Reader
::
MINOR
,
minor
);
return
minor
;
}
void
setDofValues
(
int
macroElIndex
,
Mesh
*
mesh
,
...
...
@@ -215,8 +216,12 @@ namespace AMDiS { namespace io {
file
.
open
(
filename
.
c_str
(),
ios
::
in
|
ios
::
binary
);
TEST_EXIT
(
file
.
is_open
())
(
"Cannot open file %s
\n
"
,
filename
.
c_str
());
file
.
seekg
(
0
,
file
.
end
);
int
fileSize
=
file
.
tellg
();
file
.
seekg
(
0
,
file
.
beg
);
string
cps
(
4
,
' '
)
;
string
cps
=
"null"
;
uint32_t
headerLen
=
0
;
uint32_t
nMacroElements
=
0
;
uint32_t
nValueVectors
=
0
;
...
...
@@ -224,7 +229,7 @@ namespace AMDiS { namespace io {
uint32_t
dim
=
0
,
dow
=
0
;
// Read fixed header
firstRead
(
file
);
uint8_t
minor
=
firstRead
(
file
);
file
.
read
(
reinterpret_cast
<
char
*>
(
&
headerLen
),
4
);
file
.
read
(
reinterpret_cast
<
char
*>
(
&
dow
),
4
);
...
...
@@ -232,7 +237,9 @@ namespace AMDiS { namespace io {
file
.
read
(
reinterpret_cast
<
char
*>
(
&
nFeSpaces
),
4
);
file
.
read
(
reinterpret_cast
<
char
*>
(
&
nValueVectors
),
4
);
file
.
read
(
reinterpret_cast
<
char
*>
(
&
nMacroElements
),
4
);
file
.
read
(
const_cast
<
char
*>
(
cps
.
data
()),
4
);
if
(
minor
>=
1
)
file
.
read
(
const_cast
<
char
*>
(
cps
.
data
()),
4
);
#ifdef HAVE_COMPRESSION
TEST_EXIT
(
cps
==
"null"
||
cps
==
"zlib"
)
...
...
@@ -351,11 +358,14 @@ namespace AMDiS { namespace io {
}
}
}
// Read data: meshstructure and dof values
for
(
unsigned
int
i
=
0
;
i
<
nMacroElements
;
i
++
)
{
stringstream
dataStream
(
ios
::
out
|
ios
::
in
|
ios
::
binary
);
int
size
=
macroElSize
[
i
];
int
size
=
0
;
if
(
minor
>=
1
)
size
=
macroElSize
[
i
];
else
size
=
(
i
!=
nMacroElements
-
1
)
?
macroElSize
[
i
+
1
]
-
macroElSize
[
i
]
:
fileSize
-
macroElSize
[
i
];
char
*
buffer
=
new
char
[
size
];
file
.
read
(
buffer
,
size
);
dataStream
.
write
(
buffer
,
size
);
...
...
@@ -391,6 +401,7 @@ namespace AMDiS { namespace io {
{
uint32_t
nValuesPerVector
=
0
;
dataStream
.
read
(
reinterpret_cast
<
char
*>
(
&
nValuesPerVector
),
4
);
for
(
size_t
k
=
0
;
k
<
sortedFeSpaces
[
j
].
size
();
k
++
)
{
values
[
valuePos
+
k
].
resize
(
nValuesPerVector
);
...
...
@@ -448,7 +459,6 @@ namespace AMDiS { namespace io {
WARNING
(
"You haven't specified the target, no mesh or DOFVectors is given.
\n
"
);
return
;
}
if
(
writeParallel
)
{
using
boost
::
lexical_cast
;
int
sPos
=
filename
.
find
(
".arh"
);
...
...
AMDiS/src/io/detail/Arh2Reader.h
View file @
aeadcd83
...
...
@@ -21,8 +21,9 @@ namespace AMDiS { namespace io {
* 1. the type of file is equal to "arh2".
* 2. the major version of Arh2Reader is equal to the one in the file.
* 3. the minor version of Arh2Reader is bigger than the one in the file.
* return value: minor version
*/
void
firstRead
(
std
::
ifstream
&
file
);
uint8_t
firstRead
(
std
::
ifstream
&
file
);
void
setDofValues
(
int
macroElIndex
,
Mesh
*
mesh
,
std
::
vector
<
std
::
vector
<
double
>
>&
values
,
...
...
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