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

Code refactoring.

parent 85f42967
......@@ -15,28 +15,28 @@
namespace AMDiS {
ElInfo::ElInfo(Mesh *aMesh)
: mesh_(aMesh),
element_(NULL),
parent_(NULL),
macroElement_(NULL),
: mesh(aMesh),
element(NULL),
parent(NULL),
macroElement(NULL),
level(0),
elType(0),
iChild(0),
coord_(mesh_->getDim(), NO_INIT),
boundary_(mesh_->getDim(), DEFAULT_VALUE, INTERIOR),
projection_(mesh_->getDim(), NO_INIT),
oppCoord_(mesh_->getDim(), NO_INIT),
neighbour_(mesh_->getDim(), NO_INIT),
neighbourCoord(mesh_->getDim(), NO_INIT),
oppVertex(mesh_->getDim(), NO_INIT),
grdLambda(mesh_->getDim(), NO_INIT),
coord(mesh->getDim(), NO_INIT),
boundary(mesh->getDim(), DEFAULT_VALUE, INTERIOR),
projection(mesh->getDim(), NO_INIT),
oppCoord(mesh->getDim(), NO_INIT),
neighbour(mesh->getDim(), NO_INIT),
neighbourCoord(mesh->getDim(), NO_INIT),
oppVertex(mesh->getDim(), NO_INIT),
grdLambda(mesh->getDim(), NO_INIT),
refinementPath(0),
refinementPathLength(0)
{
projection_.set(NULL);
projection.set(NULL);
for (int i = 0; i < neighbourCoord.getSize(); i++)
neighbourCoord[i].init(mesh_->getDim());
neighbourCoord[i].init(mesh->getDim());
dimOfWorld = Global::getGeo(WORLD);
}
......@@ -53,21 +53,21 @@ namespace AMDiS {
double c = l[0];
for (int j = 0; j < dimOfWorld; j++)
w[j] = c * coord_[0][j];
w[j] = c * coord[0][j];
int vertices = Global::getGeo(VERTEX, l.getSize() - 1);
for (int i = 1; i < vertices; i++) {
c = l[i];
for (int j = 0; j < dimOfWorld; j++)
w[j] += c * coord_[i][j];
w[j] += c * coord[i][j];
}
}
double ElInfo::calcDet() const
{
testFlag(Mesh::FILL_COORDS);
return calcDet(coord_);
return calcDet(coord);
}
double ElInfo::calcDet(const FixVec<WorldVector<double>, VERTEX> &coords) const
......@@ -147,11 +147,11 @@ namespace AMDiS {
void ElInfo::fillDetGrdLambda()
{
if (fillFlag_.isSet(Mesh::FILL_GRD_LAMBDA)) {
det_ = calcGrdLambda(grdLambda);
if (fillFlag.isSet(Mesh::FILL_GRD_LAMBDA)) {
det = calcGrdLambda(grdLambda);
} else {
if (fillFlag_.isSet(Mesh::FILL_DET))
det_ = calcDet();
if (fillFlag.isSet(Mesh::FILL_DET))
det = calcDet();
}
}
......@@ -163,11 +163,11 @@ namespace AMDiS {
{10, 4, 0}
};
int dim = mesh_->getDim();
int dim = mesh->getDim();
int posIndex = DIM_OF_INDEX(pos, dim);
int offset = indexOffset[dim - 1][posIndex];
return boundary_[offset + i];
return boundary[offset + i];
}
}
......@@ -66,17 +66,17 @@ namespace AMDiS {
*/
ElInfo& operator=(const ElInfo& rhs)
{
mesh_ = rhs.mesh_;
element_ = rhs.element_;
parent_ = rhs.parent_;
macroElement_ = rhs.macroElement_;
fillFlag_ = rhs.fillFlag_;
mesh = rhs.mesh;
element = rhs.element;
parent = rhs.parent;
macroElement = rhs.macroElement;
fillFlag = rhs.fillFlag;
level = rhs.level;
iChild = rhs.iChild;
coord_ = rhs.coord_;
boundary_ = rhs.boundary_;
oppCoord_ = rhs.oppCoord_;
neighbour_ = rhs.neighbour_;
coord = rhs.coord;
boundary = rhs.boundary;
oppCoord = rhs.oppCoord;
neighbour = rhs.neighbour;
neighbourCoord = rhs.neighbourCoord;
oppVertex = rhs.oppVertex;
return *this;
......@@ -87,34 +87,34 @@ namespace AMDiS {
* \{
*/
/// Get ElInfo's \ref mesh_
/// Get ElInfo's \ref mesh
inline Mesh* getMesh() const
{
return mesh_;
return mesh;
}
/// Get ElInfo's \ref macroElement_
/// Get ElInfo's \ref macroElement
inline MacroElement* getMacroElement() const
{
return macroElement_;
return macroElement;
}
/// Get ElInfo's \ref element
inline Element* getElement() const
{
return element_;
return element;
}
/// Get ElInfo's \ref parent_
/// Get ElInfo's \ref parent
inline Element* getParent() const
{
return parent_;
return parent;
}
/// Get ElInfo's \ref fillFlag_
/// Get ElInfo's \ref fillFlag
inline Flag getFillFlag() const
{
return fillFlag_;
return fillFlag;
}
/// Get ElInfo's \ref level
......@@ -130,60 +130,60 @@ namespace AMDiS {
}
/** \brief
* Get ElInfo's \ref coord_[i]. This is a WorldVector<double> filled with the
* Get ElInfo's \ref coord[i]. This is a WorldVector<double> filled with the
* coordinates of the i-th vertex of element \ref el.
*/
inline WorldVector<double>& getCoord(int i)
{
return coord_[i];
return coord[i];
}
/** \brief
* Get ElInfo's \ref coord_[i]. This is a WorldVector<double> filled with the
* Get ElInfo's \ref coord[i]. This is a WorldVector<double> filled with the
* coordinates of the i-th vertex of element \ref el.
*/
inline const WorldVector<double>& getCoord(int i) const
{
return coord_[i];
return coord[i];
}
/** \brief
* Get ElInfo's \ref coord_. This is a FixVec<WorldVector<double> > filled with the
* Get ElInfo's \ref coord. This is a FixVec<WorldVector<double> > filled with the
* coordinates of the all vertice of element \ref el.
*/
inline FixVec<WorldVector<double>, VERTEX>& getCoords()
{
return coord_;
return coord;
}
/** \brief
* Get ElInfo's \ref coord_. This is a FixVec<WorldVector<double> > filled with the
* Get ElInfo's \ref coord. This is a FixVec<WorldVector<double> > filled with the
* coordinates of the all vertice of element \ref el.
*/
inline const FixVec<WorldVector<double>, VERTEX>& getCoords() const
{
return coord_;
return coord;
}
/// Get ElInfo's \ref oppCoord_[i]
/// Get ElInfo's \ref oppCoord[i]
inline WorldVector<double>& getOppCoord(int i)
{
return oppCoord_[i];
return oppCoord[i];
}
/// Get ElInfo's \ref boundary_[i]
/// Get ElInfo's \ref boundary[i]
inline BoundaryType getBoundary(int i) const
{
return boundary_[i];
return boundary[i];
}
/// Get boundary type of i-th vertex/edge/face (pos).
BoundaryType getBoundary(GeoIndex pos, int i);
/// Get ElInfo's \ref neighbour_[i]
/// Get ElInfo's \ref neighbour[i]
inline Element* getNeighbour(int i) const
{
return neighbour_[i];
return neighbour[i];
}
/// Get ElInfo's \ref neighbourCoord[i]
......@@ -203,10 +203,10 @@ namespace AMDiS {
return oppVertex[i];
}
/// Get ElInfo's \ref det_
/// Get ElInfo's \ref det
inline double getDet() const
{
return det_;
return det;
}
/// Returns \ref grdLambda
......@@ -215,10 +215,10 @@ namespace AMDiS {
return grdLambda;
}
/// Returns \ref projection_[i]
/// Returns \ref projection[i]
inline Projection *getProjection(int i) const
{
return projection_[i];
return projection[i];
}
/// Returns \ref parametric
......@@ -239,46 +239,46 @@ namespace AMDiS {
* \{
*/
/// Set ElInfo's \ref mesh_
/// Set ElInfo's \ref mesh
inline void setMesh(Mesh* aMesh)
{
mesh_ = aMesh;
mesh = aMesh;
}
/// Set ElInfo's \ref macroElement_
/// Set ElInfo's \ref macroElement
inline void setMacroElement(MacroElement* mel)
{
macroElement_ = mel;
macroElement = mel;
}
/// Set ElInfo's \ref element
inline void setElement(Element* elem)
{
element_ = elem;
element = elem;
}
/// Set ElInfo's \ref parent_
/// Set ElInfo's \ref parent
inline void setParent(Element* elem)
{
parent_ = elem;
parent = elem;
}
/// Set ElInfo's \ref fillFlag_
/// Set ElInfo's \ref fillFlag
inline void setFillFlag(Flag flag)
{
fillFlag_ = flag;
fillFlag = flag;
}
/// Sets ElInfo's \ref coord_[i].
inline void setCoord(int i,WorldVector<double>& coord)
/// Sets ElInfo's \ref coord[i].
inline void setCoord(int i,WorldVector<double>& c)
{
coord_[i] = coord;
coord[i] = c;
}
/// Sets ElInfo's \ref coord.
inline void setCoords(FixVec<WorldVector<double>,VERTEX >& coords)
inline void setCoords(FixVec<WorldVector<double>,VERTEX >& c)
{
coord_ = coords;
coord = c;
}
/// Set ElInfo's \ref level
......@@ -287,22 +287,22 @@ namespace AMDiS {
level = l;
}
/// Set ElInfo's \ref boundary_[i]
/// Set ElInfo's \ref boundary[i]
inline void setBoundary(int i, BoundaryType t)
{
boundary_[i] = newBound(boundary_[i], t);
boundary[i] = newBound(boundary[i], t);
}
/// Set \ref projection_[i] = p
/// Set \ref projection[i] = p
inline void setProjection(int i, Projection *p)
{
projection_[i] = p;
projection[i] = p;
}
/// Set \ref det_ = d
/// Set \ref det = d
inline void setDet(double d)
{
det_ = d;
det = d;
}
/// Set \ref parametric = param
......@@ -345,7 +345,7 @@ namespace AMDiS {
double calcDet(const FixVec<WorldVector<double>, VERTEX> &coords) const;
/** \brief
* Checks whether flag is set in ElInfo's \ref fillFlag_. If not, the program
* Checks whether flag is set in ElInfo's \ref fillFlag. If not, the program
* exits.
*/
void testFlag(const Flag& flag) const;
......@@ -357,7 +357,7 @@ namespace AMDiS {
void coordToWorld(const DimVec<double>& lambda,
WorldVector<double>& world) const;
/// Fills ElInfo's \ref det_ and \ref grdLambda entries.
/// Fills ElInfo's \ref det and \ref grdLambda entries.
virtual void fillDetGrdLambda();
/** \brief
......@@ -422,25 +422,25 @@ namespace AMDiS {
protected:
/// Pointer to the current mesh
Mesh *mesh_;
Mesh *mesh;
/// Pointer to the current element
Element *element_;
Element *element;
/// \ref element is child of element parent_
Element *parent_;
/// \ref element is child of element parent
Element *parent;
/** \brief
* \ref element is an element of the binary tree located at MacroElement
* macroElement_
* macroElement
*/
MacroElement *macroElement_;
MacroElement *macroElement;
/** \brief
* Indicates wich elements will be called and wich information should be
* present while mesh traversal.
*/
Flag fillFlag_;
Flag fillFlag;
/** \brief
* Level of the element. The level is zero for macro elements and the level
......@@ -462,36 +462,36 @@ namespace AMDiS {
int iChild;
/** \brief
* \ref coord_[i] is a WorldVector<double> storing the world coordinates of the
* \ref coord[i] is a WorldVector<double> storing the world coordinates of the
* i-th vertex of element \ref element.
*/
FixVec<WorldVector<double>, VERTEX> coord_;
FixVec<WorldVector<double>, VERTEX> coord;
/** \brief
* boundary_[i] is the BoundaryType of the i-th edge/face
* boundary[i] is the BoundaryType of the i-th edge/face
* for i=0,...,N_NEIGH - 1. In 3d
* (*boundary_)[N_FACES + i] is a pointer to the Boundary
* (*boundary)[N_FACES + i] is a pointer to the Boundary
* object of the i-th edge, for i=0,..,N_EDGES - 1. It is
* a pointer to NULL for an interior edge/face.
*/
FixVec<BoundaryType, BOUNDARY> boundary_;
FixVec<BoundaryType, BOUNDARY> boundary;
/** \brief
* Vector storing pointers to projections for each face, edge, vertex.
*/
FixVec<Projection*, PROJECTION> projection_;
FixVec<Projection*, PROJECTION> projection;
/** \brief
* oppCoord_[i] coordinates of the i-th neighbour vertex opposite the
* oppCoord[i] coordinates of the i-th neighbour vertex opposite the
* common edge/face.
*/
FixVec<WorldVector<double>, NEIGH> oppCoord_;
FixVec<WorldVector<double>, NEIGH> oppCoord;
/** \brief
* neighbour_[i] pointer to the element at the edge/face with local index i.
* neighbour[i] pointer to the element at the edge/face with local index i.
* It is a pointer to NULL for boundary edges/faces.
*/
FixVec<Element*, NEIGH> neighbour_;
FixVec<Element*, NEIGH> neighbour;
/** \brief
* neighbourCoord[i][j] are the coordinate of the j-th vertex of the i-th
......@@ -500,14 +500,14 @@ namespace AMDiS {
FixVec<FixVec<WorldVector<double>, VERTEX>, NEIGH> neighbourCoord;
/** \brief
* oppVertex[i] is undefined if neighbour_[i] is a pointer to NULL.
* oppVertex[i] is undefined if neighbour[i] is a pointer to NULL.
* Otherwise it is the local index of the neighbour's vertex opposite the
* common edge/face.
*/
FixVec<unsigned char, NEIGH> oppVertex;
/// Elements determinant.
double det_;
double det;
/// Gradient of lambda.
DimVec<WorldVector<double> > grdLambda;
......
......@@ -52,35 +52,35 @@ namespace AMDiS {
Element *nb;
MacroElement *mnb;
macroElement_ = const_cast<MacroElement*>( mel);
element_ = const_cast<Element*>( mel->getElement());
parent_ = NULL;
macroElement = const_cast<MacroElement*>( mel);
element = const_cast<Element*>( mel->getElement());
parent = NULL;
level = 0;
int vertices = mesh_->getGeo(VERTEX);
int vertices = mesh->getGeo(VERTEX);
if (fillFlag_.isSet(Mesh::FILL_COORDS) || fillFlag_.isSet(Mesh::FILL_DET) ||
fillFlag_.isSet(Mesh::FILL_GRD_LAMBDA)) {
if (fillFlag.isSet(Mesh::FILL_COORDS) || fillFlag.isSet(Mesh::FILL_DET) ||
fillFlag.isSet(Mesh::FILL_GRD_LAMBDA)) {
for (int i = 0; i < vertices; i++)
coord_[i] = mel->coord[i];
coord[i] = mel->coord[i];
}
if (fillFlag_.isSet(Mesh::FILL_NEIGH) || fillFlag_.isSet(Mesh::FILL_OPP_COORDS)) {
if (fillFlag.isSet(Mesh::FILL_NEIGH) || fillFlag.isSet(Mesh::FILL_OPP_COORDS)) {
WorldVector<double> oppC;
int neighbours = mesh_->getGeo(NEIGH);
int neighbours = mesh->getGeo(NEIGH);
for (int i = 0; i < neighbours; i++) {
nb = NULL;
if ((mnb = const_cast<MacroElement*>( mel->getNeighbour(i)))) {
if (fillFlag_.isSet(Mesh::FILL_OPP_COORDS)) {
if (fillFlag.isSet(Mesh::FILL_OPP_COORDS)) {
oppC = mnb->coord[i];
}
nb = const_cast<Element*>( mnb->getElement());
while (!(nb->isLeaf())) { // make nb nearest element
if (fillFlag_.isSet(Mesh::FILL_OPP_COORDS)) {
if (fillFlag.isSet(Mesh::FILL_OPP_COORDS)) {
if (nb->isNewCoordSet()) {
oppC = *(nb->getNewCoord());
} else {
......@@ -90,21 +90,21 @@ namespace AMDiS {
nb = const_cast<Element*>( nb->getChild(1-i));
}
if (fillFlag_.isSet(Mesh::FILL_OPP_COORDS)) {
oppCoord_[i] = oppC;
if (fillFlag.isSet(Mesh::FILL_OPP_COORDS)) {
oppCoord[i] = oppC;
}
}
neighbour_[i] = nb;
neighbour[i] = nb;
oppVertex[i] = nb ? i : -1;
}
}
if (fillFlag_.isSet(Mesh::FILL_BOUND) ) {
if (fillFlag.isSet(Mesh::FILL_BOUND) ) {
for (int i = 0; i < vertices; i++)
boundary_[i] = mel->getBoundary(i);
boundary[i] = mel->getBoundary(i);
for (int i = 0; i < element_->getGeo(PROJECTION); i++)
projection_[i] = mel->getProjection(i);
for (int i = 0; i < element->getGeo(PROJECTION); i++)
projection[i] = mel->getProjection(i);
}
}
......@@ -120,8 +120,8 @@ namespace AMDiS {
testFlag(Mesh::FILL_COORDS);
WorldVector<double> e;
e = coord_[1];
e -= coord_[0];
e = coord[1];
e -= coord[0];
double adet2 = e * e;
if (adet2 < 1.0E-15) {
......@@ -141,9 +141,9 @@ namespace AMDiS {
FUNCNAME("ElInfo1d::worldToCoord()");
double lmin;
double a = coord_[0][0];
double length = (coord_[1][0] - a);
int dim = mesh_->getDim();
double a = coord[0][0];
double length = (coord[1][0] - a);
int dim = mesh->getDim();
static DimVec<double> vec(dim, NO_INIT);
......@@ -180,7 +180,7 @@ namespace AMDiS {
/****************************************************************************/
double ElInfo1d::getNormal(int side, WorldVector<double> &normal)
{
normal = coord_[side] - coord_[(side + 1) % 2];
normal = coord[side] - coord[(side + 1) % 2];
double det = norm(&normal);
TEST_EXIT_DBG(det > 1.e-30)("det = 0 on side %d\n", side);
normal *= 1.0 / det;
......@@ -201,8 +201,8 @@ namespace AMDiS {
TEST_EXIT_DBG(dimOfWorld == 2)
(" element normal only well defined for DIM_OF_WORLD = DIM + 1 !!");
elementNormal[0] = coord_[1][1] - coord_[0][1];
elementNormal[1] = coord_[0][0] - coord_[1][0];
elementNormal[0] = coord[1][1] - coord[0][1];
elementNormal[1] = coord[0][0] - coord[1][0];
double det = norm(&elementNormal);
......@@ -219,77 +219,77 @@ namespace AMDiS {
FUNCNAME("ElInfo1d::fillElInfo()");
Element *nb;
Element *elem = elInfoOld->element_;
Element *elem = elInfoOld->element;
TEST_EXIT_DBG(elem->getChild(0))("no children?\n");
element_ = const_cast<Element*>(elem->getChild(ichild));
element = const_cast<Element*>(elem->getChild(ichild));
TEST_EXIT_DBG(element_)("missing child %d?\n", ichild);
TEST_EXIT_DBG(element)("missing child %d?\n", ichild);
macroElement_ = elInfoOld->macroElement_;
fillFlag_ = elInfoOld->fillFlag_;
parent_ = elem;
macroElement = elInfoOld->macroElement;
fillFlag = elInfoOld->fillFlag;
parent = elem;
level = elInfoOld->level + 1;
iChild = ichild;
int neighbours = mesh_->getGeo(NEIGH);
int neighbours = mesh->getGeo(NEIGH);
if (fillFlag_.isSet(Mesh::FILL_COORDS) || fillFlag_.isSet(Mesh::FILL_DET) ||
fillFlag_.isSet(Mesh::FILL_GRD_LAMBDA)) {
if (fillFlag.isSet(Mesh::FILL_COORDS) || fillFlag.isSet(Mesh::FILL_DET) ||
fillFlag.isSet(Mesh::FILL_GRD_LAMBDA)) {
const FixVec<WorldVector<double>, VERTEX> *old_coord = &(elInfoOld->coord_);
const FixVec<WorldVector<double>, VERTEX> *old_coord = &(elInfoOld->coord);
coord_[ichild] = (*old_coord)[ichild];
coord[ichild] = (*old_coord)[ichild];
if (elem->isNewCoordSet())
coord_[1 - ichild] = *(elem->getNewCoord());
coord[1 - ichild] = *(elem->getNewCoord());
else
coord_[1 - ichild] = ((*old_coord)[0] + (*old_coord)[