Commit ded81b7f authored by Thomas Witkowski's avatar Thomas Witkowski

Moved debugging functions in ProblemVec to a new class ProblemVecDbg.

parent c7167424
...@@ -82,6 +82,7 @@ $(SOURCE_DIR)/ProblemIterationInterface.h \ ...@@ -82,6 +82,7 @@ $(SOURCE_DIR)/ProblemIterationInterface.h \
$(SOURCE_DIR)/StandardProblemIteration.h $(SOURCE_DIR)/StandardProblemIteration.cc \ $(SOURCE_DIR)/StandardProblemIteration.h $(SOURCE_DIR)/StandardProblemIteration.cc \
$(SOURCE_DIR)/ProblemScal.h $(SOURCE_DIR)/ProblemScal.cc \ $(SOURCE_DIR)/ProblemScal.h $(SOURCE_DIR)/ProblemScal.cc \
$(SOURCE_DIR)/ProblemVec.h $(SOURCE_DIR)/ProblemVec.cc \ $(SOURCE_DIR)/ProblemVec.h $(SOURCE_DIR)/ProblemVec.cc \
$(SOURCE_DIR)/ProblemVecDbg.h $(SOURCE_DIR)/ProblemVecDbg.cc \
$(SOURCE_DIR)/DualTraverse.h $(SOURCE_DIR)/DualTraverse.cc \ $(SOURCE_DIR)/DualTraverse.h $(SOURCE_DIR)/DualTraverse.cc \
$(SOURCE_DIR)/ElementPartition_ED.h $(SOURCE_DIR)/SurfacePartition_ED.h \ $(SOURCE_DIR)/ElementPartition_ED.h $(SOURCE_DIR)/SurfacePartition_ED.h \
$(SOURCE_DIR)/ElementData.h $(SOURCE_DIR)/ElementData.cc \ $(SOURCE_DIR)/ElementData.h $(SOURCE_DIR)/ElementData.cc \
......
...@@ -109,6 +109,7 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ParallelDomainBase.h \ ...@@ -109,6 +109,7 @@ am__libamdis_la_SOURCES_DIST = $(PARALLEL_DIR)/ParallelDomainBase.h \
$(SOURCE_DIR)/StandardProblemIteration.cc \ $(SOURCE_DIR)/StandardProblemIteration.cc \
$(SOURCE_DIR)/ProblemScal.h $(SOURCE_DIR)/ProblemScal.cc \ $(SOURCE_DIR)/ProblemScal.h $(SOURCE_DIR)/ProblemScal.cc \
$(SOURCE_DIR)/ProblemVec.h $(SOURCE_DIR)/ProblemVec.cc \ $(SOURCE_DIR)/ProblemVec.h $(SOURCE_DIR)/ProblemVec.cc \
$(SOURCE_DIR)/ProblemVecDbg.h $(SOURCE_DIR)/ProblemVecDbg.cc \
$(SOURCE_DIR)/DualTraverse.h $(SOURCE_DIR)/DualTraverse.cc \ $(SOURCE_DIR)/DualTraverse.h $(SOURCE_DIR)/DualTraverse.cc \
$(SOURCE_DIR)/ElementPartition_ED.h \ $(SOURCE_DIR)/ElementPartition_ED.h \
$(SOURCE_DIR)/SurfacePartition_ED.h \ $(SOURCE_DIR)/SurfacePartition_ED.h \
...@@ -248,7 +249,8 @@ am_libamdis_la_OBJECTS = $(am__objects_2) libamdis_la-DOFIndexed.lo \ ...@@ -248,7 +249,8 @@ am_libamdis_la_OBJECTS = $(am__objects_2) libamdis_la-DOFIndexed.lo \
libamdis_la-AdaptBase.lo \ libamdis_la-AdaptBase.lo \
libamdis_la-StandardProblemIteration.lo \ libamdis_la-StandardProblemIteration.lo \
libamdis_la-ProblemScal.lo libamdis_la-ProblemVec.lo \ libamdis_la-ProblemScal.lo libamdis_la-ProblemVec.lo \
libamdis_la-DualTraverse.lo libamdis_la-ElementData.lo \ libamdis_la-ProblemVecDbg.lo libamdis_la-DualTraverse.lo \
libamdis_la-ElementData.lo \
libamdis_la-ComponentTraverseInfo.lo libamdis_la-CreatorMap.lo \ libamdis_la-ComponentTraverseInfo.lo libamdis_la-CreatorMap.lo \
libamdis_la-ProblemInterpolScal.lo \ libamdis_la-ProblemInterpolScal.lo \
libamdis_la-ProblemInterpolVec.lo libamdis_la-MacroReader.lo \ libamdis_la-ProblemInterpolVec.lo libamdis_la-MacroReader.lo \
...@@ -493,6 +495,7 @@ $(SOURCE_DIR)/ProblemIterationInterface.h \ ...@@ -493,6 +495,7 @@ $(SOURCE_DIR)/ProblemIterationInterface.h \
$(SOURCE_DIR)/StandardProblemIteration.h $(SOURCE_DIR)/StandardProblemIteration.cc \ $(SOURCE_DIR)/StandardProblemIteration.h $(SOURCE_DIR)/StandardProblemIteration.cc \
$(SOURCE_DIR)/ProblemScal.h $(SOURCE_DIR)/ProblemScal.cc \ $(SOURCE_DIR)/ProblemScal.h $(SOURCE_DIR)/ProblemScal.cc \
$(SOURCE_DIR)/ProblemVec.h $(SOURCE_DIR)/ProblemVec.cc \ $(SOURCE_DIR)/ProblemVec.h $(SOURCE_DIR)/ProblemVec.cc \
$(SOURCE_DIR)/ProblemVecDbg.h $(SOURCE_DIR)/ProblemVecDbg.cc \
$(SOURCE_DIR)/DualTraverse.h $(SOURCE_DIR)/DualTraverse.cc \ $(SOURCE_DIR)/DualTraverse.h $(SOURCE_DIR)/DualTraverse.cc \
$(SOURCE_DIR)/ElementPartition_ED.h $(SOURCE_DIR)/SurfacePartition_ED.h \ $(SOURCE_DIR)/ElementPartition_ED.h $(SOURCE_DIR)/SurfacePartition_ED.h \
$(SOURCE_DIR)/ElementData.h $(SOURCE_DIR)/ElementData.cc \ $(SOURCE_DIR)/ElementData.h $(SOURCE_DIR)/ElementData.cc \
...@@ -777,6 +780,7 @@ distclean-compile: ...@@ -777,6 +780,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemNonLin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemNonLin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemScal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemScal.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemVec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemVec.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-ProblemVecDbg.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Projection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Projection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-QPsiPhi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-QPsiPhi.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Quadrature.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libamdis_la-Quadrature.Plo@am__quote@
...@@ -969,6 +973,13 @@ libamdis_la-ProblemVec.lo: $(SOURCE_DIR)/ProblemVec.cc ...@@ -969,6 +973,13 @@ libamdis_la-ProblemVec.lo: $(SOURCE_DIR)/ProblemVec.cc
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @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-ProblemVec.lo `test -f '$(SOURCE_DIR)/ProblemVec.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ProblemVec.cc @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libamdis_la_CXXFLAGS) $(CXXFLAGS) -c -o libamdis_la-ProblemVec.lo `test -f '$(SOURCE_DIR)/ProblemVec.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ProblemVec.cc
libamdis_la-ProblemVecDbg.lo: $(SOURCE_DIR)/ProblemVecDbg.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-ProblemVecDbg.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-ProblemVecDbg.Tpo" -c -o libamdis_la-ProblemVecDbg.lo `test -f '$(SOURCE_DIR)/ProblemVecDbg.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ProblemVecDbg.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-ProblemVecDbg.Tpo" "$(DEPDIR)/libamdis_la-ProblemVecDbg.Plo"; else rm -f "$(DEPDIR)/libamdis_la-ProblemVecDbg.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$(SOURCE_DIR)/ProblemVecDbg.cc' object='libamdis_la-ProblemVecDbg.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-ProblemVecDbg.lo `test -f '$(SOURCE_DIR)/ProblemVecDbg.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/ProblemVecDbg.cc
libamdis_la-DualTraverse.lo: $(SOURCE_DIR)/DualTraverse.cc libamdis_la-DualTraverse.lo: $(SOURCE_DIR)/DualTraverse.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-DualTraverse.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-DualTraverse.Tpo" -c -o libamdis_la-DualTraverse.lo `test -f '$(SOURCE_DIR)/DualTraverse.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/DualTraverse.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-DualTraverse.lo -MD -MP -MF "$(DEPDIR)/libamdis_la-DualTraverse.Tpo" -c -o libamdis_la-DualTraverse.lo `test -f '$(SOURCE_DIR)/DualTraverse.cc' || echo '$(srcdir)/'`$(SOURCE_DIR)/DualTraverse.cc; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-DualTraverse.Tpo" "$(DEPDIR)/libamdis_la-DualTraverse.Plo"; else rm -f "$(DEPDIR)/libamdis_la-DualTraverse.Tpo"; exit 1; fi @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/libamdis_la-DualTraverse.Tpo" "$(DEPDIR)/libamdis_la-DualTraverse.Plo"; else rm -f "$(DEPDIR)/libamdis_la-DualTraverse.Tpo"; exit 1; fi
......
...@@ -44,7 +44,7 @@ available_tags=" CXX F77" ...@@ -44,7 +44,7 @@ available_tags=" CXX F77"
# ### BEGIN LIBTOOL CONFIG # ### BEGIN LIBTOOL CONFIG
# Libtool was configured on host deimos104: # Libtool was configured on host p2d125:
# Shell to use when invoking shell scripts. # Shell to use when invoking shell scripts.
SHELL="/bin/sh" SHELL="/bin/sh"
...@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` ...@@ -6760,7 +6760,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
# End: # End:
# ### BEGIN LIBTOOL TAG CONFIG: CXX # ### BEGIN LIBTOOL TAG CONFIG: CXX
# Libtool was configured on host deimos104: # Libtool was configured on host p2d125:
# Shell to use when invoking shell scripts. # Shell to use when invoking shell scripts.
SHELL="/bin/sh" SHELL="/bin/sh"
...@@ -7065,7 +7065,7 @@ include_expsyms="" ...@@ -7065,7 +7065,7 @@ include_expsyms=""
# ### BEGIN LIBTOOL TAG CONFIG: F77 # ### BEGIN LIBTOOL TAG CONFIG: F77
# Libtool was configured on host deimos104: # Libtool was configured on host p2d125:
# Shell to use when invoking shell scripts. # Shell to use when invoking shell scripts.
SHELL="/bin/sh" SHELL="/bin/sh"
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "ProblemStatBase.h" #include "ProblemStatBase.h"
#include "StandardProblemIteration.h" #include "StandardProblemIteration.h"
#include "ElementFileWriter.h" #include "ElementFileWriter.h"
#include "Serializer.h"
#include "petscksp.h" #include "petscksp.h"
...@@ -35,13 +34,13 @@ namespace AMDiS { ...@@ -35,13 +34,13 @@ namespace AMDiS {
return (*dof1 < *dof2); return (*dof1 < *dof2);
} }
ParallelDomainBase::ParallelDomainBase(std::string name, ParallelDomainBase::ParallelDomainBase(ProblemIterationInterface *iIF,
ProblemIterationInterface *iIF,
ProblemTimeInterface *tIF, ProblemTimeInterface *tIF,
FiniteElemSpace *fe, FiniteElemSpace *fe,
RefinementManager *refineManager) RefinementManager *refineManager)
: iterationIF(iIF), : iterationIF(iIF),
timeIF(tIF), timeIF(tIF),
name(iIF->getName()),
feSpace(fe), feSpace(fe),
mesh(fe->getMesh()), mesh(fe->getMesh()),
refinementManager(refineManager), refinementManager(refineManager),
...@@ -1605,7 +1604,7 @@ namespace AMDiS { ...@@ -1605,7 +1604,7 @@ namespace AMDiS {
SerUtil::serialize(out, mapLocalToDofIndex); SerUtil::serialize(out, mapLocalToDofIndex);
SerUtil::serialize(out, isRankDof); SerUtil::serialize(out, isRankDof);
// SerUtil::serialize(out, vertexDof); serialize(out, vertexDof);
SerUtil::serialize(out, &rstart); SerUtil::serialize(out, &rstart);
SerUtil::serialize(out, &nRankRows); SerUtil::serialize(out, &nRankRows);
...@@ -1649,7 +1648,7 @@ namespace AMDiS { ...@@ -1649,7 +1648,7 @@ namespace AMDiS {
SerUtil::deserialize(in, mapLocalToDofIndex); SerUtil::deserialize(in, mapLocalToDofIndex);
SerUtil::deserialize(in, isRankDof); SerUtil::deserialize(in, isRankDof);
// SerUtil::deserialize(in, vertexDof); deserialize(in, vertexDof, dofMap);
SerUtil::deserialize(in, &rstart); SerUtil::deserialize(in, &rstart);
SerUtil::deserialize(in, &nRankRows); SerUtil::deserialize(in, &nRankRows);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "FiniteElemSpace.h" #include "FiniteElemSpace.h"
#include "AdaptInfo.h" #include "AdaptInfo.h"
#include "InteriorBoundary.h" #include "InteriorBoundary.h"
#include "Serializer.h"
#include "AMDiS_fwd.h" #include "AMDiS_fwd.h"
#include "petsc.h" #include "petsc.h"
...@@ -81,8 +82,7 @@ namespace AMDiS { ...@@ -81,8 +82,7 @@ namespace AMDiS {
typedef std::map<const DegreeOfFreedom*, DegreeOfFreedom> DofIndexMap; typedef std::map<const DegreeOfFreedom*, DegreeOfFreedom> DofIndexMap;
public: public:
ParallelDomainBase(std::string name, ParallelDomainBase(ProblemIterationInterface *iterationIF,
ProblemIterationInterface *iterationIF,
ProblemTimeInterface *timeIF, ProblemTimeInterface *timeIF,
FiniteElemSpace *feSpace, FiniteElemSpace *feSpace,
RefinementManager *refineManager); RefinementManager *refineManager);
...@@ -305,7 +305,38 @@ namespace AMDiS { ...@@ -305,7 +305,38 @@ namespace AMDiS {
/// Reads a \ref RankToDofContainer from an input stream. /// Reads a \ref RankToDofContainer from an input stream.
void deserialize(std::istream &in, RankToDofContainer &data, void deserialize(std::istream &in, RankToDofContainer &data,
std::map<int, const DegreeOfFreedom*> &dofMap); std::map<int, const DegreeOfFreedom*> &dofMap);
/// Writes a mapping from dof pointers to some values to an output stream.
template<typename T>
void serialize(std::ostream &out, std::map<const DegreeOfFreedom*, T> &data)
{
int mapSize = data.size();
SerUtil::serialize(out, &mapSize);
for (typename std::map<const DegreeOfFreedom*, T>::iterator it = data.begin();
it != data.end(); ++it) {
int v1 = (*(it->first));
T v2 = it->second;
SerUtil::serialize(out, &v1);
SerUtil::serialize(out, &v2);
}
}
/// Reads a mapping from dof pointer to some values from an input stream.
template<typename T>
void deserialize(std::istream &in, std::map<const DegreeOfFreedom*, T> &data,
std::map<int, const DegreeOfFreedom*> &dofMap)
{
int mapSize = 0;
SerUtil::deserialize(in, &mapSize);
for (int i = 0; i < mapSize; i++) {
int v1 = 0;
T v2;
SerUtil::deserialize(in, &v1);
SerUtil::deserialize(in, &v2);
data[dofMap[v1]] = v2;
}
}
inline void orderDOFs(const DegreeOfFreedom* dof1, inline void orderDOFs(const DegreeOfFreedom* dof1,
const DegreeOfFreedom* dof2, const DegreeOfFreedom* dof2,
const DegreeOfFreedom* dof3, const DegreeOfFreedom* dof3,
......
...@@ -5,11 +5,9 @@ ...@@ -5,11 +5,9 @@
namespace AMDiS { namespace AMDiS {
ParallelDomainScal::ParallelDomainScal(std::string name, ParallelDomainScal::ParallelDomainScal(ProblemScal *problem,
ProblemScal *problem,
ProblemInstatScal *problemInstat) ProblemInstatScal *problemInstat)
: ParallelDomainBase(name, : ParallelDomainBase(problem,
problem,
problemInstat, problemInstat,
problem->getFESpace(), problem->getFESpace(),
problem->getRefinementManager()), problem->getRefinementManager()),
......
...@@ -29,8 +29,7 @@ namespace AMDiS { ...@@ -29,8 +29,7 @@ namespace AMDiS {
class ParallelDomainScal : public ParallelDomainBase class ParallelDomainScal : public ParallelDomainBase
{ {
public: public:
ParallelDomainScal(std::string name, ParallelDomainScal(ProblemScal *problem,
ProblemScal *problem,
ProblemInstatScal *problemInstat); ProblemInstatScal *problemInstat);
void initParallelization(AdaptInfo *adaptInfo); void initParallelization(AdaptInfo *adaptInfo);
......
...@@ -5,11 +5,9 @@ ...@@ -5,11 +5,9 @@
namespace AMDiS { namespace AMDiS {
ParallelDomainVec::ParallelDomainVec(std::string name, ParallelDomainVec::ParallelDomainVec(ProblemVec *problem,
ProblemVec *problem,
ProblemInstatVec *problemInstat) ProblemInstatVec *problemInstat)
: ParallelDomainBase(name, : ParallelDomainBase(problem,
problem,
problemInstat, problemInstat,
problem->getFESpace(0), problem->getFESpace(0),
problem->getRefinementManager(0)), problem->getRefinementManager(0)),
......
...@@ -30,8 +30,7 @@ namespace AMDiS { ...@@ -30,8 +30,7 @@ namespace AMDiS {
class ParallelDomainVec : public ParallelDomainBase class ParallelDomainVec : public ParallelDomainBase
{ {
public: public:
ParallelDomainVec(std::string name, ParallelDomainVec(ProblemVec *problem,
ProblemVec *problem,
ProblemInstatVec *problemInstat); ProblemInstatVec *problemInstat);
void initParallelization(AdaptInfo *adaptInfo); void initParallelization(AdaptInfo *adaptInfo);
......
...@@ -485,10 +485,14 @@ namespace AMDiS { ...@@ -485,10 +485,14 @@ namespace AMDiS {
{ {
fileWriters.push_back(new FileWriter(name + "->output", mesh, solution)); fileWriters.push_back(new FileWriter(name + "->output", mesh, solution));
int writeSerialization = 0; int writeSerialization = 0;
GET_PARAMETER(0, name + "->output->write serialization", "%d", GET_PARAMETER(0, name + "->output->write serialization", "%d", &writeSerialization);
&writeSerialization);
// Serialization is not allowed to be done by the problem, if its part of a parallel
// problem definition. Than, the parallel problem object must be serialized.
#ifndef HAVE_PARALLEL_DOMAIN_AMDIS
if (writeSerialization) if (writeSerialization)
fileWriters.push_back(new Serializer<ProblemScal>(this)); fileWriters.push_back(new Serializer<ProblemScal>(this));
#endif
} }
void ProblemScal::estimate(AdaptInfo *adaptInfo) void ProblemScal::estimate(AdaptInfo *adaptInfo)
......
...@@ -470,8 +470,13 @@ namespace AMDiS { ...@@ -470,8 +470,13 @@ namespace AMDiS {
} }
GET_PARAMETER(0, name + "->output->write serialization", "%d", &writeSerialization); GET_PARAMETER(0, name + "->output->write serialization", "%d", &writeSerialization);
// Serialization is not allowed to be done by the problem, if its part of a parallel
// problem definition. Than, the parallel problem object must be serialized.
#ifndef HAVE_PARALLEL_DOMAIN_AMDIS
if (writeSerialization) if (writeSerialization)
fileWriters.push_back(new Serializer<ProblemVec>(this)); fileWriters.push_back(new Serializer<ProblemVec>(this));
#endif
} }
void ProblemVec::doOtherStuff() void ProblemVec::doOtherStuff()
...@@ -1385,404 +1390,6 @@ namespace AMDiS { ...@@ -1385,404 +1390,6 @@ namespace AMDiS {
delete sol; delete sol;
} }
} }
void ProblemVec::createDofToCoordMap(DofToCoord &dofMap)
{
const BasisFunction *basisFcts = componentSpaces[0]->getBasisFcts();
WorldVector<double> coords;
ElementDofIterator elDofIter(componentSpaces[0], true);
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirst(componentMeshes[0], -1,
Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
while (elInfo) {
elDofIter.reset(elInfo->getElement());
int i = 0;
do {
DimVec<double> *baryCoord = basisFcts->getCoords(i);
elInfo->coordToWorld(*baryCoord, coords);
i++;
dofMap[elDofIter.getDof()] = coords;
} while (elDofIter.next());
elInfo = stack.traverseNext(elInfo);
}
}
void ProblemVec::createCoordToDofMap(CoordToDof &dofMap)
{
const BasisFunction *basisFcts = componentSpaces[0]->getBasisFcts();
WorldVector<double> coords;
ElementDofIterator elDofIter(componentSpaces[0], true);
TraverseStack stack;
ElInfo *elInfo = stack.traverseFirst(componentMeshes[0], -1,
Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
while (elInfo) {
elDofIter.reset(elInfo->getElement());
int i = 0;
do {
DimVec<double> *baryCoord = basisFcts->getCoords(i);
elInfo->coordToWorld(*baryCoord, coords);
i++;
dofMap[coords] = elDofIter.getDof();
} while (elDofIter.next());
elInfo = stack.traverseNext(elInfo);
}
}
void ProblemVec::writeDbgMatrix(std::string filename)
{
FUNCNAME("ProblemVec::writeDbMatrix()");
using mtl::tag::major; using mtl::tag::nz; using mtl::begin; using mtl::end;
namespace traits = mtl::traits;
typedef DOFMatrix::base_matrix_type Matrix;
typedef traits::range_generator<major, Matrix>::type cursor_type;
typedef traits::range_generator<nz, cursor_type>::type icursor_type;
// Create map with all world coordinates of all DOFs.
DofToCoord dofToCoords;
createDofToCoordMap(dofToCoords);
// Start writing output file.
std::ofstream out(filename.c_str());
out.precision(15);
// First, we write the number of DOFs the file contains.
out << dofToCoords.size() << std::endl;
int dimOfWorld = Global::getGeo(WORLD);
// And now write all the DOF's coords. The first line contains the dof index, all
// the other lines contain one component of the coordinates.
for (DofToCoord::iterator it = dofToCoords.begin(); it != dofToCoords.end(); ++it) {
out << it->first << std::endl;
for (int j = 0; j < dimOfWorld; j++)
out << (it->second)[j] << std::endl;
}
// Write the matrices.
for (int i = 0; i < nComponents; i++) {
for (int j = 0; j < nComponents; j++) {
DOFMatrix *dofmatrix = (*systemMatrix)[i][j];
if (!dofmatrix)
continue;
Matrix& matrix = dofmatrix->getBaseMatrix();
int nnz = matrix.nnz();
int testNnz = 0;
// Write to file, how many entries the matrix conatins.
out << nnz << std::endl;
traits::row<Matrix>::type row(matrix);
traits::col<Matrix>::type col(matrix);
traits::const_value<Matrix>::type value(matrix);
for (cursor_type cursor = begin<major>(matrix), cend = end<major>(matrix); cursor != cend; ++cursor) {
for (icursor_type icursor = begin<nz>(cursor), icend = end<nz>(cursor); icursor != icend; ++icursor) {
out << row(*icursor) << " "
<< col(*icursor) << " "
<< value(*icursor) << std::endl;
testNnz++;
}
}
// Just to check, if nnz() is correct.
TEST_EXIT(testNnz == nnz)("NNZ does not fit together!\n");
}
}
for (int i = 0; i < nComponents; i++) {
out << rhs->getDOFVector(i)->getUsedSize() << std::endl;
DOFIterator<double> it(rhs->getDOFVector(i), USED_DOFS);
int c = 0;
for (it.reset(); !it.end(); ++it) {
out << c << " " << *it << std::endl;
c++;
}
TEST_EXIT(c == rhs->getDOFVector(i)->getUsedSize())
("RHS NNZ does not fit together!\n");
}
for (int i = 0; i < nComponents; i++) {
out << solution->getDOFVector(i)->getUsedSize() << std::endl;
DOFIterator<double> it(solution->getDOFVector(i), USED_DOFS);
int c = 0;
for (it.reset(); !it.end(); ++it) {
out << c << " " << *it << std::endl;
c++;
}
TEST_EXIT(c == rhs->getDOFVector(i)->getUsedSize())
("RHS NNZ does not fit together!\n");
}
out.close();
}
void ProblemVec::readAndCompareDbgMatrix(std::vector<std::string> filenames)
{
using mtl::tag::major; using mtl::tag::nz; using mtl::begin; using mtl::end;
namespace traits = mtl::traits;
typedef DOFMatrix::base_matrix_type Matrix;
typedef traits::range_generator<major, Matrix>::type cursor_type;
typedef traits::range_generator<nz, cursor_type>::type icursor_type;
// Create a map from coords of all DOFs, to the DOF indices in this problem.
CoordToDof coordToDof;
createCoordToDofMap(coordToDof);
int dimOfWorld = Global::getGeo(WORLD);
std::vector<std::vector<std::map<std::pair<int, int>, double> > > nnzValues(nComponents);
std::vector<std::map<int, double> > rhsValues(nComponents);
std::vector<std::map<int, double> > solValues(nComponents);
for (int i = 0; i < nComponents; i++)
nnzValues[i].resize(nComponents);
// Stores to each dof index of this problem a map from rank indices (of each rank
// that also has this dof) to the corresponding local dof index.
std::map<DegreeOfFreedom, std::vector<DegreeOfFreedom> > dofMapHereToFiles;
for (std::vector<std::string>::iterator fileIt = filenames.begin();
fileIt != filenames.end(); ++fileIt) {
// Open file and read the number of DOFs the file contains.
std::ifstream in(fileIt->c_str());
int nReadDofs;
in >> nReadDofs;
// Is used to map the dof indices in the files to the global coordinates.
DofToCoord dofToCoord;
// Read all DOF indices and their world coordinates.
for (int i = 0; i < nReadDofs; i++) {
DegreeOfFreedom dof;
WorldVector<double> coords;
in >> dof;
for (int j = 0; j < dimOfWorld; j++)
in >> coords[j];
dofToCoord[dof] = coords;
}
std::map<DegreeOfFreedom, DegreeOfFreedom> dofMapFileToHere;
for (DofToCoord::iterator it = dofToCoord.begin(); it != dofToCoord.end(); ++it) {
DegreeOfFreedom dofIndexInFile = it->first;
WorldVector<double> &dofCoords = it->second;
if (coordToDof.find(dofCoords) == coordToDof.end()) {
std::cout << "Cannot find dof index for coords: " << std::endl;
dofCoords.print();
exit(0);
}
DegreeOfFreedom dofIndexHere = coordToDof[dofCoords];
dofMapHereToFiles[dofIndexHere].push_back(dofIndexInFile);
dofMapFileToHere[dofIndexInFile] = dofIndexHere;
}
// Now we traverse all matrices and check them.
for (int i = 0; i < nComponents; i++) {
for (int j = 0; j < nComponents; j++) {
DOFMatrix *dofmatrix = (*systemMatrix)[i][j];
if (!dofmatrix)
continue;
int readNnz;
in >> readNnz;
// Read each entry in file and check it with the corresponding matrix value
// in this problem.
for (int k = 0; k < readNnz; k++) {