Commit 3390223d authored by Tomáš Jakubec's avatar Tomáš Jakubec
Browse files

MeshElements refactor the requirements to standard version lovered to at

least c++14.
parent 65872aa5
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2019-11-20T11:13:14. -->
<!-- Written by QtCreator 4.10.0, 2019-11-20T22:43:48. -->
<qtcreator>
<qtcreator>
 <data>
 <data>
  <variable>EnvironmentId</variable>
  <variable>EnvironmentId</variable>
@@ -58,7 +58,8 @@
   <valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
   <valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
    <value type="QString">-fno-delayed-template-parsing</value>
    <value type="QString">-fno-delayed-template-parsing</value>
   </valuelist>
   </valuelist>
   <value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
   <value type="bool" key="ClangCodeModel.UseGlobalConfig">false</value>
   <value type="QString" key="ClangCodeModel.WarningConfigId">{49cc42df-eb96-4f55-a479-d83d49acb284}</value>
  </valuemap>
  </valuemap>
 </data>
 </data>
 <data>
 <data>
+2 −3
Original line number Original line Diff line number Diff line
#include <iostream>
#include <iostream>
//#define UNDEBUG
//#define UNDEBUG
#define CONSOLE_COLOURED_OUTPUT
//#define CONSOLE_COLOURED_OUTPUT
#include "../src/Debug/Debug.h"
#include "../src/Debug/Debug.h"
#include "../src/UnstructuredMesh/UnstructuredMesh.h"
#include "../src/UnstructuredMesh/UnstructuredMesh.h"
#include "../src/UnstructuredMesh/MeshFunctions/MeshFunctions.h"
#include "../src/UnstructuredMesh/MeshFunctions/MeshFunctions.h"
@@ -14,7 +14,6 @@
#include "../src/Traits/MemberApproach/MemberApproach.h"
#include "../src/Traits/MemberApproach/MemberApproach.h"
#include <fstream>
#include <fstream>
#include <list>
#include <list>
#include <windows.h>
using namespace std;
using namespace std;




@@ -931,7 +930,7 @@ int main()
{
{
    //testMesh2D();
    //testMesh2D();
    //testMesh2DLoadAndWrite();
    //testMesh2DLoadAndWrite();
    //testMesh3D();
    testMesh3D();
    test3DMeshDeformedPrisms();
    test3DMeshDeformedPrisms();
    //testMeshRefine();
    //testMeshRefine();
    //testMeshDataContainer();
    //testMeshDataContainer();
+30 −33
Original line number Original line Diff line number Diff line
@@ -267,63 +267,60 @@ public:
template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
struct MeshElements{
struct MeshElements{
private:
private:
    template <unsigned int _Dimension,unsigned int ElemDim, typename _IndexType, typename _Real, unsigned int ..._Reserve>
    struct _MeshElements : public _MeshElements<_Dimension, ElemDim - 1, _IndexType, _Real, _Reserve...>{
        std::vector<MeshElement<_Dimension, ElemDim, _IndexType, _Real, std::get<_Dimension - ElemDim - 1>(std::array<unsigned int, sizeof... (Reserve)>{Reserve...})>> elements;
    };

    template <unsigned int _Dimension, typename _IndexType, typename _Real, unsigned int ..._Reserve>
    struct _MeshElements<_Dimension, 0, _IndexType, _Real, _Reserve...>{
        std::vector<MeshElement<Dimension, 0, IndexType, Real, 0>> elements;
    };


    template <unsigned int _Dimension, typename _IndexType, typename _Real, unsigned int ..._Reserve>
    template<unsigned int dim, typename Void = void>
    struct _MeshElements<_Dimension, 1, _IndexType, _Real, _Reserve...> : public _MeshElements<_Dimension, 0, _IndexType, _Real, _Reserve...>{
    struct _Reserve{
        std::vector<MeshElement<Dimension, 1, IndexType, Real, 0>> elements;
    };


        static unsigned int constexpr value = std::get<Dimension - dim - 1>(std::array<unsigned int, sizeof... (Reserve)>{Reserve...});


    template <unsigned int _Dimension,typename _IndexType, typename _Real, unsigned int ..._Reserve>
    struct _MeshElements<_Dimension, _Dimension, _IndexType, _Real, _Reserve...> : public _MeshElements<_Dimension, _Dimension - 1, _IndexType, _Real, _Reserve...>{
        std::vector<MeshElement<_Dimension, _Dimension, _IndexType, _Real, 0>> elements;
    };
    };


    template<unsigned int dim>
    template<unsigned int dim>
    static unsigned int constexpr reserve(){
    struct _Reserve<dim, typename std::enable_if<dim == Dimension || dim == 1 || dim == 0 || (Dimension - dim - 1 > sizeof...(Reserve))>::type>{
        if constexpr (dim == Dimension || dim == 1 || dim == 0){
            return 0;
        } else {
            return std::get<(dim == Dimension || dim == 1 || dim == 0) ? 0 : Dimension - dim - 1>(std::array<unsigned int, sizeof... (Reserve)>{Reserve...});
        }
    }




        static unsigned int constexpr value = 0;
    };


    _MeshElements<Dimension, Dimension, IndexType, Real, Reserve...> Refs;
    std::vector<MeshElement<Dimension, Dimension, IndexType, Real, 0>> BoundaryCells;
public:
public:


    using Vertex = MeshElement<Dimension, 0, IndexType, Real, 0>;
    using Vertex = MeshElement<Dimension, 0, IndexType, Real, 0>;
    using Edge = MeshElement<Dimension, 1, IndexType, Real, 0>;
    using Edge = MeshElement<Dimension, 1, IndexType, Real, 0>;
    using Face = MeshElement<Dimension, Dimension - 1, IndexType, Real, reserve<Dimension - 1>()>;
    using Face = MeshElement<Dimension, Dimension - 1, IndexType, Real, _Reserve<Dimension - 1>::value>;
    using Cell = MeshElement<Dimension, Dimension, IndexType, Real, 0>;
    using Cell = MeshElement<Dimension, Dimension, IndexType, Real, 0>;


    template<unsigned int ElementDimension>
    template<unsigned int ElementDimension>
    using ElementType = MeshElement<Dimension, ElementDimension, IndexType, Real, reserve<ElementDimension>()>;
    using ElementType = MeshElement<Dimension, ElementDimension, IndexType, Real, _Reserve<ElementDimension>::value>;

private:
    template <unsigned int ElemDim = Dimension, typename Dummy = void>
    struct _MeshElements : public _MeshElements<ElemDim - 1, Dummy>{
        std::vector<typename MeshElements<Dimension, IndexType, Real, Reserve...>:: template ElementType<ElemDim>> elements;
    };

    template <typename Dummy>
    struct _MeshElements<0, Dummy>{
        std::vector<typename MeshElements<Dimension, IndexType, Real, Reserve...>:: template ElementType<0>> elements;
    };






private:
    _MeshElements<Dimension> Refs;
    std::vector<Cell> BoundaryCells;

public:
    template<unsigned int dim>
    template<unsigned int dim>
    std::vector<ElementType<dim>>& getElements(){
    std::vector<ElementType<dim>>& getElements(){
        static_assert (Dimension >= dim, "In GetElements template parameter dim must be less or equal to Dimension.");
        static_assert (Dimension >= dim, "In GetElements template parameter dim must be less or equal to Dimension.");
        return Refs._MeshElements<Dimension, dim, IndexType, Real, Reserve...>::elements;
        return Refs._MeshElements<dim>::elements;
    }
    }




    template<unsigned int dim>
    template<unsigned int dim>
    const std::vector<ElementType<dim>>&  getElements() const {
    const std::vector<ElementType<dim>>&  getElements() const {
        static_assert (Dimension >= dim, "In GetElements template parameter dim must be less or equal to Dimension.");
        static_assert (Dimension >= dim, "In GetElements template parameter dim must be less or equal to Dimension.");
        return Refs._MeshElements<Dimension, dim, IndexType, Real, Reserve...>::elements;
        return Refs._MeshElements<dim>::elements;
    }
    }


    std::vector<Vertex>& getVertices(){
    std::vector<Vertex>& getVertices(){
@@ -447,7 +444,7 @@ public:
        IndexType elementIndex;
        IndexType elementIndex;
        MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh;
        MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh;
    public:
    public:
        MeshElementWrap(MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh, MeshElement<Dimension, ElementDim, IndexType, Real, reserve<ElementDim>()>& meshElement){
        MeshElementWrap(MeshElements<Dimension, IndexType, Real, Reserve...>* parentMesh, MeshElement<Dimension, ElementDim, IndexType, Real, _Reserve<Dimension - 1>::value>& meshElement){
            elementIndex = meshElement.getIndex();
            elementIndex = meshElement.getIndex();
            this->parentMesh = parentMesh;
            this->parentMesh = parentMesh;
        }
        }
@@ -461,7 +458,7 @@ public:
            return elementIndex;
            return elementIndex;
        }
        }


        SubelementContainer<IndexType, reserve<ElementDim>()>& getSubelements(){
        SubelementContainer<IndexType, _Reserve<Dimension - 1>::value>& getSubelements(){
            return parentMesh->template getElements<ElementDim>()[elementIndex].getSubelements();
            return parentMesh->template getElements<ElementDim>()[elementIndex].getSubelements();
        }
        }
    };
    };
+1 −3
Original line number Original line Diff line number Diff line
@@ -4,6 +4,7 @@
#include "../MeshElements/MeshElement.h"
#include "../MeshElements/MeshElement.h"
#include "../MeshDataContainer/MeshDataContainer.h"
#include "../MeshDataContainer/MeshDataContainer.h"
#include "../../NumericStaticArray/Vector.h"
#include "../../NumericStaticArray/Vector.h"
#include "../../Debug/Debug.h"
#include <valarray>
#include <valarray>
#include <functional>
#include <functional>
#include <set>
#include <set>
@@ -52,7 +53,6 @@ struct _ComputeCenters{
            elemCenters.at(i) /= subElemCnt;
            elemCenters.at(i) /= subElemCnt;
        }
        }


        DBGMSG(dim);
        _ComputeCenters<dim + 1, Dimension>::compute(centers, mesh);
        _ComputeCenters<dim + 1, Dimension>::compute(centers, mesh);
    }
    }
};
};
@@ -79,7 +79,6 @@ struct _ComputeCenters<Dimension, Dimension>{


            elemCenters.at(i) /= subElemCnt;
            elemCenters.at(i) /= subElemCnt;
        }
        }
        DBGMSG(Dimension);
    }
    }


};
};
@@ -99,7 +98,6 @@ struct _ComputeCenters<1, Dimension>{
                                mesh.template getElements<0>().at(edge.getVertexBIndex())) * 0.5;
                                mesh.template getElements<0>().at(edge.getVertexBIndex())) * 0.5;
        }
        }


        DBGMSG("1");
        _ComputeCenters<2, Dimension>::compute(centers, mesh);
        _ComputeCenters<2, Dimension>::compute(centers, mesh);
    }
    }
};
};