Commit 299ccf0d authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* writeResidualMesh() for ProblemScal and ProblemVec

parent 6c052dc3
......@@ -12,7 +12,6 @@ if USE_PARALLEL_AMDIS
PARALLEL_AMDIS_SOURCES = \
$(PARALLEL_DIR)/ConditionalEstimator.h $(PARALLEL_DIR)/ConditionalEstimator.cc \
$(PARALLEL_DIR)/ConditionalMarker.h \
$(PARALLEL_DIR)/ElementFileWriter.h $(PARALLEL_DIR)/ElementFileWriter.cc \
$(PARALLEL_DIR)/MeshStructure.h $(PARALLEL_DIR)/MeshStructure.cc \
$(PARALLEL_DIR)/MeshStructure_ED.h \
$(PARALLEL_DIR)/ParallelError.h $(PARALLEL_DIR)/ParallelError.hh \
......@@ -95,6 +94,7 @@ $(SOURCE_DIR)/ProblemStatBase.h \
$(SOURCE_DIR)/MatVecMultiplier.cc \
$(SOURCE_DIR)/DOFContainer.h \
$(SOURCE_DIR)/FileWriter.h $(SOURCE_DIR)/FileWriter.hh $(SOURCE_DIR)/FileWriter.cc \
$(SOURCE_DIR)/ElementFileWriter.h $(SOURCE_DIR)/ElementFileWriter.cc \
$(SOURCE_DIR)/ElInfo.cc \
$(SOURCE_DIR)/MatVecMultiplier.h \
$(SOURCE_DIR)/Operator.h $(SOURCE_DIR)/Operator.cc \
......
......@@ -64,8 +64,6 @@ libamdis_la_LIBADD =
am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ConditionalEstimator.h \
$(PARALLEL_DIR)/ConditionalEstimator.cc \
$(PARALLEL_DIR)/ConditionalMarker.h \
$(PARALLEL_DIR)/ElementFileWriter.h \
$(PARALLEL_DIR)/ElementFileWriter.cc \
$(PARALLEL_DIR)/MeshStructure.h \
$(PARALLEL_DIR)/MeshStructure.cc \
$(PARALLEL_DIR)/MeshStructure_ED.h \
......@@ -137,7 +135,8 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ConditionalEstimator.h \
$(SOURCE_DIR)/ProblemStatBase.h \
$(SOURCE_DIR)/MatVecMultiplier.cc $(SOURCE_DIR)/DOFContainer.h \
$(SOURCE_DIR)/FileWriter.h $(SOURCE_DIR)/FileWriter.hh \
$(SOURCE_DIR)/FileWriter.cc $(SOURCE_DIR)/ElInfo.cc \
$(SOURCE_DIR)/FileWriter.cc $(SOURCE_DIR)/ElementFileWriter.h \
$(SOURCE_DIR)/ElementFileWriter.cc $(SOURCE_DIR)/ElInfo.cc \
$(SOURCE_DIR)/MatVecMultiplier.h $(SOURCE_DIR)/Operator.h \
$(SOURCE_DIR)/Operator.cc $(SOURCE_DIR)/Mesh.cc \
$(SOURCE_DIR)/AMDiS.h $(SOURCE_DIR)/AdaptStationary.h \
......@@ -228,7 +227,6 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ConditionalEstimator.h \
$(SOURCE_DIR)/PeriodicInfo.h $(SOURCE_DIR)/OpenMP.h
@USE_PARALLEL_AMDIS_TRUE@am__objects_1 = \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ConditionalEstimator.lo \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ElementFileWriter.lo \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-MeshStructure.lo \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ParallelProblem.lo \
@USE_PARALLEL_AMDIS_TRUE@ libamdis_la-ParMetisPartitioner.lo
......@@ -254,9 +252,9 @@ am_libamdis_la_OBJECTS = $(am__objects_1) \
libamdis_la-SurfaceQuadrature.lo libamdis_la-LeafData.lo \
libamdis_la-BoundaryManager.lo libamdis_la-DirichletBC.lo \
libamdis_la-RobinBC.lo libamdis_la-MatVecMultiplier.lo \
libamdis_la-FileWriter.lo libamdis_la-ElInfo.lo \
libamdis_la-Operator.lo libamdis_la-Mesh.lo \
libamdis_la-AdaptStationary.lo \
libamdis_la-FileWriter.lo libamdis_la-ElementFileWriter.lo \
libamdis_la-ElInfo.lo libamdis_la-Operator.lo \
libamdis_la-Mesh.lo libamdis_la-AdaptStationary.lo \
libamdis_la-AdaptInstationary.lo \
libamdis_la-DiagonalPreconditioner.lo \
libamdis_la-ILUPreconditioner.lo \
......@@ -447,7 +445,6 @@ AMDIS_INCLUDES = -I$(SOURCE_DIR) $(am__append_2)
@USE_PARALLEL_AMDIS_TRUE@PARALLEL_AMDIS_SOURCES = \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ConditionalEstimator.h $(PARALLEL_DIR)/ConditionalEstimator.cc \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ConditionalMarker.h \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ElementFileWriter.h $(PARALLEL_DIR)/ElementFileWriter.cc \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/MeshStructure.h $(PARALLEL_DIR)/MeshStructure.cc \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/MeshStructure_ED.h \
@USE_PARALLEL_AMDIS_TRUE@ $(PARALLEL_DIR)/ParallelError.h $(PARALLEL_DIR)/ParallelError.hh \
......@@ -511,6 +508,7 @@ $(SOURCE_DIR)/ProblemStatBase.h \
$(SOURCE_DIR)/MatVecMultiplier.cc \
$(SOURCE_DIR)/DOFContainer.h \
$(SOURCE_DIR)/FileWriter.h $(SOURCE_DIR)/FileWriter.hh $(SOURCE_DIR)/FileWriter.cc \
$(SOURCE_DIR)/ElementFileWriter.h $(SOURCE_DIR)/ElementFileWriter.cc \
$(SOURCE_DIR)/ElInfo.cc \
$(SOURCE_DIR)/MatVecMultiplier.h \
$(SOURCE_DIR)/Operator.h $(SOURCE_DIR)/Operator.cc \
......@@ -799,13 +797,6 @@ libamdis_la-ConditionalEstimator.lo: $(PARALLEL_DIR)/ConditionalEstimator.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-ConditionalEstimator.lo `test -f '$(PARALLEL_DIR)/ConditionalEstimator.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/ConditionalEstimator.cc
libamdis_la-ElementFileWriter.lo: $(PARALLEL_DIR)/ElementFileWriter.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-ElementFileWriter.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ElementFileWriter.Tpo" -c -o libamdis_la-ElementFileWriter.lo `test -f '$(PARALLEL_DIR)/ElementFileWriter.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/ElementFileWriter.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ElementFileWriter.Tpo" "$(DEPDIR)/libamdis_la-ElementFileWriter.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ElementFileWriter.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(PARALLEL_DIR)/ElementFileWriter.cc' object='libamdis_la-ElementFileWriter.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-ElementFileWriter.lo `test -f '$(PARALLEL_DIR)/ElementFileWriter.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/ElementFileWriter.cc
libamdis_la-MeshStructure.lo: $(PARALLEL_DIR)/MeshStructure.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-MeshStructure.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-MeshStructure.Tpo" -c -o libamdis_la-MeshStructure.lo `test -f '$(PARALLEL_DIR)/MeshStructure.cc' || echo '$(srcdir)/'`$(PARALLEL_DIR)/MeshStructure.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-MeshStructure.Tpo" "$(DEPDIR)/libamdis_la-MeshStructure.Plo"; else rm -f "$(DEPDIR)/libamdis_la-MeshStructure.Tpo"; exit 1; fi
......@@ -1100,6 +1091,13 @@ libamdis_la-FileWriter.lo: $(SOURCE_DIR)/FileWriter.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-FileWriter.lo `test -f '$(SOURCE_DIR)/FileWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/FileWriter.cc
libamdis_la-ElementFileWriter.lo: $(SOURCE_DIR)/ElementFileWriter.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-ElementFileWriter.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ElementFileWriter.Tpo" -c -o libamdis_la-ElementFileWriter.lo `test -f '$(SOURCE_DIR)/ElementFileWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ElementFileWriter.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ElementFileWriter.Tpo" "$(DEPDIR)/libamdis_la-ElementFileWriter.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ElementFileWriter.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/ElementFileWriter.cc' object='libamdis_la-ElementFileWriter.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-ElementFileWriter.lo `test -f '$(SOURCE_DIR)/ElementFileWriter.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ElementFileWriter.cc
libamdis_la-ElInfo.lo: $(SOURCE_DIR)/ElInfo.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-ElInfo.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ElInfo.Tpo" -c -o libamdis_la-ElInfo.lo `test -f '$(SOURCE_DIR)/ElInfo.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ElInfo.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ElInfo.Tpo" "$(DEPDIR)/libamdis_la-ElInfo.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ElInfo.Tpo"; exit 1; fi
......
......@@ -44,7 +44,7 @@ available_tags=" CXX F77"
# ### BEGIN LIBTOOL CONFIG
# Libtool was configured on host NWRW20:
# Libtool was configured on host NWRW15:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
......@@ -7266,7 +7266,7 @@ disable_libs=static
# End:
# ### BEGIN LIBTOOL TAG CONFIG: CXX
# Libtool was configured on host NWRW20:
# Libtool was configured on host NWRW15:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
......@@ -7574,7 +7574,7 @@ include_expsyms=""
# ### BEGIN LIBTOOL TAG CONFIG: F77
# Libtool was configured on host NWRW20:
# Libtool was configured on host NWRW15:
# Shell to use when invoking shell scripts.
SHELL="/bin/sh"
......@@ -7618,7 +7618,7 @@ LTCC="gcc"
LTCFLAGS="-g -O2"
# A language-specific compiler.
CC="f95"
CC="g77"
# Is the compiler the GNU C compiler?
with_gcc=yes
......@@ -7858,7 +7858,7 @@ variables_saved_for_relink="PATH LD_LIBRARY_PATH LD_RUN_PATH GCC_EXEC_PREFIX COM
link_all_deplibs=unknown
# Compile-time system search path for libraries
sys_lib_search_path_spec=`echo " /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../i386-redhat-linux/4.1.2/ /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../ /lib/i386-redhat-linux/4.1.2/ /lib/ /usr/lib/i386-redhat-linux/4.1.2/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"`
sys_lib_search_path_spec=`echo " /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../i386-redhat-linux/lib/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../i386-redhat-linux/3.4.6/ /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../ /lib/i386-redhat-linux/3.4.6/ /lib/ /usr/lib/i386-redhat-linux/3.4.6/ /usr/lib/" | $SED -e "s@${gcc_dir}@\${gcc_dir}@g;s@${gcc_ver}@\${gcc_ver}@g"`
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/qt-3.3/lib "
......
#include "ElementFileWriter.h"
#include "BasisFunction.h"
#include "Parameters.h"
#include "Traverse.h"
#include "AdaptInfo.h"
using namespace std;
namespace AMDiS {
ElementFileWriter::ElementFileWriter(const std::string& name_,
ElementFileWriter::ElementFileWriter(const std::string& name_,
Mesh *mesh_,
const FiniteElemSpace *feSpace_,
std::map<int, int> &vec_)
std::map<int, double> &vec_)
: name(name_),
tecplotExt(".plt"),
amdisMeshDatExt(".elem.mesh"),
vtkExt(".vtu"),
writeTecPlotFormat(0),
writeAMDiSFormat(0),
writeVtkFormat(0),
appendIndex(0),
indexLength(5),
indexDecimals(3),
......@@ -24,13 +25,14 @@ ElementFileWriter::ElementFileWriter(const std::string& name_,
mesh(mesh_),
feSpace(feSpace_),
vec(vec_)
{
{
GET_PARAMETER(0, name + "->output->filename", &filename);
GET_PARAMETER(0, name + "->output->TecPlot format", "%d",
&writeTecPlotFormat);
GET_PARAMETER(0, name + "->output->TecPlot ext", &tecplotExt);
GET_PARAMETER(0, name + "->output->AMDiS format", "%d", &writeAMDiSFormat);
GET_PARAMETER(0, name + "->output->AMDiS mesh-dat ext", &amdisMeshDatExt);
GET_PARAMETER(0, name + "->output->ParaView format", "%d", &writeVtkFormat);
GET_PARAMETER(0, name + "->output->append index", "%d", &appendIndex);
GET_PARAMETER(0, name + "->output->index length", "%d", &indexLength);
GET_PARAMETER(0, name + "->output->index decimals", "%d", &indexDecimals);
......@@ -39,25 +41,25 @@ ElementFileWriter::ElementFileWriter(const std::string& name_,
// TEST_EXIT(vec.size() == mesh->getNumberOfLeaves())
// ("illegal size !\n");
}
}
void
ElementFileWriter::writeFiles(AdaptInfo *adaptInfo, bool force)
{
void ElementFileWriter::writeFiles(AdaptInfo *adaptInfo, bool force,
int level, Flag traverseFlag, bool (*writeElem)(ElInfo*))
{
FUNCNAME("ElementFileWriter::writeFiles()");
timestepNumber++;
timestepNumber %= tsModulo;
if((timestepNumber != 0) && !force) return;
if ((timestepNumber != 0) && !force)
return;
std::string fn = filename;
if(appendIndex) {
if (appendIndex) {
TEST_EXIT(indexLength <= 99)("index lenght > 99\n");
TEST_EXIT(indexDecimals <= 97)("index decimals > 97\n");
TEST_EXIT(indexDecimals < indexLength)
("index length <= index decimals\n");
TEST_EXIT(indexDecimals < indexLength)("index length <= index decimals\n");
char formatStr[9];
......@@ -71,26 +73,33 @@ ElementFileWriter::writeFiles(AdaptInfo *adaptInfo, bool force)
}
if(writeTecPlotFormat) {
if (writeTecPlotFormat) {
TEST_EXIT(mesh)("no mesh\n");
writeTecPlotValues(const_cast<char*>((fn + tecplotExt).c_str()));
MSG("TecPlot file written to %s\n", (fn + tecplotExt).c_str());
}
if(writeAMDiSFormat) {
if (writeAMDiSFormat) {
TEST_EXIT(mesh)("no mesh\n");
writeMeshDatValues(const_cast<char*>( (fn + amdisMeshDatExt).c_str()),
adaptInfo ? adaptInfo->getTime() : 0.0);
MSG("MeshDat file written to %s\n", (fn + amdisMeshDatExt).c_str());
}
}
void
ElementFileWriter::writeTecPlotValues(const char* filename)
{
if (writeVtkFormat) {
TEST_EXIT(mesh)("no mesh\n");
writeVtkValues(const_cast<char*>( (fn + vtkExt).c_str()));
MSG("VTK file written to %s\n", (fn + vtkExt).c_str());
}
}
void ElementFileWriter::writeTecPlotValues(const char* filename)
{
FUNCNAME("ElementFileWriter::writeTecPlotValues()");
ofstream fout(filename);
::std::ofstream fout(filename);
TEST_EXIT(fout)("Could not open file %s !\n", filename);
fout.setf(std::ios::scientific,std::ios::floatfield);
......@@ -102,7 +111,7 @@ ElementFileWriter::writeTecPlotValues(const char* filename)
// === Write header. ===
fout << "TITLE = \"" << name.c_str() << "\"\n";
fout << "VARIABLES = ";
switch(dim) {
switch (dim) {
case 2: fout << "\"x\",\"y\"";
break;
case 3: fout << "\"x\",\"y\",\"z\"";
......@@ -115,7 +124,7 @@ ElementFileWriter::writeTecPlotValues(const char* filename)
<< ", N=" << 3*mesh->getNumberOfLeaves()
<< ", E=" << mesh->getNumberOfLeaves()
<< ", F=FEPOINT, ";
switch(dim) {
switch (dim) {
case 2: fout << "ET=TRIANGLE\n\n";
break;
case 3: fout << "ET=TETRAHEDRON\n\n";
......@@ -133,15 +142,14 @@ ElementFileWriter::writeTecPlotValues(const char* filename)
Mesh::CALL_LEAF_EL |
Mesh::FILL_COORDS);
while(elInfo) {
while (elInfo) {
// Get element value.
val = (double) vec[elInfo->getElement()->getIndex()];
val = vec[elInfo->getElement()->getIndex()];
// Write coordinates of all element vertices and element value.
for (int i=0; i<=dim; ++i) {
for (int i = 0; i <= dim; ++i) {
for (int j=0; j<dim; ++j) {
for (int j = 0; j < dim; ++j) {
fout << elInfo->getCoord(i)[j] << " ";
}
fout << val << "\n";
......@@ -155,10 +163,9 @@ ElementFileWriter::writeTecPlotValues(const char* filename)
int numLeaves = mesh->getNumberOfLeaves();
int vertCntr = 0;
fout << "\n";
for (int i=0; i<numLeaves; ++i) {
for (int j=0; j<=dim; ++j) {
for (int i = 0; i<numLeaves; ++i) {
for (int j = 0; j<=dim; ++j) {
++vertCntr;
fout << vertCntr << " ";
}
......@@ -167,13 +174,12 @@ ElementFileWriter::writeTecPlotValues(const char* filename)
fout.close();
}
}
void
ElementFileWriter::writeMeshDatValues(const char* filename, double time)
{
void ElementFileWriter::writeMeshDatValues(const char* filename, double time)
{
FUNCNAME("ElementFileWriter::writeMeshDatValues()");
ofstream fout(filename);
::std::ofstream fout(filename);
TEST_EXIT(fout)("Could not open file %s !\n", filename);
......@@ -198,19 +204,18 @@ ElementFileWriter::writeMeshDatValues(const char* filename, double time)
Mesh::CALL_LEAF_EL |
Mesh::FILL_COORDS);
while(elInfo) {
while (elInfo) {
// Write coordinates of all element vertices.
for (int i=0; i<=dim; ++i) {
for (int j=0; j<dim; ++j) {
for (int i = 0; i <= dim; ++i) {
for (int j = 0; j < dim; ++j) {
fout << elInfo->getCoord(i)[j] << " ";
}
fout << "\n";
}
elInfo = stack.traverseNext(elInfo);
} // end of: mesh traverse
}
// === Write elements. ===
......@@ -218,10 +223,8 @@ ElementFileWriter::writeMeshDatValues(const char* filename, double time)
int vertCntr = 0;
fout << "\n";
fout << "element vertices:\n";
for (int i=0; i<numLeaves; ++i) {
for (int j=0; j<=dim; ++j) {
for (int i = 0; i < numLeaves; ++i) {
for (int j = 0; j <= dim; ++j) {
fout << vertCntr << " ";
++vertCntr;
}
......@@ -250,14 +253,12 @@ ElementFileWriter::writeMeshDatValues(const char* filename, double time)
-1,
Mesh::CALL_LEAF_EL);
while(elInfo) {
while (elInfo) {
// Get element value.
val = (double) vec[elInfo->getElement()->getIndex()];
val = vec[elInfo->getElement()->getIndex()];
// Write value for each vertex of each element.
for (int i=0; i<=dim; ++i) {
for (int i = 0; i <= dim; ++i) {
fout << val << "\n";
}
......@@ -272,4 +273,152 @@ ElementFileWriter::writeMeshDatValues(const char* filename, double time)
fout.close();
}
void ElementFileWriter::writeVtkValues(const char* filename)
{
FUNCNAME("ElementFileWriter::writeVtkValues()");
::std::ofstream fout(filename);
TEST_EXIT(fout)("Could not open file %s !\n", filename);
int dim = mesh->getDim();
int vertices = mesh->getGeo(VERTEX);
int nElements = mesh->getNumberOfLeaves();
double val;
fout << "<?xml version=\"1.0\"?>" << ::std::endl;
fout << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">" << ::std::endl;
fout << " <UnstructuredGrid>" << ::std::endl;
fout << " <Piece NumberOfPoints=\"" << (dim + 1) * mesh->getNumberOfLeaves()
<< "\" NumberOfCells=\"" << nElements << "\">" << ::std::endl;
fout << " <Points>" << ::std::endl;
fout << " <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">" << ::std::endl;
// === Write vertex coordinates (every vertex for every element). ===
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirst(mesh,
-1,
Mesh::CALL_LEAF_EL |
Mesh::FILL_COORDS);
while (elInfo) {
// Write coordinates of all element vertices.
for (int i = 0; i <= dim; i++) {
for (int j = 0; j < dim; j++) {
fout << elInfo->getCoord(i)[j] << " ";
}
for (int j = dim; j < 3; j++) {
fout << "0.0";
}
fout << "\n";
}
elInfo = stack.traverseNext(elInfo);
}
fout << " </DataArray>" << ::std::endl;
fout << " </Points>" << ::std::endl;
fout << " <Cells>" << ::std::endl;
fout << " <DataArray type=\"Int32\" Name=\"offsets\">" << ::std::endl;
for (int i = 0; i < nElements; i++) {
fout << " " << (i + 1) * vertices << ::std::endl;
}
fout << " </DataArray>" << ::std::endl;
fout << " <DataArray type=\"UInt8\" Name=\"types\">" << ::std::endl;
for (int i = 0; i < nElements; i++) {
switch (vertices) {
case 2:
fout << " 3" << ::std::endl;
break;
case 3:
fout << " 5" << ::std::endl;
break;
case 4:
fout << " 10" << ::std::endl;
break;
default:
break;
}
}
fout << " </DataArray>" << ::std::endl;
fout << " <DataArray type=\"Int32\" Name=\"connectivity\">" << ::std::endl;
int vertCntr = 0;
for (int i = 0; i < nElements; ++i) {
for (int j = 0; j <= dim; ++j) {
fout << vertCntr << " ";
++vertCntr;
}
fout << ::std::endl;
}
fout << " </DataArray>" << ::std::endl;
fout << " </Cells>" << ::std::endl;
fout << " <PointData>" << ::std::endl;
fout << " <DataArray type=\"Float32\" Name=\"value\" format=\"ascii\">" << ::std::endl;
fout.setf(std::ios::scientific,std::ios::floatfield);
elInfo = stack.traverseFirst(mesh,
-1,
Mesh::CALL_LEAF_EL |
Mesh::FILL_COORDS);
int vc = 0;
while (elInfo) {
// Get element value.
val = vec[elInfo->getElement()->getIndex()];
/* if ((elInfo->getCoord(0)[0] == 80.0) &&
(elInfo->getCoord(0)[1] == 1.25) &&
(elInfo->getCoord(1)[0] == 79.9609375) &&
(elInfo->getCoord(1)[1] == 1.2109375) &&
(elInfo->getCoord(2)[0] == 80.0) &&
(elInfo->getCoord(2)[1] == 1.2109375))
{
::std::cout << "------" << ::std::endl;
::std::cout << "val = " << val << " I = " << elInfo->getElement()->getIndex() << ::std::endl;
::std::cout << "PARENT-I = " << elInfo->getParent()->getIndex() << ::std::endl;
::std::cout << "vc = " << vc << ::std::endl;
::std::cout.precision(10);
for (int i = 0; i < 3; i++) {
::std::cout << elInfo->getCoord(i)[0] << "/" << elInfo->getCoord(i)[1] << ::std::endl;
}
}
*/
if (val > 0.3) {
::std::cout.precision(10);
::std::cout << "------" << ::std::endl;
::std::cout << "val = " << val << " I = " << elInfo->getElement()->getIndex() << ::std::endl;
::std::cout << "vc = " << vc << ::std::endl;
for (int i = 0; i < 3; i++) {
::std::cout << elInfo->getCoord(i)[0] << "/" << elInfo->getCoord(i)[1] << ::std::endl;
}
}
// Write value for each vertex of each element.
for (int i = 0; i <= dim; i++) {
fout << (fabs(val) < 1e-40 ? 0.0 : val) << "\n";
}
vc++;
elInfo = stack.traverseNext(elInfo);
}
fout << " </DataArray>" << ::std::endl;
fout << " </PointData>" << ::std::endl;
fout << " </Piece>" << ::std::endl;
fout << " </UnstructuredGrid>" << ::std::endl;
fout << "</VTKFile>" << ::std::endl;
fout.close();
}
}
......@@ -7,10 +7,10 @@
#include "MemoryManager.h"
#include "Mesh.h"
using namespace AMDiS;
namespace AMDiS {
class ElementFileWriter : public FileWriterInterface
{
class ElementFileWriter : public FileWriterInterface
{
public:
MEMORY_MANAGED(ElementFileWriter);
......@@ -20,12 +20,15 @@ class ElementFileWriter : public FileWriterInterface
ElementFileWriter(const std::string& name_,
Mesh *mesh_,
const FiniteElemSpace *feSpace_,
std::map<int, int> &vec_);
std::map<int, double> &vec_);
/**
* Implementation of FileWriterInterface::writeFiles().
*/
void writeFiles(AdaptInfo *adaptInfo, bool force);
void writeFiles(AdaptInfo *adaptInfo, bool force,
int level = -1,
Flag traverseFlag = Mesh::CALL_LEAF_EL,
bool (*writeElem)(ElInfo*) = NULL);
protected:
/**
......@@ -38,6 +41,11 @@ class ElementFileWriter : public FileWriterInterface
*/
void writeMeshDatValues(const char* filename, double time);
/**
* Writes element data in VTK format.
*/
void writeVtkValues(const char* filename);
protected:
/** \brief
* Name.
......@@ -59,6 +67,11 @@ class ElementFileWriter : public FileWriterInterface
*/
std::string amdisMeshDatExt;
/** \brief
* VTK file extension.
*/
std::string vtkExt;
/** \brief
* 0: Don't write TecPlot files.
* 1: Write TecPlot files.
......@@ -71,6 +84,12 @@ class ElementFileWriter : public FileWriterInterface
*/
int writeAMDiSFormat;
/** \brief
* 0: Don't write VTK files.
* 1: Write VTK files.
*/
int writeVtkFormat;
/** \brief
* 0: Don't append time index to filename prefix.
* 1: Append time index to filename prefix.
......@@ -109,7 +128,10 @@ class ElementFileWriter : public FileWriterInterface
/** \brief
* Vector that stores the solution.
*/
std::map<int, int> vec;
};
std::map<int, double> vec;
};
}
#endif // ELEMENTFILEWRITER_H
<