Loading Unstructured_mesh/inline_array_operations.h +7 −7 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ template <unsigned int N, typename Real> struct inlineScalarProduct { static inline Real computation(const Real *x, const Real *y){ return x[N-1] * y[N-1] + inlineScalarProduct<N-1, Real>::computation(x, y); return inlineScalarProduct<N-1, Real>::computation(x, y) + x[N-1] * y[N-1]; } }; Loading @@ -24,12 +24,12 @@ struct inlineScalarProduct<1, Real> template <unsigned int N, typename Real> struct inlineAddition{ static inline void computation(Real *res, const Real *x, const Real *y){ res[N-1] = x[N-1] + y[N-1]; inlineAddition<N-1, Real>::computation(res, x, y); res[N-1] = x[N-1] + y[N-1]; } static inline void computation(Real *x, const Real *y){ x[N-1] += y[N-1]; inlineAddition<N-1, Real>::computation(x, y); x[N-1] += y[N-1]; } }; Loading @@ -47,12 +47,12 @@ struct inlineAddition<1, Real>{ template <unsigned int N, typename Real> struct inlineSubtraction{ static inline void computation(Real *res, const Real *x, const Real *y){ res[N-1] = x[N-1] - y[N-1]; inlineSubtraction<N-1, Real>::computation(res, x, y); res[N-1] = x[N-1] - y[N-1]; } static inline void computation(Real *x, const Real *y){ x[N-1] -= y[N-1]; inlineSubtraction<N-1, Real>::computation(x, y); x[N-1] -= y[N-1]; } }; Loading @@ -71,12 +71,12 @@ struct inlineSubtraction<1, Real>{ template <unsigned int N, typename Real> struct inlineMultiplication{ static inline void computation(Real *res, const Real *x, const Real& alpha){ res[N-1] = x[N-1] * alpha; inlineMultiplication<N-1, Real>::computation(res, x, alpha); res[N-1] = x[N-1] * alpha; } static inline void computation(Real *x, const Real alpha){ x[N-1] *= alpha; inlineMultiplication<N-1, Real>::computation(x, alpha); x[N-1] *= alpha; } }; Loading Unstructured_mesh/main.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -270,16 +270,16 @@ void testMesh2D() { mesh.GetVertices().at(3) = {1,1}; mesh.GetFaces().resize(5); mesh.GetFaces().at(0).VertexA = 1; mesh.GetFaces().at(0).VertexB = 0; mesh.GetFaces().at(1).VertexA = 0; mesh.GetFaces().at(1).VertexB = 2; mesh.GetFaces().at(2).VertexA = 2; mesh.GetFaces().at(2).VertexB = 1; mesh.GetFaces().at(3).VertexA = 3; mesh.GetFaces().at(3).VertexB = 1; mesh.GetFaces().at(4).VertexA = 2; mesh.GetFaces().at(4).VertexB = 3; mesh.GetFaces().at(0).vertexAIndex = 1; mesh.GetFaces().at(0).vertexBIndex = 0; mesh.GetFaces().at(1).vertexAIndex = 0; mesh.GetFaces().at(1).vertexBIndex = 2; mesh.GetFaces().at(2).vertexAIndex = 2; mesh.GetFaces().at(2).vertexBIndex = 1; mesh.GetFaces().at(3).vertexAIndex = 3; mesh.GetFaces().at(3).vertexBIndex = 1; mesh.GetFaces().at(4).vertexAIndex = 2; mesh.GetFaces().at(4).vertexBIndex = 3; for(size_t i = 0; i < 5; i++) mesh.GetFaces().at(i).SetIndex(i); Loading Loading @@ -651,9 +651,9 @@ void testTemplate() { int main() { //testMesh2D(); //testMesh3D(); //test3DMeshDeformedPrisms(); testMesh2D(); testMesh3D(); test3DMeshDeformedPrisms(); testMeshDataContainer(); //testTemplate(); UnstructuredMesh<5, size_t, double, 6,5,4> m; Loading Unstructured_mesh/mesh_element.h +37 −37 Original line number Diff line number Diff line Loading @@ -39,11 +39,11 @@ public: } /* IndexType GetGlobalIndex(){ return GlobalElementIndex; return globalElementIndex; } void SetGlobalIndex(IndexType index){ GlobalElementIndex = index; globalElementIndex = index; } */ }; Loading @@ -58,19 +58,19 @@ struct Subelement{ template <typename IndexType, unsigned int Reserve> class SubelementContainer : public std::array<Subelement<IndexType>, Reserve>{ unsigned char NumberOfElements = 0; unsigned char numberOfElements = 0; public: unsigned char GetNumberOfSubElements(){ return NumberOfElements; return numberOfElements; } void AddSubelement(IndexType index, bool isLeft) { if (NumberOfElements < Reserve){ this->at(NumberOfElements).index = index; this->at(NumberOfElements).isLeft = isLeft; NumberOfElements++; if (numberOfElements < Reserve){ this->at(numberOfElements).index = index; this->at(numberOfElements).isLeft = isLeft; numberOfElements++; } else { throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase<IndexType>::GetIndex()) + ") number of edges overgrew the number of reserved indexes (" + std::to_string(Reserve) Loading @@ -80,16 +80,16 @@ public: } void RemoveSubelement(unsigned char atIndex){ if (atIndex < NumberOfElements){ for(unsigned char i = atIndex; i < NumberOfElements - 1; i++){ if (atIndex < numberOfElements){ for(unsigned char i = atIndex; i < numberOfElements - 1; i++){ this->at(i) = this->at(i+1); } this->at(NumberOfElements) = {INVALID_INDEX(IndexType), false}; NumberOfElements--; this->at(numberOfElements) = {INVALID_INDEX(IndexType), false}; numberOfElements--; } else { throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase<IndexType>::GetIndex()) + ") removing index " + std::to_string(atIndex) +" is greather than number of subelements " + std::to_string(NumberOfElements)+ ".")); +" is greather than number of subelements " + std::to_string(numberOfElements)+ ".")); } } Loading @@ -115,20 +115,20 @@ template <unsigned int MeshDim, unsigned int ElementDim, typename IndexType, typ class MeshElement : public MeshElementBase<IndexType>, public std::conditional<ElementDim == MeshDim - 1,CellBoundaryConnection<IndexType>, emptyStruct>::type, public std::conditional<ElementDim == MeshDim - 1,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{ SubelementContainer<IndexType, Reserve> Subelements; SubelementContainer<IndexType, Reserve> subelements; public: SubelementContainer<IndexType, Reserve>& GetSubelements(){ return Subelements; return subelements; } const SubelementContainer<IndexType, Reserve>& GetSubelements() const { return Subelements; return subelements; } MeshElement(IndexType index = INVALID_INDEX(IndexType)) :MeshElementBase<IndexType>(index), CellBoundaryConnection<IndexType> () { Subelements.fill({INVALID_INDEX(IndexType), false}); subelements.fill({INVALID_INDEX(IndexType), false}); } }; Loading Loading @@ -163,8 +163,8 @@ class MeshElement<MeshDim, 1, IndexType, Real, Reserve> public std::conditional<MeshDim == 2,CellBoundaryConnection<IndexType>, emptyStruct>::type, public std::conditional<MeshDim == 2,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{ public: IndexType VertexA; IndexType VertexB; IndexType vertexAIndex; IndexType vertexBIndex; public: MeshElement(IndexType index = INVALID_INDEX(IndexType), Loading @@ -178,20 +178,20 @@ public: IndexType GetVertexAIndex(){ return VertexA; return vertexAIndex; } IndexType GetVertexBIndex(){ return VertexB; return vertexBIndex; } void SetVertexAIndex(IndexType index){ VertexA = index; vertexAIndex = index; } void SetVertexBIndex(IndexType index){ VertexB = index; vertexBIndex = index; } }; Loading @@ -213,7 +213,7 @@ class MeshElement<MeshDim, MeshDim, IndexType, Real, Reserve> : public MeshElementBase<IndexType>, public ComputationallySignificantElement<MeshDim, Real>{ IndexType BoundaryElement; IndexType boundaryElementIndex; public: //GetBoundaryElement MeshElement(IndexType index = INVALID_INDEX(IndexType)) Loading @@ -222,11 +222,11 @@ public: } IndexType GetBoundaryElementIndex(){ return BoundaryElement; return boundaryElementIndex; } void SetBoundaryElementIndex(IndexType index){ BoundaryElement = index; boundaryElementIndex = index; } }; Loading Loading @@ -353,21 +353,21 @@ public: struct CellSubelementIterator: public std::iterator<std::forward_iterator_tag, IndexType> { IndexType Actual; IndexType FirstBElem; IndexType Cell; IndexType actual; IndexType firstBElem; IndexType cellIndex; MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh; public: CellSubelementIterator(IndexType ci, IndexType act, MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh):Cell(ci){ FirstBElem = act; Actual = FirstBElem; CellSubelementIterator(IndexType ci, IndexType act, MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh):cellIndex(ci){ firstBElem = act; actual = firstBElem; this->parentMesh = parentMesh; } CellSubelementIterator& operator++ () {Actual = parentMesh->GetFaces().at(Actual).GetNextBElem(Cell) == FirstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(Actual).GetNextBElem(Cell); return *this;} CellSubelementIterator& operator++ (int) {Actual = parentMesh->GetFaces().at(Actual).GetNextBElem(Cell) == FirstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(Actual).GetNextBElem(Cell); return *this;} IndexType operator* (){return Actual;} bool operator== (CellSubelementIterator& it) {return Actual == it.Actual;} bool operator!= (CellSubelementIterator& it) {return Actual != it.Actual;} CellSubelementIterator& operator++ () {actual = parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex) == firstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex); return *this;} CellSubelementIterator& operator++ (int) {actual = parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex) == firstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex); return *this;} IndexType operator* (){return actual;} bool operator== (CellSubelementIterator& it) {return actual == it.actual;} bool operator!= (CellSubelementIterator& it) {return actual != it.actual;} }; class CellSubelements { Loading Loading
Unstructured_mesh/inline_array_operations.h +7 −7 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ template <unsigned int N, typename Real> struct inlineScalarProduct { static inline Real computation(const Real *x, const Real *y){ return x[N-1] * y[N-1] + inlineScalarProduct<N-1, Real>::computation(x, y); return inlineScalarProduct<N-1, Real>::computation(x, y) + x[N-1] * y[N-1]; } }; Loading @@ -24,12 +24,12 @@ struct inlineScalarProduct<1, Real> template <unsigned int N, typename Real> struct inlineAddition{ static inline void computation(Real *res, const Real *x, const Real *y){ res[N-1] = x[N-1] + y[N-1]; inlineAddition<N-1, Real>::computation(res, x, y); res[N-1] = x[N-1] + y[N-1]; } static inline void computation(Real *x, const Real *y){ x[N-1] += y[N-1]; inlineAddition<N-1, Real>::computation(x, y); x[N-1] += y[N-1]; } }; Loading @@ -47,12 +47,12 @@ struct inlineAddition<1, Real>{ template <unsigned int N, typename Real> struct inlineSubtraction{ static inline void computation(Real *res, const Real *x, const Real *y){ res[N-1] = x[N-1] - y[N-1]; inlineSubtraction<N-1, Real>::computation(res, x, y); res[N-1] = x[N-1] - y[N-1]; } static inline void computation(Real *x, const Real *y){ x[N-1] -= y[N-1]; inlineSubtraction<N-1, Real>::computation(x, y); x[N-1] -= y[N-1]; } }; Loading @@ -71,12 +71,12 @@ struct inlineSubtraction<1, Real>{ template <unsigned int N, typename Real> struct inlineMultiplication{ static inline void computation(Real *res, const Real *x, const Real& alpha){ res[N-1] = x[N-1] * alpha; inlineMultiplication<N-1, Real>::computation(res, x, alpha); res[N-1] = x[N-1] * alpha; } static inline void computation(Real *x, const Real alpha){ x[N-1] *= alpha; inlineMultiplication<N-1, Real>::computation(x, alpha); x[N-1] *= alpha; } }; Loading
Unstructured_mesh/main.cpp +13 −13 Original line number Diff line number Diff line Loading @@ -270,16 +270,16 @@ void testMesh2D() { mesh.GetVertices().at(3) = {1,1}; mesh.GetFaces().resize(5); mesh.GetFaces().at(0).VertexA = 1; mesh.GetFaces().at(0).VertexB = 0; mesh.GetFaces().at(1).VertexA = 0; mesh.GetFaces().at(1).VertexB = 2; mesh.GetFaces().at(2).VertexA = 2; mesh.GetFaces().at(2).VertexB = 1; mesh.GetFaces().at(3).VertexA = 3; mesh.GetFaces().at(3).VertexB = 1; mesh.GetFaces().at(4).VertexA = 2; mesh.GetFaces().at(4).VertexB = 3; mesh.GetFaces().at(0).vertexAIndex = 1; mesh.GetFaces().at(0).vertexBIndex = 0; mesh.GetFaces().at(1).vertexAIndex = 0; mesh.GetFaces().at(1).vertexBIndex = 2; mesh.GetFaces().at(2).vertexAIndex = 2; mesh.GetFaces().at(2).vertexBIndex = 1; mesh.GetFaces().at(3).vertexAIndex = 3; mesh.GetFaces().at(3).vertexBIndex = 1; mesh.GetFaces().at(4).vertexAIndex = 2; mesh.GetFaces().at(4).vertexBIndex = 3; for(size_t i = 0; i < 5; i++) mesh.GetFaces().at(i).SetIndex(i); Loading Loading @@ -651,9 +651,9 @@ void testTemplate() { int main() { //testMesh2D(); //testMesh3D(); //test3DMeshDeformedPrisms(); testMesh2D(); testMesh3D(); test3DMeshDeformedPrisms(); testMeshDataContainer(); //testTemplate(); UnstructuredMesh<5, size_t, double, 6,5,4> m; Loading
Unstructured_mesh/mesh_element.h +37 −37 Original line number Diff line number Diff line Loading @@ -39,11 +39,11 @@ public: } /* IndexType GetGlobalIndex(){ return GlobalElementIndex; return globalElementIndex; } void SetGlobalIndex(IndexType index){ GlobalElementIndex = index; globalElementIndex = index; } */ }; Loading @@ -58,19 +58,19 @@ struct Subelement{ template <typename IndexType, unsigned int Reserve> class SubelementContainer : public std::array<Subelement<IndexType>, Reserve>{ unsigned char NumberOfElements = 0; unsigned char numberOfElements = 0; public: unsigned char GetNumberOfSubElements(){ return NumberOfElements; return numberOfElements; } void AddSubelement(IndexType index, bool isLeft) { if (NumberOfElements < Reserve){ this->at(NumberOfElements).index = index; this->at(NumberOfElements).isLeft = isLeft; NumberOfElements++; if (numberOfElements < Reserve){ this->at(numberOfElements).index = index; this->at(numberOfElements).isLeft = isLeft; numberOfElements++; } else { throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase<IndexType>::GetIndex()) + ") number of edges overgrew the number of reserved indexes (" + std::to_string(Reserve) Loading @@ -80,16 +80,16 @@ public: } void RemoveSubelement(unsigned char atIndex){ if (atIndex < NumberOfElements){ for(unsigned char i = atIndex; i < NumberOfElements - 1; i++){ if (atIndex < numberOfElements){ for(unsigned char i = atIndex; i < numberOfElements - 1; i++){ this->at(i) = this->at(i+1); } this->at(NumberOfElements) = {INVALID_INDEX(IndexType), false}; NumberOfElements--; this->at(numberOfElements) = {INVALID_INDEX(IndexType), false}; numberOfElements--; } else { throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase<IndexType>::GetIndex()) + ") removing index " + std::to_string(atIndex) +" is greather than number of subelements " + std::to_string(NumberOfElements)+ ".")); +" is greather than number of subelements " + std::to_string(numberOfElements)+ ".")); } } Loading @@ -115,20 +115,20 @@ template <unsigned int MeshDim, unsigned int ElementDim, typename IndexType, typ class MeshElement : public MeshElementBase<IndexType>, public std::conditional<ElementDim == MeshDim - 1,CellBoundaryConnection<IndexType>, emptyStruct>::type, public std::conditional<ElementDim == MeshDim - 1,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{ SubelementContainer<IndexType, Reserve> Subelements; SubelementContainer<IndexType, Reserve> subelements; public: SubelementContainer<IndexType, Reserve>& GetSubelements(){ return Subelements; return subelements; } const SubelementContainer<IndexType, Reserve>& GetSubelements() const { return Subelements; return subelements; } MeshElement(IndexType index = INVALID_INDEX(IndexType)) :MeshElementBase<IndexType>(index), CellBoundaryConnection<IndexType> () { Subelements.fill({INVALID_INDEX(IndexType), false}); subelements.fill({INVALID_INDEX(IndexType), false}); } }; Loading Loading @@ -163,8 +163,8 @@ class MeshElement<MeshDim, 1, IndexType, Real, Reserve> public std::conditional<MeshDim == 2,CellBoundaryConnection<IndexType>, emptyStruct>::type, public std::conditional<MeshDim == 2,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{ public: IndexType VertexA; IndexType VertexB; IndexType vertexAIndex; IndexType vertexBIndex; public: MeshElement(IndexType index = INVALID_INDEX(IndexType), Loading @@ -178,20 +178,20 @@ public: IndexType GetVertexAIndex(){ return VertexA; return vertexAIndex; } IndexType GetVertexBIndex(){ return VertexB; return vertexBIndex; } void SetVertexAIndex(IndexType index){ VertexA = index; vertexAIndex = index; } void SetVertexBIndex(IndexType index){ VertexB = index; vertexBIndex = index; } }; Loading @@ -213,7 +213,7 @@ class MeshElement<MeshDim, MeshDim, IndexType, Real, Reserve> : public MeshElementBase<IndexType>, public ComputationallySignificantElement<MeshDim, Real>{ IndexType BoundaryElement; IndexType boundaryElementIndex; public: //GetBoundaryElement MeshElement(IndexType index = INVALID_INDEX(IndexType)) Loading @@ -222,11 +222,11 @@ public: } IndexType GetBoundaryElementIndex(){ return BoundaryElement; return boundaryElementIndex; } void SetBoundaryElementIndex(IndexType index){ BoundaryElement = index; boundaryElementIndex = index; } }; Loading Loading @@ -353,21 +353,21 @@ public: struct CellSubelementIterator: public std::iterator<std::forward_iterator_tag, IndexType> { IndexType Actual; IndexType FirstBElem; IndexType Cell; IndexType actual; IndexType firstBElem; IndexType cellIndex; MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh; public: CellSubelementIterator(IndexType ci, IndexType act, MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh):Cell(ci){ FirstBElem = act; Actual = FirstBElem; CellSubelementIterator(IndexType ci, IndexType act, MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh):cellIndex(ci){ firstBElem = act; actual = firstBElem; this->parentMesh = parentMesh; } CellSubelementIterator& operator++ () {Actual = parentMesh->GetFaces().at(Actual).GetNextBElem(Cell) == FirstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(Actual).GetNextBElem(Cell); return *this;} CellSubelementIterator& operator++ (int) {Actual = parentMesh->GetFaces().at(Actual).GetNextBElem(Cell) == FirstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(Actual).GetNextBElem(Cell); return *this;} IndexType operator* (){return Actual;} bool operator== (CellSubelementIterator& it) {return Actual == it.Actual;} bool operator!= (CellSubelementIterator& it) {return Actual != it.Actual;} CellSubelementIterator& operator++ () {actual = parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex) == firstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex); return *this;} CellSubelementIterator& operator++ (int) {actual = parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex) == firstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(actual).GetNextBElem(cellIndex); return *this;} IndexType operator* (){return actual;} bool operator== (CellSubelementIterator& it) {return actual == it.actual;} bool operator!= (CellSubelementIterator& it) {return actual != it.actual;} }; class CellSubelements { Loading