Commit 4a0bdb2f authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Work on pdd and some other small code refactorings.

parent a27257cd
...@@ -52,6 +52,7 @@ namespace AMDiS { ...@@ -52,6 +52,7 @@ namespace AMDiS {
class ITL_BasePreconditioner; class ITL_BasePreconditioner;
class LeafDataPeriodic; class LeafDataPeriodic;
class LevelAdmin; class LevelAdmin;
class Line;
class MacroElement; class MacroElement;
class MacroInfo; class MacroInfo;
class Marker; class Marker;
...@@ -80,9 +81,13 @@ namespace AMDiS { ...@@ -80,9 +81,13 @@ namespace AMDiS {
class RCNeighbourList; class RCNeighbourList;
class RefinementManager; class RefinementManager;
class RobinBC; class RobinBC;
class SubElInfo;
class SurfaceOperator;
class SMIAdapter; class SMIAdapter;
class SystemVector; class SystemVector;
class Tetrahedron;
class TraverseStack; class TraverseStack;
class Triangle;
class VertexInfo; class VertexInfo;
class VertexVector; class VertexVector;
......
...@@ -222,6 +222,17 @@ namespace AMDiS { ...@@ -222,6 +222,17 @@ namespace AMDiS {
DegreeOfFreedom col = colIndices[j]; DegreeOfFreedom col = colIndices[j];
double entry = elMat[i][j]; double entry = elMat[i][j];
/*
if (MPI::COMM_WORLD.Get_rank() == 0 && (row >= 156 || col >= 156))
std::cout << "PROB 0: " << row << " " << col << std::endl;
if (MPI::COMM_WORLD.Get_rank() == 1 && (row >= 151 || col >= 151))
std::cout << "PROB 1: " << row << " " << col << std::endl;
if (MPI::COMM_WORLD.Get_rank() == 2 && (row >= 146 || col >= 146))
std::cout << "PROB 2: " << row << " " << col << std::endl;
if (MPI::COMM_WORLD.Get_rank() == 3 && (row >= 153 || col >= 153))
std::cout << "PROB 3: " << row << " " << col << std::endl;
*/
if (add) if (add)
ins[row][col] += sign * entry; ins[row][col] += sign * entry;
else else
......
...@@ -88,11 +88,9 @@ namespace AMDiS { ...@@ -88,11 +88,9 @@ namespace AMDiS {
// === Global refinements. === // === Global refinements. ===
// refinementManager->globalRefine(mesh, 1); refinementManager->globalRefine(mesh, 12);
// updateLocalGlobalNumbering(nRankDOFs, nOverallDOFs); updateLocalGlobalNumbering(nRankDOFs, nOverallDOFs);
// exit(0);
// === Create petsc matrix. === // === Create petsc matrix. ===
...@@ -155,6 +153,8 @@ namespace AMDiS { ...@@ -155,6 +153,8 @@ namespace AMDiS {
void ParallelDomainProblemBase::solvePetscMatrix(DOFVector<double> *vec) void ParallelDomainProblemBase::solvePetscMatrix(DOFVector<double> *vec)
{ {
clock_t t = clock();
KSP ksp; KSP ksp;
PC pc; PC pc;
...@@ -221,6 +221,8 @@ namespace AMDiS { ...@@ -221,6 +221,8 @@ namespace AMDiS {
for (int i = 0; i < static_cast<int>(sendBuffers.size()); i++) for (int i = 0; i < static_cast<int>(sendBuffers.size()); i++)
delete [] sendBuffers[i]; delete [] sendBuffers[i];
std::cout << "SOLUTION = " << TIME_USED(t,clock()) << std::endl;
} }
...@@ -513,8 +515,8 @@ namespace AMDiS { ...@@ -513,8 +515,8 @@ namespace AMDiS {
sendIt = sendNewDofs.begin(); sendIt = sendNewDofs.begin();
sendIt != sendNewDofs.end(); sendIt != sendNewDofs.end();
++sendIt, i++) { ++sendIt, i++) {
int nSendDOFs = sendIt->second.size() * 2; int nSendDofs = sendIt->second.size() * 2;
sendBuffers[i] = new int[nSendDOFs]; sendBuffers[i] = new int[nSendDofs];
int c = 0; int c = 0;
for (std::map<const DegreeOfFreedom*, DegreeOfFreedom>::iterator for (std::map<const DegreeOfFreedom*, DegreeOfFreedom>::iterator
dofIt = sendIt->second.begin(); dofIt = sendIt->second.begin();
...@@ -526,7 +528,7 @@ namespace AMDiS { ...@@ -526,7 +528,7 @@ namespace AMDiS {
sendDofs[sendIt->first].push_back(dofIt->first); sendDofs[sendIt->first].push_back(dofIt->first);
} }
mpiComm.Isend(sendBuffers[i], nSendDOFs, MPI_INT, sendIt->first, 0); mpiComm.Isend(sendBuffers[i], nSendDofs, MPI_INT, sendIt->first, 0);
} }
i = 0; i = 0;
...@@ -602,32 +604,6 @@ namespace AMDiS { ...@@ -602,32 +604,6 @@ namespace AMDiS {
delete [] recvBuffers[i]; delete [] recvBuffers[i];
} }
#if 1
// === Create local information from sendDofs and recvDofs
for (std::map<int, std::vector<const DegreeOfFreedom*> >::iterator
it = sendDofs.begin();
it != sendDofs.end();
++it)
for (std::vector<const DegreeOfFreedom*>::iterator dofIt = it->second.begin();
dofIt != it->second.end();
dofIt++) {
// std::cout << "AND SET S " << (*dofIt)[0] << " = " << mapGlobalLocalDOFs[(*dofIt)[0]] << std::endl;
// const_cast<DegreeOfFreedom*>(*dofIt)[0] = mapGlobalLocalDOFs[(*dofIt)[0]];
}
for (std::map<int, std::vector<const DegreeOfFreedom*> >::iterator
it = recvDofs.begin();
it != recvDofs.end();
++it)
for (std::vector<const DegreeOfFreedom*>::iterator dofIt = it->second.begin();
dofIt != it->second.end();
dofIt++) {
// std::cout << "AND SET R " << (*dofIt)[0] << " = " << mapGlobalLocalDOFs[(*dofIt)[0]] << std::endl;
// const_cast<DegreeOfFreedom*>(*dofIt)[0] = mapGlobalLocalDOFs[(*dofIt)[0]];
}
#endif
} }
...@@ -656,8 +632,8 @@ namespace AMDiS { ...@@ -656,8 +632,8 @@ namespace AMDiS {
// === Traverse on interior boundaries and move all not ranked owned DOFs from === // === Traverse on interior boundaries and move all not ranked owned DOFs from ===
// === rankDOFs to boundaryDOFs === // === rankDOFs to boundaryDOFs ===
std::map<int, std::vector<const DegreeOfFreedom*> > sendNewDOFs; std::map<int, std::vector<const DegreeOfFreedom*> > sendNewDofs = sendDofs;
std::map<int, std::vector<const DegreeOfFreedom*> > recvNewDOFs; std::map<int, std::vector<const DegreeOfFreedom*> > recvNewDofs = recvDofs;
for (std::map<int, std::vector<AtomicBoundary> >::iterator it = for (std::map<int, std::vector<AtomicBoundary> >::iterator it =
myIntBoundary.boundary.begin(); myIntBoundary.boundary.begin();
...@@ -699,7 +675,7 @@ namespace AMDiS { ...@@ -699,7 +675,7 @@ namespace AMDiS {
boundDOFs); boundDOFs);
for (int i = 0; i < static_cast<int>(boundDOFs.size()); i++) { for (int i = 0; i < static_cast<int>(boundDOFs.size()); i++) {
newBoundaryDOFs[boundDOFs[i]] = mpiRank; newBoundaryDOFs[boundDOFs[i]] = mpiRank;
sendNewDOFs[it->first].push_back(boundDOFs[i]); sendNewDofs[it->first].push_back(boundDOFs[i]);
} }
} }
} }
...@@ -748,7 +724,7 @@ namespace AMDiS { ...@@ -748,7 +724,7 @@ namespace AMDiS {
for (int i = 0; i < static_cast<int>(boundDOFs.size()); i++) { for (int i = 0; i < static_cast<int>(boundDOFs.size()); i++) {
rankDOFs.erase(boundDOFs[i]); rankDOFs.erase(boundDOFs[i]);
newBoundaryDOFs[boundDOFs[i]] = it->first; newBoundaryDOFs[boundDOFs[i]] = it->first;
recvNewDOFs[it->first].push_back(boundDOFs[i]); recvNewDofs[it->first].push_back(boundDOFs[i]);
} }
} }
...@@ -787,13 +763,72 @@ namespace AMDiS { ...@@ -787,13 +763,72 @@ namespace AMDiS {
// === Send new DOF indices. === // === Send new DOF indices. ===
for (int rank = 0; rank < mpiSize; rank++) { std::vector<int*> sendBuffers(sendNewDofs.size());
if (rank == mpiRank) std::vector<int*> recvBuffers(recvNewDofs.size());
continue;
i = 0;
for (std::map<int, std::vector<const DegreeOfFreedom*> >::iterator
sendIt = sendNewDofs.begin();
sendIt != sendNewDofs.end();
++sendIt, i++) {
int nSendDofs = sendIt->second.size();
sendBuffers[i] = new int[nSendDofs];
int c = 0;
for (std::vector<const DegreeOfFreedom*>::iterator dofIt = sendIt->second.begin();
dofIt != sendIt->second.end();
++dofIt)
sendBuffers[i][c++] = (*dofIt)[0] + rstart;
mpiComm.Isend(sendBuffers[i], nSendDofs, MPI_INT, sendIt->first, 0);
} }
i = 0;
for (std::map<int, std::vector<const DegreeOfFreedom*> >::iterator
recvIt = recvNewDofs.begin();
recvIt != recvNewDofs.end(); ++recvIt, i++) {
int nRecvDofs = recvIt->second.size();
recvBuffers[i] = new int[nRecvDofs];
mpiComm.Irecv(recvBuffers[i], nRecvDofs, MPI_INT, recvIt->first, 0);
}
mpiComm.Barrier();
i = 0;
for (std::map<int, std::vector<const DegreeOfFreedom*> >::iterator
sendIt = sendNewDofs.begin();
sendIt != sendNewDofs.end();
++sendIt)
delete [] sendBuffers[i++];
i = 0;
int newDofIndex = nRankDOFs;
for (std::map<int, std::vector<const DegreeOfFreedom*> >::iterator
recvIt = recvNewDofs.begin();
recvIt != recvNewDofs.end(); ++recvIt) {
int j = 0;
for (std::vector<const DegreeOfFreedom*>::iterator dofIt = recvIt->second.begin();
dofIt != recvIt->second.end();
++dofIt) {
const_cast<DegreeOfFreedom*>(*dofIt)[0] = newDofIndex;
// if (mpiRank == 1)
// std::cout << "SET TO " << newDofIndex << std::endl;
mapLocalGlobalDOFs[newDofIndex] = recvBuffers[i][j];
mapGlobalLocalDOFs[recvBuffers[i][j]] = newDofIndex;
isRankDOF[newDofIndex] = false;
newDofIndex++;
j++;
}
delete [] recvBuffers[i++];
}
// === Update list of dofs that must be communicated for solution exchange. ===
sendDofs = sendNewDofs;
recvDofs = recvNewDofs;
} }
......
...@@ -31,10 +31,6 @@ ...@@ -31,10 +31,6 @@
using namespace std; using namespace std;
using namespace AMDiS; using namespace AMDiS;
// ============================================================================
// ===== class Monomial =======================================================
// ============================================================================
class Monomial : public class Monomial : public
BinaryAbstractFunction<double, WorldVector<double>, WorldVector<double> > BinaryAbstractFunction<double, WorldVector<double>, WorldVector<double> >
{ {
...@@ -46,9 +42,9 @@ public: ...@@ -46,9 +42,9 @@ public:
exponent(expon) exponent(expon)
{ {
degree_ = exponent[0]; degree_ = exponent[0];
for (int i=1; i<exponent.size(); i++) for (int i = 1; i<exponent.size(); i++)
degree_ += exponent[i]; degree_ += exponent[i];
}; }
virtual ~Monomial() {}; virtual ~Monomial() {};
...@@ -60,39 +56,40 @@ public: ...@@ -60,39 +56,40 @@ public:
result *= pow(y[i] - z[i], exponent[i]); result *= pow(y[i] - z[i], exponent[i]);
return result; return result;
}; }
private: private:
WorldVector<int> exponent; WorldVector<int> exponent;
}; };
// ============================================================================
// ===== class RecoveryStructure ==============================================
// ============================================================================
class RecoveryStructure class RecoveryStructure
{ {
public: // construtor, destructor public: // construtor, destructor
// constructor // constructor
RecoveryStructure() : RecoveryStructure() :
coords(NULL), coords(NULL),
A(NULL), rec_uh(NULL), rec_grdUh(NULL), A(NULL),
rec_uh(NULL),
rec_grdUh(NULL),
neighbors(NULL) neighbors(NULL)
{}; {}
// Destructor? // Destructor?
~RecoveryStructure() ~RecoveryStructure()
{ {
clear(); clear();
}; }
RecoveryStructure(const RecoveryStructure& rhs) : RecoveryStructure(const RecoveryStructure& rhs)
coords(NULL), : coords(NULL),
A(NULL), rec_uh(NULL), rec_grdUh(NULL), A(NULL),
neighbors(NULL) { rec_uh(NULL),
rec_grdUh(NULL),
neighbors(NULL)
{
*this=rhs; *this=rhs;
}; }
RecoveryStructure& operator=(const RecoveryStructure& rhs); RecoveryStructure& operator=(const RecoveryStructure& rhs);
......
...@@ -27,161 +27,120 @@ ...@@ -27,161 +27,120 @@
namespace AMDiS { namespace AMDiS {
// ============================================================================ /// Error estimator using the recovery gradient of the finite element solution.
// ===== class RecoveryEstimator ============================================
// ============================================================================
/** \brief
* Error estimator using the recovery gradient of the finite element solution.
*/
class RecoveryEstimator : public Estimator class RecoveryEstimator : public Estimator
{ {
public: public:
/** \brief /// Creator class.
* Creator class.
*/
class Creator : public EstimatorCreator class Creator : public EstimatorCreator
{ {
public: public:
Creator() : EstimatorCreator(), uh(NULL) {}; Creator()
: EstimatorCreator(),
uh(NULL)
{}
virtual ~Creator() {}; virtual ~Creator() {}
inline void setSolution(DOFVector<double> *uh_) inline void setSolution(DOFVector<double> *uh_)
{ {
uh = uh_; uh = uh_;
}; }
/** \brief /// Returns a new Estimator object.
* Returns a new Estimator object.
*/
Estimator* create() Estimator* create()
{ {
return new RecoveryEstimator(name, uh, row); return new RecoveryEstimator(name, uh, row);
}; }
protected: protected:
DOFVector<double> *uh; DOFVector<double> *uh;
}; };
/** \brief /// constructor
* constructor
*/
RecoveryEstimator(std::string name, DOFVector<double> *uh, int r = -1); RecoveryEstimator(std::string name, DOFVector<double> *uh, int r = -1);
/** \brief /// destructor.
* destructor. virtual ~RecoveryEstimator() {}
*/
virtual ~RecoveryEstimator() {};
/** \brief /// implements \ref Estimator::estimate().
* implements \ref Estimator::estimate().
*/
virtual double estimate(double timestep = 0.0); virtual double estimate(double timestep = 0.0);
/*----- Setting functions -----*/ /// Sets uh.
// Sets uh.
inline void setUh(DOFVector<double> *uh) inline void setUh(DOFVector<double> *uh)
{ {
uh_ = uh; uh_ = uh;
}; }
// Sets f. /// Sets f.
inline void setFct(AbstractFunction<double, WorldVector<double> > *fct) inline void setFct(AbstractFunction<double, WorldVector<double> > *fct)
{ {
f_vec = fct; f_vec = fct;
}; }
///
inline void setFct(AbstractFunction<double, double> *fct) inline void setFct(AbstractFunction<double, double> *fct)
{ {
f_scal = fct; f_scal = fct;
}; }
// Sets auxiliar vector. /// Sets auxiliar vector.
inline void setAuxVec(DOFVector<double> *uh) inline void setAuxVec(DOFVector<double> *uh)
{ {
aux_vec = uh; aux_vec = uh;
}; }
/*----- Getting functions -----*/
// Gets recovery gradient. /// Gets recovery gradient.
inline DOFVector<WorldVector<double> >* getRecGrd() inline DOFVector<WorldVector<double> >* getRecGrd()
{ {
return rec_grd; return rec_grd;
}; }
// Gets higher-order recovery solution. /// Gets higher-order recovery solution.
inline DOFVector<double>* getRecUh() inline DOFVector<double>* getRecUh()
{ {
return rec_uh; return rec_uh;
}; }
protected: // protected members
/** \brief protected:
* finite element solution /// finite element solution
*/
DOFVector<double> *uh_; DOFVector<double> *uh_;
/** \brief /// absolute or relative error?
* absolute or relative error?
*/
int relative_; int relative_;
/** \brief /// constant for scaling the estimator
* constant for scaling the estimator
*/
double C; double C;
/** \brief /// recovery method
* recovery method
*/
int method; int method;
/** \brief /// Working finite element space
* Working finite element space
*/
const FiniteElemSpace *feSpace; const FiniteElemSpace *feSpace;
/** \brief /// Degree of corresponding basic functions
* Degree of corresponding basic functions
*/
int degree; int degree;
/** \brief /// Basis functions for recovery vector.
* Basis functions for recovery vector.
*/
const BasisFunction *rec_basFcts; const BasisFunction *rec_basFcts;
/** \brief /// Recovery gradient
* Recovery gradient
*/