Commit b538f51c authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

First try to move assembling from DimMat to dense2D taken from the very cool mtl.

parent 1a50a838
...@@ -47,6 +47,7 @@ namespace AMDiS { ...@@ -47,6 +47,7 @@ namespace AMDiS {
class ITL_BasePreconditioner; class ITL_BasePreconditioner;
class LeafDataPeriodic; class LeafDataPeriodic;
class LevelAdmin; class LevelAdmin;
class MacroElement;
class Marker; class Marker;
class Mesh; class Mesh;
class OEMSolver; class OEMSolver;
...@@ -54,6 +55,7 @@ namespace AMDiS { ...@@ -54,6 +55,7 @@ namespace AMDiS {
class ProblemInstat; class ProblemInstat;
class ProblemIterationInterface; class ProblemIterationInterface;
class ProblemVec; class ProblemVec;
class Projection;
class PreconditionerScal; class PreconditionerScal;
class Quadrature; class Quadrature;
class RCNeighbourList; class RCNeighbourList;
......
...@@ -25,12 +25,10 @@ ...@@ -25,12 +25,10 @@
#include "Traverse.h" #include "Traverse.h"
#include "Flag.h" #include "Flag.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "AMDiS_fwd.h"
namespace AMDiS { namespace AMDiS {
class Mesh;
class ElInfo;
/// Parallel traversal of two meshes. /// Parallel traversal of two meshes.
class DualTraverse class DualTraverse
{ {
...@@ -56,9 +54,7 @@ namespace AMDiS { ...@@ -56,9 +54,7 @@ namespace AMDiS {
ElInfo **elInfoSmall, ElInfo **elInfoSmall,
ElInfo **elInfoLarge); ElInfo **elInfoLarge);
/** \brief /// Get next ElInfo combination
* Get next ElInfo combination
*/
bool traverseNext(ElInfo **elInfoNext1, bool traverseNext(ElInfo **elInfoNext1,
ElInfo **elInfoNext2, ElInfo **elInfoNext2,
ElInfo **elInfoSmall, ElInfo **elInfoSmall,
......
...@@ -29,22 +29,21 @@ namespace AMDiS { ...@@ -29,22 +29,21 @@ namespace AMDiS {
neighbourCoord_(mesh_->getDim(), NO_INIT), neighbourCoord_(mesh_->getDim(), NO_INIT),
oppVertex_(mesh_->getDim(), NO_INIT), oppVertex_(mesh_->getDim(), NO_INIT),
grdLambda(mesh_->getDim(), NO_INIT), grdLambda(mesh_->getDim(), NO_INIT),
subElemCoordsMat(NULL) subElemCoordsMat(NULL),
subElemCoordsMat_mtl(2, 2)
{ {
projection_.set(NULL); projection_.set(NULL);
for (int i = 0; i < neighbourCoord_.getSize(); i++) { for (int i = 0; i < neighbourCoord_.getSize(); i++)
neighbourCoord_[i].init(mesh_->getDim()); neighbourCoord_[i].init(mesh_->getDim());
}
dimOfWorld = Global::getGeo(WORLD); dimOfWorld = Global::getGeo(WORLD);
} }
ElInfo::~ElInfo() ElInfo::~ElInfo()
{ {
if (subElemCoordsMat) { if (subElemCoordsMat)
DELETE subElemCoordsMat; DELETE subElemCoordsMat;
}
} }
......
...@@ -22,21 +22,17 @@ ...@@ -22,21 +22,17 @@
#ifndef AMDIS_ELINFO_H #ifndef AMDIS_ELINFO_H
#define AMDIS_ELINFO_H #define AMDIS_ELINFO_H
#include <boost/numeric/mtl/mtl.hpp>
#include "Flag.h" #include "Flag.h"
#include "Boundary.h" #include "Boundary.h"
#include "Global.h" #include "Global.h"
#include "FixVec.h" #include "FixVec.h"
#include "Element.h" #include "Element.h"
#include "AMDiS_fwd.h"
namespace AMDiS { namespace AMDiS {
class MacroElement;
class Mesh;
class Element;
class BasisFunction;
class Projection;
template<typename ReturnType, typename ArgumentType> class AbstractFunction;
/** \ingroup Traverse /** \ingroup Traverse
* \brief * \brief
* An ElInfo object holds informations wich are not stored in the corresponding * An ElInfo object holds informations wich are not stored in the corresponding
...@@ -217,6 +213,10 @@ namespace AMDiS { ...@@ -217,6 +213,10 @@ namespace AMDiS {
return subElemCoordsMat; return subElemCoordsMat;
} }
inline mtl::dense2D<double>& getSubElemCoordsMat_mtl4() {
return subElemCoordsMat_mtl;
}
/** \} */ /** \} */
/** \name setting methods /** \name setting methods
...@@ -379,10 +379,18 @@ namespace AMDiS { ...@@ -379,10 +379,18 @@ namespace AMDiS {
virtual void getRefSimplexCoords(const BasisFunction *basisFcts, virtual void getRefSimplexCoords(const BasisFunction *basisFcts,
DimMat<double> *coords) const = 0; DimMat<double> *coords) const = 0;
virtual void getRefSimplexCoords(const BasisFunction *basisFcts,
mtl::dense2D<double>& coords) const = 0;
virtual void getSubElementCoords(const BasisFunction *basisFcts, virtual void getSubElementCoords(const BasisFunction *basisFcts,
int iChild, int iChild,
DimMat<double> *coords) const = 0; DimMat<double> *coords) const = 0;
virtual void getSubElementCoords(const BasisFunction *basisFcts,
int iChild,
mtl::dense2D<double>& coords) const = 0;
protected: protected:
/// Pointer to the current mesh /// Pointer to the current mesh
Mesh *mesh_; Mesh *mesh_;
...@@ -483,6 +491,8 @@ namespace AMDiS { ...@@ -483,6 +491,8 @@ namespace AMDiS {
*/ */
DimMat<double> *subElemCoordsMat; DimMat<double> *subElemCoordsMat;
mtl::dense2D<double> subElemCoordsMat_mtl;
public: public:
/** \brief /** \brief
* child_vertex[el_type][child][i] = father's local vertex index of new * child_vertex[el_type][child][i] = father's local vertex index of new
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#ifndef AMDIS_ELINFO2D_H #ifndef AMDIS_ELINFO2D_H
#define AMDIS_ELINFO2D_H #define AMDIS_ELINFO2D_H
#include <boost/numeric/mtl/mtl.hpp>
#include "ElInfo.h" #include "ElInfo.h"
#include "MemoryManager.h" #include "MemoryManager.h"
...@@ -63,10 +65,18 @@ namespace AMDiS { ...@@ -63,10 +65,18 @@ namespace AMDiS {
void getRefSimplexCoords(const BasisFunction *basisFcts, void getRefSimplexCoords(const BasisFunction *basisFcts,
DimMat<double> *coords) const; DimMat<double> *coords) const;
void getRefSimplexCoords(const BasisFunction *basisFcts,
mtl::dense2D<double>& coords) const {}
void getSubElementCoords(const BasisFunction *basisFcts, void getSubElementCoords(const BasisFunction *basisFcts,
int iChild, int iChild,
DimMat<double> *coords) const; DimMat<double> *coords) const;
void getSubElementCoords(const BasisFunction *basisFcts,
int iChild,
mtl::dense2D<double>& coords) const {}
protected: protected:
/// Temp vectors for function \ref calcGrdLambda. /// Temp vectors for function \ref calcGrdLambda.
WorldVector<double> *e1, *e2, *normal; WorldVector<double> *e1, *e2, *normal;
......
...@@ -22,9 +22,10 @@ ...@@ -22,9 +22,10 @@
#ifndef AMDIS_ELINFO3D_H #ifndef AMDIS_ELINFO3D_H
#define AMDIS_ELINFO3D_H #define AMDIS_ELINFO3D_H
#include <boost/numeric/mtl/mtl.hpp>
#include "ElInfo.h" #include "ElInfo.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "OpenMP.h"
namespace AMDiS { namespace AMDiS {
...@@ -93,10 +94,17 @@ namespace AMDiS { ...@@ -93,10 +94,17 @@ namespace AMDiS {
void getRefSimplexCoords(const BasisFunction *basisFcts, void getRefSimplexCoords(const BasisFunction *basisFcts,
DimMat<double> *coords) const; DimMat<double> *coords) const;
void getRefSimplexCoords(const BasisFunction *basisFcts,
mtl::dense2D<double>& coords) const {}
void getSubElementCoords(const BasisFunction *basisFcts, void getSubElementCoords(const BasisFunction *basisFcts,
int iChild, int iChild,
DimMat<double> *coords) const; DimMat<double> *coords) const;
void getSubElementCoords(const BasisFunction *basisFcts,
int iChild,
mtl::dense2D<double>& coords) const {}
protected: protected:
/// \ref el 's type. Is Filled automatically by the traversal routines. /// \ref el 's type. Is Filled automatically by the traversal routines.
unsigned char el_type; unsigned char el_type;
......
...@@ -649,7 +649,7 @@ namespace AMDiS { ...@@ -649,7 +649,7 @@ namespace AMDiS {
default: default:
ERROR_EXIT("invalid dim\n"); ERROR_EXIT("invalid dim\n");
return NULL; return NULL;
}; }
} }
bool Mesh::findElInfoAtPoint(const WorldVector<double>& xy, bool Mesh::findElInfoAtPoint(const WorldVector<double>& xy,
...@@ -690,9 +690,8 @@ namespace AMDiS { ...@@ -690,9 +690,8 @@ namespace AMDiS {
/* now, descend in tree to find leaf element at point */ /* now, descend in tree to find leaf element at point */
bool inside = findElementAtPointRecursive(mel_info, lambda, k, el_info); bool inside = findElementAtPointRecursive(mel_info, lambda, k, el_info);
for (int i = 0; i <= dim; i++) { for (int i = 0; i <= dim; i++)
bary[i] = final_lambda[i]; bary[i] = final_lambda[i];
}
DELETE mel_info; DELETE mel_info;
...@@ -716,8 +715,6 @@ namespace AMDiS { ...@@ -716,8 +715,6 @@ namespace AMDiS {
return val; return val;
} }
bool Mesh::findElementAtPointRecursive(ElInfo *el_info, bool Mesh::findElementAtPointRecursive(ElInfo *el_info,
const DimVec<double>& lambda, const DimVec<double>& lambda,
int outside, int outside,
...@@ -940,18 +937,16 @@ namespace AMDiS { ...@@ -940,18 +937,16 @@ namespace AMDiS {
node.serialize(out); node.serialize(out);
// write admins // write admins
int i, size = static_cast<int>(admin.size()); int size = static_cast<int>(admin.size());
out.write(reinterpret_cast<const char*>(&size), sizeof(int)); out.write(reinterpret_cast<const char*>(&size), sizeof(int));
for (i = 0; i < size; i++) { for (int i = 0; i < size; i++)
admin[i]->serialize(out); admin[i]->serialize(out);
}
// write macroElements // write macroElements
size = static_cast<int>(macroElements.size()); size = static_cast<int>(macroElements.size());
out.write(reinterpret_cast<const char*>(&size), sizeof(int)); out.write(reinterpret_cast<const char*>(&size), sizeof(int));
for (i = 0; i < size; i++) { for (int i = 0; i < size; i++)
macroElements[i]->serialize(out); macroElements[i]->serialize(out);
}
// write elementIndex // write elementIndex
out.write(reinterpret_cast<const char*>(&elementIndex), sizeof(int)); out.write(reinterpret_cast<const char*>(&elementIndex), sizeof(int));
...@@ -1020,9 +1015,9 @@ namespace AMDiS { ...@@ -1020,9 +1015,9 @@ namespace AMDiS {
in.read(reinterpret_cast<char*>(&size), sizeof(int)); in.read(reinterpret_cast<char*>(&size), sizeof(int));
admin.resize(size, NULL); admin.resize(size, NULL);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (!admin[i]) { if (!admin[i])
admin[i] = NEW DOFAdmin(this); admin[i] = NEW DOFAdmin(this);
}
admin[i]->deserialize(in); admin[i]->deserialize(in);
} }
...@@ -1032,10 +1027,10 @@ namespace AMDiS { ...@@ -1032,10 +1027,10 @@ namespace AMDiS {
std::vector< std::vector<int> > neighbourIndices(size); std::vector< std::vector<int> > neighbourIndices(size);
for (int i = 0; i < static_cast<int>(macroElements.size()); i++) { for (int i = 0; i < static_cast<int>(macroElements.size()); i++) {
if (macroElements[i]) { if (macroElements[i])
DELETE macroElements[i]; DELETE macroElements[i];
}
} }
macroElements.resize(size); macroElements.resize(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
macroElements[i] = NEW MacroElement(dim); macroElements[i] = NEW MacroElement(dim);
...@@ -1151,9 +1146,8 @@ namespace AMDiS { ...@@ -1151,9 +1146,8 @@ namespace AMDiS {
result += admin[i]->getUsedSize() * sizeof(DegreeOfFreedom); result += admin[i]->getUsedSize() * sizeof(DegreeOfFreedom);
} }
for (int i = 0; i < static_cast<int>(macroElements.size()); i++) { for (int i = 0; i < static_cast<int>(macroElements.size()); i++)
result += macroElements[i]->calcMemoryUsage(); result += macroElements[i]->calcMemoryUsage();
}
return result; return result;
} }
......
...@@ -151,9 +151,8 @@ namespace AMDiS { ...@@ -151,9 +151,8 @@ namespace AMDiS {
Projection *projector = el_info->getProjection(0); Projection *projector = el_info->getProjection(0);
if (!projector || projector->getType() != VOLUME_PROJECTION) { if (!projector || projector->getType() != VOLUME_PROJECTION)
projector = el_info->getProjection(2); projector = el_info->getProjection(2);
}
if (el->getFirstChild() && projector && (!el->isNewCoordSet())) { if (el->getFirstChild() && projector && (!el->isNewCoordSet())) {
WorldVector<double> *new_coord = NEW WorldVector<double>; WorldVector<double> *new_coord = NEW WorldVector<double>;
...@@ -229,9 +228,8 @@ namespace AMDiS { ...@@ -229,9 +228,8 @@ namespace AMDiS {
/* if there are functions to interpolate data to the finer grid, do so */ /* if there are functions to interpolate data to the finer grid, do so */
/****************************************************************************/ /****************************************************************************/
int iadmin;
int nrAdmin = mesh->getNumberOfDOFAdmin(); int nrAdmin = mesh->getNumberOfDOFAdmin();
for(iadmin = 0; iadmin < nrAdmin; iadmin++) { for(int iadmin = 0; iadmin < nrAdmin; iadmin++) {
std::list<DOFIndexedBase*>::iterator it; std::list<DOFIndexedBase*>::iterator it;
DOFAdmin* admin = const_cast<DOFAdmin*>(&mesh->getDOFAdmin(iadmin)); DOFAdmin* admin = const_cast<DOFAdmin*>(&mesh->getDOFAdmin(iadmin));
std::list<DOFIndexedBase*>::iterator end = admin->endDOFIndexed(); std::list<DOFIndexedBase*>::iterator end = admin->endDOFIndexed();
...@@ -358,15 +356,12 @@ namespace AMDiS { ...@@ -358,15 +356,12 @@ namespace AMDiS {
{ {
FUNCNAME("RefinementManager2d::getRefinePatch()"); FUNCNAME("RefinementManager2d::getRefinePatch()");
Triangle *el = dynamic_cast<Triangle*>(const_cast<Element*>( (*el_info)->getElement()));
int opp_vertex = 0;
if ((*el_info)->getNeighbour(2) && (*el_info)->getOppVertex(2) != 2) { if ((*el_info)->getNeighbour(2) && (*el_info)->getOppVertex(2) != 2) {
/****************************************************************************/ /****************************************************************************/
/* neighbour is not compatible devisible; refine neighbour first, store the*/ /* neighbour is not compatible devisible; refine neighbour first, store the*/
/* opp_vertex to traverse back to el */ /* opp_vertex to traverse back to el */
/****************************************************************************/ /****************************************************************************/
opp_vertex = (*el_info)->getOppVertex(2); int opp_vertex = (*el_info)->getOppVertex(2);
ElInfo *neigh_info = stack->traverseNeighbour2d(*el_info, 2); ElInfo *neigh_info = stack->traverseNeighbour2d(*el_info, 2);
neigh_info->getElement()->setMark(max(neigh_info->getElement()->getMark(), 1)); neigh_info->getElement()->setMark(max(neigh_info->getElement()->getMark(), 1));
...@@ -376,7 +371,9 @@ namespace AMDiS { ...@@ -376,7 +371,9 @@ namespace AMDiS {
/* now go back to the original element and refine the patch */ /* now go back to the original element and refine the patch */
/****************************************************************************/ /****************************************************************************/
*el_info = neigh_info = stack->traverseNeighbour2d(neigh_info, opp_vertex); *el_info = neigh_info = stack->traverseNeighbour2d(neigh_info, opp_vertex);
TEST_EXIT_DBG(neigh_info->getElement() == el)("invalid traverse_neighbour1\n"); TEST_EXIT_DBG(neigh_info->getElement() ==
dynamic_cast<Triangle*>(const_cast<Element*>((*el_info)->getElement())))
("invalid traverse_neighbour1\n");
} }
if (refineList->setElement(1, (*el_info)->getNeighbour(2))) { if (refineList->setElement(1, (*el_info)->getNeighbour(2))) {
...@@ -385,7 +382,7 @@ namespace AMDiS { ...@@ -385,7 +382,7 @@ namespace AMDiS {
*n_neigh = 2; *n_neigh = 2;
} }
return(0); return 0;
} }
} }
...@@ -1064,9 +1064,8 @@ namespace AMDiS { ...@@ -1064,9 +1064,8 @@ namespace AMDiS {
TEST_EXIT_DBG(traverse_mesh->getDim() == 3)("update only in 3d\n"); TEST_EXIT_DBG(traverse_mesh->getDim() == 3)("update only in 3d\n");
for (int i = stack_used; i > 0; i--) { for (int i = stack_used; i > 0; i--)
dynamic_cast<ElInfo3d*>(elinfo_stack[i])->update(); dynamic_cast<ElInfo3d*>(elinfo_stack[i])->update();
}
} }
void TraverseStack::getCoordsInElem(const ElInfo *upperElInfo, void TraverseStack::getCoordsInElem(const ElInfo *upperElInfo,
...@@ -1077,11 +1076,24 @@ namespace AMDiS { ...@@ -1077,11 +1076,24 @@ namespace AMDiS {
upperElInfo->getRefSimplexCoords(basisFcts, coords); upperElInfo->getRefSimplexCoords(basisFcts, coords);
for (int i = 1; i <= levelDif; i++) { for (int i = 1; i <= levelDif; i++)
upperElInfo->getSubElementCoords(basisFcts,
elinfo_stack[stack_used - levelDif + i]->getIChild(),
coords);
}
void TraverseStack::getCoordsInElem(const ElInfo *upperElInfo,
const BasisFunction *basisFcts,
mtl::dense2D<double>& coords)
{
int levelDif = elinfo_stack[stack_used]->getLevel() - upperElInfo->getLevel();
upperElInfo->getRefSimplexCoords(basisFcts, coords);
for (int i = 1; i <= levelDif; i++)
upperElInfo->getSubElementCoords(basisFcts, upperElInfo->getSubElementCoords(basisFcts,
elinfo_stack[stack_used - levelDif + i]->getIChild(), elinfo_stack[stack_used - levelDif + i]->getIChild(),
coords); coords);
}
} }
} }
...@@ -29,21 +29,20 @@ ...@@ -29,21 +29,20 @@
#ifndef AMDIS_TRAVERSE_H #ifndef AMDIS_TRAVERSE_H
#define AMDIS_TRAVERSE_H #define AMDIS_TRAVERSE_H
#include <vector>
#include <deque>
#include <stack>
#include "Flag.h" #include "Flag.h"
#include "Global.h" #include "Global.h"
#include "ElInfo.h" #include "ElInfo.h"
#include "ElInfoStack.h" #include "ElInfoStack.h"
#include "MemoryManager.h" #include "MemoryManager.h"
#include "OpenMP.h" #include "OpenMP.h"
#include <vector> #include "AMDiS_fwd.h"
#include <deque>
#include <stack>
namespace AMDiS { namespace AMDiS {
class MacroElement;
class Mesh;
/** \ingroup Traverse /** \ingroup Traverse
* \brief * \brief
* Mesh refinement and coarsening routines are examples of functions which * Mesh refinement and coarsening routines are examples of functions which
...@@ -59,9 +58,7 @@ namespace AMDiS { ...@@ -59,9 +58,7 @@ namespace AMDiS {
public: public:
MEMORY_MANAGED(TraverseStack); MEMORY_MANAGED(TraverseStack);
/** \brief /// Creates an empty TraverseStack
* Creates an empty TraverseStack
*/
TraverseStack() TraverseStack()
: traverse_mel(NULL), : traverse_mel(NULL),
stack_size(0), stack_size(0),
...@@ -69,20 +66,16 @@ namespace AMDiS { ...@@ -69,20 +66,16 @@ namespace AMDiS {
save_stack_used(0), save_stack_used(0),
myThreadId_(0), myThreadId_(0),
maxThreads_(1) maxThreads_(1)
{ {}
}
/** \brief /// Destructor
* Destructor
*/
~TraverseStack() ~TraverseStack()
{ {
for (int i = 0; i < static_cast<int>(elinfo_stack.size()); i++) { for (int i = 0; i < static_cast<int>(elinfo_stack.size()); i++)
DELETE elinfo_stack[i]; DELETE elinfo_stack[i];
}