Commit d1af7d66 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Add DofWriter.

parent ae62aab5
......@@ -136,7 +136,8 @@ SET(AMDIS_SRC ${SOURCE_DIR}/DOFIndexed.cc
${SOURCE_DIR}/TraverseParallel.cc
${SOURCE_DIR}/Triangle.cc
${SOURCE_DIR}/io/ValueWriter.cc
${SOURCE_DIR}/io/VtkWriter.cc
${SOURCE_DIR}/io/VtkWriter.cc
${SOURCE_DIR}/io/DofWriter.cc
${SOURCE_DIR}/io/PngWriter.cc
${SOURCE_DIR}/io/PovrayWriter.cc
${SOURCE_DIR}/io/DataCollector.cc
......
......@@ -206,6 +206,7 @@ $(SOURCE_DIR)/TraverseParallel.h $(SOURCE_DIR)/TraverseParallel.cc \
$(SOURCE_DIR)/Triangle.cc \
$(SOURCE_DIR)/io/ValueWriter.cc \
$(SOURCE_DIR)/io/VtkWriter.h $(SOURCE_DIR)/io/VtkWriter.cc \
$(SOURCE_DIR)/io/DofWriter.h $(SOURCE_DIR)/io/DofWriter.cc \
$(SOURCE_DIR)/io/PngWriter.h $(SOURCE_DIR)/io/PngWriter.cc \
$(SOURCE_DIR)/io/PovrayWriter.h $(SOURCE_DIR)/io/PovrayWriter.cc \
$(SOURCE_DIR)/io/DataCollector.h $(SOURCE_DIR)/io/DataCollector.cc \
......
......@@ -234,7 +234,8 @@ am__libamdis_la_SOURCES_DIST = $(SOURCE_DIR)/parallel/StdMpi.h \
$(SOURCE_DIR)/TraverseParallel.h \
$(SOURCE_DIR)/TraverseParallel.cc $(SOURCE_DIR)/Triangle.cc \
$(SOURCE_DIR)/io/ValueWriter.cc $(SOURCE_DIR)/io/VtkWriter.h \
$(SOURCE_DIR)/io/VtkWriter.cc $(SOURCE_DIR)/io/PngWriter.h \
$(SOURCE_DIR)/io/VtkWriter.cc $(SOURCE_DIR)/io/DofWriter.h \
$(SOURCE_DIR)/io/DofWriter.cc $(SOURCE_DIR)/io/PngWriter.h \
$(SOURCE_DIR)/io/PngWriter.cc $(SOURCE_DIR)/io/PovrayWriter.h \
$(SOURCE_DIR)/io/PovrayWriter.cc \
$(SOURCE_DIR)/io/DataCollector.h \
......@@ -319,10 +320,10 @@ am_libamdis_la_OBJECTS = $(am__objects_2) libamdis_la-DOFIndexed.lo \
libamdis_la-RefinementManager3d.lo libamdis_la-Tetrahedron.lo \
libamdis_la-Traverse.lo libamdis_la-TraverseParallel.lo \
libamdis_la-Triangle.lo libamdis_la-ValueWriter.lo \
libamdis_la-VtkWriter.lo libamdis_la-PngWriter.lo \
libamdis_la-PovrayWriter.lo libamdis_la-DataCollector.lo \
libamdis_la-ScalableQuadrature.lo libamdis_la-SubElInfo.lo \
libamdis_la-ElementDofIterator.lo \
libamdis_la-VtkWriter.lo libamdis_la-DofWriter.lo \
libamdis_la-PngWriter.lo libamdis_la-PovrayWriter.lo \
libamdis_la-DataCollector.lo libamdis_la-ScalableQuadrature.lo \
libamdis_la-SubElInfo.lo libamdis_la-ElementDofIterator.lo \
libamdis_la-InteriorBoundary.lo libamdis_la-Debug.lo \
libamdis_la-ArhReader.lo libamdis_la-ArhWriter.lo \
libamdis_la-RosenbrockAdaptInstationary.lo \
......@@ -645,6 +646,7 @@ $(SOURCE_DIR)/TraverseParallel.h $(SOURCE_DIR)/TraverseParallel.cc \
$(SOURCE_DIR)/Triangle.cc \
$(SOURCE_DIR)/io/ValueWriter.cc \
$(SOURCE_DIR)/io/VtkWriter.h $(SOURCE_DIR)/io/VtkWriter.cc \
$(SOURCE_DIR)/io/DofWriter.h $(SOURCE_DIR)/io/DofWriter.cc \
$(SOURCE_DIR)/io/PngWriter.h $(SOURCE_DIR)/io/PngWriter.cc \
$(SOURCE_DIR)/io/PovrayWriter.h $(SOURCE_DIR)/io/PovrayWriter.cc \
$(SOURCE_DIR)/io/DataCollector.h $(SOURCE_DIR)/io/DataCollector.cc \
......@@ -780,6 +782,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DataCollector.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Debug.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DirichletBC.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DofWriter.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-DualTraverse.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ElInfo.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ElInfo1d.Plo@am__quote@
......@@ -1592,6 +1595,13 @@ libamdis_la-VtkWriter.lo: $(SOURCE_DIR)/io/VtkWriter.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-VtkWriter.lo `test -f '$(SOURCE_DIR)/io/VtkWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/io/VtkWriter.cc
libamdis_la-DofWriter.lo: $(SOURCE_DIR)/io/DofWriter.cc
@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-DofWriter.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-DofWriter.Tpo" -c -o libamdis_la-DofWriter.lo `test -f '$(SOURCE_DIR)/io/DofWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/io/DofWriter.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-DofWriter.Tpo" "$(DEPDIR)/libamdis_la-DofWriter.Plo"; else rm -f "$(DEPDIR)/libamdis_la-DofWriter.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/io/DofWriter.cc' object='libamdis_la-DofWriter.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-DofWriter.lo `test -f '$(SOURCE_DIR)/io/DofWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/io/DofWriter.cc
libamdis_la-PngWriter.lo: $(SOURCE_DIR)/io/PngWriter.cc
@am__fastdepCXX_TRUE@ if $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -MT libamdis_la-PngWriter.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-PngWriter.Tpo" -c -o libamdis_la-PngWriter.lo `test -f '$(SOURCE_DIR)/io/PngWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/io/PngWriter.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-PngWriter.Tpo" "$(DEPDIR)/libamdis_la-PngWriter.Plo"; else rm -f "$(DEPDIR)/libamdis_la-PngWriter.Tpo"; exit 1; fi
......
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.
#include "DofWriter.h"
#include "DOFVector.h"
#include "BasisFunction.h"
namespace AMDiS {
void DofWriter::writeFile(std::string filename, std::vector<DOFVector<double>*> &vec)
{
FUNCNAME("DofWriter::writeFile()");
DOFVector<WorldVector<double> > coordDof(feSpace, "tmp");
Mesh *mesh = feSpace->getMesh();
const BasisFunction* basFcts = feSpace->getBasisFcts();
int nBasFcts = basFcts->getNumber();
std::vector<DegreeOfFreedom> dofVec(nBasFcts);
TraverseStack stack;
ElInfo *elInfo =
stack.traverseFirst(mesh, -1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
while (elInfo) {
basFcts->getLocalIndices(elInfo->getElement(), feSpace->getAdmin(), dofVec);
for (int i = 0; i < nBasFcts; i++) {
DimVec<double> *baryCoords = basFcts->getCoords(i);
elInfo->coordToWorld(*baryCoords, coordDof[dofVec[i]]);
}
elInfo = stack.traverseNext(elInfo);
}
std::ofstream outfile;
outfile.open(filename.c_str());
outfile.precision(10);
DOFIterator<WorldVector<double> > it(&coordDof, USED_DOFS);
for (it.reset(); !it.end(); ++it) {
outfile << it.getDOFIndex() << " ";
for (int i = 0; i < Global::getGeo(WORLD); i++)
outfile << (*it)[i] << " ";
for (unsigned int i = 0; i < vec.size(); i++)
outfile << (*(vec[i]))[it.getDOFIndex()] << " ";
outfile << std::endl;
}
outfile.close();
}
}
// ============================================================================
// == ==
// == AMDiS - Adaptive multidimensional simulations ==
// == ==
// == http://www.amdis-fem.org ==
// == ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.
/** \file DofWriter.h */
#ifndef AMDIS_DOF_WRITER_H
#define AMDIS_DOF_WRITER_H
#include <fstream>
#include <vector>
#include "AMDiS_fwd.h"
#include "FiniteElemSpace.h"
#include "Mesh.h"
namespace AMDiS {
class DofWriter
{
public:
DofWriter(const FiniteElemSpace *feSpace)
: feSpace(feSpace),
mesh(feSpace->getMesh())
{}
void writeFile(std::string filename, std::vector<DOFVector<double>*> &vec);
protected:
const FiniteElemSpace *feSpace;
Mesh *mesh;
};
}
#endif
......@@ -19,6 +19,7 @@
#include "VtkWriter.h"
#include "PngWriter.h"
#include "PovrayWriter.h"
#include "DofWriter.h"
#include "FiniteElemSpace.h"
#include "AdaptInfo.h"
#include "Flag.h"
......@@ -51,7 +52,7 @@ namespace AMDiS {
FileWriter::FileWriter(std::string name_,
Mesh *mesh_,
std::vector< DOFVector<double>* > vecs)
std::vector<DOFVector<double>*> vecs)
: name(name_),
mesh(mesh_)
{
......@@ -70,7 +71,7 @@ namespace AMDiS {
FileWriter::FileWriter(std::string name_,
Mesh *mesh_,
DOFVector< WorldVector<double> > *vec)
DOFVector<WorldVector<double> > *vec)
: name(name_),
mesh(mesh_)
{
......@@ -156,6 +157,8 @@ namespace AMDiS {
GET_PARAMETER(0, name + "->Povray camera location", &povrayCameraLocation);
GET_PARAMETER(0, name + "->Povray camera look_at", &povrayCameraLookAt);
GET_PARAMETER(0, name + "->DOF format", "%d", &writeDofFormat);
std::string compressionStr = "";
GET_PARAMETER(0, name + "->compression", &compressionStr);
if (compressionStr == "gzip" || compressionStr == "gz") {
......@@ -268,6 +271,13 @@ namespace AMDiS {
#endif
}
if (writeDofFormat) {
DofWriter dofWriter(feSpace);
dofWriter.writeFile(fn + ".dof", solutionVecs);
}
#ifdef HAVE_PNG
if (writePngFormat) {
PngWriter pngWriter(dataCollectors[0]);
......
......@@ -175,6 +175,9 @@ namespace AMDiS {
/// 0: Don't write Povray scripts; 1: Write Povray scripts
int writePovrayFormat;
/// 0: Don't write DOF files; 1: Write DOF files
int writeDofFormat;
/// camera position for povray script files
std::string povrayCameraLocation;
......@@ -212,7 +215,7 @@ namespace AMDiS {
const FiniteElemSpace *feSpace;
/// Pointers to the vectors which store the solution.
std::vector< DOFVector<double>* > solutionVecs;
std::vector<DOFVector<double>*> solutionVecs;
/** \brief
* Stores the number of temporal solutions vectors, which have been created
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment