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

Work on pdd.

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