From 9346a213682ef8f02d9220d53f1ad1dd906689ab Mon Sep 17 00:00:00 2001 From: Tomas Jakubec <jakubto1@fjfi.cvut.cz> Date: Sun, 29 Sep 2019 15:53:08 +0200 Subject: [PATCH] mesh_element.h -> rename inline_array_operations.h -> reorder of operations --- Unstructured_mesh/inline_array_operations.h | 14 ++-- Unstructured_mesh/main.cpp | 26 ++++---- Unstructured_mesh/mesh_element.h | 74 ++++++++++----------- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/Unstructured_mesh/inline_array_operations.h b/Unstructured_mesh/inline_array_operations.h index 70ddf85..0025677 100644 --- a/Unstructured_mesh/inline_array_operations.h +++ b/Unstructured_mesh/inline_array_operations.h @@ -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]; } }; @@ -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]; } }; @@ -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]; } }; @@ -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; } }; diff --git a/Unstructured_mesh/main.cpp b/Unstructured_mesh/main.cpp index 6a962cb..e0bd621 100644 --- a/Unstructured_mesh/main.cpp +++ b/Unstructured_mesh/main.cpp @@ -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); @@ -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; diff --git a/Unstructured_mesh/mesh_element.h b/Unstructured_mesh/mesh_element.h index 36207ea..d18a6ff 100644 --- a/Unstructured_mesh/mesh_element.h +++ b/Unstructured_mesh/mesh_element.h @@ -39,11 +39,11 @@ public: } /* IndexType GetGlobalIndex(){ - return GlobalElementIndex; + return globalElementIndex; } void SetGlobalIndex(IndexType index){ - GlobalElementIndex = index; + globalElementIndex = index; } */ }; @@ -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) @@ -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)+ ".")); } } @@ -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}); } }; @@ -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), @@ -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; } }; @@ -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)) @@ -222,11 +222,11 @@ public: } IndexType GetBoundaryElementIndex(){ - return BoundaryElement; + return boundaryElementIndex; } void SetBoundaryElementIndex(IndexType index){ - BoundaryElement = index; + boundaryElementIndex = index; } }; @@ -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 { -- GitLab