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

refactor

parent bf45364b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ HEADERS += \
    ../src/UnstructuredMesh/MeshFunctions/ComputeNormals.h \
    ../src/UnstructuredMesh/MeshFunctions/EdgesOrientation.h \
    ../src/UnstructuredMesh/MeshFunctions/MeshApply.h \
    ../src/UnstructuredMesh/MeshFunctions/MeshColouring.h \
    ../src/UnstructuredMesh/MeshFunctions/MeshColoring.h \
    ../src/UnstructuredMesh/MeshFunctions/MeshConnections.h \
    ../src/UnstructuredMesh/MeshFunctions/MeshFunctions.h \
    ../src/UnstructuredMesh/MeshFunctions/MeshFunctionsDefine.h \
+6 −6
Original line number Diff line number Diff line
@@ -579,13 +579,13 @@ DBGMSG("tessellated cell volume");
    }

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

    DBGMSG("vertex to face colouring");
    auto colours1 = ColourMesh<0,2>::colour(mesh3);
    auto colours1 = ColorMesh<0,2>::color(mesh3);
    for (auto& vert : mesh3.getVertices()){
        DBGVAR(vert.getIndex(), colours1.at(vert));
    }
@@ -635,7 +635,7 @@ void testMeshRefine() {
    writer.writeHeader(out3D, "test data");
    writer.writeToStream(out3D, mesh, types);

    auto colours = MeshColouring<3,0>::colour(mesh);
    auto colours = MeshColoring<3,0>::color(mesh);

    out3D << "CELL_DATA " << mesh.getCells().size() << endl;
    out3D << "SCALARS cell_wrt_vertex_colour double 1\nLOOKUP_TABLE default" << endl;
@@ -650,7 +650,7 @@ void testMeshRefine() {
    out3D.open("mesh_refine_1.vtk");
    writer1.writeHeader(out3D, "test data");
    writer1.writeToStream(out3D, mesh, types1);
    auto colours1 = MeshColouring<3,0>::colour(mesh);
    auto colours1 = MeshColoring<3,0>::color(mesh);

    MeshDataContainer<colourData, 3> cd(mesh);
    auto normals = mesh.computeFaceNormals();
@@ -699,7 +699,7 @@ void testMeshRefine() {
    writer1.writeHeader(out3D, "test data");
    writer1.writeToStream(out3D, mesh, types2);

    auto colours2 = MeshColouring<3,0>::colour(mesh);
    auto colours2 = MeshColoring<3,0>::color(mesh);

    out3D << "CELL_DATA " << writer1.cellVert.getDataByPos<0>().size() << endl;
    out3D << "SCALARS cell_wrt_vertex_colour double 1\nLOOKUP_TABLE default" << endl;
@@ -727,7 +727,7 @@ void testMeshRefine() {
    out3D.open("mesh_refine_3.vtk");
    writer1.writeHeader(out3D, "test data");
    writer1.writeToStream(out3D, mesh, types3);
    auto colours3 = MeshColouring<3,0>::colour(mesh);
    auto colours3 = MeshColoring<3,0>::color(mesh);

    out3D << "CELL_DATA " << writer1.cellVert.getDataByPos<0>().size() << endl;
    out3D << "SCALARS cell_wrt_vertex_colour double 1\nLOOKUP_TABLE default" << endl;
+12 −4
Original line number Diff line number Diff line
@@ -18,13 +18,18 @@ struct DataContainer : public std::vector<DataType> {

/**
 * @brief The MeshDataContainer struct<HR>
 * A struct designed to manage data boud to mesh.
 * A struct designed to manage data bound to a mesh.
 * Creates a serie of vectors sized acording to dimension.
 */
template <typename DataType, unsigned int ...Dimensions>
struct MeshDataContainer{
private:

    /**
     * @brief The DimensionPos struct
     * realizes the method indexof in the parameter pack @a Dimensions.
     * If the searched value is nor present, the index @a pos ran out of bounds.
     */
    template<unsigned int dim, unsigned int pos, unsigned int _dim>
    struct DimensionPos : DimensionPos<dim, pos + 1,std::get<pos + 1>(std::array<unsigned int, sizeof... (Dimensions)>{Dimensions...})>{};

@@ -506,11 +511,14 @@ public:




/**
 * @brief The MeshDataContainer struct
 * @brief The MeshDataContainer<std::tuple<DataTypes>, Dimensions> struct<HR>
 * This specialization of MeshDataContainer allows to declare
 * a data type for each dimension separately. The data types are
 * given by a tuple.
 *
 * A struct designed to manage data boud to mesh.
 * Creates a serie of vectors sized acording to dimension.
 * @example MeshDataContainer<std::tuple<int, double>, 3,2> data;
 */
template <typename ...DataTypes, unsigned int ...Dimensions>
struct MeshDataContainer<std::tuple<DataTypes...>, Dimensions...>{
+7 −7
Original line number Diff line number Diff line
@@ -4,10 +4,10 @@
#include "MeshConnections.h"

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

    template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
    static MeshDataContainer<unsigned int, FromDim> colour(
    static MeshDataContainer<unsigned int, FromDim> color(
            MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh
            ) {
        MeshDataContainer<unsigned int, FromDim> result(mesh);
@@ -62,9 +62,9 @@ struct MeshColouring {


template<unsigned int FromDim, unsigned int ToDim>
struct MeshColouring <FromDim, ToDim, false> {
struct MeshColoring <FromDim, ToDim, false> {
    template<unsigned int MeshDimension, typename IndexType, typename Real, unsigned int ...Reserve>
    static MeshDataContainer<unsigned int, FromDim> colour(
    static MeshDataContainer<unsigned int, FromDim> color(
            MeshElements<MeshDimension, IndexType, Real, Reserve...>& mesh
            ) {
        // resulting container of colours
@@ -117,13 +117,13 @@ struct MeshColouring <FromDim, ToDim, false> {


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

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

+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
#include "EdgesOrientation.h"
#include "MeshConnections.h"
#include "MeshNeighborhood.h"
#include "MeshColouring.h"
#include "MeshColoring.h"