Commit 9346a213 authored by Tomáš Jakubec's avatar Tomáš Jakubec
Browse files

mesh_element.h -> rename

inline_array_operations.h -> reorder of operations
parent cf075a72
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@
template <unsigned int N, typename Real>
template <unsigned int N, typename Real>
struct inlineScalarProduct {
struct inlineScalarProduct {
    static inline Real computation(const Real *x, const Real *y){
    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>
template <unsigned int N, typename Real>
struct inlineAddition{
struct inlineAddition{
    static inline void computation(Real *res, const Real *x, const Real *y){
    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);
        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){
    static inline void computation(Real *x, const Real *y){
        x[N-1] += y[N-1];
        inlineAddition<N-1, Real>::computation(x, y);
        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>
template <unsigned int N, typename Real>
struct inlineSubtraction{
struct inlineSubtraction{
    static inline void computation(Real *res, const Real *x, const Real *y){
    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);
        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){
    static inline void computation(Real *x, const Real *y){
        x[N-1] -= y[N-1];
        inlineSubtraction<N-1, Real>::computation(x, y);
        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>
template <unsigned int N, typename Real>
struct inlineMultiplication{
struct inlineMultiplication{
    static inline void computation(Real *res, const Real *x, const Real& alpha){
    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);
        inlineMultiplication<N-1, Real>::computation(res, x, alpha);
        res[N-1] = x[N-1] * alpha;
    }
    }
    static inline void computation(Real *x, const Real alpha){
    static inline void computation(Real *x, const Real alpha){
        x[N-1] *= alpha;
        inlineMultiplication<N-1, Real>::computation(x, alpha);
        inlineMultiplication<N-1, Real>::computation(x, alpha);
        x[N-1] *= alpha;
    }
    }
};
};


+13 −13
Original line number Original line Diff line number Diff line
@@ -270,16 +270,16 @@ void testMesh2D() {
    mesh.GetVertices().at(3) = {1,1};
    mesh.GetVertices().at(3) = {1,1};


    mesh.GetFaces().resize(5);
    mesh.GetFaces().resize(5);
    mesh.GetFaces().at(0).VertexA = 1;
    mesh.GetFaces().at(0).vertexAIndex = 1;
    mesh.GetFaces().at(0).VertexB = 0;
    mesh.GetFaces().at(0).vertexBIndex = 0;
    mesh.GetFaces().at(1).VertexA = 0;
    mesh.GetFaces().at(1).vertexAIndex = 0;
    mesh.GetFaces().at(1).VertexB = 2;
    mesh.GetFaces().at(1).vertexBIndex = 2;
    mesh.GetFaces().at(2).VertexA = 2;
    mesh.GetFaces().at(2).vertexAIndex = 2;
    mesh.GetFaces().at(2).VertexB = 1;
    mesh.GetFaces().at(2).vertexBIndex = 1;
    mesh.GetFaces().at(3).VertexA = 3;
    mesh.GetFaces().at(3).vertexAIndex = 3;
    mesh.GetFaces().at(3).VertexB = 1;
    mesh.GetFaces().at(3).vertexBIndex = 1;
    mesh.GetFaces().at(4).VertexA = 2;
    mesh.GetFaces().at(4).vertexAIndex = 2;
    mesh.GetFaces().at(4).VertexB = 3;
    mesh.GetFaces().at(4).vertexBIndex = 3;
    for(size_t i = 0; i < 5; i++)
    for(size_t i = 0; i < 5; i++)
        mesh.GetFaces().at(i).SetIndex(i);
        mesh.GetFaces().at(i).SetIndex(i);


@@ -651,9 +651,9 @@ void testTemplate() {


int main()
int main()
{
{
    //testMesh2D();
    testMesh2D();
    //testMesh3D();
    testMesh3D();
    //test3DMeshDeformedPrisms();
    test3DMeshDeformedPrisms();
    testMeshDataContainer();
    testMeshDataContainer();
    //testTemplate();
    //testTemplate();
    UnstructuredMesh<5, size_t, double, 6,5,4> m;
    UnstructuredMesh<5, size_t, double, 6,5,4> m;
+37 −37
Original line number Original line Diff line number Diff line
@@ -39,11 +39,11 @@ public:
    }
    }
/*
/*
    IndexType GetGlobalIndex(){
    IndexType GetGlobalIndex(){
        return GlobalElementIndex;
        return globalElementIndex;
    }
    }


    void SetGlobalIndex(IndexType index){
    void SetGlobalIndex(IndexType index){
        GlobalElementIndex = index;
        globalElementIndex = index;
    }
    }
*/
*/
};
};
@@ -58,19 +58,19 @@ struct Subelement{


template <typename IndexType, unsigned int Reserve>
template <typename IndexType, unsigned int Reserve>
class SubelementContainer : public std::array<Subelement<IndexType>, Reserve>{
class SubelementContainer : public std::array<Subelement<IndexType>, Reserve>{
    unsigned char NumberOfElements = 0;
    unsigned char numberOfElements = 0;


public:
public:
    unsigned char GetNumberOfSubElements(){
    unsigned char GetNumberOfSubElements(){
        return NumberOfElements;
        return numberOfElements;
    }
    }




    void AddSubelement(IndexType index, bool isLeft) {
    void AddSubelement(IndexType index, bool isLeft) {
        if (NumberOfElements < Reserve){
        if (numberOfElements < Reserve){
            this->at(NumberOfElements).index = index;
            this->at(numberOfElements).index = index;
            this->at(NumberOfElements).isLeft = isLeft;
            this->at(numberOfElements).isLeft = isLeft;
            NumberOfElements++;
            numberOfElements++;
        } else {
        } else {
            throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase<IndexType>::GetIndex()) +
            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)
                                     ") number of edges overgrew the number of reserved indexes (" + std::to_string(Reserve)
@@ -80,16 +80,16 @@ public:
    }
    }


    void RemoveSubelement(unsigned char atIndex){
    void RemoveSubelement(unsigned char atIndex){
        if (atIndex < NumberOfElements){
        if (atIndex < numberOfElements){
            for(unsigned char i = atIndex; i < NumberOfElements - 1; i++){
            for(unsigned char i = atIndex; i < numberOfElements - 1; i++){
                this->at(i) = this->at(i+1);
                this->at(i) = this->at(i+1);
            }
            }
            this->at(NumberOfElements) = {INVALID_INDEX(IndexType), false};
            this->at(numberOfElements) = {INVALID_INDEX(IndexType), false};
            NumberOfElements--;
            numberOfElements--;
        } else {
        } else {
            throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase<IndexType>::GetIndex()) +
            throw(std::runtime_error(//"In face element (" + std::to_string(MeshElementBase<IndexType>::GetIndex()) +
                                     ") removing index " + std::to_string(atIndex)
                                     ") 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>,
class MeshElement : public MeshElementBase<IndexType>,
                    public std::conditional<ElementDim == MeshDim - 1,CellBoundaryConnection<IndexType>, emptyStruct>::type,
                    public std::conditional<ElementDim == MeshDim - 1,CellBoundaryConnection<IndexType>, emptyStruct>::type,
                    public std::conditional<ElementDim == MeshDim - 1,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{
                    public std::conditional<ElementDim == MeshDim - 1,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{
    SubelementContainer<IndexType, Reserve> Subelements;
    SubelementContainer<IndexType, Reserve> subelements;
public:
public:


    SubelementContainer<IndexType, Reserve>& GetSubelements(){
    SubelementContainer<IndexType, Reserve>& GetSubelements(){
        return Subelements;
        return subelements;
    }
    }


    const SubelementContainer<IndexType, Reserve>& GetSubelements() const {
    const SubelementContainer<IndexType, Reserve>& GetSubelements() const {
        return Subelements;
        return subelements;
    }
    }


    MeshElement(IndexType index = INVALID_INDEX(IndexType))
    MeshElement(IndexType index = INVALID_INDEX(IndexType))
        :MeshElementBase<IndexType>(index), CellBoundaryConnection<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,CellBoundaryConnection<IndexType>, emptyStruct>::type,
          public std::conditional<MeshDim == 2,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{
          public std::conditional<MeshDim == 2,ComputationallySignificantElement<MeshDim, Real>, emptyStruct2>::type{
public:
public:
    IndexType VertexA;
    IndexType vertexAIndex;
    IndexType VertexB;
    IndexType vertexBIndex;
public:
public:


    MeshElement(IndexType index = INVALID_INDEX(IndexType),
    MeshElement(IndexType index = INVALID_INDEX(IndexType),
@@ -178,20 +178,20 @@ public:




    IndexType GetVertexAIndex(){
    IndexType GetVertexAIndex(){
        return VertexA;
        return vertexAIndex;
    }
    }


    IndexType GetVertexBIndex(){
    IndexType GetVertexBIndex(){
        return VertexB;
        return vertexBIndex;
    }
    }


    void SetVertexAIndex(IndexType index){
    void SetVertexAIndex(IndexType index){
        VertexA = index;
        vertexAIndex = index;
    }
    }




    void SetVertexBIndex(IndexType index){
    void SetVertexBIndex(IndexType index){
        VertexB = index;
        vertexBIndex = index;
    }
    }


};
};
@@ -213,7 +213,7 @@ class MeshElement<MeshDim, MeshDim, IndexType, Real, Reserve>
        : public MeshElementBase<IndexType>,
        : public MeshElementBase<IndexType>,
          public ComputationallySignificantElement<MeshDim, Real>{
          public ComputationallySignificantElement<MeshDim, Real>{


    IndexType BoundaryElement;
    IndexType boundaryElementIndex;
public:
public:
//GetBoundaryElement
//GetBoundaryElement
    MeshElement(IndexType index = INVALID_INDEX(IndexType))
    MeshElement(IndexType index = INVALID_INDEX(IndexType))
@@ -222,11 +222,11 @@ public:
    }
    }


    IndexType GetBoundaryElementIndex(){
    IndexType GetBoundaryElementIndex(){
        return BoundaryElement;
        return boundaryElementIndex;
    }
    }


    void SetBoundaryElementIndex(IndexType index){
    void SetBoundaryElementIndex(IndexType index){
        BoundaryElement = index;
        boundaryElementIndex = index;
    }
    }


};
};
@@ -353,21 +353,21 @@ public:
    struct CellSubelementIterator: public std::iterator<std::forward_iterator_tag, IndexType>
    struct CellSubelementIterator: public std::iterator<std::forward_iterator_tag, IndexType>
    {
    {


        IndexType Actual;
        IndexType actual;
        IndexType FirstBElem;
        IndexType firstBElem;
        IndexType Cell;
        IndexType cellIndex;
        MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh;
        MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh;
    public:
    public:
        CellSubelementIterator(IndexType ci, IndexType act, MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh):Cell(ci){
        CellSubelementIterator(IndexType ci, IndexType act, MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh):cellIndex(ci){
            FirstBElem = act;
            firstBElem = act;
            Actual = FirstBElem;
            actual = firstBElem;
            this->parentMesh = parentMesh;
            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++ () {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(Cell) == FirstBElem ? INVALID_INDEX(IndexType) : parentMesh->GetFaces().at(Actual).GetNextBElem(Cell); 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;}
        IndexType operator* (){return actual;}
        bool operator== (CellSubelementIterator& it) {return Actual == it.Actual;}
        bool operator== (CellSubelementIterator& it) {return actual == it.actual;}
        bool operator!= (CellSubelementIterator& it) {return Actual != it.Actual;}
        bool operator!= (CellSubelementIterator& it) {return actual != it.actual;}
    };
    };


    class CellSubelements {
    class CellSubelements {