Commit 6fd5f942 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Work on pdd.

parent f1d2d34b
...@@ -278,17 +278,22 @@ namespace AMDiS { ...@@ -278,17 +278,22 @@ namespace AMDiS {
{} {}
/// Returns local dof indices of the element for the given fe space. /// Returns local dof indices of the element for the given fe space.
virtual const DegreeOfFreedom *getLocalIndices(const Element*, virtual const DegreeOfFreedom *getLocalIndices(const Element *el,
const DOFAdmin*, const DOFAdmin *admin,
DegreeOfFreedom*) const DegreeOfFreedom *dofPtr) const
{ {
return NULL; return NULL;
} }
/// Returns local dof indices of the element for the given fe space. /// Returns local dof indices of the element for the given fe space.
virtual void getLocalIndicesVec(const Element*, virtual void getLocalIndicesVec(const Element *el,
const DOFAdmin*, const DOFAdmin *admin,
Vector<DegreeOfFreedom>*) const Vector<DegreeOfFreedom> *ve) const
{}
virtual void getLocalDofPtrVec(const Element *el,
const DOFAdmin *admin,
std::vector<const DegreeOfFreedom*>& vec) const
{} {}
......
...@@ -2,16 +2,20 @@ ...@@ -2,16 +2,20 @@
#include "Mesh.h" #include "Mesh.h"
#include "DOFAdmin.h" #include "DOFAdmin.h"
#include "Element.h" #include "Element.h"
#include "BasisFunction.h"
namespace AMDiS { namespace AMDiS {
void ElementDofIterator::reset(Element* element) void ElementDofIterator::reset(Element* el)
{ {
FUNCNAME("ElementDofIterator::reset()"); FUNCNAME("ElementDofIterator::reset()");
TEST_EXIT_DBG(el->getMesh() == mesh)
("Mesh and element does not fit together!\n");
TEST_EXIT_DBG(el)("No element!\n");
element = el;
dofs = element->getDOF(); dofs = element->getDOF();
mesh = element->getMesh();
dim = mesh->getDim();
// Start with vertices. // Start with vertices.
pos = 0; pos = 0;
...@@ -31,6 +35,9 @@ namespace AMDiS { ...@@ -31,6 +35,9 @@ namespace AMDiS {
node0 = mesh->getNode(posIndex); node0 = mesh->getNode(posIndex);
// Get number of vertices in this dimension. // Get number of vertices in this dimension.
nElements = Global::getGeo(posIndex, mesh->getDim()); nElements = Global::getGeo(posIndex, mesh->getDim());
if (inOrder)
orderPosition = basisFcts->orderOfPositionIndices(element, posIndex, 0);
} }
bool ElementDofIterator::next() bool ElementDofIterator::next()
...@@ -73,15 +80,28 @@ namespace AMDiS { ...@@ -73,15 +80,28 @@ namespace AMDiS {
// Get first dof index position for the geo index position. // Get first dof index position for the geo index position.
node0 = mesh->getNode(posIndex); node0 = mesh->getNode(posIndex);
if (inOrder)
orderPosition = basisFcts->orderOfPositionIndices(element, posIndex, 0);
} else { } else {
// That's all, we jave traversed all dofs of the mesh element. // That's all, we jave traversed all dofs of the mesh element.
return false; return false;
} }
} else {
if (inOrder)
orderPosition =
basisFcts->orderOfPositionIndices(element, posIndex, elementPos);
} }
} }
return true; return true;
} }
bool ElementDofIterator::nextStrict()
{
dofPos = nDofs;
return next();
}
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "AMDiS_fwd.h" #include "AMDiS_fwd.h"
#include "Global.h" #include "Global.h"
#include "Mesh.h"
namespace AMDiS { namespace AMDiS {
...@@ -44,8 +45,12 @@ namespace AMDiS { ...@@ -44,8 +45,12 @@ namespace AMDiS {
{ {
public: public:
/// Constructor. /// Constructor.
ElementDofIterator(const DOFAdmin* dofAdmin) ElementDofIterator(const FiniteElemSpace* feSpace, bool inOrderPos = false)
: admin(dofAdmin) : admin(feSpace->getAdmin()),
basisFcts(feSpace->getBasisFcts()),
mesh(feSpace->getMesh()),
dim(mesh->getDim()),
inOrder(inOrderPos)
{} {}
/// Start a new traverse with the given element. /// Start a new traverse with the given element.
...@@ -54,35 +59,50 @@ namespace AMDiS { ...@@ -54,35 +59,50 @@ namespace AMDiS {
/// Go to next dof. Returns false, if there is dof anymore. /// Go to next dof. Returns false, if there is dof anymore.
bool next(); bool next();
bool nextStrict();
/// Returns the dof index of the current dof. /// Returns the dof index of the current dof.
const DegreeOfFreedom getDof() inline const DegreeOfFreedom getDof()
{ {
return dofs[node0 + elementPos][n0 + dofPos]; if (inOrder)
return dofs[node0 + elementPos][n0 + orderPosition[dofPos]];
else
return dofs[node0 + elementPos][n0 + dofPos];
} }
/// Returns a pointer to the current dof. /// Returns a pointer to the current dof.
const DegreeOfFreedom* getDofPtr() inline const DegreeOfFreedom* getDofPtr()
{ {
return &dofs[node0 + elementPos][n0 + dofPos]; if (inOrder)
return &dofs[node0 + elementPos][n0 + orderPosition[dofPos]];
else
return &dofs[node0 + elementPos][n0 + dofPos];
} }
/// Returns \ref pos, the current position (vertex, edge, face) of the traverse. /// Returns \ref pos, the current position (vertex, edge, face) of the traverse.
int getCurrentPos() inline int getCurrentPos()
{ {
return pos; return pos;
} }
/// Returns \ref elementPos, the number of vertex, edge or face that is traversed. /// Returns \ref elementPos, the number of vertex, edge or face that is traversed.
int getCurrentElementPos() inline int getCurrentElementPos()
{ {
return elementPos; return elementPos;
} }
inline GeoIndex getPosIndex()
{
return posIndex;
}
protected: protected:
/// The dof admin for which dofs should be traversed. /// The dof admin for which dofs should be traversed.
const DOFAdmin* admin; const DOFAdmin* admin;
const BasisFunction* basisFcts;
/// Pointer to the dofs that should be traversed. /// Pointer to the dofs that should be traversed.
const DegreeOfFreedom **dofs; const DegreeOfFreedom **dofs;
...@@ -92,6 +112,12 @@ namespace AMDiS { ...@@ -92,6 +112,12 @@ namespace AMDiS {
/// Dimension of the mesh. /// Dimension of the mesh.
int dim; int dim;
bool inOrder;
int* orderPosition;
Element* element;
/// Current position (i.e., vertex, edge, face) of the traverse. /// Current position (i.e., vertex, edge, face) of the traverse.
int pos; int pos;
......
...@@ -70,13 +70,16 @@ namespace AMDiS { ...@@ -70,13 +70,16 @@ namespace AMDiS {
* the classical domain decomposition parallelization. * the classical domain decomposition parallelization.
*/ */
class InteriorBoundary { class InteriorBoundary {
public:
typedef std::map<int, std::vector<AtomicBoundary> > RankToBoundMap;
public: public:
InteriorBoundary() {} InteriorBoundary() {}
AtomicBoundary& getNewAtomicBoundary(int rank); AtomicBoundary& getNewAtomicBoundary(int rank);
public: public:
std::map<int, std::vector<AtomicBoundary> > boundary; RankToBoundMap boundary;
}; };
} }
......
This diff is collapsed.
...@@ -119,14 +119,18 @@ namespace AMDiS { ...@@ -119,14 +119,18 @@ namespace AMDiS {
} }
/// Implements BasisFunction::getLocalIndices(). /// Implements BasisFunction::getLocalIndices().
const DegreeOfFreedom *getLocalIndices(const Element*, const DegreeOfFreedom *getLocalIndices(const Element *el,
const DOFAdmin*, const DOFAdmin *admin,
DegreeOfFreedom*) const; DegreeOfFreedom *dofs) const;
/// ///
void getLocalIndicesVec(const Element*, void getLocalIndicesVec(const Element *el,
const DOFAdmin*, const DOFAdmin *admin,
Vector<DegreeOfFreedom>*) const; Vector<DegreeOfFreedom> *vec) const;
void getLocalDofPtrVec(const Element *el,
const DOFAdmin *admin,
std::vector<const DegreeOfFreedom*>& vec) const;
/// Implements BasisFunction::l2ScpFctBas /// Implements BasisFunction::l2ScpFctBas
void l2ScpFctBas(Quadrature* q, void l2ScpFctBas(Quadrature* q,
......
...@@ -267,53 +267,54 @@ namespace AMDiS { ...@@ -267,53 +267,54 @@ namespace AMDiS {
me->setIndex(macroElements.size()); me->setIndex(macroElements.size());
} }
void Mesh::removeMacroElements(std::vector<MacroElement*>& macros) void Mesh::removeMacroElements(std::vector<MacroElement*>& macros,
const FiniteElemSpace *feSpace)
{ {
FUNCNAME("Mesh::removeMacroElement()"); FUNCNAME("Mesh::removeMacroElement()");
TEST_EXIT(dim == 2)("Not yet implemented!\n"); typedef std::map<const DegreeOfFreedom*, std::set<MacroElement*> > DofElMap;
typedef std::map<const DegreeOfFreedom*, GeoIndex> DofPosMap;
TEST_EXIT(dim == 2)("Not yet implemented for dim != 2!\n");
TEST_EXIT(admin.size() == 1)("Not yet implemented for multiple admins!\n");
TEST_EXIT(admin[0])("There is something wrong!\n");
ElementDofIterator elDofIter(feSpace);
// Map that stores for each dof pointer (which may have a list of dofs) // Map that stores for each dof pointer (which may have a list of dofs)
// all macro element indices that own the dof. // all macro element indices that own the dof.
std::map<const DegreeOfFreedom*, std::set<MacroElement*> > dofsOwner; DofElMap dofsOwner;
DofPosMap dofsPosIndex;
// Determine all dof owner macro elements. // Determine all dof owner macro elements.
for (std::deque<MacroElement*>::iterator macroIt = macroElements.begin(); for (std::deque<MacroElement*>::iterator macroIt = macroElements.begin();
macroIt != macroElements.end(); macroIt != macroElements.end();
++macroIt) { ++macroIt) {
Element *el = (*macroIt)->getElement(); elDofIter.reset((*macroIt)->getElement());
for (int i = 0; i < 3; i++) do {
dofsOwner[el->getDOF(i)].insert(*macroIt); dofsOwner[elDofIter.getDofPtr()].insert(*macroIt);
dofsPosIndex[elDofIter.getDofPtr()] = elDofIter.getPosIndex();
} while (elDofIter.nextStrict());
} }
// Remove all the given macro elements. // Remove all the given macro elements.
for (std::vector<MacroElement*>::iterator macroIt = macros.begin(); for (std::vector<MacroElement*>::iterator macroIt = macros.begin();
macroIt != macros.end(); macroIt != macros.end();
++macroIt) { ++macroIt) {
bool found = false;
std::deque<MacroElement*>::iterator mEl =
// Remove the macro element from mesh's list of all macro elements. find(macroElements.begin(), macroElements.end(), *macroIt);
for (std::deque<MacroElement*>::iterator it = macroElements.begin(); TEST_EXIT(mEl != macroElements.end())
it != macroElements.end(); ("Cannot find MacroElement that should be removed!\n");
++it) { macroElements.erase(mEl);
if (*it == *macroIt) {
macroElements.erase(it, it + 1);
found = true;
break;
}
}
TEST_EXIT(found)("Cannot find MacroElement that should be removed!\n");
// Go through all neighbours of the macro element and remove this macro element // Go through all neighbours of the macro element and remove this macro element
// to be neighbour of some other macro element. // to be neighbour of some other macro element.
for (int i = 0; i <= dim; i++) { for (int i = 0; i <= dim; i++) {
if ((*macroIt)->getNeighbour(i)) { if ((*macroIt)->getNeighbour(i)) {
for (int j = 0; j <= dim; j++) { for (int j = 0; j <= dim; j++)
if ((*macroIt)->getNeighbour(i)->getNeighbour(j) == *macroIt) { if ((*macroIt)->getNeighbour(i)->getNeighbour(j) == *macroIt)
(*macroIt)->getNeighbour(i)->setNeighbour(j, NULL); (*macroIt)->getNeighbour(i)->setNeighbour(j, NULL);
}
}
} else { } else {
// There is no neighbour at this edge, so we have to decrease the number // There is no neighbour at this edge, so we have to decrease the number
// of edges in the mesh. // of edges in the mesh.
...@@ -325,30 +326,28 @@ namespace AMDiS { ...@@ -325,30 +326,28 @@ namespace AMDiS {
nElements--; nElements--;
// Remove this macro element from the dof owner list. // Remove this macro element from the dof owner list.
for (std::map<const DegreeOfFreedom*, std::set<MacroElement*> >::iterator dofsIt = dofsOwner.begin(); for (DofElMap::iterator dofsIt = dofsOwner.begin();
dofsIt != dofsOwner.end(); dofsIt != dofsOwner.end(); ++dofsIt) {
++dofsIt) {
std::set<MacroElement*>::iterator mIt = dofsIt->second.find(*macroIt); std::set<MacroElement*>::iterator mIt = dofsIt->second.find(*macroIt);
if (mIt != dofsIt->second.end()) { if (mIt != dofsIt->second.end())
dofsIt->second.erase(mIt); dofsIt->second.erase(mIt);
}
} }
// And remove the macro element from memory // And remove the macro element from memory
delete *macroIt; delete *macroIt;
} }
int nRemainDofs = 0; int nRemainDofs = 0;
// Check now all the dofs, that have no owner anymore and therefore have to // Check now all the dofs, that have no owner anymore and therefore have to
// be removed. // be removed.
for (std::map<const DegreeOfFreedom*, std::set<MacroElement*> >::iterator dofsIt = dofsOwner.begin(); for (DofElMap::iterator dofsIt = dofsOwner.begin();
dofsIt != dofsOwner.end(); dofsIt != dofsOwner.end(); ++dofsIt) {
++dofsIt) { if (dofsIt->second.size() == 0)
if (dofsIt->second.size() == 0) { freeDOF(const_cast<DegreeOfFreedom*>(dofsIt->first),
freeDOF(const_cast<DegreeOfFreedom*>(dofsIt->first), VERTEX); dofsPosIndex[dofsIt->first]);
} else { else
nRemainDofs++; nRemainDofs++;
}
} }
nVertices = nRemainDofs; nVertices = nRemainDofs;
...@@ -868,26 +867,27 @@ namespace AMDiS { ...@@ -868,26 +867,27 @@ namespace AMDiS {
{ {
DimVec<double>* baryCoords; DimVec<double>* baryCoords;
bool found = false; bool found = false;
ElementDofIterator elDofIter(feSpace->getAdmin());
TraverseStack stack; TraverseStack stack;
Vector<DegreeOfFreedom> dofVec(feSpace->getBasisFcts()->getNumber());
ElInfo *elInfo = stack.traverseFirst(this, -1, ElInfo *elInfo = stack.traverseFirst(this, -1,
Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS); Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
while (elInfo) { while (elInfo) {
elDofIter.reset(elInfo->getElement()); feSpace->getBasisFcts()->getLocalIndicesVec(elInfo->getElement(),
int i = 0; feSpace->getAdmin(),
do { &dofVec);
if (elDofIter.getDofPtr() == dof) { for (int i = 0; i < feSpace->getBasisFcts()->getNumber(); i++) {
if (dofVec[i] == *dof) {
baryCoords = feSpace->getBasisFcts()->getCoords(i); baryCoords = feSpace->getBasisFcts()->getCoords(i);
elInfo->coordToWorld(*baryCoords, coords); elInfo->coordToWorld(*baryCoords, coords);
found = true; found = true;
break; break;
} }
i++; }
} while (elDofIter.next());
if (found) if (found)
break; break;
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
......
...@@ -429,7 +429,8 @@ namespace AMDiS { ...@@ -429,7 +429,8 @@ namespace AMDiS {
* that there are no global or local refinements, i.e., all macro elements have * that there are no global or local refinements, i.e., all macro elements have
* no children. * no children.
*/ */
void removeMacroElements(std::vector<MacroElement*>& macros); void removeMacroElements(std::vector<MacroElement*>& macros,
const FiniteElemSpace* feSpace);
/// Frees the array of DOF pointers (see \ref createDOFPtrs) /// Frees the array of DOF pointers (see \ref createDOFPtrs)
void freeDOFPtrs(DegreeOfFreedom **ptrs); void freeDOFPtrs(DegreeOfFreedom **ptrs);
......
This diff is collapsed.
...@@ -64,6 +64,12 @@ namespace AMDiS { ...@@ -64,6 +64,12 @@ namespace AMDiS {
/// Defines a mapping type from DOF indices to boolean values. /// Defines a mapping type from DOF indices to boolean values.
typedef std::map<DegreeOfFreedom, bool> DofToBool; typedef std::map<DegreeOfFreedom, bool> DofToBool;
/// Defines a mapping type from rank numbers to sets of coordinates.
typedef std::map<int, std::vector<WorldVector<double> > > RankToCoords;
/// Forward type (it maps rank numbers to the interior boundary objects).
typedef InteriorBoundary::RankToBoundMap RankToBoundMap;
public: public:
ParallelDomainBase(const std::string& name, ParallelDomainBase(const std::string& name,
ProblemIterationInterface *iterationIF, ProblemIterationInterface *iterationIF,
...@@ -196,6 +202,8 @@ namespace AMDiS { ...@@ -196,6 +202,8 @@ namespace AMDiS {
DofContainer& rankDOFs, DofContainer& rankDOFs,
DofToRank& boundaryDOFs); DofToRank& boundaryDOFs);
void DbgTestInteriorBoundary();
/** \brief /** \brief
* This function is used for debugging only. It traverses all interior boundaries * This function is used for debugging only. It traverses all interior boundaries
...@@ -203,7 +211,7 @@ namespace AMDiS { ...@@ -203,7 +211,7 @@ namespace AMDiS {
* neighbours. The function fails, when dof indices on an interior boundary does * neighbours. The function fails, when dof indices on an interior boundary does
* not fit together. * not fit together.
*/ */
void testInteriorBoundary(); void DbgTestCommonDofs();
protected: protected:
/// ///
......
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