Commit 357b8b66 authored by Tomáš Jakubec's avatar Tomáš Jakubec
Browse files

Elements connections

Mesh Colouring
MeshDataContainer
parent bfe87de0
Loading
Loading
Loading
Loading
+1 −1
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-09-21T11:13:09. -->
<!-- Written by QtCreator 4.10.0, 2019-09-27T11:56:39. -->
<qtcreator>
<qtcreator>
 <data>
 <data>
  <variable>EnvironmentId</variable>
  <variable>EnvironmentId</variable>
+78 −7
Original line number Original line Diff line number Diff line
@@ -324,7 +324,18 @@ void testMesh2D() {
        }
        }
    }
    }


    CellsVertices<2,2,size_t, double>::run(mesh);
    MeshDataContainer<std::set<size_t>, 2> vertices(mesh);

    DBGMSG("vertices of cells in 2D");
    for (auto& cell : mesh.GetCells()){
        std::set<size_t>& _set = vertices.at(cell);
        DBGVAR(cell.GetIndex())
        for (size_t index: _set){
            DBGVAR(index)
        }
    }




    auto centers = ComputeCenters(mesh);
    auto centers = ComputeCenters(mesh);


@@ -398,14 +409,15 @@ void testMesh3D() {
        DBGVAR(i.index)
        DBGVAR(i.index)
    }
    }


    DBGMSG("3D cell vertices");
    CellsVertices<3,3,size_t, double, 6>::run(mesh3);






    DBGMSG("mesh conatiner test");
    DBGMSG("mesh conatiner test");
    MeshDataContainer<double, 3,2,1,0> cont(mesh3);
    MeshDataContainer<double, 3,2,1,0> cont(mesh3);


    MakeMeshDataContainer_t<double, make_custom_integer_sequence_t<unsigned int, 0,3>> cont1(mesh3);


    //cont.GetDataDim<3>().resize(20);
    //cont.GetDataDim<3>().resize(20);
    DBGVAR(cont.GetDataPos<1>().size())
    DBGVAR(cont.GetDataPos<1>().size())


@@ -452,6 +464,47 @@ void testMesh3D() {
    for(auto& face : mesh3.GetFaces()){
    for(auto& face : mesh3.GetFaces()){
        DBGVAR(face.GetIndex(),normals.at(face))
        DBGVAR(face.GetIndex(),normals.at(face))
    }
    }

    DBGMSG("mesh apply test");
    temp1::MeshApply<3, 2, 3>::apply(mesh3, [](unsigned int S, unsigned int T, size_t ori, size_t i){
        DBGVAR(S,T,ori,i)
    });
    DBGMSG("mesh apply test");
    temp1::MeshApply<2, 3, 3>::apply(mesh3,[](unsigned int S, unsigned int T, size_t ori, size_t i){
        DBGVAR(S,T,ori,i)
    });


    DBGMSG("connection test");
    auto con = temp1::MeshConnections<3,0>::connections(mesh3);
    for (auto& cell : mesh3.GetCells()){
        DBGVAR(cell.GetIndex())
        for(size_t i : con[cell]){
            DBGVAR(i)
        }
    }


    DBGMSG("connection test oposite");
    auto con1 = temp1::MeshConnections<0,3>::connections(mesh3);
    for (auto& vert : mesh3.GetVertices()){
        DBGVAR(vert.GetIndex())
        for(size_t i : con1[vert]){
            DBGVAR(i)
        }
    }

    DBGMSG("face to vertex colouring");
    auto colours = temp1::ColourMesh<2,0>::colour(mesh3);
    for (auto& face : mesh3.GetFaces()){
        DBGVAR(face.GetIndex(), colours.at(face))
    }

    DBGMSG("vertex to face colouring");
    auto colours1 = temp1::ColourMesh<0,2>::colour(mesh3);
    for (auto& vert : mesh3.GetVertices()){
        DBGVAR(vert.GetIndex(), colours1.at(vert))
    }
}
}




@@ -511,6 +564,24 @@ void testMeshDataContainer() {
    for(auto& v : mesh3.GetVertices()){
    for(auto& v : mesh3.GetVertices()){
        DBGVAR(container.at(v))
        DBGVAR(container.at(v))
    }
    }

    MeshDataContainer<std::tuple<int, double, char, int>, 3, 2, 0, 2> containerIni(mesh3,3, 42.15, 'a', 15);

    for (auto& val : containerIni.GetDataPos<0>()){
        DBGVAR(val)
    }

    for (auto& val : containerIni.GetDataPos<1>()){
        DBGVAR(val)
    }

    for (auto& val : containerIni.GetDataPos<2>()){
        DBGVAR(val)
    }

    for (auto& val : containerIni.GetDataPos<3>()){
        DBGVAR(val)
    }
}
}


template <unsigned int ... Is>
template <unsigned int ... Is>
@@ -580,11 +651,11 @@ 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;
    m.ComputeElementMeasures();
    //m.ComputeElementMeasures();
}
}
+202 −22
Original line number Original line Diff line number Diff line

#ifndef MESH_FUNCTIONS_H
#ifndef MESH_FUNCTIONS_H
#define MESH_FUNCTIONS_H
#define MESH_FUNCTIONS_H
#include "mesh_element.h"
#include "mesh_element.h"
#include "meshdatacontainer.h"
#include "meshdatacontainer.h"
#include "vector.h"
#include "vector.h"
#include <valarray>
#include <set>


template <typename Type, Type startIndex, Type EndIndex, int increment = 1, Type... t>
template <typename Type, Type startIndex, Type EndIndex, int increment = 1, Type... t>
struct MakeCustomIntegerSequence : public MakeCustomIntegerSequence<Type, startIndex + increment, EndIndex, increment, t..., startIndex> {
struct MakeCustomIntegerSequence : public MakeCustomIntegerSequence<Type, startIndex + increment, EndIndex, increment, t..., startIndex> {
@@ -121,10 +124,12 @@ ComputeCenters(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){






/* TODO implement GS to compute volume and normal vector
template <unsigned int Dimension,typename IndexType, typename Real>
std::vector<Vertex<Dimension, Real>> GrammSchmidt(std::vector<Vertex<Dimension, Real>> vectors){



}

*/







@@ -326,7 +331,10 @@ struct _ComputeNormals<3>{


            bool vectorSign = true;
            bool vectorSign = true;
            IndexType cellIndex = face.GetCellLeftIndex();
            IndexType cellIndex = face.GetCellLeftIndex();
            if (cellIndex == INVALID_INDEX(IndexType)) {
            if (
                    cellIndex == INVALID_INDEX(IndexType) ||
                    (cellIndex & BOUNDARY_INDEX(IndexType)) == BOUNDARY_INDEX(IndexType)
                ) {
                vectorSign = false;
                vectorSign = false;
                cellIndex = face.GetCellRightIndex();
                cellIndex = face.GetCellRightIndex();
            }
            }
@@ -439,40 +447,212 @@ MeshDataContainer<Real, Dimension-1> ComputeCellsDistance(MeshElements<Dimension






namespace temp1 {

template <unsigned int CurrentDimension, unsigned int StartDimension, unsigned int TargetDimension, unsigned int MeshDimension, bool End, bool Ascend>
struct MeshRun {

    template<typename Func, typename IndexType, typename Real, unsigned int ...Reserve>
    static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh,
                    IndexType origElementIndex,
                    IndexType index,
                    Func fun){


        auto i = mesh.template GetElements<CurrentDimension>().at(index);
        for (auto sube: mesh.template GetElement<CurrentDimension>(i.GetIndex()).GetSubelements())
        MeshRun< CurrentDimension - 1, StartDimension, TargetDimension, MeshDimension, TargetDimension == CurrentDimension - 1, Ascend>::run(mesh, origElementIndex, sube.index, fun);


    }
};

template <unsigned int StartDimension, unsigned int TargetDimension, unsigned int MeshDimension, bool Ascend>
struct MeshRun<MeshDimension, StartDimension, TargetDimension, MeshDimension, false, Ascend> {

    template<typename Func, typename IndexType, typename Real, unsigned int ...Reserve>
    static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh,
                    IndexType origElementIndex,
                    IndexType index,
                    Func fun){

        auto& cell = mesh.GetCells().at(index);
        IndexType tmpFace = cell.GetBoundaryElementIndex();
        do {
            MeshRun<MeshDimension - 1, StartDimension, TargetDimension, MeshDimension, TargetDimension == MeshDimension - 1, Ascend>::run(mesh, origElementIndex, tmpFace, fun);
            tmpFace = mesh.GetFaces().at(tmpFace).GetNextBElem(cell.GetIndex());
        } while (tmpFace != cell.GetBoundaryElementIndex());

    }
};


template <unsigned int StartDimension, unsigned int TargetDimension, unsigned int MeshDimension, bool Ascend>
struct MeshRun<1, StartDimension, TargetDimension, MeshDimension, false, Ascend> {

    template<typename Func, typename IndexType, typename Real, unsigned int ...Reserve>
    static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh,
                    IndexType origElementIndex,
                    IndexType index,
                    Func fun){

        auto& edge = mesh.GetEdges().at(index);
        MeshRun<0, StartDimension, TargetDimension, MeshDimension, TargetDimension == 0, Ascend>::run(mesh, origElementIndex, edge.GetVertexAIndex(), fun);
        MeshRun<0, StartDimension, TargetDimension, MeshDimension, TargetDimension == 0, Ascend>::run(mesh, origElementIndex, edge.GetVertexBIndex(), fun);
    }
};



template <unsigned int CurrentDimension,unsigned int StartDimension, unsigned int TargetDimension, unsigned int MeshDimension, bool Ascend>
struct MeshRun<CurrentDimension, StartDimension, TargetDimension, MeshDimension, true, Ascend> {

    template<typename Func, typename IndexType, typename Real, unsigned int ...Reserve>
    static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& ,
                    IndexType origElementIndex,
                    IndexType index,
                    Func fun){
        if(Ascend){
            fun(StartDimension, TargetDimension, origElementIndex, index);
        }else{
            fun(TargetDimension, StartDimension, index, origElementIndex);
        }
    }
};







template<unsigned int MeshDimension, unsigned int ElementDim,typename IndexType, typename Real, unsigned int ...Reserve>
template <unsigned int StartDimension, unsigned int TargetDimension, unsigned int MeshDimension>
struct CellsVertices {
struct MeshApply {
    static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh, IndexType index){
    template<typename Functor, typename IndexType, typename Real, unsigned int ...Reserve>
        DBGMSG("face number "<<index);
    static void apply(MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh,
        for(auto i : mesh.template GetElement<ElementDim>(index).GetSubelements()) {
                      Functor f) {
            CellsVertices<MeshDimension, ElementDim - 1, IndexType, Real, Reserve...>::run(mesh, i.index);
        for (auto& startElement : mesh.template GetElements<(StartDimension > TargetDimension) ? StartDimension : TargetDimension>()){
            MeshRun<
                    (StartDimension > TargetDimension) ? StartDimension : TargetDimension,
                    (StartDimension > TargetDimension) ? StartDimension : TargetDimension,
                    (StartDimension > TargetDimension) ? TargetDimension : StartDimension,
                    MeshDimension,
                    false,
                    (StartDimension > TargetDimension)>::run(mesh, startElement.GetIndex(), startElement.GetIndex(), f);
        }
    }
    }
};


template<unsigned int StartDim, unsigned int TargetDim>
struct MeshConnections {
    template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
    static MeshDataContainer<std::set<IndexType>, StartDim> connections(
            MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh
            ) {
        MeshDataContainer<std::set<IndexType>, StartDim> result(mesh);
        MeshApply<StartDim, TargetDim, MeshDimension>::apply(mesh, [&result](unsigned int, unsigned int, IndexType ori, IndexType element){
            result.template GetDataPos<0>().at(ori).insert(element);
        });

        return result;
    }
    }
};
};


template<unsigned int FromDim, unsigned int ToDim, bool Descend = true>
struct MeshColouring {


    template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
    template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
struct CellsVertices<MeshDimension, MeshDimension, IndexType, Real, Reserve...> {
    static MeshDataContainer<unsigned int, FromDim> colour(
    static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh){
            MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh
        for(IndexType i = 0; i < mesh.GetCells().size(); i++){
            ) {
            DBGMSG("cell number "<<i);
        MeshDataContainer<unsigned int, FromDim> result(mesh);
            for(auto j : mesh.template GetElement<MeshDimension>(i).GetSubelements()) {

                CellsVertices<MeshDimension, MeshDimension - 1, IndexType, Real, Reserve...>::run(mesh, j);
        DBGMSG("starting the coloring procedure");
        unsigned int reserve = 16;
        MeshDataContainer<std::valarray<bool>, ToDim> attachedColours(mesh, std::valarray<bool>(false, reserve));



        for (auto& startElement : mesh.template GetElements<FromDim>()){
            std::valarray<bool> possibleColours(true,reserve);
            MeshRun<FromDim, FromDim, ToDim, MeshDimension, false, true>::
                run(mesh,
                    startElement.GetIndex(),
                    startElement.GetIndex(),
                    [&possibleColours, &attachedColours](unsigned int, unsigned int, IndexType, IndexType element){
                        DBGTRY(possibleColours &= !attachedColours.template GetDataPos<0>().at(element);)
                    }
                    }
                );

            // Select the first possible colour
            unsigned int selectedColour = 0;
            while (!possibleColours[selectedColour]) {
                selectedColour++;
            }
            result.template GetDataPos<0>().at(startElement.GetIndex()) = selectedColour;
            MeshRun<FromDim, FromDim, ToDim, MeshDimension, false, true>::
                run(mesh,
                    startElement.GetIndex(),
                    startElement.GetIndex(),
                    [selectedColour, &attachedColours](unsigned int, unsigned int, IndexType, IndexType element){
                        DBGTRY(attachedColours.template GetDataPos<0>().at(element)[selectedColour] = true;)
                    }
                    }
                );
        }
        return result;
    }
    }
};
};




template<unsigned int FromDim, unsigned int ToDim>
struct MeshColouring <FromDim, ToDim, false> {
    template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
    template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
struct CellsVertices<MeshDimension, 1, IndexType, Real, Reserve...> {
    static MeshDataContainer<unsigned int, FromDim> colour(
    static void run(MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh, IndexType index){
            MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh
            ) {
        MeshDataContainer<unsigned int, FromDim> result(mesh);

        DBGMSG("starting the coloring procedure");
        unsigned int reserve = 16;
        MeshDataContainer<std::valarray<bool>, ToDim> attachedColours(mesh, std::valarray<bool>(false, reserve));


            auto e = mesh.template GetElement<1>(index);
        auto connections = MeshConnections<FromDim, ToDim>::connections(mesh);
            DBGVAR(mesh.GetVertices()[e.GetElement().GetVertexAIndex()], mesh.GetVertices()[e.GetElement().GetVertexBIndex()])


        for (auto& startElement : mesh.template GetElements<FromDim>()){
            std::valarray<bool> possibleColours(true,reserve);
            for (IndexType element : connections.at(startElement)){

                DBGTRY(possibleColours &= !attachedColours.template GetDataPos<0>().at(element);)

            }

            unsigned int selectedColour = 0;
            while (!possibleColours[selectedColour]) {
                selectedColour++;
            }

            result.template GetDataPos<0>().at(startElement.GetIndex()) = selectedColour;

            for (IndexType element : connections.at(startElement)){
                DBGTRY(attachedColours.template GetDataPos<0>().at(element)[selectedColour] = true;)
            }
        }
        return result;
    }
    }
};
};



template <unsigned int FromDim, unsigned int ToDim>
struct ColourMesh{

template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
static MeshDataContainer<unsigned int, FromDim> colour(
        MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh
        ){
    return MeshColouring<FromDim, ToDim, (FromDim > ToDim)>::colour(mesh);
}
};

}


#endif // MESH_FUNCTIONS_H
#endif // MESH_FUNCTIONS_H
+104 −13
Original line number Original line Diff line number Diff line
@@ -48,6 +48,16 @@ private:
                        mesh.template GetElements<std::get<pos>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());
                        mesh.template GetElements<std::get<pos>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());
            Alocator<pos - 1>::AlocateMemory(parent, mesh);
            Alocator<pos - 1>::AlocateMemory(parent, mesh);
        }
        }

        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        static void AlocateMemory(MeshDataContainer<DataType, Dimensions...>& parent ,
                                  MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                                  const DataType& initialValue) {
            parent.template GetDataPos<pos>().resize(
                        mesh.template GetElements<std::get<pos>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size(),
                        initialValue);
            Alocator<pos - 1>::AlocateMemory(parent, mesh, initialValue);
        }
    };
    };


    template<typename dummy>
    template<typename dummy>
@@ -59,6 +69,16 @@ private:
                        mesh.template GetElements<std::get<0>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());
                        mesh.template GetElements<std::get<0>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());


        }
        }
        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        static void AlocateMemory(MeshDataContainer<DataType, Dimensions...>& parent ,
                                  MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                                  const DataType& initialValue) {

            parent.template GetDataPos<0>().resize(
                        mesh.template GetElements<std::get<0>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size(),
                        initialValue);

        }
    };
    };




@@ -107,14 +127,43 @@ public:


    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){
        Alocator<sizeof... (Dimensions) - 1>::AlocateMemory(*this, mesh);
        AlocateData(mesh);
    }
    }


    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, std::integer_sequence<unsigned int,Dimensions...>, DataType){
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, std::integer_sequence<unsigned int,Dimensions...>, DataType){
        DBGVAR(sizeof... (Dimensions))
        AlocateData(mesh);
    }


    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                      const DataType& initialValue){
        AlocateData(mesh, initialValue);
    }

    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                      const DataType& initialValue,
                      std::integer_sequence<unsigned int,Dimensions...>,
                      DataType){
        AlocateData(mesh, initialValue);
    }



    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    void AlocateData(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){
        Alocator<sizeof... (Dimensions) - 1>::AlocateMemory(*this, mesh);
        Alocator<sizeof... (Dimensions) - 1>::AlocateMemory(*this, mesh);
    }
    }

    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    void AlocateData(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue){
        Alocator<sizeof... (Dimensions) - 1>::AlocateMemory(*this, mesh,initialValue);
    }



};
};




@@ -148,9 +197,9 @@ public:
    template<unsigned int pos>
    template<unsigned int pos>
    using DataType = typename std::tuple_element<pos,std::tuple<DataTypes...>>::type;
    using DataType = typename std::tuple_element<pos,std::tuple<DataTypes...>>::type;


    template<unsigned int _Dim, typename Dummy = void>
    template<unsigned int Pos, typename Dummy = void>
    struct _DataContainer : _DataContainer<_Dim - 1, Dummy>{
    struct _DataContainer : _DataContainer<Pos - 1, Dummy>{
        std::vector<DataType<_Dim>> _data;
        std::vector<DataType<Pos>> _data;
    };
    };


    template<typename Dummy>
    template<typename Dummy>
@@ -158,24 +207,45 @@ public:
        std::vector<DataType<0>> _data;
        std::vector<DataType<0>> _data;
    };
    };


    template<unsigned int pos, typename dummy = void>
    template<unsigned int pos, typename _DataType, typename... _DataTypes>
    struct Alocator{
    struct Alocator{
        MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent;
        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        static void AlocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent ,MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) {
        static void AlocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent ,MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) {
            parent.template GetDataPos<pos>().resize(
            parent.template GetDataPos<pos>().resize(
                        mesh.template GetElements<std::get<pos>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());
                        mesh.template GetElements<std::get<pos>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());
            Alocator<pos - 1>::AlocateMemory(parent, mesh);
            Alocator<pos + 1, _DataTypes...>::AlocateMemory(parent, mesh);
        }

        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        static void AlocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent,
                                  MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                                  const _DataType& initialValue,
                                  const _DataTypes&... values) {
            parent.template GetDataPos<pos>().resize(
                        mesh.template GetElements<std::get<pos>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size(),
                        initialValue);
            Alocator<pos + 1, _DataTypes...>::AlocateMemory(parent, mesh, values...);
        }
        }
    };
    };


    template<typename dummy>
    template<typename _DataType, typename... _DataTypes>
    struct Alocator<0, dummy>{
    struct Alocator<sizeof... (Dimensions) - 1, _DataType, _DataTypes...>{
        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        static void AlocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent ,MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) {
        static void AlocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent ,MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) {


            parent.template GetDataPos<0>().resize(
            parent.template GetDataPos<sizeof... (Dimensions) - 1>().resize(
                        mesh.template GetElements<std::get<0>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());
                        mesh.template GetElements<std::get<sizeof... (Dimensions) - 1>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size());

        }
        template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
        static void AlocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent,
                                  MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                                  const _DataType& initialValue,
                                  const _DataTypes&...) {

            parent.template GetDataPos<sizeof... (Dimensions) - 1>().resize(
                        mesh.template GetElements<std::get<sizeof... (Dimensions) - 1>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>().size(),
                        initialValue);


        }
        }
    };
    };
@@ -226,9 +296,30 @@ public:


    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){
        Alocator<sizeof... (Dimensions) - 1>::AlocateMemory(*this, mesh);
        AlocateData(mesh);
    }

    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    MeshDataContainer(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                      const DataTypes&... initialValues){
        AlocateData(mesh, initialValues...);
    }

    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    void AlocateData(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){
        Alocator<0, DataTypes...>::AlocateMemory(*this, mesh);
    }
    }




    template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve>
    void AlocateData(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh,
                     const DataTypes&... initialValues){
        Alocator<0, DataTypes...>::AlocateMemory(*this, mesh, initialValues...);
    }



};
};