Loading Unstructured_mesh/main.cpp +17 −4 Original line number Original line Diff line number Diff line Loading @@ -456,8 +456,9 @@ void testMesh3D() { 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); MakeMeshDataContainer_t<double, make_custom_integer_sequence_t<unsigned int, 3,0,-1>> cont1(mesh3); cont = cont1; //cont.getDataByDim<3>().resize(20); //cont.getDataByDim<3>().resize(20); DBGVAR(cont.getDataByPos<1>().size(), cont.getDataByPos<1>().getMappedDimension()); DBGVAR(cont.getDataByPos<1>().size(), cont.getDataByPos<1>().getMappedDimension()); Loading @@ -474,6 +475,8 @@ void testMesh3D() { //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); for(auto& face : mesh3.getFaces()) { for(auto& face : mesh3.getFaces()) { face.setCenter(centers.template getDataByDim<2>().at(face.getIndex())); face.setCenter(centers.template getDataByDim<2>().at(face.getIndex())); DBGVAR(face.getCenter()); DBGVAR(face.getCenter()); Loading Loading @@ -811,6 +814,7 @@ void testMeshDataContainer() { MeshDataContainer<std::tuple<int, double, char, int>, 3, 2, 0, 2> containerIni(mesh3,3, 42.15, 'a', 15); MeshDataContainer<std::tuple<int, double, char, int>, 3, 2, 0, 2> containerIni(mesh3,3, 42.15, 'a', 15); for (auto& val : containerIni.getDataByPos<0>()){ for (auto& val : containerIni.getDataByPos<0>()){ DBGVAR(val); DBGVAR(val); } } Loading @@ -826,6 +830,15 @@ void testMeshDataContainer() { for (auto& val : containerIni.getDataByPos<3>()){ for (auto& val : containerIni.getDataByPos<3>()){ DBGVAR(val); DBGVAR(val); } } DBGMSG("assign test"); MeshDataContainer<std::tuple<int, double, char, int>, 3, 2, 0, 2> containerAssign; containerAssign = containerIni; for (auto& val : containerAssign.getDataByPos<0>()){ DBGVAR(val); } } } Loading Loading @@ -956,10 +969,10 @@ int main() { { //testMesh2D(); //testMesh2D(); //testMesh2DLoadAndWrite(); //testMesh2DLoadAndWrite(); testMesh3D(); //testMesh3D(); test3DMeshDeformedPrisms(); //test3DMeshDeformedPrisms(); //testMeshRefine(); //testMeshRefine(); //testMeshDataContainer(); testMeshDataContainer(); //UnstructuredMesh<5, size_t, double, 6,5,4> m; //UnstructuredMesh<5, size_t, double, 6,5,4> m; //m.ComputeElementMeasures(); //m.ComputeElementMeasures(); //test3DMeshLoad(); //test3DMeshLoad(); Loading src/UnstructuredMesh/MeshDataContainer/MeshDataContainer.h +143 −32 Original line number Original line Diff line number Diff line Loading @@ -20,8 +20,7 @@ struct DataContainer : public std::vector<DataType> { /** /** * @brief The MeshDataContainer struct * @brief The MeshDataContainer struct<HR> * * A struct designed to manage data boud to mesh. * A struct designed to manage data boud to mesh. * Creates a serie of vectors sized acording to dimension. * Creates a serie of vectors sized acording to dimension. */ */ Loading Loading @@ -76,31 +75,57 @@ public: private: private: template<unsigned int pos, typename dummy = void> template<unsigned int pos, typename dummy = void> struct Alocator{ struct Allocator{ MeshDataContainer<DataType, Dimensions...>& parent; MeshDataContainer<DataType, 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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); Allocator<pos - 1>::allocateMemory(parent, mesh); } } 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue) { const DataType& initialValue) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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(), initialValue); initialValue); Alocator<pos - 1>::alocateMemory(parent, mesh, initialValue); Allocator<pos - 1>::allocateMemory(parent, mesh, initialValue); } /** * @brief allocateMemory * allocates memory according to another MashDataContainer of the same type * @param parent * @param meshDataContainer */ template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size()); Allocator<pos - 1>::allocateMemory(parent, meshDataContainer); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer, const DataType& initialValue) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size(), initialValue); Allocator<pos - 1>::allocateMemory(parent, meshDataContainer, initialValue); } } }; }; template<typename dummy> template<typename dummy> struct Alocator<0, dummy>{ struct Allocator<0, dummy>{ 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<0>().resize( parent.template getDataByPos<0>().resize( Loading @@ -108,7 +133,7 @@ private: } } 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue) { const DataType& initialValue) { Loading @@ -117,6 +142,22 @@ private: initialValue); initialValue); } } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size()); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer, const DataType& initialValue) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size(), initialValue); } }; }; Loading Loading @@ -157,20 +198,20 @@ public: template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ alocateData(mesh); allocateData(mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, std::integer_sequence<unsigned int,Dimensions...>, DataType){ std::integer_sequence<unsigned int,Dimensions...>, DataType){ alocateData(mesh); allocateData(mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue){ const DataType& initialValue){ alocateData(mesh, initialValue); allocateData(mesh, initialValue); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> Loading @@ -178,22 +219,36 @@ public: const DataType& initialValue, const DataType& initialValue, std::integer_sequence<unsigned int,Dimensions...>, std::integer_sequence<unsigned int,Dimensions...>, DataType){ DataType){ alocateData(mesh, initialValue); allocateData(mesh, initialValue); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ Alocator<sizeof... (Dimensions) - 1>::alocateMemory(*this, mesh); Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue){ void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue){ Alocator<sizeof... (Dimensions) - 1>::alocateMemory(*this, mesh,initialValue); Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, mesh,initialValue); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<DataType, Dimensions...>& meshDataContainer){ Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, meshDataContainer); } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<DataType, Dimensions...>& meshDataContainer, const DataType& initialValue){ Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, meshDataContainer,initialValue); } MeshDataContainer<DataType, Dimensions...>& operator=(const MeshDataContainer<DataType, Dimensions...>& rhs) { this->data = rhs.data; return *this; } }; }; Loading Loading @@ -261,31 +316,50 @@ public: } } template<unsigned int pos, typename _DataType, typename... _DataTypes> template<unsigned int pos, typename _DataType, typename... _DataTypes> struct Alocator{ struct Allocator{ 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 , static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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, _DataTypes...>::alocateMemory(parent, mesh); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, mesh); } } 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, static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const _DataType& initialValue, const _DataType& initialValue, const _DataTypes&... values) { const _DataTypes&... values) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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(), initialValue); initialValue); Alocator<pos + 1, _DataTypes...>::alocateMemory(parent, mesh, values...); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, mesh, values...); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size()); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, meshDataContainer); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer, const _DataType& initialValue, const _DataTypes&... values) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size(), initialValue); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, meshDataContainer, values...); } } }; }; template<typename _DataType, typename... _DataTypes> template<typename _DataType, typename... _DataTypes> struct Alocator<sizeof... (Dimensions) - 1, _DataType, _DataTypes...>{ struct Allocator<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 , static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<sizeof... (Dimensions) - 1>().resize( parent.template getDataByPos<sizeof... (Dimensions) - 1>().resize( Loading @@ -293,7 +367,7 @@ public: } } 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, static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const _DataType& initialValue, const _DataType& initialValue, const _DataTypes&...) { const _DataTypes&...) { Loading @@ -303,6 +377,26 @@ public: initialValue); initialValue); } } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size()); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer, const _DataType& initialValue, const _DataTypes&...) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size(), initialValue); } }; }; Loading Loading @@ -354,29 +448,46 @@ public: template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ alocateData(mesh); allocateData(mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataTypes&... initialValues){ const DataTypes&... initialValues){ alocateData(mesh, initialValues...); allocateData(mesh, initialValues...); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ Alocator<0, DataTypes...>::alocateMemory(*this, mesh); Allocator<0, DataTypes...>::allocateMemory(*this, mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataTypes&... initialValues){ const DataTypes&... initialValues){ Alocator<0, DataTypes...>::alocateMemory(*this, mesh, initialValues...); Allocator<0, DataTypes...>::allocateMemory(*this, mesh, initialValues...); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer){ Allocator<0, DataTypes...>::allocateMemory(*this, meshDataContainer); } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer, const DataTypes&... initialValues){ Allocator<0, DataTypes...>::allocateMemory(*this, meshDataContainer, initialValues...); } MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& operator=(const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& rhs) { this->data = rhs.data; return *this; } }; }; Loading src/UnstructuredMesh/MeshIO/MeshReader/VTKMeshReader.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -126,7 +126,7 @@ public: void loadCellTypes(std::istream& ist, MeshElements<2, IndexType, Real, Reserve...>& mesh){ void loadCellTypes(std::istream& ist, MeshElements<2, IndexType, Real, Reserve...>& mesh){ IndexType numCells; IndexType numCells; ist >> numCells; ist >> numCells; cellTypes.alocateData(mesh); cellTypes.allocateData(mesh); for (IndexType i = 0; i < numCells; i++) { for (IndexType i = 0; i < numCells; i++) { int vtkType = 0; int vtkType = 0; ist >> vtkType; ist >> vtkType; Loading Loading @@ -393,7 +393,7 @@ public: void loadCellTypes(std::istream& ist, MeshElements<3, IndexType, Real, Reserve...>& mesh){ void loadCellTypes(std::istream& ist, MeshElements<3, IndexType, Real, Reserve...>& mesh){ IndexType numCells; IndexType numCells; ist >> numCells; ist >> numCells; cellTypes.alocateData(mesh); cellTypes.allocateData(mesh); for (IndexType i = 0; i < numCells; i++) { for (IndexType i = 0; i < numCells; i++) { int vtkType = 0; int vtkType = 0; ist >> vtkType; ist >> vtkType; Loading src/UnstructuredMesh/MeshIO/MeshWriter/FPMAMeshWriter.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -95,7 +95,7 @@ class FPMAMeshWriter<3, IndexType, Real> : public MeshWriter<3>{ faceVert.template getDataByPos<0>().clear(); faceVert.template getDataByPos<0>().clear(); faceVert.alocateData(mesh); faceVert.allocateData(mesh); DBGMSG("indexing mesh"); DBGMSG("indexing mesh"); // write cells of the mesh // write cells of the mesh // prepare connections // prepare connections Loading Loading
Unstructured_mesh/main.cpp +17 −4 Original line number Original line Diff line number Diff line Loading @@ -456,8 +456,9 @@ void testMesh3D() { 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); MakeMeshDataContainer_t<double, make_custom_integer_sequence_t<unsigned int, 3,0,-1>> cont1(mesh3); cont = cont1; //cont.getDataByDim<3>().resize(20); //cont.getDataByDim<3>().resize(20); DBGVAR(cont.getDataByPos<1>().size(), cont.getDataByPos<1>().getMappedDimension()); DBGVAR(cont.getDataByPos<1>().size(), cont.getDataByPos<1>().getMappedDimension()); Loading @@ -474,6 +475,8 @@ void testMesh3D() { //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); for(auto& face : mesh3.getFaces()) { for(auto& face : mesh3.getFaces()) { face.setCenter(centers.template getDataByDim<2>().at(face.getIndex())); face.setCenter(centers.template getDataByDim<2>().at(face.getIndex())); DBGVAR(face.getCenter()); DBGVAR(face.getCenter()); Loading Loading @@ -811,6 +814,7 @@ void testMeshDataContainer() { MeshDataContainer<std::tuple<int, double, char, int>, 3, 2, 0, 2> containerIni(mesh3,3, 42.15, 'a', 15); MeshDataContainer<std::tuple<int, double, char, int>, 3, 2, 0, 2> containerIni(mesh3,3, 42.15, 'a', 15); for (auto& val : containerIni.getDataByPos<0>()){ for (auto& val : containerIni.getDataByPos<0>()){ DBGVAR(val); DBGVAR(val); } } Loading @@ -826,6 +830,15 @@ void testMeshDataContainer() { for (auto& val : containerIni.getDataByPos<3>()){ for (auto& val : containerIni.getDataByPos<3>()){ DBGVAR(val); DBGVAR(val); } } DBGMSG("assign test"); MeshDataContainer<std::tuple<int, double, char, int>, 3, 2, 0, 2> containerAssign; containerAssign = containerIni; for (auto& val : containerAssign.getDataByPos<0>()){ DBGVAR(val); } } } Loading Loading @@ -956,10 +969,10 @@ int main() { { //testMesh2D(); //testMesh2D(); //testMesh2DLoadAndWrite(); //testMesh2DLoadAndWrite(); testMesh3D(); //testMesh3D(); test3DMeshDeformedPrisms(); //test3DMeshDeformedPrisms(); //testMeshRefine(); //testMeshRefine(); //testMeshDataContainer(); testMeshDataContainer(); //UnstructuredMesh<5, size_t, double, 6,5,4> m; //UnstructuredMesh<5, size_t, double, 6,5,4> m; //m.ComputeElementMeasures(); //m.ComputeElementMeasures(); //test3DMeshLoad(); //test3DMeshLoad(); Loading
src/UnstructuredMesh/MeshDataContainer/MeshDataContainer.h +143 −32 Original line number Original line Diff line number Diff line Loading @@ -20,8 +20,7 @@ struct DataContainer : public std::vector<DataType> { /** /** * @brief The MeshDataContainer struct * @brief The MeshDataContainer struct<HR> * * A struct designed to manage data boud to mesh. * A struct designed to manage data boud to mesh. * Creates a serie of vectors sized acording to dimension. * Creates a serie of vectors sized acording to dimension. */ */ Loading Loading @@ -76,31 +75,57 @@ public: private: private: template<unsigned int pos, typename dummy = void> template<unsigned int pos, typename dummy = void> struct Alocator{ struct Allocator{ MeshDataContainer<DataType, Dimensions...>& parent; MeshDataContainer<DataType, 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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); Allocator<pos - 1>::allocateMemory(parent, mesh); } } 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue) { const DataType& initialValue) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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(), initialValue); initialValue); Alocator<pos - 1>::alocateMemory(parent, mesh, initialValue); Allocator<pos - 1>::allocateMemory(parent, mesh, initialValue); } /** * @brief allocateMemory * allocates memory according to another MashDataContainer of the same type * @param parent * @param meshDataContainer */ template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size()); Allocator<pos - 1>::allocateMemory(parent, meshDataContainer); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer, const DataType& initialValue) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size(), initialValue); Allocator<pos - 1>::allocateMemory(parent, meshDataContainer, initialValue); } } }; }; template<typename dummy> template<typename dummy> struct Alocator<0, dummy>{ struct Allocator<0, dummy>{ 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<0>().resize( parent.template getDataByPos<0>().resize( Loading @@ -108,7 +133,7 @@ private: } } 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<DataType, Dimensions...>& parent , static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue) { const DataType& initialValue) { Loading @@ -117,6 +142,22 @@ private: initialValue); initialValue); } } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size()); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<DataType, Dimensions...>& parent , const MeshDataContainer<DataType, Dimensions...>& meshDataContainer, const DataType& initialValue) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size(), initialValue); } }; }; Loading Loading @@ -157,20 +198,20 @@ public: template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ alocateData(mesh); allocateData(mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, std::integer_sequence<unsigned int,Dimensions...>, DataType){ std::integer_sequence<unsigned int,Dimensions...>, DataType){ alocateData(mesh); allocateData(mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue){ const DataType& initialValue){ alocateData(mesh, initialValue); allocateData(mesh, initialValue); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> Loading @@ -178,22 +219,36 @@ public: const DataType& initialValue, const DataType& initialValue, std::integer_sequence<unsigned int,Dimensions...>, std::integer_sequence<unsigned int,Dimensions...>, DataType){ DataType){ alocateData(mesh, initialValue); allocateData(mesh, initialValue); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ Alocator<sizeof... (Dimensions) - 1>::alocateMemory(*this, mesh); Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue){ void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataType& initialValue){ Alocator<sizeof... (Dimensions) - 1>::alocateMemory(*this, mesh,initialValue); Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, mesh,initialValue); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<DataType, Dimensions...>& meshDataContainer){ Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, meshDataContainer); } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<DataType, Dimensions...>& meshDataContainer, const DataType& initialValue){ Allocator<sizeof... (Dimensions) - 1>::allocateMemory(*this, meshDataContainer,initialValue); } MeshDataContainer<DataType, Dimensions...>& operator=(const MeshDataContainer<DataType, Dimensions...>& rhs) { this->data = rhs.data; return *this; } }; }; Loading Loading @@ -261,31 +316,50 @@ public: } } template<unsigned int pos, typename _DataType, typename... _DataTypes> template<unsigned int pos, typename _DataType, typename... _DataTypes> struct Alocator{ struct Allocator{ 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 , static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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, _DataTypes...>::alocateMemory(parent, mesh); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, mesh); } } 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, static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const _DataType& initialValue, const _DataType& initialValue, const _DataTypes&... values) { const _DataTypes&... values) { parent.template getDataByPos<pos>().resize( parent.template getDataByPos<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(), initialValue); initialValue); Alocator<pos + 1, _DataTypes...>::alocateMemory(parent, mesh, values...); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, mesh, values...); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size()); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, meshDataContainer); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer, const _DataType& initialValue, const _DataTypes&... values) { parent.template getDataByPos<pos>().resize( meshDataContainer.template getDataByPos<pos>().size(), initialValue); Allocator<pos + 1, _DataTypes...>::allocateMemory(parent, meshDataContainer, values...); } } }; }; template<typename _DataType, typename... _DataTypes> template<typename _DataType, typename... _DataTypes> struct Alocator<sizeof... (Dimensions) - 1, _DataType, _DataTypes...>{ struct Allocator<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 , static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh) { parent.template getDataByPos<sizeof... (Dimensions) - 1>().resize( parent.template getDataByPos<sizeof... (Dimensions) - 1>().resize( Loading @@ -293,7 +367,7 @@ public: } } 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, static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const _DataType& initialValue, const _DataType& initialValue, const _DataTypes&...) { const _DataTypes&...) { Loading @@ -303,6 +377,26 @@ public: initialValue); initialValue); } } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent , const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size()); } template<unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> static void allocateMemory(MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& parent, const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer, const _DataType& initialValue, const _DataTypes&...) { parent.template getDataByPos<0>().resize( meshDataContainer.template getDataByPos<0>().size(), initialValue); } }; }; Loading Loading @@ -354,29 +448,46 @@ public: template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ alocateData(mesh); allocateData(mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, MeshDataContainer(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataTypes&... initialValues){ const DataTypes&... initialValues){ alocateData(mesh, initialValues...); allocateData(mesh, initialValues...); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ Alocator<0, DataTypes...>::alocateMemory(*this, mesh); Allocator<0, DataTypes...>::allocateMemory(*this, mesh); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void alocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, void allocateData(const MeshElements<Dimension, IndexType, Real, Reserve...>& mesh, const DataTypes&... initialValues){ const DataTypes&... initialValues){ Alocator<0, DataTypes...>::alocateMemory(*this, mesh, initialValues...); Allocator<0, DataTypes...>::allocateMemory(*this, mesh, initialValues...); } } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer){ Allocator<0, DataTypes...>::allocateMemory(*this, meshDataContainer); } template <unsigned int Dimension, typename IndexType, typename Real, unsigned int ...Reserve> void allocateData(const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& meshDataContainer, const DataTypes&... initialValues){ Allocator<0, DataTypes...>::allocateMemory(*this, meshDataContainer, initialValues...); } MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& operator=(const MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>& rhs) { this->data = rhs.data; return *this; } }; }; Loading
src/UnstructuredMesh/MeshIO/MeshReader/VTKMeshReader.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -126,7 +126,7 @@ public: void loadCellTypes(std::istream& ist, MeshElements<2, IndexType, Real, Reserve...>& mesh){ void loadCellTypes(std::istream& ist, MeshElements<2, IndexType, Real, Reserve...>& mesh){ IndexType numCells; IndexType numCells; ist >> numCells; ist >> numCells; cellTypes.alocateData(mesh); cellTypes.allocateData(mesh); for (IndexType i = 0; i < numCells; i++) { for (IndexType i = 0; i < numCells; i++) { int vtkType = 0; int vtkType = 0; ist >> vtkType; ist >> vtkType; Loading Loading @@ -393,7 +393,7 @@ public: void loadCellTypes(std::istream& ist, MeshElements<3, IndexType, Real, Reserve...>& mesh){ void loadCellTypes(std::istream& ist, MeshElements<3, IndexType, Real, Reserve...>& mesh){ IndexType numCells; IndexType numCells; ist >> numCells; ist >> numCells; cellTypes.alocateData(mesh); cellTypes.allocateData(mesh); for (IndexType i = 0; i < numCells; i++) { for (IndexType i = 0; i < numCells; i++) { int vtkType = 0; int vtkType = 0; ist >> vtkType; ist >> vtkType; Loading
src/UnstructuredMesh/MeshIO/MeshWriter/FPMAMeshWriter.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -95,7 +95,7 @@ class FPMAMeshWriter<3, IndexType, Real> : public MeshWriter<3>{ faceVert.template getDataByPos<0>().clear(); faceVert.template getDataByPos<0>().clear(); faceVert.alocateData(mesh); faceVert.allocateData(mesh); DBGMSG("indexing mesh"); DBGMSG("indexing mesh"); // write cells of the mesh // write cells of the mesh // prepare connections // prepare connections Loading