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
7db0b6df
Commit
7db0b6df
authored
Nov 06, 2012
by
Thomas Witkowski
Browse files
Work on ARH read and writer.
parent
edc55c09
Changes
5
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/Debug.cc
View file @
7db0b6df
...
@@ -111,6 +111,24 @@ namespace AMDiS {
...
@@ -111,6 +111,24 @@ namespace AMDiS {
}
}
void
writeMacroElementIndexMesh
(
Mesh
*
mesh
,
std
::
string
filename
)
{
std
::
map
<
int
,
double
>
vec
;
TraverseStack
stack
;
ElInfo
*
elInfo
=
stack
.
traverseFirst
(
mesh
,
-
1
,
Mesh
::
CALL_LEAF_EL
);
while
(
elInfo
)
{
int
index
=
elInfo
->
getElement
()
->
getIndex
();
int
macroIndex
=
elInfo
->
getMacroElement
()
->
getIndex
();
vec
[
index
]
=
macroIndex
;
elInfo
=
stack
.
traverseNext
(
elInfo
);
}
ElementFileWriter
::
writeFile
(
vec
,
mesh
,
filename
,
".vtu"
);
}
void
highlightElementIndexMesh
(
Mesh
*
mesh
,
int
idx
,
std
::
string
filename
)
void
highlightElementIndexMesh
(
Mesh
*
mesh
,
int
idx
,
std
::
string
filename
)
{
{
std
::
map
<
int
,
double
>
vec
;
std
::
map
<
int
,
double
>
vec
;
...
...
AMDiS/src/Debug.h
View file @
7db0b6df
...
@@ -93,6 +93,16 @@ namespace AMDiS {
...
@@ -93,6 +93,16 @@ namespace AMDiS {
std
::
string
filename
,
std
::
string
filename
,
int
level
=
-
1
);
int
level
=
-
1
);
/** \brief
* Creates a vtu file where all elements in the mesh are colored by the
* macro element indices.
*
* \param[in] feSpace The FE space to be used.
* \param[in] filename Name of the file.
*/
void
writeMacroElementIndexMesh
(
Mesh
*
mesh
,
std
::
string
filename
);
void
highlightElementIndexMesh
(
Mesh
*
mesh
,
int
idx
,
std
::
string
filename
);
void
highlightElementIndexMesh
(
Mesh
*
mesh
,
int
idx
,
std
::
string
filename
);
void
colorMeshByMacroIndex
(
Mesh
*
mesh
,
std
::
string
filename
);
void
colorMeshByMacroIndex
(
Mesh
*
mesh
,
std
::
string
filename
);
...
...
AMDiS/src/io/ArhReader.cc
View file @
7db0b6df
...
@@ -12,12 +12,14 @@
...
@@ -12,12 +12,14 @@
#include
<fstream>
#include
<fstream>
#include
<stdint.h>
#include
<stdint.h>
#include
<boost/filesystem.hpp>
#include
"ArhReader.h"
#include
"ArhReader.h"
#include
"Mesh.h"
#include
"Mesh.h"
#include
"MeshStructure.h"
#include
"MeshStructure.h"
#include
"Traverse.h"
#include
"Traverse.h"
#include
"DOFVector.h"
#include
"DOFVector.h"
#include
"Debug.h"
namespace
AMDiS
{
namespace
AMDiS
{
...
@@ -76,6 +78,85 @@ namespace AMDiS {
...
@@ -76,6 +78,85 @@ namespace AMDiS {
}
}
void
ArhReader
::
readMeta
(
string
filename
,
Mesh
*
mesh
,
DOFVector
<
double
>*
vec0
,
DOFVector
<
double
>*
vec1
,
DOFVector
<
double
>*
vec2
)
{
vector
<
DOFVector
<
double
>*>
vecs
;
if
(
vec0
)
vecs
.
push_back
(
vec0
);
if
(
vec1
)
vecs
.
push_back
(
vec1
);
if
(
vec2
)
vecs
.
push_back
(
vec2
);
readMeta
(
filename
,
mesh
,
vecs
);
}
void
ArhReader
::
readMeta
(
string
filename
,
Mesh
*
mesh
,
vector
<
DOFVector
<
double
>*>
vecs
)
{
FUNCNAME
(
"ArhReader::readMeta()"
);
boost
::
filesystem
::
path
p
(
filename
.
c_str
());
boost
::
filesystem
::
path
directory
=
p
.
parent_path
();
ifstream
file
;
file
.
open
(
filename
.
c_str
());
TEST_EXIT
(
file
.
is_open
())
(
"Cannot open arh meta file
\"
%s
\"\n
"
,
filename
.
c_str
());
string
readStr
=
""
;
file
>>
readStr
;
string
arhPrefix
=
""
;
file
>>
arhPrefix
;
int
nProc
;
file
>>
nProc
;
// Maps to each macro element index the arh file index it is stored in.
map
<
int
,
int
>
macroInProc
;
for
(
int
i
=
0
;
i
<
nProc
;
i
++
)
{
int
tmp
;
file
>>
tmp
;
TEST_EXIT
(
tmp
==
i
)(
"Should not happen!
\n
"
);
int
nMacroEl
;
file
>>
nMacroEl
;
for
(
int
j
=
0
;
j
<
nMacroEl
;
j
++
)
{
int
elIndex
;
file
>>
elIndex
;
macroInProc
[
elIndex
]
=
i
;
}
}
file
.
close
();
// Set of all file indices which should be read to restore all macro elements.
std
::
set
<
int
>
readArhFiles
;
TraverseStack
stack
;
ElInfo
*
elInfo
=
stack
.
traverseFirst
(
mesh
,
0
,
Mesh
::
CALL_EL_LEVEL
);
while
(
elInfo
)
{
int
macroElIndex
=
elInfo
->
getElement
()
->
getIndex
();
TEST_EXIT
(
macroInProc
.
count
(
macroElIndex
))(
"Should not happen!
\n
"
);
readArhFiles
.
insert
(
macroInProc
[
macroElIndex
]);
elInfo
=
stack
.
traverseNext
(
elInfo
);
}
for
(
std
::
set
<
int
>::
iterator
it
=
readArhFiles
.
begin
();
it
!=
readArhFiles
.
end
();
++
it
)
{
string
arhFilename
=
directory
.
native
()
+
"/"
+
arhPrefix
+
"-p"
+
boost
::
lexical_cast
<
string
>
(
*
it
)
+
"-.arh"
;
MSG
(
"READ FILE: %s
\n
"
,
arhFilename
.
c_str
());
readFile
(
arhFilename
,
mesh
,
vecs
);
}
}
void
ArhReader
::
readFile
(
string
filename
,
void
ArhReader
::
readFile
(
string
filename
,
Mesh
*
mesh
,
Mesh
*
mesh
,
vector
<
DOFVector
<
double
>*>
vecs
)
vector
<
DOFVector
<
double
>*>
vecs
)
...
@@ -135,8 +216,16 @@ namespace AMDiS {
...
@@ -135,8 +216,16 @@ namespace AMDiS {
MeshStructure
elementStructure
;
MeshStructure
elementStructure
;
elementStructure
.
init
(
structureCode
,
codeSize
);
elementStructure
.
init
(
structureCode
,
codeSize
);
if
(
macroInMesh
.
count
(
elIndex
)
==
1
)
if
(
macroInMesh
.
count
(
elIndex
))
{
MSG
(
"READ MACRO EL %d
\n
"
,
elIndex
);
if
(
MPI
::
COMM_WORLD
.
Get_rank
()
==
52
&&
elIndex
==
19777
)
{
debug
::
writeMacroElementIndexMesh
(
mesh
,
"test"
);
}
elementStructure
.
fitMeshToStructure
(
mesh
,
refManager
,
false
,
elIndex
);
elementStructure
.
fitMeshToStructure
(
mesh
,
refManager
,
false
,
elIndex
);
}
if
(
nValueVectors
>
0
)
{
if
(
nValueVectors
>
0
)
{
uint32_t
nValuesPerVector
=
0
;
uint32_t
nValuesPerVector
=
0
;
...
@@ -146,7 +235,7 @@ namespace AMDiS {
...
@@ -146,7 +235,7 @@ namespace AMDiS {
vector
<
double
>
values
(
nValuesPerVector
);
vector
<
double
>
values
(
nValuesPerVector
);
file
.
read
(
reinterpret_cast
<
char
*>
(
&
(
values
[
0
])),
8
*
nValuesPerVector
);
file
.
read
(
reinterpret_cast
<
char
*>
(
&
(
values
[
0
])),
8
*
nValuesPerVector
);
if
(
vecs
[
j
]
!=
NULL
)
{
if
(
vecs
[
j
]
!=
NULL
)
{
if
(
macroInMesh
.
count
(
elIndex
)
==
1
)
if
(
macroInMesh
.
count
(
elIndex
))
setDofValues
(
elIndex
,
mesh
,
values
,
vecs
[
j
]);
setDofValues
(
elIndex
,
mesh
,
values
,
vecs
[
j
]);
}
}
}
}
...
...
AMDiS/src/io/ArhReader.h
View file @
7db0b6df
...
@@ -32,7 +32,8 @@ namespace AMDiS {
...
@@ -32,7 +32,8 @@ namespace AMDiS {
class
ArhReader
class
ArhReader
{
{
public:
public:
static
void
read
(
string
filename
,
Mesh
*
mesh
,
static
void
read
(
string
filename
,
Mesh
*
mesh
,
DOFVector
<
double
>*
vec0
=
NULL
,
DOFVector
<
double
>*
vec0
=
NULL
,
DOFVector
<
double
>*
vec1
=
NULL
,
DOFVector
<
double
>*
vec1
=
NULL
,
DOFVector
<
double
>*
vec2
=
NULL
,
DOFVector
<
double
>*
vec2
=
NULL
,
...
@@ -43,7 +44,8 @@ namespace AMDiS {
...
@@ -43,7 +44,8 @@ namespace AMDiS {
#endif
#endif
int
nProcs
=
-
1
);
int
nProcs
=
-
1
);
static
void
read
(
string
filename
,
Mesh
*
mesh
,
static
void
read
(
string
filename
,
Mesh
*
mesh
,
vector
<
DOFVector
<
double
>*>
vecs
,
vector
<
DOFVector
<
double
>*>
vecs
,
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
bool
writeParallel
=
true
,
bool
writeParallel
=
true
,
...
@@ -52,6 +54,16 @@ namespace AMDiS {
...
@@ -52,6 +54,16 @@ namespace AMDiS {
#endif
#endif
int
nProcs
=
-
1
);
int
nProcs
=
-
1
);
static
void
readMeta
(
string
filename
,
Mesh
*
mesh
,
DOFVector
<
double
>*
vec0
=
NULL
,
DOFVector
<
double
>*
vec1
=
NULL
,
DOFVector
<
double
>*
vec2
=
NULL
);
static
void
readMeta
(
string
filename
,
Mesh
*
mesh
,
vector
<
DOFVector
<
double
>*>
vecs
);
static
void
readFromMemoryBlock
(
vector
<
char
>
&
data
,
Mesh
*
mesh
,
static
void
readFromMemoryBlock
(
vector
<
char
>
&
data
,
Mesh
*
mesh
,
DOFVector
<
double
>*
vec0
=
NULL
,
DOFVector
<
double
>*
vec0
=
NULL
,
DOFVector
<
double
>*
vec1
=
NULL
,
DOFVector
<
double
>*
vec1
=
NULL
,
...
...
AMDiS/src/io/ArhWriter.cc
View file @
7db0b6df
...
@@ -131,7 +131,6 @@ namespace AMDiS {
...
@@ -131,7 +131,6 @@ namespace AMDiS {
{
{
FUNCNAME
(
"ArhWriter::writeMacroElement()"
);
FUNCNAME
(
"ArhWriter::writeMacroElement()"
);
MSG
(
"WRITE INDEX: %d
\n
"
,
elIndex
);
file
.
write
(
reinterpret_cast
<
char
*>
(
&
elIndex
),
4
);
file
.
write
(
reinterpret_cast
<
char
*>
(
&
elIndex
),
4
);
uint32_t
nStructureCodes
=
code
.
getCode
().
size
();
uint32_t
nStructureCodes
=
code
.
getCode
().
size
();
...
...
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