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
Backofen, Rainer
amdis
Commits
a9897bbf
Commit
a9897bbf
authored
Apr 15, 2009
by
Thomas Witkowski
Browse files
* And now, real code to write pngs!
parent
c8ee0e76
Changes
12
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/BasisFunction.h
View file @
a9897bbf
...
...
@@ -362,9 +362,7 @@ namespace AMDiS {
virtual
void
coarseRestr
(
DOFVector
<
WorldVector
<
double
>
>*
,
RCNeighbourList
*
,
int
)
{}
/** \brief
* Returns local dof indices of the element for the given fe space.
*/
/// Returns local dof indices of the element for the given fe space.
virtual
const
DegreeOfFreedom
*
getLocalIndices
(
const
Element
*
,
const
DOFAdmin
*
,
DegreeOfFreedom
*
)
const
...
...
@@ -372,9 +370,7 @@ namespace AMDiS {
return
NULL
;
}
/** \brief
* Returns local dof indices of the element for the given fe space.
*/
/// Returns local dof indices of the element for the given fe space.
virtual
void
getLocalIndicesVec
(
const
Element
*
,
const
DOFAdmin
*
,
Vector
<
DegreeOfFreedom
>*
)
const
...
...
AMDiS/src/DOFMatrix.cc
View file @
a9897bbf
#include
"DOFMatrix.h"
#include
<algorithm>
#include
<png.h>
#include
"DOFMatrix.h"
#include
"QPsiPhi.h"
#include
"BasisFunction.h"
#include
"Boundary.h"
...
...
@@ -754,7 +755,8 @@ namespace AMDiS {
void
DOFMatrix
::
createPictureFile
(
const
char
*
filename
,
int
dim
)
{
png_structp
png_ptr
=
png_create_write_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
png_structp
png_ptr
=
png_create_write_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
if
(
!
png_ptr
)
return
;
...
...
@@ -763,9 +765,8 @@ namespace AMDiS {
for
(
int
i
=
0
;
i
<
dim
;
i
++
)
{
rowPointers
[
i
]
=
(
png_byte
*
)
png_malloc
(
png_ptr
,
dim
);
for
(
int
j
=
0
;
j
<
dim
;
j
++
)
{
for
(
int
j
=
0
;
j
<
dim
;
j
++
)
rowPointers
[
i
][
j
]
=
255
;
}
}
double
scalFactor
=
static_cast
<
double
>
(
dim
)
/
static_cast
<
double
>
(
matrix
.
size
());
...
...
AMDiS/src/DataCollector.h
View file @
a9897bbf
...
...
@@ -42,17 +42,14 @@ namespace AMDiS {
* \ingroup Output
*
* \brief
* Provides data collecting of element, vertex and value data
* for file writers.
* Provides data collecting of element, vertex and value data for file writer.
*/
class
DataCollector
{
public:
MEMORY_MANAGED
(
DataCollector
);
/** \brief
* Constructor.
*/
/// Constructor
DataCollector
(
const
FiniteElemSpace
*
feSpace
,
DOFVector
<
double
>
*
values
,
int
level
=
-
1
,
...
...
@@ -61,156 +58,96 @@ namespace AMDiS {
~
DataCollector
();
/** \brief
* Fills the DataCollector with all possible datas.
*/
/// Fills the DataCollector with all possible datas.
void
fillAllData
();
/** \brief
* Returns list with element information.
*/
/// Returns list with element information.
std
::
list
<
ElementInfo
>*
getElementInfos
();
/** \brief
* Returns vector with vertex information.
*/
/// Returns vector with vertex information.
DOFVector
<
std
::
list
<
VertexInfo
>
>*
getVertexInfos
();
/** \brief
* Returns the finite element space of the problem.
*/
/// Returns the finite element space of the problem.
const
FiniteElemSpace
*
getFeSpace
();
/** \brief
* Returns vector with value information.
*/
/// Returns vector with value information.
DOFVector
<
double
>*
getValues
();
/** \brief
* Returns vector with information about dof coordinates.
*/
/// Returns vector with information about dof coordinates.
DOFVector
<
std
::
list
<
WorldVector
<
double
>
>
>*
getDofCoords
();
/** \brief
* Returns vector with information about interpolation
* point indexing.
*/
/// Returns vector with information about interpolation point indexing.
DOFVector
<
int
>*
getInterpPointInd
();
/** \brief
*
*/
///
DOFVector
<
std
::
list
<
WorldVector
<
double
>
>
>*
getInterpPointCoords
();
/** \brief
* Returns list of interpolation point information.
*/
/// Returns list of interpolation point information.
std
::
vector
<
std
::
vector
<
int
>
>*
getInterpPoints
();
/** \brief
* Returns list of information about periodics.
*/
/// Returns list of information about periodics.
std
::
list
<
PeriodicInfo
>*
getPeriodicInfos
();
/** \brief
* Returns the number of vertices.
*/
/// Returns the number of vertices.
int
getNumberVertices
();
/** \brief
* Returns the number of elements.
*/
/// Returns the number of elements.
int
getNumberElements
();
/** \brief
* Returns the number of interpolation points.
*/
/// Returns the number of interpolation points.
int
getNumberInterpPoints
();
/** \brief
* Returns the number of connections.
*/
// Returns the number of connections.
int
getNumberConnections
();
/** \brief
* Returns the mesh of the problem.
*/
/// Returns the mesh of the problem.
Mesh
*
getMesh
();
void
setMesh
(
Mesh
*
mesh
)
{
mesh_
=
mesh
;
}
;
}
protected:
/** \brief
* Start collecting element and vertex data of the problem.
*/
/// Start collecting element and vertex data of the problem.
int
startCollectingElementData
();
/** \brief
* Start collecting value data of the problem.
*/
/// Start collecting value data of the problem.
int
startCollectingValueData
();
/** \brief
* Start collecting periodic data of the problem.
*/
/// Start collecting periodic data of the problem.
int
startCollectingPeriodicData
();
/** \brief
* Adds information about one element and its vertices.
*/
/// Adds information about one element and its vertices.
int
addElementData
(
ElInfo
*
elInfo
);
/** \brief
* Adds value information of one element.
*/
/// Adds value information of one element.
int
addValueData
(
ElInfo
*
elInfo
);
/** \brief
* Adds information about interpolation points of vertices.
*/
/// Adds information about interpolation points of vertices.
int
addInterpData
(
ElInfo
*
elInfo
);
/** \brief
* Adds value information of one element.
*/
/// Adds value information of one element.
int
addPeriodicData
(
ElInfo
*
elInfo
);
/** \brief
* Vector with vertex values
*/
/// Vector with vertex values
DOFVector
<
double
>
*
values_
;
/** \brief
* Level information for traversing the mesh.
*/
/// Level information for traversing the mesh.
int
level_
;
/** \brief
* Flags for traversing the mesh.
*/
/// Flags for traversing the mesh.
Flag
traverseFlag_
;
/** \brief
*
*/
///
const
FiniteElemSpace
*
feSpace_
;
/** \brief
* Mesh that should be written
*/
/// Mesh that should be written
Mesh
*
mesh_
;
/** \brief
* DOFAdmin of values
*/
/// DOFAdmin of values
DOFAdmin
*
localAdmin_
;
/** \brief
* vertex pre-dofs
*/
/// vertex pre-dofs
int
nPreDofs_
;
/// Number of vertices.
...
...
AMDiS/src/ElInfo.h
View file @
a9897bbf
...
...
@@ -101,57 +101,42 @@ namespace AMDiS {
return
*
this
;
}
// ===== getting-methods ======================================================
public:
/** \name getting methods
* \{
*/
/** \brief
* Get ElInfo's \ref mesh_
*/
/// Get ElInfo's \ref mesh_
inline
Mesh
*
getMesh
()
const
{
return
mesh_
;
}
/** \brief
* Get ElInfo's \ref macroElement_
*/
/// Get ElInfo's \ref macroElement_
inline
MacroElement
*
getMacroElement
()
const
{
return
macroElement_
;
}
/** \brief
* Get ElInfo's \ref element
*/
/// Get ElInfo's \ref element
inline
Element
*
getElement
()
const
{
return
element_
;
}
/** \brief
* Get ElInfo's \ref parent_
*/
/// Get ElInfo's \ref parent_
inline
Element
*
getParent
()
const
{
return
parent_
;
}
/** \brief
* Get ElInfo's \ref fillFlag_
*/
/// Get ElInfo's \ref fillFlag_
inline
Flag
getFillFlag
()
const
{
return
fillFlag_
;
}
/** \brief
* Get ElInfo's \ref level
*/
/// Get ElInfo's \ref level
inline
int
getLevel
()
const
{
return
level
;
}
/** \brief
* Get ElInfo's \ref iChild
*/
/// Get ElInfo's \ref iChild
inline
int
getIChild
()
const
{
return
iChild
;
}
...
...
@@ -188,12 +173,10 @@ namespace AMDiS {
return
coord_
;
}
/** \brief
* Get ElInfo's \ref oppCoord_[i]
*/
/// Get ElInfo's \ref oppCoord_[i]
inline
WorldVector
<
double
>&
getOppCoord
(
int
i
)
{
return
oppCoord_
[
i
];
}
;
}
/** \brief
* Get ElInfo's \ref boundary_[i]
...
...
@@ -466,20 +449,13 @@ namespace AMDiS {
int
iChild
)
const
=
0
;
protected:
/** \brief
* Pointer to the current mesh
*/
/// Pointer to the current mesh
Mesh
*
mesh_
;
/** \brief
* Pointer to the current element
*/
/// Pointer to the current element
Element
*
element_
;
/** \brief
* \ref element is child of element parent_
*/
/// \ref element is child of element parent_
Element
*
parent_
;
/** \brief
...
...
AMDiS/src/ElementMatrix.h
View file @
a9897bbf
...
...
@@ -27,10 +27,6 @@
namespace
AMDiS
{
// =============================================================================
// ===== class ElementMatrix ===================================================
// =============================================================================
/** \ingroup Assembler
*
* \brief
...
...
@@ -42,24 +38,18 @@ namespace AMDiS {
public:
MEMORY_MANAGED
(
ElementMatrix
);
/** \brief
* Constructor.
*/
/// Constructor
ElementMatrix
(
int
numRows
,
int
numCols
)
:
Matrix
<
double
>
(
numRows
,
numCols
),
rowIndices
(
numRows
),
colIndices
(
numCols
)
{}
;
{}
public:
/** \brief
* row dof indices.
*/
/// Row dof indices.
Vector
<
DegreeOfFreedom
>
rowIndices
;
/** \brief
* column dof indices.
*/
/// Column dof indices.
Vector
<
DegreeOfFreedom
>
colIndices
;
};
...
...
AMDiS/src/FileWriter.cc
View file @
a9897bbf
...
...
@@ -108,6 +108,7 @@ namespace AMDiS {
writeParaViewAnimation
=
0
;
writePeriodicFormat
=
0
;
writePngFormat
=
0
;
pngType
=
0
;
appendIndex
=
0
;
indexLength
=
5
;
indexDecimals
=
3
;
...
...
@@ -135,6 +136,7 @@ namespace AMDiS {
GET_PARAMETER
(
0
,
name
+
"->Periodic format"
,
"%d"
,
&
writePeriodicFormat
);
GET_PARAMETER
(
0
,
name
+
"->Periodic ext"
,
&
periodicFileExt
);
GET_PARAMETER
(
0
,
name
+
"->PNG format"
,
"%d"
,
&
writePngFormat
);
GET_PARAMETER
(
0
,
name
+
"->PNG type"
,
"%d"
,
&
pngType
);
GET_PARAMETER
(
0
,
name
+
"->append index"
,
"%d"
,
&
appendIndex
);
GET_PARAMETER
(
0
,
name
+
"->index length"
,
"%d"
,
&
indexLength
);
GET_PARAMETER
(
0
,
name
+
"->index decimals"
,
"%d"
,
&
indexDecimals
);
...
...
@@ -233,14 +235,14 @@ namespace AMDiS {
VtkWriter
vtkWriter
(
&
dataCollectors
);
vtkWriter
.
updateAnimationFile
(
fn
+
paraViewFileExt
,
&
paraViewAnimationFrames_
,
const_cast
<
char
*>
((
filename
+
".pvd"
)
.
c_str
()))
;
filename
+
".pvd"
);
}
if
(
writePngFormat
)
{
PngWriter
pngWriter
(
dataCollectors
[
0
]);
pngWriter
.
writeFile
(
const_cast
<
char
*>
((
fn
+
paraViewFileExt
).
c_str
())
);
pngWriter
.
writeFile
(
fn
+
".png"
,
pngType
);
MSG
(
"PNG image file written to %s
\n
"
,
(
fn
+
paraViewFileExt
).
c_str
());
MSG
(
"PNG image file written to %s
\n
"
,
(
fn
+
".png"
).
c_str
());
}
...
...
AMDiS/src/FileWriter.h
View file @
a9897bbf
...
...
@@ -184,6 +184,9 @@ namespace AMDiS {
/// 0: Don't write png files; 1: Write png image files.
int
writePngFormat
;
/// 0: Gray color picture; 1: RGB picture.
int
pngType
;
/** \brief
* 0: Don't append time index to filename prefix.
* 1: Append time index to filename prefix.
...
...
AMDiS/src/FiniteElemSpace.h
View file @
a9897bbf
...
...
@@ -32,10 +32,6 @@
namespace
AMDiS
{
// ============================================================================
// ===== forward declarations =================================================
// ============================================================================
class
DOFAdmin
;
class
BasisFunction
;
class
Mesh
;
...
...
@@ -43,29 +39,19 @@ namespace AMDiS {
template
<
typename
T
>
class
DOFVector
;
template
<
typename
T
>
class
DimVec
;
// ============================================================================
// ===== class FiniteElemSpace ================================================
// ============================================================================
/** \ingroup FEMSpace
* \brief
* A FiniteElemSpace is a triple of a DOFAdmin and a set of BasisFunction on a
* Mesh.
* A FiniteElemSpace is a triple of a DOFAdmin and a set of BasisFunction on a mesh.
*/
class
FiniteElemSpace
{
public:
MEMORY_MANAGED
(
FiniteElemSpace
);
/** \brief
* Create an empty fe space.
*/
/// Create an empty fe space.
FiniteElemSpace
();
/** \brief
*
*/
///
static
FiniteElemSpace
*
provideFESpace
(
DOFAdmin
*
admin
,
const
BasisFunction
*
basFcts
,
Mesh
*
mesh
,
...
...
@@ -116,29 +102,19 @@ namespace AMDiS {
const
std
::
string
&
name
=
""
);
protected:
/** \brief
* Name of this FiniteElemSpace
*/
/// Name of this FiniteElemSpace.
const
std
::
string
name
;
/** \brief
* DOFAdmin corresponding to this FiniteElemSpace
*/
/// DOFAdmin corresponding to this FiniteElemSpace.
DOFAdmin
*
admin
;
/** \brief
* set of BasisFunction of this FiniteElemSpace
*/
/// Set of BasisFunction of this FiniteElemSpace.
const
BasisFunction
*
basFcts
;
/** \brief
* The Mesh this FiniteElemSpace belongs to
*/
/// The Mesh this FiniteElemSpace belongs to.
Mesh
*
mesh
;
/** \brief
*
*/
///
static
std
::
vector
<
FiniteElemSpace
*>
feSpaces
;
};
...
...
AMDiS/src/PngWriter.cc
View file @
a9897bbf
#include
<float.h>
#include
<png.h>
#include
"PngWriter.h"
#include
"Traverse.h"
#include
"DOFVector.h"
namespace
AMDiS
{
int
PngWriter
::
writeFile
(
const
std
::
string
nam
e
)
int
PngWriter
::
writeFile
(
const
std
::
string
filename
,
int
imageTyp
e
)
{
FUNCNAME
(
"PngWriter::writeFile()"
);
double
minX
=
DBL_MAX
,
minY
=
DBL_MAX
;
double
maxX
=
DBL_MIN
,
maxY
=
DBL_MIN
;
TraverseStack
stack
;
ElInfo
*
elInfo
=
stack
.
traverseFirst
(
dataCollector
->
getMesh
(),
-
1
,
Mesh
::
CALL_LEAF_EL
|
Mesh
::
FILL_COORDS
);
double
pointdist
=
min
(
absteukl
(
elInfo
->
getCoord
(
0
),
elInfo
->
getCoord
(
1
)),
min
(
absteukl
(
elInfo
->
getCoord
(
1
),
elInfo
->
getCoord
(
2
)),
absteukl
(
elInfo
->
getCoord
(
2
),
elInfo
->
getCoord
(
0
))));
while
(
elInfo
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
double
x
=
(
elInfo
->
getCoord
(
i
))[
0
];
double
y
=
(
elInfo
->
getCoord
(
i
))[
1
];
if
(
x
<
minX
)
minX
=
x
;
if
(
x
>
maxX
)
maxX
=
x
;
if
(
y
<
minY
)
minY
=
y
;
if
(
y
>
maxY
)
maxY
=
y
;
}
elInfo
=
stack
.
traverseNext
(
elInfo
);
}
TEST_EXIT
(
minX
==
0.0
&&
minY
==
0.0
)(
"Only supported for minX = minY = 0.0!
\n
"
);
TEST_EXIT
(
pointdist
>
0.0
)(
"This should not happen!
\n
"
);
int
imageX
=
static_cast
<
int
>
(
maxX
/
pointdist
)
+
1
;
int
imageY
=
static_cast
<
int
>
(
maxY
/
pointdist
)
+
1
;
png_structp
png_ptr
=
png_create_write_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
if
(
!
png_ptr
)
return
0
;
png_bytep
rowPointers
[
imageY
];
for
(
int
i
=
0
;
i
<
imageY
;
i
++
)
{
rowPointers
[
i
]
=
(
png_byte
*
)
png_malloc
(
png_ptr
,
(
imageType
==
0
?
imageX
:
imageX
*
3
));
}
const
BasisFunction
*
basisFcts
=
dataCollector
->
getFeSpace
()
->
getBasisFcts
();
Vector
<
DegreeOfFreedom
>
localDofs
(
3
);
DOFVector
<
double
>*
dofvalues
=
dataCollector
->
getValues
();
elInfo
=
stack
.
traverseFirst
(
dataCollector
->
getMesh
(),
-
1
,
Mesh
::
CALL_LEAF_EL
|
Mesh
::
FILL_COORDS
);
while
(
elInfo
)
{
basisFcts
->
getLocalIndicesVec
(
elInfo
->
getElement
(),
dataCollector
->
getFeSpace
()
->
getAdmin
(),
&
localDofs
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
if
(
imageType
==
0
)
{
int
indexX
=
static_cast
<
int
>
((
elInfo
->
getCoord
(
i
))[
0
]
/
pointdist
);
int
indexY
=
static_cast
<
int
>
((
elInfo
->
getCoord
(
i
))[
1
]
/
pointdist
);
rowPointers
[
indexY
][
indexX
]
=
static_cast
<
unsigned
char
>
((
*
dofvalues
)[
localDofs
[
i
]]);
}
else
{
int
indexX
=
static_cast
<
int
>
((
elInfo
->
getCoord
(
i
))[
0
]
/
pointdist
)
*
3
;
int
indexY
=
static_cast
<
int
>
((
elInfo
->
getCoord
(
i
))[
1
]
/
pointdist
);
int
value
=
static_cast
<
int
>
((
*
dofvalues
)[
localDofs
[
i
]]);
unsigned
char
r
=
value
%
256
;
unsigned
char
g
=
(
value
-
r
%
(
256
*
256
))
/
256
;
unsigned
char
b
=
(
value
-
r
-
g
)
/
(
256
*
256
);
rowPointers
[
indexY
][
indexX
]
=
r
;
rowPointers
[
indexY
][
indexX
+
1
]
=
g
;
rowPointers
[
indexY
][
indexX
+
2
]
=
b
;
}
}
elInfo
=
stack
.
traverseNext
(
elInfo
);
}
FILE
*
fp
=
fopen
(
filename
.
c_str
(),
"wb"
);
TEST_EXIT
(
fp
)(
"Cannot open file for writing matrix picture file!
\n
"
);
png_infop
info_ptr
=
png_create_info_struct
(
png_ptr
);
if
(
!
info_ptr
)
{
png_destroy_write_struct
(
&
png_ptr
,
(
png_infopp
)
NULL
);
return
0
;
}
png_init_io
(
png_ptr
,
fp
);
png_set_IHDR
(
png_ptr
,
info_ptr
,
imageX
,
imageY
,
8
,
(
imageType
==
0
?
PNG_COLOR_TYPE_GRAY
:
PNG_COLOR_TYPE_RGB
),
PNG_INTERLACE_NONE
,
PNG_COMPRESSION_TYPE_DEFAULT
,
PNG_FILTER_TYPE_DEFAULT
);
png_set_rows
(
png_ptr
,