diff --git a/AMDiS/src/DOFAdmin.cc b/AMDiS/src/DOFAdmin.cc index 6575877e367b27bfea14feeb86b5c54121d1af68..d62b63dc8dd91fd8127e37a9fc631d0e9548fb6b 100755 --- a/AMDiS/src/DOFAdmin.cc +++ b/AMDiS/src/DOFAdmin.cc @@ -23,7 +23,7 @@ namespace AMDiS { init(); } - DOFAdmin::DOFAdmin(Mesh* m,std::string aName) + DOFAdmin::DOFAdmin(Mesh* m, std::string aName) : name(aName), mesh(m), nrDOF(mesh->getDim(), NO_INIT), @@ -34,7 +34,11 @@ namespace AMDiS { void DOFAdmin::init() { - firstHole = size = usedCount = holeCount = sizeUsed = 0; + firstHole = 0; + size = 0; + usedCount = 0; + holeCount = 0; + sizeUsed = 0; dofFree.clear(); } @@ -75,6 +79,9 @@ namespace AMDiS { DOFAdmin::DOFAdmin(const DOFAdmin&) { + FUNCNAME("DOFAdmin::DOFAdmin()"); + + ERROR_EXIT("TODO\n"); } void DOFAdmin::freeDOFIndex(int dof) { diff --git a/AMDiS/src/DOFAdmin.h b/AMDiS/src/DOFAdmin.h index 097fe7dc82a77f015f168c0c9240261299118591..6462be44c64781e3045284ff6685e5b994a3ac58 100644 --- a/AMDiS/src/DOFAdmin.h +++ b/AMDiS/src/DOFAdmin.h @@ -152,14 +152,14 @@ namespace AMDiS { */ std::list<DOFIndexedBase*>::iterator beginDOFIndexed() { return dofIndexedList.begin(); - }; + } /** \brief * Returns an iterator to the end of \ref dofIndexedList */ std::list<DOFIndexedBase*>::iterator endDOFIndexed() { return dofIndexedList.end(); - }; + } // ===== getting methods ====================================================== @@ -172,38 +172,39 @@ namespace AMDiS { */ inline const int getUsedSize() const { return sizeUsed; - }; + } /** \brief * Returns \ref size */ inline const int getSize() const { return size; - }; + } /** \brief * Returns \ref usedCount */ inline const int getUsedDOFs() const { return usedCount; - }; + } /** \brief * Returns \ref holeCount */ inline const int getHoleCount() const { return holeCount; - }; + } /** \brief * Returns \ref name */ inline const std::string& getName() const { return name; - }; + } /** \brief - * Returns \ref nrDOF[i] + * Returns \ref nrDOF[i], i.e., the number of dofs for the + * position i. */ inline const int getNumberOfDOFs(int i) const { return nrDOF[i]; @@ -214,7 +215,7 @@ namespace AMDiS { */ inline const DimVec<int>& getNumberOfDOFs() const { return nrDOF; - }; + } /** \brief * Returns \ref nr0DOF[i] @@ -228,28 +229,28 @@ namespace AMDiS { */ inline const DimVec<int>& getNumberOfPreDOFs() const { return nr0DOF; - }; + } /** \brief * Returns \ref mesh */ inline const Mesh* getMesh() const { return mesh; - }; + } /** \brief * Returns \ref dofFree, the array denoting DOFs to be either free or used. */ inline const std::vector<bool>& getDOFFree() const { return dofFree; - }; + } /** \brief * Returns if the given DOF is free. */ inline const bool isDOFFree(int i) const { return dofFree[i]; - }; + } /** \} */ @@ -262,7 +263,7 @@ namespace AMDiS { /** \brief * Sets \ref nrDOF[i] = v */ - void setNumberOfDOFs(int i,int v); + void setNumberOfDOFs(int i, int v); /** \brief * Sets \ref nr0DOF[i] = v @@ -274,14 +275,14 @@ namespace AMDiS { */ inline void setName(const std::string& n) { name = n; - }; + } /** \brief * Sets \ref mesh = m */ inline void setMesh(Mesh* m) { mesh = m; - }; + } /** \} */ @@ -350,7 +351,8 @@ namespace AMDiS { int sizeUsed; /** \brief - * dofs from THIS DOFAdmin + * Number of dofs for each position, i.e., vertex, + * edge, ..., center, for this DOFAdmin. */ DimVec<int> nrDOF; diff --git a/AMDiS/src/Element.cc b/AMDiS/src/Element.cc index b853cb1db81f6218183663aa8991eefc8dd3788f..76981b8156a32c42ce754133424be33c5dc0596c 100644 --- a/AMDiS/src/Element.cc +++ b/AMDiS/src/Element.cc @@ -64,6 +64,72 @@ namespace AMDiS { } } + Element* Element::cloneWithDOFs() + { + Element *el; + + if (isLine()) { + el = NEW Line(mesh); + } else if (isTriangle()) { + el = NEW Triangle(mesh); + } else { + el = NEW Tetrahedron(mesh); + } + el->index = index; + el->mark = mark; + if (newCoord) { + WorldVector<double> *nc = NEW WorldVector<double>(); + *nc = *newCoord; + el->newCoord = nc; + } + + /* =========== And here we clone the DOFs =========== */ + + el->dof = GET_MEMORY(DegreeOfFreedom*, mesh->getNumberOfNodes()); + + int dim = mesh->getDim(); + int j = 0; + + for (int pos = 0; pos <= dim; pos++) { + GeoIndex position = INDEX_OF_DIM(pos, dim); + int ndof = 0; + + for (int i = 0; i < mesh->getNumberOfDOFAdmin(); i++) { + ndof += mesh->getDOFAdmin(i).getNumberOfDOFs(position); + } + + if (ndof > 0) { + for (int i = 0; i < mesh->getGeo(position); i++) { + if (dof[j] != NULL) { + if (Mesh::serializedDOFs[dof[j][0]] == NULL) { + el->dof[j] = GET_MEMORY(DegreeOfFreedom, ndof); + for (int k = 0; k < ndof; k++) { + el->dof[j][k] = dof[j][k]; + } + Mesh::serializedDOFs[dof[j][0]] = el->dof[j]; + } else { + el->dof[j] = Mesh::serializedDOFs[dof[j][0]]; + } + } else { + el->dof[j] = NULL; + } + j++; + } + } + } + + /* =========== And clone the children ============= */ + + if (child[0]) { + el->child[0] = child[0]->clone(); + } + if (child[1]) { + el->child[1] = child[1]->clone(); + } + + return el; + } + /****************************************************************************/ /* ATTENTION: */ /* new_dof_fct() destroys new_dof !!!!!!!!!! */ @@ -92,9 +158,8 @@ namespace AMDiS { void Element::newDOFFct1(const DOFAdmin* admin) { - int i, j, k, n0, nd, nd0; - DegreeOfFreedom *ldof; - + int j, k, n0, nd, nd0; + DegreeOfFreedom *ldof; int vertices = mesh->getGeo(VERTEX); int edges = mesh->getGeo(EDGE); int faces = mesh->getGeo(FACE); @@ -102,7 +167,7 @@ namespace AMDiS { if ((nd = admin->getNumberOfDOFs(VERTEX))) { nd0 = admin->getNumberOfPreDOFs(VERTEX); n0 = admin->getMesh()->getNode(VERTEX); - for (i = 0; i < vertices; i++) { + for (int i = 0; i < vertices; i++) { CHANGE_DOFS_1(this); } } @@ -111,7 +176,7 @@ namespace AMDiS { if ((nd = admin->getNumberOfDOFs(EDGE))) { nd0 = admin->getNumberOfPreDOFs(EDGE); n0 = admin->getMesh()->getNode(EDGE); - for (i = 0; i < edges; i++) { + for (int i = 0; i < edges; i++) { CHANGE_DOFS_1(this); } } @@ -121,7 +186,7 @@ namespace AMDiS { if ((nd = admin->getNumberOfDOFs(FACE))) { nd0 = admin->getNumberOfPreDOFs(FACE); n0 = admin->getMesh()->getNode(FACE); - for (i = 0; i < faces; i++) { + for (int i = 0; i < faces; i++) { CHANGE_DOFS_1(this); } } @@ -130,7 +195,7 @@ namespace AMDiS { if ((nd = admin->getNumberOfDOFs(CENTER))) { nd0 = admin->getNumberOfPreDOFs(CENTER); n0 = admin->getMesh()->getNode(CENTER); - i = 0; /* only one center */ + int i = 0; /* only one center */ CHANGE_DOFS_1(this); } } @@ -138,9 +203,8 @@ namespace AMDiS { void Element::newDOFFct2(const DOFAdmin* admin) { - int i, j, k, n0, nd, nd0; - DegreeOfFreedom *ldof; - + int i, j, k, n0, nd, nd0; + DegreeOfFreedom *ldof; int vertices = mesh->getGeo(VERTEX); int edges = mesh->getGeo(EDGE); int faces = mesh->getGeo(FACE); @@ -191,13 +255,13 @@ namespace AMDiS { int Element::oppVertex(FixVec<DegreeOfFreedom*, DIMEN> pdof) const { - int nv = 0, ov = 0; - + int nv = 0; + int ov = 0; int vertices = mesh->getGeo(VERTEX); int dim = mesh->getDim(); for (int i = 0; i < vertices; i++) { - if (nv < i-1) + if (nv < i - 1) return(-1); for (int j = 0; j < dim; j++) { @@ -225,10 +289,10 @@ namespace AMDiS { return ov; break; case 2: - return 3-ov; + return 3 - ov; break; case 3: - return 6-ov; + return 6 - ov; break; default: ERROR_EXIT("invalid dim\n"); @@ -237,19 +301,19 @@ namespace AMDiS { } double Element::getNewCoord(int j) const { - if (j >=0 ) { + if (j >= 0) { TEST_EXIT_DBG(newCoord)("newCoord = NULL\n"); return (*newCoord)[j]; } else { - return (newCoord!=NULL); + return (newCoord != NULL); } } void Element::eraseNewCoord() { - if (newCoord!=NULL) { + if (newCoord != NULL) { DELETE newCoord; - newCoord=NULL; - }; + newCoord = NULL; + } } void Element::serialize(std::ostream &out) @@ -270,13 +334,11 @@ namespace AMDiS { out.write(reinterpret_cast<const char*>(&nodes), sizeof(int)); for (int pos = 0; pos <= dim; pos++) { - GeoIndex position = INDEX_OF_DIM(pos ,dim); + GeoIndex position = INDEX_OF_DIM(pos, dim); int ndof = 0; for (int i = 0; i < mesh->getNumberOfDOFAdmin(); i++) { - const DOFAdmin *localAdmin = &mesh->getDOFAdmin(i); - TEST_EXIT_DBG(localAdmin)("no admin[%d]\n", i); - ndof += localAdmin->getNumberOfDOFs(position); + ndof += mesh->getDOFAdmin(i).getNumberOfDOFs(position); } if (ndof > 0) { @@ -285,8 +347,7 @@ namespace AMDiS { if (Mesh::serializedDOFs[dof[j][0]] == NULL) { Mesh::serializedDOFs[dof[j][0]] = dof[j]; out.write(reinterpret_cast<const char*>(&ndof), sizeof(int)); - out.write(reinterpret_cast<const char*>(dof[j]), - ndof * sizeof(DegreeOfFreedom)); + out.write(reinterpret_cast<const char*>(dof[j]), ndof * sizeof(DegreeOfFreedom)); } else { int minusOne = -1; out.write(reinterpret_cast<const char*>(&minusOne), sizeof(int)); @@ -334,17 +395,17 @@ namespace AMDiS { if (typeName != "NULL") { if (typeName == "Line") { - child[0] = new Line(NULL); - child[1] = new Line(NULL); - }; + child[0] = NEW Line(NULL); + child[1] = NEW Line(NULL); + } if (typeName == "Triangle") { - child[0] = new Triangle(NULL); - child[1] = new Triangle(NULL); - }; + child[0] = NEW Triangle(NULL); + child[1] = NEW Triangle(NULL); + } if (typeName == "Tetrahedron") { - child[0] = new Tetrahedron(NULL); - child[1] = new Tetrahedron(NULL); - }; + child[0] = NEW Tetrahedron(NULL); + child[1] = NEW Tetrahedron(NULL); + } child[0]->deserialize(in); child[1]->deserialize(in); } else { @@ -357,22 +418,21 @@ namespace AMDiS { dof = GET_MEMORY(DegreeOfFreedom*, nodes); - int i; - for(i = 0; i < nodes; i++) { + for (int i = 0; i < nodes; i++) { int dofs; in.read(reinterpret_cast<char*>(&dofs), sizeof(int)); - if(dofs) { - if(dofs != -1) { + if (dofs) { + if (dofs != -1) { dof[i] = GET_MEMORY(DegreeOfFreedom, dofs); in.read(reinterpret_cast<char*>(dof[i]), dofs * sizeof(DegreeOfFreedom)); - if(Mesh::serializedDOFs[dof[i][0]] != NULL) { - //WARNING("christina -> dofs already deserialized\n"); + if (Mesh::serializedDOFs[dof[i][0]] != NULL) { DegreeOfFreedom *dofPtr = Mesh::serializedDOFs[dof[i][0]]; FREE_MEMORY(dof[i], DegreeOfFreedom, dofs); dof[i] = dofPtr; + } else { + Mesh::serializedDOFs[dof[i][0]] = dof[i]; } - Mesh::serializedDOFs[dof[i][0]] = dof[i]; } else { DegreeOfFreedom index; in.read(reinterpret_cast<char*>(&index), sizeof(DegreeOfFreedom)); @@ -393,8 +453,8 @@ namespace AMDiS { in >> typeName; in.get(); - if(typeName != "NULL") { - if(typeName == "WorldVector") { + if (typeName != "NULL") { + if (typeName == "WorldVector") { newCoord = NEW WorldVector<double>; newCoord->deserialize(in); } else { @@ -408,9 +468,9 @@ namespace AMDiS { in >> typeName; in.get(); - if(typeName != "NULL") { + if (typeName != "NULL") { elementData = CreatorMap<ElementData>::getCreator(typeName)->create(); - if(elementData) { + if (elementData) { elementData->deserialize(in); } else { ERROR_EXIT("unexpected type name\n"); diff --git a/AMDiS/src/Element.h b/AMDiS/src/Element.h index c9daec1e3063dbe157d5f63ef36c3d08de6662f8..91426b22a8611eb494ed57b607f4735136cbe70e 100644 --- a/AMDiS/src/Element.h +++ b/AMDiS/src/Element.h @@ -101,6 +101,12 @@ namespace AMDiS { */ virtual ~Element(); + /** \brief + * Clone this Element and return a reference to it. Because also the DOFs + * are cloned, \ref Mesh::serializedDOfs must be used. + */ + Element* cloneWithDOFs(); + // ===== getting methods ====================================================== /** \name getting methods @@ -213,8 +219,8 @@ namespace AMDiS { * positionIndex-th part of type position (vertex, edge, face) */ virtual int getVertexOfPosition(GeoIndex position, - int positionIndex, - int vertexIndex) const = 0; + int positionIndex, + int vertexIndex) const = 0; /** \brief * @@ -431,7 +437,7 @@ namespace AMDiS { /** \brief * assignment operator */ - Element& operator=(const Element& old); + Element& operator=(const Element& el); /** \brief * Checks whether the face with vertices dof[0],..,dof[DIM-1] is @@ -571,10 +577,9 @@ namespace AMDiS { * Vector of pointers to DOFs. These pointers must be available for elements * vertices (for the geometric description of the mesh). There my be pointers * for the edges, for faces and for the center of an element. They are - * ordered - * the following way: The first N_VERTICES entries correspond to the DOFs at - * the vertices of the element. The next ones are those at the edges, if - * present, then those at the faces, if present, and then those at the + * ordered the following way: The first N_VERTICES entries correspond to the + * DOFs at the vertices of the element. The next ones are those at the edges, + * if present, then those at the faces, if present, and then those at the * barycenter, if present. */ DegreeOfFreedom **dof; @@ -597,9 +602,8 @@ namespace AMDiS { * If the element has a boundary edge on a curved boundary, this is a pointer * to the coordinates of the new vertex that is created due to the refinement * of the element, otherwise it is a NULL pointer. Thus coordinate - * information - * can be also produced by the traversal routines in the case of curved - * boundary. + * information can be also produced by the traversal routines in the case of + * curved boundary. */ WorldVector<double> *newCoord; diff --git a/AMDiS/src/ElementData.h b/AMDiS/src/ElementData.h index 0761aa92973880e60a2c14bfed92e96ec329199d..6eae31603825dfde77d3d0f335dc390bd8c24ac5 100644 --- a/AMDiS/src/ElementData.h +++ b/AMDiS/src/ElementData.h @@ -51,12 +51,12 @@ namespace AMDiS { */ ElementData(ElementData *decorated = NULL) : decorated_(decorated) - {}; + {} /** \brief * destructor */ - virtual ~ElementData() {}; + virtual ~ElementData() {} /** \brief * Refinement of parent to child1 and child2. @@ -66,18 +66,18 @@ namespace AMDiS { Element* child2, int elType) { - if(decorated_) { + if (decorated_) { bool remove = decorated_->refineElementData(parent, child1, child2, elType); - if(remove) { + if (remove) { ElementData *tmp = decorated_->decorated_; delete decorated_; decorated_ = tmp; } } return false; - }; + } /** \brief * @@ -95,7 +95,7 @@ namespace AMDiS { delete decorated_; decorated_ = NULL; } - }; + } /** \brief * Returns a copy of this ElementData object including all decorated data. @@ -105,7 +105,7 @@ namespace AMDiS { return decorated_->clone(); } return NULL; - }; + } /** \brief * Returns the name of element data type. @@ -140,14 +140,14 @@ namespace AMDiS { } } return NULL; - }; + } inline ElementData *getDecorated(int typeID) { if (decorated_) { return decorated_->getElementData(typeID); } return NULL; - }; + } inline bool deleteDecorated(int typeID) { if(decorated_) { @@ -161,9 +161,15 @@ namespace AMDiS { } } return false; - }; + } + + inline ElementData *getDecorated() { + return decorated_; + } - inline ElementData *getDecorated() { return decorated_; }; + inline void setDecorated(ElementData *d) { + decorated_ = d; + } protected: /** \brief diff --git a/AMDiS/src/FiniteElemSpace.cc b/AMDiS/src/FiniteElemSpace.cc index 8662e3626c286513bc8e63505f7d75b5af6e80d7..92f6840c3f513eeba67a1f4e603fdf549e6f076f 100644 --- a/AMDiS/src/FiniteElemSpace.cc +++ b/AMDiS/src/FiniteElemSpace.cc @@ -45,10 +45,10 @@ namespace AMDiS { feSpaces.push_back(this); } - FiniteElemSpace *FiniteElemSpace::provideFESpace(DOFAdmin *admin, + FiniteElemSpace *FiniteElemSpace::provideFESpace(DOFAdmin *admin, const BasisFunction *basFcts, - Mesh *mesh, - const std::string& name_) + Mesh *mesh, + const std::string& name_) { int numSpaces = static_cast<int>(feSpaces.size()); diff --git a/AMDiS/src/FixVec.h b/AMDiS/src/FixVec.h index 0ccaf6c4c721263a4cc0ab4f92494ea808725bd5..6fcb65d4a1fc2a60b54dbf4548ab61f2d12dfc21 100644 --- a/AMDiS/src/FixVec.h +++ b/AMDiS/src/FixVec.h @@ -95,7 +95,7 @@ namespace AMDiS { { TEST_EXIT_DBG(initType == VALUE_LIST)("wrong initType or wrong initializer\n"); setValues(ini); - }; + } /** \brief * constructor with default value initialisation. initType must be @@ -114,7 +114,7 @@ namespace AMDiS { inline void init(int dim) { this->resize(calcSize(dim)); - }; + } /** \brief * Initialisation for size @@ -122,14 +122,14 @@ namespace AMDiS { inline void initSize(int size) { this->resize(size); - }; + } /** \brief * Returns the \ref size_ of the FixVec. */ inline int size() const { return this->getSize(); - }; + } protected: /** \brief @@ -141,7 +141,7 @@ namespace AMDiS { } else { return Global::getGeo(d, dim); } - }; + } public: friend class GLWindow; @@ -500,21 +500,21 @@ namespace AMDiS { */ WorldVector() : FixVec<T, WORLD>(Global::getGeo(WORLD), NO_INIT) - {}; + {} /** \brief * Calls the corresponding constructor of AlgoVec */ WorldVector(InitType initType, T* ini) : FixVec<T, WORLD>(Global::getGeo(WORLD), initType, ini) - {}; + {} /** \brief * Calls the corresponding constructor of AlgoVec */ WorldVector(InitType initType, const T& ini) : FixVec<T, WORLD>(Global::getGeo(WORLD), initType, ini) - {}; + {} /** \brief * Sets all entries to d @@ -523,7 +523,7 @@ namespace AMDiS { { this->set(d); return (*this); - }; + } /** \brief * Sets the arrays value to the geometric midpoint of the points diff --git a/AMDiS/src/Global.h b/AMDiS/src/Global.h index 589bf359f24eb540254f0eb92b2453758dcdaf36..d497dd664aba8e0df7d61030649d33ef42ee12e7 100644 --- a/AMDiS/src/Global.h +++ b/AMDiS/src/Global.h @@ -71,7 +71,9 @@ namespace AMDiS { ConjugateTranspose } MatrixTranspose; /** \brief speciefies the norm used by Estimator. */ - typedef enum { NO_NORM = 0, H1_NORM = 1, L2_NORM = 2 } Norm; + typedef enum { NO_NORM = 0, + H1_NORM = 1, + L2_NORM = 2 } Norm; /** \brief datatype for degrees of freedom */ diff --git a/AMDiS/src/Line.h b/AMDiS/src/Line.h index 7f68b6e5e1e2b6eb6a49fc13617dc50ff16a6070..f14a82d86a949ee0f5adbd898c734d865d1c2ccc 100644 --- a/AMDiS/src/Line.h +++ b/AMDiS/src/Line.h @@ -27,147 +27,160 @@ namespace AMDiS { -// ========================================================================== -// ===== class Line ========================================================= -// ========================================================================== - -/** \ingroup Triangulation - * \brief - * A Line is an 1-dimensional Element. - * - * A Line and its refinements: - * - * <img src = "line.png"> - */ -class Line : public Element -{ -public: - MEMORY_MANAGED(Line); - - /** \brief - * calls base class contructor. + // ========================================================================== + // ===== class Line ========================================================= + // ========================================================================== + + /** \ingroup Triangulation + * \brief + * A Line is an 1-dimensional Element. + * + * A Line and its refinements: + * + * <img src = "line.png"> */ - Line(Mesh* aMesh) : Element(aMesh) {}; + class Line : public Element + { + public: + MEMORY_MANAGED(Line); + + /** \brief + * calls base class contructor. + */ + Line(Mesh* aMesh) + : Element(aMesh) + {} + + /** \brief + * implements Element::getVertexOfEdge + */ + inline int getVertexOfEdge(int i, int j) const { + return vertexOfEdge[i][j]; + } - /** \brief - * implements Element::getVertexOfEdge - */ - inline int getVertexOfEdge(int i, int j) const { - return vertexOfEdge[i][j]; - }; + /** \brief + * implements Element::getVertexOfPosition + */ + virtual int getVertexOfPosition(GeoIndex position, + int positionIndex, + int vertexIndex) const; - /** \brief - * implements Element::getVertexOfPosition - */ - virtual int getVertexOfPosition(GeoIndex position, - int positionIndex, - int vertexIndex) const; + virtual int getPositionOfVertex(int side, int vertex) const { + static int positionOfVertex[2][2] = {{0,-1},{-1,0}}; + return positionOfVertex[side][vertex]; + } - virtual int getPositionOfVertex(int side, int vertex) const { - static int positionOfVertex[2][2] = {{0,-1},{-1,0}}; - return positionOfVertex[side][vertex]; - }; + /** \brief + * implements Element::getGeo + */ + inline int getGeo(GeoIndex i) const { + switch(i) { + case VERTEX: case PARTS: case NEIGH: + return 2; + break; + case EDGE: case FACE: + return 0; + break; + case CENTER: case DIMEN: + return 1; + break; + case PROJECTION: case BOUNDARY: + return 2; + break; + default: + ERROR_EXIT("invalid geo-index\n"); + return 0; + } + } - /** \brief - * implements Element::getGeo - */ - inline int getGeo(GeoIndex i) const { - switch(i) { - case VERTEX: case PARTS: case NEIGH: - return 2; - break; - case EDGE: case FACE: - return 0; - break; - case CENTER: case DIMEN: - return 1; - break; - case PROJECTION: case BOUNDARY: - return 2; - break; - default: - ERROR_EXIT("invalid geo-index\n"); + inline int getEdgeOfFace(int /* face */, int /*edge*/ ) const { + ERROR_EXIT("called for a line\n"); return 0; } - }; - - inline int getEdgeOfFace(int /* face */, int /*edge*/ ) const { - ERROR_EXIT("called for a line\n"); - return 0; - }; - /** \brief - * implements Element::sortFaceIndices - */ - const FixVec<int,WORLD>& sortFaceIndices(int face, - FixVec<int,WORLD> *vec) const; + /** \brief + * implements Element::sortFaceIndices + */ + const FixVec<int,WORLD>& sortFaceIndices(int face, + FixVec<int,WORLD> *vec) const; - /** \brief - * implements Element::clone - */ - inline Element *clone() { return NEW Line(mesh); }; + /** \brief + * implements Element::clone + */ + inline Element *clone() { + return NEW Line(mesh); + } - /** \brief - * implements Element::getSideOfChild() - */ - virtual int getSideOfChild(int child, int side, int ) const { - FUNCNAME("Line::getSideOfChild()"); - TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); - TEST_EXIT_DBG(side >= 0 && side <= 1)("side must be between 0 and 1\n"); - return sideOfChild[child][side]; - }; + /** \brief + * implements Element::getSideOfChild() + */ + virtual int getSideOfChild(int child, int side, int ) const { + FUNCNAME("Line::getSideOfChild()"); + TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); + TEST_EXIT_DBG(side >= 0 && side <= 1)("side must be between 0 and 1\n"); + return sideOfChild[child][side]; + } - /** \brief - * implements Element::getVertexOfParent() - */ - virtual int getVertexOfParent(int child, int side, int) const { - FUNCNAME("Line::getVertexOfParent()"); - TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); - TEST_EXIT_DBG(side >= 0 && side <= 2)("side must be between 0 and 1\n"); - return vertexOfParent[child][side]; - }; + /** \brief + * implements Element::getVertexOfParent() + */ + virtual int getVertexOfParent(int child, int side, int) const { + FUNCNAME("Line::getVertexOfParent()"); + TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); + TEST_EXIT_DBG(side >= 0 && side <= 2)("side must be between 0 and 1\n"); + return vertexOfParent[child][side]; + } - /** \brief - * implements Element::hasSide - */ - inline bool hasSide(Element* /*sideElem*/) const { - ERROR_EXIT("a Line has no side elements!\n"); - return false; - }; + /** \brief + * implements Element::hasSide + */ + inline bool hasSide(Element* /*sideElem*/) const { + ERROR_EXIT("a Line has no side elements!\n"); + return false; + } - /** \brief - * implements Element::isLine. Returns true because this element is a Line - */ - inline bool isLine() const { return true; }; + /** \brief + * implements Element::isLine. Returns true because this element is a Line + */ + inline bool isLine() const { + return true; + } - /** \brief - * implements Element::isTriangle. Returns false because this element is a - * Line - */ - inline bool isTriangle() const { return false; }; + /** \brief + * implements Element::isTriangle. Returns false because this element is a + * Line + */ + inline bool isTriangle() const { + return false; + } - /** \brief - * implements Element::isTetrahedron. Returns false because this element is - * a Line - */ - inline bool isTetrahedron() const { return false; }; + /** \brief + * implements Element::isTetrahedron. Returns false because this element is + * a Line + */ + inline bool isTetrahedron() const { + return false; + } - // ===== Serializable implementation ===== + // ===== Serializable implementation ===== - std::string getTypeName() const { return "Line"; }; + std::string getTypeName() const { + return "Line"; + } -protected: - /** \brief - * vertexOfEdge[i][j] is the local number of the j-th vertex of the i-th - * edge of this element. - */ - static const int vertexOfEdge[1][2]; + protected: + /** \brief + * vertexOfEdge[i][j] is the local number of the j-th vertex of the i-th + * edge of this element. + */ + static const int vertexOfEdge[1][2]; - static const int sideOfChild[2][2]; - static const int vertexOfParent[2][2]; -}; + static const int sideOfChild[2][2]; + + static const int vertexOfParent[2][2]; + }; } diff --git a/AMDiS/src/MacroElement.cc b/AMDiS/src/MacroElement.cc index 427e032c2bebe1c213c9d0977013d24b190b5290..d970805cbb66693c4a9decced7a0f0284eee18dc 100644 --- a/AMDiS/src/MacroElement.cc +++ b/AMDiS/src/MacroElement.cc @@ -28,7 +28,24 @@ namespace AMDiS { { if (element) DELETE element; - }; + } + + MacroElement& MacroElement::operator=(const MacroElement &el) + { + FUNCNAME("MacroElement::operator=()"); + + if (this == &el) + return *this; + + coord = el.coord; + boundary = el.boundary; + projection = el.projection; + oppVertex = el.oppVertex; + index = el.index; + elType = el.elType; + + return *this; + } void MacroElement::serialize(std::ostream &out) { @@ -126,7 +143,7 @@ namespace AMDiS { in.read(reinterpret_cast<char*>(&size), sizeof(int)); TEST_EXIT(deserializedNeighbourIndices_) - ("neighbour indices for desrializing not set\n"); + ("neighbour indices for deserializing not set\n"); deserializedNeighbourIndices_->resize(size); diff --git a/AMDiS/src/MacroElement.h b/AMDiS/src/MacroElement.h index a1aab528f2a314cae4bf0a712fae303e38947d95..dbbcc72d005fd4362e71fe3755446a6cdea0a283 100644 --- a/AMDiS/src/MacroElement.h +++ b/AMDiS/src/MacroElement.h @@ -65,6 +65,8 @@ namespace AMDiS { */ virtual ~MacroElement(); + MacroElement& operator=(const MacroElement &el); + // ===== getting methods ====================================================== /** \name getting methods @@ -76,63 +78,63 @@ namespace AMDiS { */ inline int getIndex() const { return index; - }; + } /** \brief * Returns ref projection[i]. */ inline Projection *getProjection(int i) const { return projection[i]; - }; + } /** \brief * Returns \ref el */ inline Element* getElement() const { return element; - }; + } /** \brief * Returns the i-th neighbour of this MacroElement \ref neighbour[i] */ inline MacroElement* getNeighbour(int i) const { return neighbour[i]; - }; + } /** \brief * Returns the i-th opp-vertex of this MacroElement \ref oppVertex[i] */ inline char getOppVertex(int i) const { return oppVertex[i]; - }; + } /** \brief * Returns \ref coord[i] */ inline WorldVector<double>& getCoord(int i) { return coord[i]; - }; + } /** \brief * Returns \ref coord */ inline FixVec<WorldVector<double>, VERTEX>& getCoord() { return coord; - }; + } /** \brief * Returns \ref boundary[i] */ inline BoundaryType getBoundary(int i) const { return boundary[i]; - }; + } /** \brief * Returns \ref elType */ inline unsigned char getElType() const { return elType; - }; + } /** \} */ @@ -147,7 +149,7 @@ namespace AMDiS { */ inline void setIndex(int n) { index = n ; - }; + } /** \brief * Sets \ref element if not yet set. @@ -159,14 +161,14 @@ namespace AMDiS { if (element != element_) ERROR("Trying to change element in MacroElement\n"); } - }; + } /** \brief * Sets \ref elType */ inline void setElType(unsigned char typ) { elType = typ; - }; + } /** \brief @@ -174,32 +176,32 @@ namespace AMDiS { */ inline void setProjection(int i, Projection *p) { projection[i] = p; - }; + } /** \brief * Sets the i-th Neighbour to n */ inline void setNeighbour(int i, MacroElement *n) { neighbour[i] = n; - }; + } /** \brief * Sets the i-th opp vertex to c */ inline void setOppVertex(int i, char c) { oppVertex[i] = c; - }; + } /** \brief * Sets \ref boundary[i] to b */ inline void setBoundary(int i, BoundaryType b) { boundary[i] = b; - }; + } inline void setCoord(int i, const WorldVector<double> &c) { coord[i] = c; - }; + } /** \} */ diff --git a/AMDiS/src/Mesh.cc b/AMDiS/src/Mesh.cc index 89ea32f8ac9e91ed35e05f47e4670b1684c5ab5e..4501aad23305f11ae800dd88c73df03d117ccdfd 100644 --- a/AMDiS/src/Mesh.cc +++ b/AMDiS/src/Mesh.cc @@ -95,7 +95,7 @@ namespace AMDiS { final_lambda(dimension, DEFAULT_VALUE, 0.0) { - FUNCNAME("Mesh::Mesh"); + FUNCNAME("Mesh::Mesh()"); // set default element prototype switch(dim) { @@ -114,20 +114,118 @@ namespace AMDiS { elementPrototype->setIndex(-1); - elementIndex=0; - }; + elementIndex = 0; + } Mesh::~Mesh() + {} + + Mesh& Mesh::operator=(const Mesh& m) { - }; + FUNCNAME("Mesh::operator=()"); + + if (this == &m) + return *this; + + TEST_EXIT(dim == m.dim)("operator= works only on meshes with equal dim!\n"); + + name = m.name; + nVertices = m.nVertices; + nEdges = m.nEdges; + nLeaves = m.nLeaves; + nElements = m.nElements; + nFaces = m.nFaces; + maxEdgeNeigh = m.maxEdgeNeigh; + diam = m.diam; + parametric = NULL; + + preserveCoarseDOFs = m.preserveCoarseDOFs; + nDOFEl = m.nDOFEl; + nDOF = m.nDOF; + nNodeEl = m.nNodeEl; + node = m.node; + newDOF = m.newDOF; + elementIndex = m.elementIndex; + initialized = m.initialized; + final_lambda = m.final_lambda; + + /* ====================== Create new DOFAdmins ================== */ + admin.resize(m.admin.size()); + for (int i = 0; i < static_cast<int>(admin.size()); i++) { + admin[i] = NEW DOFAdmin(this); + *admin[i] = *(m.admin[i]); + admin[i]->setMesh(this); + } - void Mesh::addMacroElement(MacroElement* m) { - macroElements.push_back(m); - m->setIndex(macroElements.size()); - }; + /* ====================== Copy macro elements =================== */ + macroElements.clear(); + + // mapIndex[i] is the index of the MacroElement element in the vector + // macroElements, for which holds: element->getIndex() = i + std::map<int, int> mapIndex; + + // We use this map for coping the DOFs of the Elements within the + // MacroElements objects. + Mesh::serializedDOFs.clear(); + + int insertCounter = 0; + // Go through all MacroElements of mesh m, and create for every a new + // MacroElement in this mesh. + for (std::deque<MacroElement*>::const_iterator it = m.macroElements.begin(); + it != m.macroElements.end(); + ++it, insertCounter++) { + // Create new MacroElement. + MacroElement *el = NEW MacroElement(dim); + // Use copy operator to copy all the data to the new MacroElement. + *el = **it; + + // Make a copy of the Element data, together with all DOFs + el->setElement((*it)->getElement()->cloneWithDOFs()); + + // Insert the new MacroElement in the vector of all MacroElements. + macroElements.push_back(el); + + // Update the index map. + mapIndex.insert(std::pair<int, int>(el->getIndex(), insertCounter)); + } + + // Now we have to go through all the new MacroElements, and update the neighbour + // connections. + insertCounter = 0; + for (std::deque<MacroElement*>::const_iterator it = m.macroElements.begin(); + it != m.macroElements.end(); + ++it, insertCounter++) { + // Go through all neighbours. + for (int i = 0; i < dim; i++) { + // 1. Get index of the old MacroElement for its i-th neighbour. + // 2. Because the index in the new MacroElement is the same, search + // for the vector index the corresponding element is stored in. + // 3. Get this element from macroElements, and set it as the i-th + // neighbour for the current element. + macroElements[insertCounter]-> + setNeighbour(i, macroElements[mapIndex[(*it)->getNeighbour(i)->getIndex()]]); + } + } + + // Cleanup + Mesh::serializedDOFs.clear(); + + /* ================== Things will be done when required ============ */ + + TEST_EXIT(elementDataPrototype == NULL)("TODO\n"); + TEST_EXIT(m.parametric == NULL)("TODO\n"); + TEST_EXIT(periodicAssociations.size() == 0)("TODO\n"); + + return *this; + } + + void Mesh::addMacroElement(MacroElement* m) { + macroElements.push_back(m); + m->setIndex(macroElements.size()); + } int Mesh::traverse(int level, Flag flag, int (*el_fct)(ElInfo*)) @@ -164,13 +262,10 @@ namespace AMDiS { { FUNCNAME("Mesh::addDOFAdmin()"); - int i, j, d, n; - std::vector<DOFAdmin*>::iterator dai; - localAdmin->setMesh(this); - n = admin.size(); - dai=std::find(admin.begin(),admin.end(),localAdmin); + std::vector<DOFAdmin*>::iterator dai = std::find(admin.begin(),admin.end(),localAdmin); + if (dai!= admin.end()) { ERROR("admin %s is already associated to mesh %s\n", localAdmin->getName().c_str(), this->getName().c_str()); @@ -201,15 +296,15 @@ namespace AMDiS { // finding necessary node number for new admin - int newNNode=0; + int newNNode = 0; GeoIndex geoIndex; - for(d = 0; d < dim+1; d++) { + for (int d = 0; d < dim+1; d++) { geoIndex = INDEX_OF_DIM(d, dim); if (localAdmin->getNumberOfDOFs(geoIndex)>0||nDOF[geoIndex]>0) - newNNode+=getGeo(geoIndex); - }; + newNNode += getGeo(geoIndex); + } bool extendNodes = (newNNode>nNodeEl); int oldNNodes = nNodeEl; @@ -234,15 +329,15 @@ namespace AMDiS { element->setDOFPtrs(); dof=const_cast<DegreeOfFreedom**>(element->getDOF()); int index=0,oldIndex=0; - for(d = 0; d < dim+1; d++) { + for (int d = 0; d < dim + 1; d++) { geoIndex = INDEX_OF_DIM(d, dim); if (nDOF[geoIndex]>0) { - for(i=0;i<getGeo(geoIndex);++i) - dof[index++]=oldDOF[oldIndex++]; + for (int i = 0;i < getGeo(geoIndex); ++i) + dof[index++] = oldDOF[oldIndex++]; } else { - if (localAdmin->getNumberOfDOFs(geoIndex)>0) - index+=getGeo(geoIndex); + if (localAdmin->getNumberOfDOFs(geoIndex) > 0) + index += getGeo(geoIndex); } } @@ -253,10 +348,10 @@ namespace AMDiS { } - index=0; + index = 0; // allocate new memory at elements - for(d = 0; d < dim+1; d++) { + for (int d = 0; d < dim+1; d++) { geoIndex = INDEX_OF_DIM(d, dim); int numberOfDOFs = localAdmin->getNumberOfDOFs(geoIndex); @@ -265,30 +360,30 @@ namespace AMDiS { if (numberOfDOFs>0||numberOfPreDOFs>0) { // for all vertices/edges/... - for(i = 0; i < getGeo(geoIndex); i++, index++) { + for (int i = 0; i < getGeo(geoIndex); i++, index++) { std::set<DegreeOfFreedom> dofSet; - for(j = 0; j < d+1; j++) { + for (int j = 0; j < d+1; j++) { dofSet.insert(dof[element->getVertexOfPosition(geoIndex, i, j)][vertexAdminPreDOFs]); } - if(element->isLeaf() || parentNeedsDOF[dim][d][i]) { - if(dofPtrMap[dofSet] == NULL) { - if(localAdmin->getNumberOfDOFs(geoIndex)) { + if (element->isLeaf() || parentNeedsDOF[dim][d][i]) { + if (dofPtrMap[dofSet] == NULL) { + if (localAdmin->getNumberOfDOFs(geoIndex)) { newDOF = GET_MEMORY(DegreeOfFreedom, numberOfPreDOFs + numberOfDOFs); // copy old dofs to new memory and free old memory - if(dof[index]) { - for(j = 0; j < numberOfPreDOFs; j++) { + if (dof[index]) { + for (int j = 0; j < numberOfPreDOFs; j++) { newDOF[j] = dof[index][j]; } // FREE_MEMORY(dof[index], DegreeOfFreedom, numberOfPreDOFs); // Do not free memory. The information has to be used to identify the part in other elements. // The memory is only marked for freeing. struct delmem fm; - fm.ptr=dof[index]; - fm.len=numberOfPreDOFs; + fm.ptr = dof[index]; + fm.len = numberOfPreDOFs; delList.push_back(fm); } - for(j = 0; j < numberOfDOFs; j++) { + for (int j = 0; j < numberOfDOFs; j++) { newDOF[numberOfPreDOFs + j] = localAdmin->getDOFIndex(); } dof[index] = newDOF; @@ -306,9 +401,9 @@ namespace AMDiS { // now free the old dof memory: - std::list<struct delmem>::iterator it=delList.begin(); + std::list<struct delmem>::iterator it = delList.begin(); - while(it!=delList.end()) { + while (it!=delList.end()) { FREE_MEMORY((*it).ptr, DegreeOfFreedom, (*it).len); it++; } @@ -338,26 +433,26 @@ namespace AMDiS { TEST_EXIT_DBG(nDOF[VERTEX] > 0)("no vertex dofs\n"); - node[VERTEX] = 0; - nNodeEl = getGeo(VERTEX); + node[VERTEX] = 0; + nNodeEl = getGeo(VERTEX); - if(dim > 1) { - node[EDGE] = nNodeEl; + if (dim > 1) { + node[EDGE] = nNodeEl; if (nDOF[EDGE] > 0) nNodeEl += getGeo(EDGE); } - if (3==dim){ + if (3 == dim){ localAdmin->setNumberOfPreDOFs(FACE,nDOF[FACE]); - nDOF[FACE] += localAdmin->getNumberOfDOFs(FACE); - nDOFEl += getGeo(FACE) * nDOF[FACE]; - node[FACE] = nNodeEl; - if (nDOF[FACE] > 0) nNodeEl += getGeo(FACE); + nDOF[FACE] += localAdmin->getNumberOfDOFs(FACE); + nDOFEl += getGeo(FACE) * nDOF[FACE]; + node[FACE] = nNodeEl; + if (nDOF[FACE] > 0) + nNodeEl += getGeo(FACE); } - node[CENTER] = nNodeEl; - if (nDOF[CENTER] > 0) nNodeEl += 1; - - return; + node[CENTER] = nNodeEl; + if (nDOF[CENTER] > 0) + nNodeEl += 1; } @@ -463,14 +558,11 @@ namespace AMDiS { const DOFAdmin *Mesh::createDOFAdmin(const std::string& lname,DimVec<int> lnDOF) { - FUNCNAME("Mesh::createDOFAdmin"); + FUNCNAME("Mesh::createDOFAdmin()"); - DOFAdmin *localAdmin; - int i; + DOFAdmin *localAdmin = NEW DOFAdmin(this, lname); - localAdmin=NEW DOFAdmin(this,lname); - - for (i = 0; i < dim+1; i++) + for (int i = 0; i < dim+1; i++) localAdmin->setNumberOfDOFs(i,lnDOF[i]); addDOFAdmin(localAdmin); @@ -479,93 +571,57 @@ namespace AMDiS { } - - - - // int Mesh::macroType(const std::string& filename, const std::string& type) - // { - // const char *fn, *t; - - // if (3==dim) return 0; - - // if (filename.size() <= type.size()) - // return(false); - - // fn = filename.data(); - // while (*fn) fn++; - // t = type.data(); - // while (*t) t++; - - // while (t != type && *t == *fn) t--; - - // return(t == type); - // } - const DOFAdmin* Mesh::getVertexAdmin() const { - int i; const DOFAdmin *localAdmin = NULL; - for (i = 0; i < static_cast<int>(admin.size()); i++) - { - if (admin[i]->getNumberOfDOFs(VERTEX)) - { - if (!localAdmin) - localAdmin = admin[i]; - else if (admin[i]->getSize() < localAdmin->getSize()) - localAdmin = admin[i]; - } + for (int i = 0; i < static_cast<int>(admin.size()); i++) { + if (admin[i]->getNumberOfDOFs(VERTEX)) { + if (!localAdmin) + localAdmin = admin[i]; + else if (admin[i]->getSize() < localAdmin->getSize()) + localAdmin = admin[i]; } + } + return(localAdmin); } void Mesh::freeDOF(DegreeOfFreedom* dof, GeoIndex position) { - FUNCNAME("Mesh::freeDOF"); - DOFAdmin *localAdmin; - int i, j, n, n0, ndof; + FUNCNAME("Mesh::freeDOF()"); TEST_EXIT_DBG(position >= CENTER && position <= FACE) ("unknown position %d\n",position); - ndof = nDOF[position]; - if (ndof) - { - if (!dof) - { - MSG("dof = NULL, but ndof=%d\n", ndof); - return; - } - } - else - { - if (dof) - { - MSG("dof != NULL, but ndof=0\n"); - } + int ndof = nDOF[position]; + if (ndof) { + if (!dof) { + MSG("dof = NULL, but ndof=%d\n", ndof); return; } + } else { + if (dof) { + MSG("dof != NULL, but ndof=0\n"); + } + return; + } TEST_EXIT_DBG(ndof <= MAX_DOF) ("ndof too big: ndof=%d, MAX_DOF=%d\n",ndof,MAX_DOF); - for (i = 0; i < static_cast<int>(admin.size()); i++) - { - localAdmin = admin[i]; - - n = localAdmin->getNumberOfDOFs(position); - n0 = localAdmin->getNumberOfPreDOFs(position); - - TEST_EXIT_DBG(n+n0 <= ndof)("n=%d, n0=%d too large: ndof=%d\n", n, n0, ndof); - - for (j = 0; j < n; j++) - { - localAdmin->freeDOFIndex(dof[n0+j]); - } - } + for (int i = 0; i < static_cast<int>(admin.size()); i++) { + DOFAdmin *localAdmin = admin[i]; + int n = localAdmin->getNumberOfDOFs(position); + int n0 = localAdmin->getNumberOfPreDOFs(position); + + TEST_EXIT_DBG(n + n0 <= ndof)("n=%d, n0=%d too large: ndof=%d\n", n, n0, ndof); + + for (int j = 0; j < n; j++) + localAdmin->freeDOFIndex(dof[n0 + j]); + } FREE_MEMORY(dof, DegreeOfFreedom, ndof); - return; } void Mesh::freeElement(Element* el) @@ -1047,10 +1103,9 @@ namespace AMDiS { GET_PARAMETER(0, name + "->preserve coarse dofs", "%d", &preserveCoarseDOFs); if (macroFilename.length()) { - macroFileInfo_ = MacroReader::readMacro(macroFilename.c_str(), - this, - periodicFile == "" ? NULL : periodicFile.c_str(), - check); + macroFileInfo = MacroReader::readMacro(macroFilename.c_str(), this, + periodicFile == "" ? NULL : periodicFile.c_str(), + check); // If there is no value file which should be written, we can delete // the information of the macro file. @@ -1097,9 +1152,9 @@ namespace AMDiS { void Mesh::clearMacroFileInfo() { - macroFileInfo_->clear(getNumberOfEdges(), - getNumberOfVertices()); - DELETE macroFileInfo_; + macroFileInfo->clear(getNumberOfEdges(), + getNumberOfVertices()); + DELETE macroFileInfo; } int Mesh::calcMemoryUsage() diff --git a/AMDiS/src/Mesh.h b/AMDiS/src/Mesh.h index 91fab922901b3f35069dccbbd8d98d285171f6c0..8830c7c9c66a495c7a3d35bf3b3063ee229200f6 100644 --- a/AMDiS/src/Mesh.h +++ b/AMDiS/src/Mesh.h @@ -133,119 +133,119 @@ namespace AMDiS { */ inline int getGeo(GeoIndex p) const { return Global::getGeo(p, dim); - }; + } /** \brief * Returns \ref name of the mesh */ inline const std::string& getName() const { return name; - }; + } /** \brief * Returns \ref dim of the mesh */ inline int getDim() const { return dim; - }; + } /** \brief * Returns \ref nDOFEl of the mesh */ inline const int getNumberOfAllDOFs() const { return nDOFEl; - }; + } /** \brief * Returns \ref nNodeEl of the mesh */ inline const int getNumberOfNodes() const { return nNodeEl; - }; + } /** \brief * Returns \ref nVertices of the mesh */ inline const int getNumberOfVertices() const { return nVertices; - }; + } /** \brief * Returns \ref nEdges of the mesh */ inline const int getNumberOfEdges() const { return nEdges; - }; + } /** \brief * Returns \ref nFaces of the mesh */ inline const int getNumberOfFaces() const { return nFaces; - }; + } /** \brief * Returns \ref nLeaves of the mesh */ inline const int getNumberOfLeaves() const { return nLeaves; - }; + } /** \brief * Returns \ref nElements of the mesh */ inline const int getNumberOfElements() const { return nElements; - }; + } /** \brief * Returns \ref maxEdgeNeigh of the mesh */ inline const int getMaxEdgeNeigh() const { return maxEdgeNeigh; - }; + } /** \brief * Returns \ref parametric of the mesh */ inline Parametric *getParametric() const { return parametric; - }; + } /** \brief * Returns \ref diam of the mesh */ inline const WorldVector<double>& getDiameter() const { return diam; - }; + } /** \brief * Returns nDOF[i] of the mesh */ inline const int getNumberOfDOFs(int i) const { return nDOF[i]; - }; + } /** \brief * Returns \ref elementPrototype of the mesh */ inline Element* getElementPrototype() { return elementPrototype; - }; + } /** \brief * Returns \ref leafDataPrototype of the mesh */ inline ElementData* getElementDataPrototype() { return elementDataPrototype; - }; + } /** \brief * Returns node[i] of the mesh */ inline int getNode(int i) const { return node[i]; - }; + } /** \brief * Allocates the number of DOFs needed at position and registers the DOFs @@ -260,7 +260,7 @@ namespace AMDiS { */ inline const DOFAdmin& getDOFAdmin(int i) const { return *(admin[i]); - }; + } /** \brief * Creates a DOFAdmin with name lname. nDOF specifies how many DOFs @@ -275,7 +275,7 @@ namespace AMDiS { */ const int getNumberOfDOFAdmin() const { return admin.size(); - }; + } /** \brief * Returns the size of \ref macroElements which is the number of @@ -283,7 +283,7 @@ namespace AMDiS { */ const int getNumberOfMacros() const { return macroElements.size(); - }; + } /** \brief * Returns a DOFAdmin which at least manages vertex DOFs @@ -294,35 +294,35 @@ namespace AMDiS { * Allocates a array of DOF pointers. The array holds one pointer for * each node. */ - DegreeOfFreedom **createDOFPtrs(); + DegreeOfFreedom **createDOFPtrs(); /** \brief * Returns \ref preserveCoarseDOFs of the mesh */ inline bool queryCoarseDOFs() const { return preserveCoarseDOFs; - }; + } /** \brief * Returns an iterator to the begin of \ref macroElements */ inline std::deque<MacroElement*>::iterator firstMacroElement() { return macroElements.begin(); - }; + } /** \brief * Returns macroElements[i]. */ inline MacroElement *getMacroElement(int i) { return macroElements[i]; - }; + } /** \brief * Returns an iterator to the end of \ref macroElements */ inline std::deque<MacroElement*>::iterator endOfMacroElements() { return macroElements.end(); - }; + } /** \} */ @@ -336,77 +336,77 @@ namespace AMDiS { */ inline void setName(const std::string& aName) { name = aName; - }; + } /** \brief * Sets \ref nVertices of the mesh */ inline void setNumberOfVertices(int n) { nVertices = n; - }; + } /** \brief * Sets \ref nFaces of the mesh */ inline void setNumberOfFaces(int n) { nFaces = n; - }; + } /** \brief * Increments \ref nVertices by inc */ inline void incrementNumberOfVertices(int inc) { nVertices += inc; - }; + } /** \brief * Sets \ref nEdges of the mesh */ inline void setNumberOfEdges(int n) { nEdges = n; - }; + } /** \brief * Increments \ref nEdges by inc */ inline void incrementNumberOfEdges(int inc) { nEdges += inc; - }; + } /** \brief * Increments \ref nFaces by inc */ inline void incrementNumberOfFaces(int inc) { nFaces += inc; - }; + } /** \brief * Sets \ref nLeaves of the mesh */ inline void setNumberOfLeaves(int n) { nLeaves = n; - }; + } /** \brief * Increments \ref nLeaves by inc */ inline void incrementNumberOfLeaves(int inc) { nLeaves += inc; - }; + } /** \brief * Sets \ref nElements of the mesh */ inline void setNumberOfElements(int n) { nElements = n; - }; + } /** \brief * Increments \ref nElements by inc */ inline void incrementNumberOfElements(int inc) { nElements += inc; - }; + } /** \brief * Sets *\ref diam to w @@ -423,43 +423,43 @@ namespace AMDiS { */ inline void retainCoarseDOFs() { preserveCoarseDOFs = true; - }; + } /** \brief * Sets \ref preserveCoarseDOFs = b */ inline void setPreserveCoarseDOFs(bool b) { preserveCoarseDOFs = b; - }; + } /** \brief * Sets \ref preserveCoarseDOFs = false */ inline void noCoarseDOFs() { preserveCoarseDOFs = false; - }; + } /** \brief * Sets \ref elementPrototype of the mesh */ inline void setElementPrototype(Element* prototype) { elementPrototype = prototype; - }; - + } + /** \brief * Sets \ref elementDataPrototype of the mesh */ inline void setElementDataPrototype(ElementData* prototype) { elementDataPrototype = prototype; - }; + } inline void setParametric(Parametric *param) { parametric = param; - }; + } inline void setMaxEdgeNeigh(int m) { maxEdgeNeigh = m; - }; + } /** \} */ // ========================================================================== @@ -492,7 +492,7 @@ namespace AMDiS { /** \brief * Adds a DOFAdmin to the mesh */ - virtual void addDOFAdmin(DOFAdmin *admin_); + virtual void addDOFAdmin(DOFAdmin *admin); /** \brief * Traverses the mesh. The argument level specifies the element level if @@ -529,12 +529,12 @@ namespace AMDiS { /** \brief * Used by \ref findElementAtPoint. */ - bool findElInfoAtPoint(const WorldVector<double>& xy, - ElInfo *el_info, - DimVec<double>& bary, + bool findElInfoAtPoint(const WorldVector<double>& xy, + ElInfo *el_info, + DimVec<double>& bary, const MacroElement *start_mel, - const WorldVector<double> *xy0, - double *sp); + const WorldVector<double> *xy0, + double *sp); /** \brief * Access to an element at world coordinates xy. Some applications need the @@ -571,12 +571,12 @@ namespace AMDiS { * For non-convex domains, it is possible that in some cases a point inside * the domain is considered as external. */ - bool findElementAtPoint(const WorldVector<double>& xy, - Element **elp, - DimVec<double>& bary, + bool findElementAtPoint(const WorldVector<double>& xy, + Element **elp, + DimVec<double>& bary, const MacroElement *start_mel, - const WorldVector<double> *xy0, - double *sp); + const WorldVector<double> *xy0, + double *sp); /** \brief @@ -597,7 +597,7 @@ namespace AMDiS { ERROR_EXIT("invalid dim\n"); return FILL_ANY_1D; } - }; + } // ===== Serializable implementation ===== @@ -628,7 +628,7 @@ namespace AMDiS { bool indirectlyAssociated(DegreeOfFreedom dof1, DegreeOfFreedom dof2); inline MacroInfo* getMacroFileInfo() { - return macroFileInfo_; + return macroFileInfo; } void clearMacroFileInfo(); @@ -736,9 +736,9 @@ namespace AMDiS { static const Flag CALL_MG_LEVEL; protected: - bool findElementAtPointRecursive(ElInfo *elinfo, + bool findElementAtPointRecursive(ElInfo *elinfo, const DimVec<double>& lambda, - int outside, + int outside, ElInfo *final_el_info); protected: @@ -930,7 +930,7 @@ namespace AMDiS { * If the mesh has been created by reading a macro file, here * the information are stored about the content of the file. */ - MacroInfo *macroFileInfo_; + MacroInfo *macroFileInfo; protected: /** \brief @@ -939,12 +939,14 @@ namespace AMDiS { DimVec<double> final_lambda; /** \brief - * + * Temporary variables that are used in functions \ref fineElInfoatPoint and + * \ref fineElementAtPointRecursive. */ const WorldVector<double> *g_xy0, *g_xy; /** \brief - * + * Temporary variable that is used in functions \ref fineElInfoatPoint and + * \ref fineElementAtPointRecursive. */ double *g_sp; diff --git a/AMDiS/src/Parametric.cc b/AMDiS/src/Parametric.cc index a3571c704082e9d934f5fc2b9b95eb7b94dabd12..7fc768d01ee9c1240c9f65bc2dc8dc5072f4a4e7 100644 --- a/AMDiS/src/Parametric.cc +++ b/AMDiS/src/Parametric.cc @@ -5,38 +5,38 @@ namespace AMDiS { -ElInfo *ParametricFirstOrder::addParametricInfo(ElInfo *elInfo) -{ - elInfo->setParametric(true); - int i, j, dow = Global::getGeo(WORLD); - Element *element = elInfo->getElement(); - const DegreeOfFreedom **dof = element->getDOF(); + ElInfo *ParametricFirstOrder::addParametricInfo(ElInfo *elInfo) + { + elInfo->setParametric(true); + int dow = Global::getGeo(WORLD); + Element *element = elInfo->getElement(); + const DegreeOfFreedom **dof = element->getDOF(); - for(i = 0; i < elInfo->getElement()->getGeo(VERTEX); i++) { - if(elInfo->getFillFlag().isSet(Mesh::FILL_COORDS)) { - for(j = 0; j < dow; j++) { - elInfo->getCoord(i)[j] = (*(*dofCoords_)[j])[dof[i][0]]; + for (int i = 0; i < elInfo->getElement()->getGeo(VERTEX); i++) { + if (elInfo->getFillFlag().isSet(Mesh::FILL_COORDS)) { + for (int j = 0; j < dow; j++) { + elInfo->getCoord(i)[j] = (*(*dofCoords_)[j])[dof[i][0]]; + } } - } - if(elInfo->getFillFlag().isSet(Mesh::FILL_OPP_COORDS)) { - TEST_EXIT(elInfo->getFillFlag().isSet(Mesh::FILL_NEIGH)) - ("FILL_NEIGH not set\n"); - if(elInfo->getNeighbour(i)) { - const DegreeOfFreedom **neighDof = elInfo->getNeighbour(i)->getDOF(); - for(j = 0; j < dow; j++) { - elInfo->getOppCoord(i)[j] = - (*(*dofCoords_)[j])[neighDof[elInfo->getOppVertex(i)][0]]; + if (elInfo->getFillFlag().isSet(Mesh::FILL_OPP_COORDS)) { + TEST_EXIT(elInfo->getFillFlag().isSet(Mesh::FILL_NEIGH)) + ("FILL_NEIGH not set\n"); + if (elInfo->getNeighbour(i)) { + const DegreeOfFreedom **neighDof = elInfo->getNeighbour(i)->getDOF(); + for (int j = 0; j < dow; j++) { + elInfo->getOppCoord(i)[j] = + (*(*dofCoords_)[j])[neighDof[elInfo->getOppVertex(i)][0]]; + } } } } + return elInfo; } - return elInfo; -} -ElInfo *ParametricFirstOrder::removeParametricInfo(ElInfo *elInfo) -{ - elInfo->setParametric(false); - return elInfo; -} + ElInfo *ParametricFirstOrder::removeParametricInfo(ElInfo *elInfo) + { + elInfo->setParametric(false); + return elInfo; + } } diff --git a/AMDiS/src/Projection.h b/AMDiS/src/Projection.h index 19e0d3cdec4625ba13f0443fa4e42b4ab5e6fff0..00260f2b3746f26a2cb409aa4e4978f5f586e476 100644 --- a/AMDiS/src/Projection.h +++ b/AMDiS/src/Projection.h @@ -61,9 +61,9 @@ namespace AMDiS { TEST_EXIT(projectionMap_[id] == NULL) ("there is already a projection with this id\n"); projectionMap_[id] = this; - }; + } - virtual ~Projection() {}; + virtual ~Projection() {} /** \brief * Projection method. Must be overriden in sub classes. @@ -73,12 +73,16 @@ namespace AMDiS { /** \brief * Returns \ref projectionID. */ - inline int getID() { return projectionID_; }; + inline int getID() { + return projectionID_; + } /** \brief * Returns \ref projectionType; */ - inline ProjectionType getType() { return projectionType_; }; + inline ProjectionType getType() { + return projectionType_; + } /** \brief * Returns the projection with the given id, if existing. @@ -86,7 +90,7 @@ namespace AMDiS { */ static Projection* getProjection(int id) { return projectionMap_[id]; - }; + } protected: /** \brief diff --git a/AMDiS/src/Triangle.h b/AMDiS/src/Triangle.h index 5ab11e52ac5e9733b759d313dd5355b507b4395b..67fb780c9b68b89854b8aa0c82f86a353f30022e 100644 --- a/AMDiS/src/Triangle.h +++ b/AMDiS/src/Triangle.h @@ -43,14 +43,16 @@ namespace AMDiS { /** \brief * calls base class contructor. */ - Triangle(Mesh* aMesh) : Element(aMesh) {}; + Triangle(Mesh* aMesh) + : Element(aMesh) + {}; /** \brief * implements Element::clone */ inline Element *clone() { return NEW Triangle(mesh); - }; + } /** \brief @@ -58,14 +60,14 @@ namespace AMDiS { */ inline int getVertexOfEdge(int i, int j) const { return vertexOfEdge[i][j]; - }; + } /** \brief * implements Element::getVertexOfPosition */ int getVertexOfPosition(GeoIndex position, - int positionIndex, - int vertexIndex) const; + int positionIndex, + int vertexIndex) const; /** \brief * implements Element::getGeo @@ -95,7 +97,7 @@ namespace AMDiS { ERROR_EXIT("invalid geo-index\n"); return 0; } - }; + } /** \brief * implements Element::hasSide @@ -114,7 +116,7 @@ namespace AMDiS { */ inline bool isLine() const { return false; - }; + } /** \brief * implements Element::isTriangle. Returns true because this element is a @@ -122,7 +124,7 @@ namespace AMDiS { */ inline bool isTriangle() const { return true; - }; + } /** \brief * implements Element::isTetrahedron. Returns false because this element is a @@ -130,7 +132,7 @@ namespace AMDiS { */ inline bool isTetrahedron() const { return false; - }; + } /** \brief * implements Element::getSideOfChild() @@ -140,7 +142,7 @@ namespace AMDiS { TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); TEST_EXIT_DBG(side >= 0 && side <= 2)("side must be between 0 and 2\n"); return sideOfChild[child][side]; - }; + } /** \brief * implements Element::getVertexOfParent() @@ -150,7 +152,7 @@ namespace AMDiS { TEST_EXIT_DBG(child==0 || child==1)("child must be in (0,1)\n"); TEST_EXIT_DBG(side >= 0 && side <= 2)("side must be between 0 and 2\n"); return vertexOfParent[child][side]; - }; + } virtual int getPositionOfVertex(int side, int vertex) const { static int positionOfVertex[3][3] = {{-1,0,1},{1,-1,0},{0,1,-1}}; @@ -161,13 +163,13 @@ namespace AMDiS { TEST_EXIT_DBG(face == 0)("face must be zero at triangle\n"); TEST_EXIT_DBG(edge >= 0 && edge < 3)("invalid edge\n"); return edge; - }; + } // ===== Serializable implementation ===== std::string getTypeName() const { return "Triangle"; - }; + } protected: /** \brief