Skip to content
Snippets Groups Projects
Commit 6c8471f5 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Fixed a bug when writing long value numbers in vtk output

parent 039fe100
No related branches found
No related tags found
No related merge requests found
......@@ -24,10 +24,6 @@
namespace AMDiS {
// ==============================================================================
// ===== class BallProject ======================================================
// ==============================================================================
/** \brief
* Projects world coordinates to the surface of a ball with given center and
* radius. Can be used as boundary or volume projection.
......@@ -35,9 +31,7 @@ namespace AMDiS {
class BallProject : public Projection
{
public:
/** \brief
* Constructor.
*/
/// Constructor.
BallProject(int id,
ProjectionType type,
WorldVector<double> &center,
......@@ -45,33 +39,25 @@ namespace AMDiS {
: Projection(id, type),
center_(center),
radius_(radius)
{};
{}
/** \brief
* Destructor.
*/
virtual ~BallProject() {};
/// Destructor.
virtual ~BallProject() {}
/** \brief
* Implementation of Projection::project();
*/
/// Implementation of Projection::project();
void project(WorldVector<double> &x) {
x -= center_;
double norm = sqrt(x*x);
TEST_EXIT(norm != 0.0)("can't project vector x\n");
x *= radius_/norm;
x *= radius_ / norm;
x += center_;
};
}
protected:
/** \brief
* Center of the ball.
*/
/// Center of the ball.
WorldVector<double> center_;
/** \brief
* Radius of the ball.
*/
/// Radius of the ball.
double radius_;
};
......
......@@ -45,8 +45,9 @@ namespace AMDiS {
png_bytep rowPointers[imageY];
for (int i = 0; i < imageY; i++) {
rowPointers[i] = (png_byte*)png_malloc(png_ptr,
(imageType == 0 ? imageX : imageX * 3));
// rowPointers[i] = (png_byte*)png_malloc(png_ptr,
// (imageType == 0 ? imageX : imageX * 3));
rowPointers[i] = (png_byte*)malloc(sizeof(png_byte) * imageX * 3);
}
const BasisFunction* basisFcts = dataCollector->getFeSpace()->getBasisFcts();
......@@ -67,16 +68,20 @@ namespace AMDiS {
rowPointers[indexY][indexX] =
static_cast<unsigned char>((*dofvalues)[localDofs[i]]);
} else {
int indexX = static_cast<int>((elInfo->getCoord(i))[0] / pointdist) * 3;
int indexX = static_cast<int>((elInfo->getCoord(i))[0] / pointdist);
int indexY = static_cast<int>((elInfo->getCoord(i))[1] / pointdist);
TEST_EXIT(indexX >= 0 && indexX < imageX)("X-index out of range!");
TEST_EXIT(indexY >= 0 && indexY < imageY)("Y-index out of range!");
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;
rowPointers[indexY][indexX * 3] = r;
rowPointers[indexY][indexX * 3 + 1] = g;
rowPointers[indexY][indexX * 3 + 2] = b;
}
}
......@@ -94,6 +99,10 @@ namespace AMDiS {
return 0;
}
if (setjmp(png_jmpbuf(png_ptr))) {
return 0;
}
png_init_io(png_ptr, fp);
png_set_IHDR(png_ptr, info_ptr, imageX, imageY, 8,
......@@ -104,7 +113,7 @@ namespace AMDiS {
png_set_rows(png_ptr, info_ptr, rowPointers);
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL);
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, png_voidp_NULL);
png_destroy_write_struct(&png_ptr, &info_ptr);
......
......@@ -27,18 +27,12 @@
namespace AMDiS {
/** \brief
* Different possible types for a \ref Projection.
*/
/// Different possible types for a \ref Projection.
enum ProjectionType {
BOUNDARY_PROJECTION = 0, /**< Projection of boundary parts of an element. */
VOLUME_PROJECTION = 1 /**< Projection of whole elements. */
};
// ==============================================================================
// ===== class Projection =======================================================
// ==============================================================================
/** \brief
* A Projection is a mapping from world coordinates to world coordinates.
* It must fullfill the condition \ref project(project(x)) == project(x).
......@@ -49,9 +43,7 @@ namespace AMDiS {
class Projection
{
public:
/** \brief
* Constructs a prjection with given id and type.
*/
/// Constructs a prjection with given id and type.
Projection(int id, ProjectionType type)
: projectionID_(id),
projectionType_(type)
......@@ -65,47 +57,32 @@ namespace AMDiS {
virtual ~Projection() {}
/** \brief
* Projection method. Must be overriden in sub classes.
*/
/// Projection method. Must be overriden in sub classes.
virtual void project(WorldVector<double>& x) = 0;
/** \brief
* Returns \ref projectionID.
*/
/// Returns \ref projectionID.
inline int getID() {
return projectionID_;
}
/** \brief
* Returns \ref projectionType;
*/
/// Returns \ref projectionType;
inline ProjectionType getType() {
return projectionType_;
}
/** \brief
* Returns the projection with the given id, if existing.
* Returns NULL otherwise.
*/
/// Returns the projection with the given id, if existing. Returns NULL otherwise.
static Projection* getProjection(int id) {
return projectionMap_[id];
}
protected:
/** \brief
* Unique projection id.
*/
/// Unique projection id.
int projectionID_;
/** \brief
* Type of this projection.
*/
/// Type of this projection.
ProjectionType projectionType_;
/** \brief
* Static mapping from ids to projection objects. Used in \ref getProjection().
*/
/// Static mapping from ids to projection objects. Used in \ref getProjection().
static std::map<int, Projection*> projectionMap_;
};
......
......@@ -138,6 +138,8 @@ namespace AMDiS {
DOFVector<int>::Iterator intPointIt(interpPointInd, USED_DOFS);
DOFVector<double>::Iterator valueIt(values, USED_DOFS);
DOFVector< std::list<WorldVector<double> > >::Iterator coordIt(dofCoords, USED_DOFS);
file << std::fixed;
// Write the values for all vertex DOFs.
for (intPointIt.reset(), valueIt.reset(), coordIt.reset();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment