Commit ecadddee authored by Naumann, Andreas's avatar Naumann, Andreas
Browse files

pmtl usage

implicit problem read arh file instead of dat files
memory error warning in dofvector
parent 8e4f16ac
...@@ -14,11 +14,17 @@ if(AMDIS_HAS_PARALLEL_DOMAIN) ...@@ -14,11 +14,17 @@ if(AMDIS_HAS_PARALLEL_DOMAIN)
list(APPEND AMDIS_LIBRARIES ${PETSC_LIBRARY_SYS} ${PETSC_LIBRARIES}) list(APPEND AMDIS_LIBRARIES ${PETSC_LIBRARY_SYS} ${PETSC_LIBRARIES})
list(APPEND AMDIS_INCLUDE_DIRS ${PETSC_INCLUDES}) list(APPEND AMDIS_INCLUDE_DIRS ${PETSC_INCLUDES})
else() else()
message(FATAL_ERROR "Could nit find PETSc!") message(FATAL_ERROR "Could not find PETSc!")
endif(PETSC_FOUND) endif(PETSC_FOUND)
elseif(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PMTL") elseif(AMDIS_HAS_PARALLEL_DOMAIN STREQUAL "PMTL")
find_package(MTL REQUIRED) find_package(MTL REQUIRED)
list(APPEND AMDIS_LIBRARIES ${MTL_LIBRARIES}) list(APPEND AMDIS_LIBRARIES ${MTL_LIBRARIES})
find_library(PARMETIS_LIB parmetis)
if(PARMETIS_LIB)
list(APPEND AMDIS_LIBRARIES ${PARMETIS_LIB})
else(PARMETIS_LIB)
message(ERROR "could not find the parmetis libraries needed by amdis")
endif(PARMETIS_LIB)
endif() endif()
endif(AMDIS_HAS_PARALLEL_DOMAIN) endif(AMDIS_HAS_PARALLEL_DOMAIN)
......
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
#if HAVE_PARALLEL_DOMAIN_AMDIS #if HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/MeshDistributor.h" #include "parallel/MeshDistributor.h"
#ifndef HAVE_PARALLEL_MTL4
#include <petsc.h> #include <petsc.h>
#endif #endif
#endif
namespace AMDiS { namespace AMDiS {
......
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
#if HAVE_PARALLEL_DOMAIN_AMDIS #if HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/MeshDistributor.h" #include "parallel/MeshDistributor.h"
#ifndef HAVE_PARALLEL_MTL4
#include <petsc.h> #include <petsc.h>
#endif #endif
#endif
namespace AMDiS { namespace AMDiS {
......
...@@ -68,7 +68,7 @@ namespace AMDiS { ...@@ -68,7 +68,7 @@ namespace AMDiS {
template<> template<>
const double& DOFVector<double>::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, double* values) const const double DOFVector<double>::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, double* values) const
{ {
FUNCNAME("DOFVector<double>::evalAtCoords()"); FUNCNAME("DOFVector<double>::evalAtCoords()");
...@@ -114,7 +114,7 @@ namespace AMDiS { ...@@ -114,7 +114,7 @@ namespace AMDiS {
template<> template<>
const WorldVector<double>& DOFVector<WorldVector<double> >::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, WorldVector<double>* values) const const WorldVector<double> DOFVector<WorldVector<double> >::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, WorldVector<double>* values) const
{ {
FUNCNAME("DOFVector<double>::evalAtCoords()"); FUNCNAME("DOFVector<double>::evalAtCoords()");
......
...@@ -542,7 +542,7 @@ namespace AMDiS { ...@@ -542,7 +542,7 @@ namespace AMDiS {
/// eval DOFVector at given point p. If oldElInfo != NULL the search for the element, where p is inside, /// eval DOFVector at given point p. If oldElInfo != NULL the search for the element, where p is inside,
/// starts from oldElInfo. /// starts from oldElInfo.
const T& evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo = NULL, T* value = NULL) const; const T evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo = NULL, T* value = NULL) const;
/// Writes the data of the DOFVector to an output stream. /// Writes the data of the DOFVector to an output stream.
void serialize(std::ostream &out) void serialize(std::ostream &out)
...@@ -582,8 +582,8 @@ namespace AMDiS { ...@@ -582,8 +582,8 @@ namespace AMDiS {
}; };
template<> /*template<>
const double& DOFVector<double>::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, double* value) const; const double DOFVector<double>::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, double* value) const;
template<> template<>
const WorldVector<double>& DOFVector<WorldVector<double> >::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, WorldVector<double>* value) const; const WorldVector<double>& DOFVector<WorldVector<double> >::evalAtPoint(WorldVector<double> &p, ElInfo *oldElInfo, WorldVector<double>* value) const;
...@@ -592,7 +592,7 @@ namespace AMDiS { ...@@ -592,7 +592,7 @@ namespace AMDiS {
void DOFVector<double>::refineInterpol(RCNeighbourList&, int); void DOFVector<double>::refineInterpol(RCNeighbourList&, int);
template<> template<>
void DOFVector<double>::coarseRestrict(RCNeighbourList&, int); void DOFVector<double>::coarseRestrict(RCNeighbourList&, int); */
inline double min(const DOFVector<double>& v) inline double min(const DOFVector<double>& v)
{ {
......
...@@ -55,7 +55,7 @@ namespace AMDiS { ...@@ -55,7 +55,7 @@ namespace AMDiS {
error = worker.solve(matrix ,mtl_x, mtl_b); error = worker.solve(matrix ,mtl_x, mtl_b);
mtl::dense_vector<typename MTLMatrix::value_type> r(mtl_b); MTLVector r(mtl_b);
r -= matrix * mtl_x; r -= matrix * mtl_x;
double residual = two_norm(r); double residual = two_norm(r);
MSG("MTL4Solver: ||b-Ax||= %e\n", residual); MSG("MTL4Solver: ||b-Ax||= %e\n", residual);
......
...@@ -12,14 +12,15 @@ ...@@ -12,14 +12,15 @@
#include "ProblemImplicit.h" #include "ProblemImplicit.h"
#include "MathFunctions.h" #include "MathFunctions.h"
#include "io/ArhReader.h"
using namespace std; using namespace std;
namespace AMDiS { namespace AMDiS {
void ProblemImplicitBase::readDofVec(std::istream& in, DOFVector<double>* vec, void ProblemImplicit::readDofVec(const std::string& filename, DOFVector<double>* vec,
Mesh* mesh) Mesh* mesh)
{ {
#if 0
long size = mesh->getNumberOfVertices(); long size = mesh->getNumberOfVertices();
TEST_EXIT(vec->getSize()>=size)("dofvector smaller than vertex data vector\n"); TEST_EXIT(vec->getSize()>=size)("dofvector smaller than vertex data vector\n");
...@@ -34,13 +35,15 @@ namespace AMDiS { ...@@ -34,13 +35,15 @@ namespace AMDiS {
in >> buf; in >> buf;
(*vec)[i] = atof(buf.c_str()); (*vec)[i] = atof(buf.c_str());
} }
#endif
ArhReader::read(filename, vec->getFeSpace()->getMesh(), vec);
} }
void ProblemImplicitBase::readR(std::istream& inStream, double eps, void ProblemImplicit::readR(const std::string& inStream, double eps,
Mesh* mesh, int implMesh , int comp) Mesh* mesh, int implMesh , int comp)
{ {
FUNCNAME("ProblemImplicitBase::readR()"); FUNCNAME("ProblemImplicit::readR()");
DOFVector<double>* r = getSignedDistance(implMesh, comp); DOFVector<double>* r = getSignedDistance(implMesh, comp);
DOFVector<double>* phi1 = getPhi1(implMesh, comp); DOFVector<double>* phi1 = getPhi1(implMesh, comp);
...@@ -67,7 +70,7 @@ namespace AMDiS { ...@@ -67,7 +70,7 @@ namespace AMDiS {
} }
void ProblemImplicitBase::readPhi1(istream& inStream, double eps, void ProblemImplicit::readPhi1(const std::string& inStream, double eps,
Mesh* mesh, int implMesh, int comp) Mesh* mesh, int implMesh, int comp)
{ {
DOFVector<double>* r = getSignedDistance(implMesh, comp); DOFVector<double>* r = getSignedDistance(implMesh, comp);
...@@ -95,7 +98,7 @@ namespace AMDiS { ...@@ -95,7 +98,7 @@ namespace AMDiS {
} }
void ProblemImplicitBase::readPhi2(istream& inStream, double eps, void ProblemImplicit::readPhi2(const std::string& inStream, double eps,
Mesh* mesh, int implMesh, int comp) Mesh* mesh, int implMesh, int comp)
{ {
DOFVector<double>* r = getSignedDistance(implMesh, comp); DOFVector<double>* r = getSignedDistance(implMesh, comp);
...@@ -122,21 +125,27 @@ namespace AMDiS { ...@@ -122,21 +125,27 @@ namespace AMDiS {
} }
std::string ProblemImplicitBase::getDofFilename(std::string path, int implMesh) std::string ProblemImplicit::getDofFilename(std::string path, int implMesh)
{ {
FUNCNAME("ProblemImplicit::getDofFilename()");
std::string suffix = "[" + std::string suffix = "[" +
boost::lexical_cast< std::string >(implMesh) + boost::lexical_cast< std::string >(implMesh) +
"]"; "]";
std::string dofFilename(""); std::string dofFilename("");
Parameters::get(path + "dof file" + suffix, dofFilename); Parameters::get(path + "dof file" + suffix, dofFilename);
if (implMesh == 0 && dofFilename.length() == 0) TEST_EXIT(dofFilename.length() == 0)("dof file was changed to \"arh file\" and reads an arh file now");
Parameters::get(path + "arh file" + suffix, dofFilename);
if (implMesh == 0 && dofFilename.length() == 0) {
Parameters::get(path + "dof file", dofFilename); Parameters::get(path + "dof file", dofFilename);
TEST_EXIT(dofFilename.length() == 0)("dof file was changed to \"arh file\" and reads an arh file now");
Parameters::get(path + "arh file", dofFilename);
}
return dofFilename; return dofFilename;
} }
double ProblemImplicitBase::getEpsilon(std::string path, int implMesh) double ProblemImplicit::getEpsilon(std::string path, int implMesh)
{ {
std::string suffix = "[" + std::string suffix = "[" +
boost::lexical_cast< std::string >(implMesh) + boost::lexical_cast< std::string >(implMesh) +
...@@ -150,7 +159,7 @@ namespace AMDiS { ...@@ -150,7 +159,7 @@ namespace AMDiS {
} }
int ProblemImplicitBase::getType(std::string path, int implMesh) int ProblemImplicit::getType(std::string path, int implMesh)
{ {
std::string suffix = "[" + std::string suffix = "[" +
boost::lexical_cast< std::string >(implMesh) + boost::lexical_cast< std::string >(implMesh) +
...@@ -215,17 +224,16 @@ namespace AMDiS { ...@@ -215,17 +224,16 @@ namespace AMDiS {
{ {
FUNCNAME("ProblemImplicit::createImplicitMesh()"); FUNCNAME("ProblemImplicit::createImplicitMesh()");
if (!isImplicitMesh(p))
return false;
std::string path = name + "->implicit mesh[" std::string path = name + "->implicit mesh["
+ boost::lexical_cast< std::string >(p) + "]->"; + boost::lexical_cast< std::string >(p) + "]->";
int nImplMeshes(0); int nImplMeshes(0);
Parameters::get(path + "nr meshes", nImplMeshes); Parameters::get(path + "nr meshes", nImplMeshes);
if (nImplMeshes == 0)
r[p].resize(nImplMeshes); return false;
phi1[p].resize(nImplMeshes); r[p].resize(nImplMeshes, NULL);
phi2[p].resize(nImplMeshes); phi1[p].resize(nImplMeshes, NULL);
levelSet[p].resize(nImplMeshes); phi2[p].resize(nImplMeshes, NULL);
levelSet[p].resize(nImplMeshes, NULL);
for ( int i = 0; i < nImplMeshes ; ++i ) { for ( int i = 0; i < nImplMeshes ; ++i ) {
(r[p])[i] = new DOFVector< double >(getFeSpace(p), "r"); (r[p])[i] = new DOFVector< double >(getFeSpace(p), "r");
...@@ -256,21 +264,19 @@ namespace AMDiS { ...@@ -256,21 +264,19 @@ namespace AMDiS {
TEST_EXIT(meshes[comp] != NULL)("the mesh was not created\n"); TEST_EXIT(meshes[comp] != NULL)("the mesh was not created\n");
std::ifstream inStream(dofFilename.c_str());
switch (serType) { switch (serType) {
case 0: case 0:
readR(inStream, eps, meshes[comp], implMesh, comp); readR(dofFilename, eps, meshes[comp], implMesh, comp);
break; break;
case 1: case 1:
readPhi1(inStream, eps, meshes[comp], implMesh, comp); readPhi1(dofFilename, eps, meshes[comp], implMesh, comp);
break; break;
case 2: case 2:
readPhi2(inStream, eps, meshes[comp], implMesh, comp); readPhi2(dofFilename, eps, meshes[comp], implMesh, comp);
break; break;
default: default:
WARNING("unknown implicit mesh type\n"); WARNING("unknown implicit mesh type\n");
} }
inStream.close();
return true; return true;
} }
...@@ -279,8 +285,8 @@ namespace AMDiS { ...@@ -279,8 +285,8 @@ namespace AMDiS {
{ {
FUNCNAME("ProblemImplicit::createMesh()"); FUNCNAME("ProblemImplicit::createMesh()");
ProblemStatSeq::createMesh(); ProblemStat::createMesh();
#if 0
implMesh.resize(meshes.size()); implMesh.resize(meshes.size());
for (unsigned int i = 0 ; i < meshes.size() ; ++i ) { for (unsigned int i = 0 ; i < meshes.size() ; ++i ) {
std::string path = name + "->implicit mesh[" + std::string path = name + "->implicit mesh[" +
...@@ -298,7 +304,8 @@ namespace AMDiS { ...@@ -298,7 +304,8 @@ namespace AMDiS {
inStream.close(); inStream.close();
} else } else
implMesh[i] = false; implMesh[i] = false;
} }
#endif
} }
...@@ -308,7 +315,27 @@ namespace AMDiS { ...@@ -308,7 +315,27 @@ namespace AMDiS {
{ {
FUNCNAME("ProblemImplicit::initialize()"); FUNCNAME("ProblemImplicit::initialize()");
ProblemStatSeq::initialize(initFlag); ProblemStat::initialize(initFlag);
createImplicitMesh(); if ( initFlag.isSet(INIT_IMPLICIT_MESH) )
createImplicitMesh();
}
ProblemImplicit::~ProblemImplicit()
{
for ( unsigned int p(0); p < meshes.size(); ++p ) {
for ( unsigned int i = 0; i < r[p].size() ; ++i )
if ( r[p][i] != NULL)
delete r[p][i];
for ( unsigned int i(0); i < phi1[p].size(); ++i )
if ( phi1[p][i] != NULL)
delete phi1[p][i];
for ( unsigned int i(0); i < phi2[p].size(); ++i )
if ( phi2[p][i] != NULL)
delete phi2[p][i];
for ( unsigned int i(0); i < levelSet[p].size(); ++i )
if ( levelSet[p][i] != NULL)
delete levelSet[p][i];
}
} }
} }
...@@ -23,81 +23,69 @@ ...@@ -23,81 +23,69 @@
#ifndef AMDIS_PROBLEM_IMPLICIT_H #ifndef AMDIS_PROBLEM_IMPLICIT_H
#define AMDIS_PROBLEM_IMPLICIT_H #define AMDIS_PROBLEM_IMPLICIT_H
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#ifdef HAVE_PARALLEL_MTL4
#include "parallel/Mtl4Solver.h"
#else
#include "parallel/PetscProblemStat.h"
#endif
#else
#include "ProblemStat.h" #include "ProblemStat.h"
#endif
namespace AMDiS { namespace AMDiS {
using namespace std; using namespace std;
const Flag INIT_IMPLICIT_MESH = 0X2000L;
class ProblemImplicitBase class ProblemImplicit : public ProblemStat
{
public:
virtual ~ProblemImplicitBase() {}
virtual bool createImplicitMesh() = 0;
virtual DOFVector<double>* getSignedDistance(unsigned int im = 0,
unsigned int m = 0) = 0;
virtual DOFVector<double>* getPhi1(unsigned int im = 0,
unsigned int m = 0) = 0;
virtual DOFVector<double>* getPhi2(unsigned int im = 0,
unsigned int m = 0) = 0;
virtual DOFVector<double>* getLevelset(unsigned int im = 0,
unsigned int m = 0) = 0;
protected:
void readDofVec(istream& , DOFVector<double>* , Mesh*);
void readR(istream&, double, Mesh*, int implMesh = 0, int comp = 0);
void readPhi1(istream&, double, Mesh*, int implMesh = 0, int comp = 0);
void readPhi2(istream&, double, Mesh*, int implMesh = 0, int comp = 0);
string getDofFilename(string path, int implMesh = 0);
double getEpsilon(string path, int implMesh = 0);
int getType(string path, int implMesh = 0);
virtual bool isImplicitMesh(int comp = 0) = 0;
};
class ProblemImplicit : public ProblemStatSeq,
public ProblemImplicitBase
{ {
public: public:
ProblemImplicit(string name, ProblemImplicit(string name,
ProblemIterationInterface* problem = NULL) ProblemIterationInterface* problem = NULL)
: ProblemStatSeq(name, problem), : ProblemStat(name, problem),
r(0), r(0),
phi1(0), phi1(0),
phi2(0), phi2(0),
levelSet(0), levelSet(0)
implMesh(0)
{} {}
virtual void createMesh(); virtual ~ProblemImplicit();
virtual bool createImplicitMesh(); virtual void createMesh();
virtual void initialize(Flag initFlag, virtual void initialize(Flag initFlag,
ProblemStatSeq* adoptProblem = NULL, ProblemStatSeq* adoptProblem = NULL,
Flag adoptFlag = INIT_NOTHING); Flag adoptFlag = INIT_NOTHING);
DOFVector<double>* getSignedDistance(unsigned int im = 0, unsigned int m = 0); bool createImplicitMesh();
DOFVector<double>* getPhi1(unsigned int im = 0, unsigned int m = 0); DOFVector<double>* getSignedDistance(unsigned int im = 0,
unsigned int m = 0) ;
DOFVector<double>* getPhi2(unsigned int im = 0, unsigned int m = 0); DOFVector<double>* getPhi1(unsigned int im = 0,
unsigned int m = 0) ;
DOFVector<double>* getPhi2(unsigned int im = 0,
unsigned int m = 0) ;
DOFVector<double>* getLevelset(unsigned int im = 0,
unsigned int m = 0) ;
DOFVector<double>* getLevelset(unsigned int im = 0, unsigned int m = 0);
protected: protected:
void readDofVec(const std::string& , DOFVector<double>* , Mesh*);
void readR(const std::string&, double, Mesh*, int implMesh = 0, int comp = 0);
void readPhi1(const std::string&, double, Mesh*, int implMesh = 0, int comp = 0);
void readPhi2(const std::string&, double, Mesh*, int implMesh = 0, int comp = 0);
string getDofFilename(string path, int implMesh = 0);
double getEpsilon(string path, int implMesh = 0);
int getType(string path, int implMesh = 0);
bool createImplicitMesh(int p); bool createImplicitMesh(int p);
bool createImplicitMesh(string, int, int); bool createImplicitMesh(string, int, int);
...@@ -115,12 +103,8 @@ namespace AMDiS { ...@@ -115,12 +103,8 @@ namespace AMDiS {
/// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0) /// (levelSet(x): x \in \Omega: 1, x \not \in Omega: -1, x \in \Gamma: 0)
vector< vector<DOFVector<double>*> > levelSet; vector< vector<DOFVector<double>*> > levelSet;
vector<bool> implMesh;
bool isImplicitMesh(int comp = 0)
{
return implMesh[comp];
}
}; };
} }
#endif #endif
...@@ -33,8 +33,12 @@ ...@@ -33,8 +33,12 @@
#include "ProblemStat.h" #include "ProblemStat.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#ifdef HAVE_PARALLEL_MTL4
#include "parallel/Mtl4Solver.h"
#else
#include "parallel/PetscProblemStat.h" #include "parallel/PetscProblemStat.h"
#endif #endif
#endif
namespace AMDiS { namespace AMDiS {
......
...@@ -30,8 +30,12 @@ ...@@ -30,8 +30,12 @@
#include "MatrixVector.h" #include "MatrixVector.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS #ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#ifdef HAVE_PARALLEL_MTL4
#include "parallel/Mtl4Solver.h"
#else
#include "parallel/PetscProblemStat.h" #include "parallel/PetscProblemStat.h"
#endif #endif
#endif
namespace AMDiS {