Loading TemplateTest/main.cpp +38 −4 Original line number Diff line number Diff line Loading @@ -83,9 +83,9 @@ void testDebug() { auto v = {1,2,3}; DBGVAR(s, v); HTMLDBGVAR(r, i, c, list, vec, b, m); DBGVAR_HTML(r, i, c, list, vec, b, m); HTMLDBGVAR(r+1, i+1, char(c+1), list, vec[0], b, m["prvni"]); DBGVAR_HTML(r+1, i+1, char(c+1), list, vec[0], b, m["prvni"]); } Loading Loading @@ -547,13 +547,47 @@ void testFunction() { applyFunc1([&b1](int i)->double{return b1.data + 42.15 + i;}, 2); } template <unsigned int dim, unsigned int Dim, CalculationMethod Method = DEFAULT> struct calcCent{ static void run() {DBGMSG("running default", dim);calcCent<dim + 1, Dim, Method>::run();} }; template <unsigned int Dim, CalculationMethod Method> struct calcCent<Dim, Dim, Method>{ static void run() {DBGMSG("running default", Dim);} }; template <unsigned int Dim, CalculationMethod Method> struct calcCent<0, Dim, Method>{ static void run() {DBGMSG("running default", 0);calcCent<1, Dim, Method>::run();} }; template <unsigned int Dim, CalculationMethod Method> struct calcCent<1, Dim, Method>{ static void run() {DBGMSG("running default", 1);calcCent<2, Dim, Method>::run();} }; template <> struct calcCent<2, 3, MESH_TESSELLATED>{ static void run() {DBGMSG("running MESH_TESSELLATED");calcCent<3, 3, MESH_TESSELLATED>::run();} }; void testCalcCent() { calcCent<0,3>::run(); calcCent<0,3, MESH_TESSELLATED>::run(); } int main() { testDebug(); //testDebug(); //testOperator(); testMemberRef(); //testMemberRef(); //testConstrucorOrder(); //testFunction(); testCalcCent(); return 0; } Loading Unstructured_mesh/Unstructured_mesh.pro +11 −0 Original line number Diff line number Diff line Loading @@ -25,7 +25,18 @@ HEADERS += \ ../src/UnstructuredMesh/MeshElements/CellConnection.h \ ../src/UnstructuredMesh/MeshElements/ComputationalySignificantElement.h \ ../src/UnstructuredMesh/MeshElements/MeshElement.h \ ../src/UnstructuredMesh/MeshFunctions/ComputeCenter.h \ ../src/UnstructuredMesh/MeshFunctions/ComputeMeasures.h \ ../src/UnstructuredMesh/MeshFunctions/ComputeNormals.h \ ../src/UnstructuredMesh/MeshFunctions/EdgeOrientation.h \ ../src/UnstructuredMesh/MeshFunctions/GrammSchmidt.h \ ../src/UnstructuredMesh/MeshFunctions/MeshApply.h \ ../src/UnstructuredMesh/MeshFunctions/MeshColouring.h \ ../src/UnstructuredMesh/MeshFunctions/MeshConnections.h \ ../src/UnstructuredMesh/MeshFunctions/MeshFunctions.h \ ../src/UnstructuredMesh/MeshFunctions/MeshFunctionsDefine.h \ ../src/UnstructuredMesh/MeshFunctions/CellsDistance.h \ ../src/UnstructuredMesh/MeshFunctions/MeshNeighborhood.h \ ../src/UnstructuredMesh/MeshIO/MeshNativeType.h \ ../src/UnstructuredMesh/MeshIO/MeshReader/FPMAMeshReader.h \ ../src/UnstructuredMesh/MeshIO/MeshReader/MeshReader.h \ Loading Unstructured_mesh/main.cpp +26 −8 Original line number Diff line number Diff line Loading @@ -349,7 +349,7 @@ void testMesh2D() { auto centers = ComputeCenters(mesh); auto centers = ComputeCenters<DEFAULT>(mesh); auto& faceCent = centers.getDataByDim<1>(); for(auto& center : faceCent) { Loading @@ -360,7 +360,6 @@ void testMesh2D() { DBGVAR(centers.getDataByDim<2>().at(cell.getIndex())); } DBGMSG("computing measures"); auto measures = mesh.computeElementMeasures(); Loading Loading @@ -472,21 +471,40 @@ void testMesh3D() { //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); auto centers = ComputeCenters(mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); for(auto& face : mesh3.getFaces()) { face.setCenter(centers.template getDataByDim<2>().at(face.getIndex())); DBGVAR(face.getCenter()); } DBGMSG("cellCenter"); DBGMSG("cellCenter - default method"); for(auto& cell : mesh3.getCells()) { cell.setCenter(centers.template getDataByDim<3>().at(cell.getIndex())); DBGVAR(cell.getCenter()); } DBGMSG("centers - tessellated faces"); auto centers1 = ComputeCenters<TESSELLATED>(mesh3); for(auto& face : mesh3.getFaces()) { face.setCenter(centers1.template getDataByDim<2>().at(face.getIndex())); DBGVAR(face.getCenter()); } DBGMSG("cellCenter"); for(auto& cell : mesh3.getCells()) { cell.setCenter(centers1.template getDataByDim<3>().at(cell.getIndex())); DBGVAR(cell.getCenter()); } DBGMSG("measure computation"); auto measures = ComputeMeasures(mesh3); DBGMSG("tessellated cell volume"); auto measures1 = ComputeMeasures<TESSELLATED>(mesh3); DBGVAR(measures1.getDataByDim<3>()); auto measures = ComputeMeasures<DEFAULT>(mesh3); for(double edgeM : measures.getDataByDim<1>()) { DBGVAR(edgeM); } Loading Loading @@ -725,7 +743,7 @@ void test3DMeshDeformedPrisms() { twoDeformedPrisms(mesh3); //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); auto centers = ComputeCenters(mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); for(auto& face : mesh3.getFaces()) { face.setCenter(centers[face]); Loading @@ -739,7 +757,7 @@ void test3DMeshDeformedPrisms() { DBGMSG("measure computation"); auto measures = ComputeMeasures(mesh3); auto measures = ComputeMeasures<DEFAULT>(mesh3); for(double edgeM : measures.getDataByDim<1>()) { DBGVAR(edgeM); } Loading Loading @@ -842,7 +860,7 @@ DBGVAR(mesh.getVertices().size(),mesh.getEdges().size(), mesh.getFaces().size(), } mesh.initializeCenters(); DBGVAR(mesh.computeElementMeasures().getDataByDim<3>(),ComputeCenters(mesh).getDataByDim<2>(),mesh.computeFaceNormals().getDataByPos<0>()); DBGVAR(mesh.computeElementMeasures().getDataByDim<3>(),ComputeCenters<DEFAULT>(mesh).getDataByDim<2>(),mesh.computeFaceNormals().getDataByPos<0>()); Loading src/UnstructuredMesh/MeshElements/MeshElement.h +6 −1 Original line number Diff line number Diff line Loading @@ -276,13 +276,18 @@ private: }; template<unsigned int dim> struct _Reserve<dim, typename std::enable_if<dim == Dimension || dim == 1 || dim == 0 || (Dimension - dim - 1 > sizeof...(Reserve))>::type>{ struct _Reserve<dim, typename std::enable_if<dim == Dimension || dim == 1 || dim == 0 || (Dimension - dim > sizeof...(Reserve))>::type>{ static unsigned int constexpr value = 0; }; public: template<unsigned int dim> static unsigned int constexpr reserve() { return _Reserve<dim>::value; } using Vertex = MeshElement<Dimension, 0, IndexType, Real, 0>; using Edge = MeshElement<Dimension, 1, IndexType, Real, 0>; using Face = MeshElement<Dimension, Dimension - 1, IndexType, Real, _Reserve<Dimension - 1>::value>; Loading src/UnstructuredMesh/MeshFunctions/CellsDistance.h 0 → 100644 +64 −0 Original line number Diff line number Diff line #ifndef CELLSDISTANCE_H #define CELLSDISTANCE_H #include "../MeshElements/MeshElement.h" #include "../MeshDataContainer/MeshDataContainer.h" #include "../../NumericStaticArray/Vector.h" #include "../../Debug/Debug.h" #include "MeshApply.h" #include <valarray> #include <set> #include <map> template <unsigned int Dimension,typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer<Real, Dimension-1> ComputeCellsDistance(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ MeshDataContainer<Real, Dimension-1> distances(mesh); if(mesh.getBoundaryCells().empty()){ for(auto& face : mesh.getFaces()) { if (face.getCellLeftIndex() != INVALID_INDEX(IndexType) && face.getCellRightIndex() != INVALID_INDEX(IndexType)){ distances.at(face) = (mesh.getCells().at(face.getCellLeftIndex()).getCenter() - mesh.getCells().at(face.getCellRightIndex()).getCenter()).normEukleid(); } else if(face.getCellLeftIndex() != INVALID_INDEX(IndexType) && face.getCellRightIndex() == INVALID_INDEX(IndexType)){ distances.at(face) = (mesh.getCells().at(face.getCellLeftIndex()).getCenter() - face.getCenter()).normEukleid(); } else if(face.getCellLeftIndex() == INVALID_INDEX(IndexType) && face.getCellRightIndex() != INVALID_INDEX(IndexType)){ distances.at(face) = (mesh.getCells().at(face.getCellRightIndex()).getCenter() - face.getCenter()).normEukleid(); } } } else { for(auto& face : mesh.getFaces()) { auto& cellLeft = (face.getCellLeftIndex() & BOUNDARY_INDEX(IndexType)) == BOUNDARY_INDEX(IndexType)? mesh.getBoundaryCells().at(face.getCellLeftIndex()&EXTRACTING_INDEX(IndexType)): mesh.getCells().at(face.getCellLeftIndex()); auto& cellRight = (face.getCellRightIndex() & BOUNDARY_INDEX(IndexType)) == BOUNDARY_INDEX(IndexType)? mesh.getBoundaryCells().at(face.getCellRightIndex()&EXTRACTING_INDEX(IndexType)): mesh.getCells().at(face.getCellRightIndex()); distances.at(face) = (cellLeft.getCenter() - cellRight.getCenter()).normEukleid(); } } return distances; } #endif // CELLSDISTANCE_H Loading
TemplateTest/main.cpp +38 −4 Original line number Diff line number Diff line Loading @@ -83,9 +83,9 @@ void testDebug() { auto v = {1,2,3}; DBGVAR(s, v); HTMLDBGVAR(r, i, c, list, vec, b, m); DBGVAR_HTML(r, i, c, list, vec, b, m); HTMLDBGVAR(r+1, i+1, char(c+1), list, vec[0], b, m["prvni"]); DBGVAR_HTML(r+1, i+1, char(c+1), list, vec[0], b, m["prvni"]); } Loading Loading @@ -547,13 +547,47 @@ void testFunction() { applyFunc1([&b1](int i)->double{return b1.data + 42.15 + i;}, 2); } template <unsigned int dim, unsigned int Dim, CalculationMethod Method = DEFAULT> struct calcCent{ static void run() {DBGMSG("running default", dim);calcCent<dim + 1, Dim, Method>::run();} }; template <unsigned int Dim, CalculationMethod Method> struct calcCent<Dim, Dim, Method>{ static void run() {DBGMSG("running default", Dim);} }; template <unsigned int Dim, CalculationMethod Method> struct calcCent<0, Dim, Method>{ static void run() {DBGMSG("running default", 0);calcCent<1, Dim, Method>::run();} }; template <unsigned int Dim, CalculationMethod Method> struct calcCent<1, Dim, Method>{ static void run() {DBGMSG("running default", 1);calcCent<2, Dim, Method>::run();} }; template <> struct calcCent<2, 3, MESH_TESSELLATED>{ static void run() {DBGMSG("running MESH_TESSELLATED");calcCent<3, 3, MESH_TESSELLATED>::run();} }; void testCalcCent() { calcCent<0,3>::run(); calcCent<0,3, MESH_TESSELLATED>::run(); } int main() { testDebug(); //testDebug(); //testOperator(); testMemberRef(); //testMemberRef(); //testConstrucorOrder(); //testFunction(); testCalcCent(); return 0; } Loading
Unstructured_mesh/Unstructured_mesh.pro +11 −0 Original line number Diff line number Diff line Loading @@ -25,7 +25,18 @@ HEADERS += \ ../src/UnstructuredMesh/MeshElements/CellConnection.h \ ../src/UnstructuredMesh/MeshElements/ComputationalySignificantElement.h \ ../src/UnstructuredMesh/MeshElements/MeshElement.h \ ../src/UnstructuredMesh/MeshFunctions/ComputeCenter.h \ ../src/UnstructuredMesh/MeshFunctions/ComputeMeasures.h \ ../src/UnstructuredMesh/MeshFunctions/ComputeNormals.h \ ../src/UnstructuredMesh/MeshFunctions/EdgeOrientation.h \ ../src/UnstructuredMesh/MeshFunctions/GrammSchmidt.h \ ../src/UnstructuredMesh/MeshFunctions/MeshApply.h \ ../src/UnstructuredMesh/MeshFunctions/MeshColouring.h \ ../src/UnstructuredMesh/MeshFunctions/MeshConnections.h \ ../src/UnstructuredMesh/MeshFunctions/MeshFunctions.h \ ../src/UnstructuredMesh/MeshFunctions/MeshFunctionsDefine.h \ ../src/UnstructuredMesh/MeshFunctions/CellsDistance.h \ ../src/UnstructuredMesh/MeshFunctions/MeshNeighborhood.h \ ../src/UnstructuredMesh/MeshIO/MeshNativeType.h \ ../src/UnstructuredMesh/MeshIO/MeshReader/FPMAMeshReader.h \ ../src/UnstructuredMesh/MeshIO/MeshReader/MeshReader.h \ Loading
Unstructured_mesh/main.cpp +26 −8 Original line number Diff line number Diff line Loading @@ -349,7 +349,7 @@ void testMesh2D() { auto centers = ComputeCenters(mesh); auto centers = ComputeCenters<DEFAULT>(mesh); auto& faceCent = centers.getDataByDim<1>(); for(auto& center : faceCent) { Loading @@ -360,7 +360,6 @@ void testMesh2D() { DBGVAR(centers.getDataByDim<2>().at(cell.getIndex())); } DBGMSG("computing measures"); auto measures = mesh.computeElementMeasures(); Loading Loading @@ -472,21 +471,40 @@ void testMesh3D() { //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); auto centers = ComputeCenters(mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); for(auto& face : mesh3.getFaces()) { face.setCenter(centers.template getDataByDim<2>().at(face.getIndex())); DBGVAR(face.getCenter()); } DBGMSG("cellCenter"); DBGMSG("cellCenter - default method"); for(auto& cell : mesh3.getCells()) { cell.setCenter(centers.template getDataByDim<3>().at(cell.getIndex())); DBGVAR(cell.getCenter()); } DBGMSG("centers - tessellated faces"); auto centers1 = ComputeCenters<TESSELLATED>(mesh3); for(auto& face : mesh3.getFaces()) { face.setCenter(centers1.template getDataByDim<2>().at(face.getIndex())); DBGVAR(face.getCenter()); } DBGMSG("cellCenter"); for(auto& cell : mesh3.getCells()) { cell.setCenter(centers1.template getDataByDim<3>().at(cell.getIndex())); DBGVAR(cell.getCenter()); } DBGMSG("measure computation"); auto measures = ComputeMeasures(mesh3); DBGMSG("tessellated cell volume"); auto measures1 = ComputeMeasures<TESSELLATED>(mesh3); DBGVAR(measures1.getDataByDim<3>()); auto measures = ComputeMeasures<DEFAULT>(mesh3); for(double edgeM : measures.getDataByDim<1>()) { DBGVAR(edgeM); } Loading Loading @@ -725,7 +743,7 @@ void test3DMeshDeformedPrisms() { twoDeformedPrisms(mesh3); //_ComputeCenters<1,3, 3,2,1>::compute<size_t, double, 6>(centers, mesh3); auto centers = ComputeCenters(mesh3); auto centers = ComputeCenters<DEFAULT>(mesh3); for(auto& face : mesh3.getFaces()) { face.setCenter(centers[face]); Loading @@ -739,7 +757,7 @@ void test3DMeshDeformedPrisms() { DBGMSG("measure computation"); auto measures = ComputeMeasures(mesh3); auto measures = ComputeMeasures<DEFAULT>(mesh3); for(double edgeM : measures.getDataByDim<1>()) { DBGVAR(edgeM); } Loading Loading @@ -842,7 +860,7 @@ DBGVAR(mesh.getVertices().size(),mesh.getEdges().size(), mesh.getFaces().size(), } mesh.initializeCenters(); DBGVAR(mesh.computeElementMeasures().getDataByDim<3>(),ComputeCenters(mesh).getDataByDim<2>(),mesh.computeFaceNormals().getDataByPos<0>()); DBGVAR(mesh.computeElementMeasures().getDataByDim<3>(),ComputeCenters<DEFAULT>(mesh).getDataByDim<2>(),mesh.computeFaceNormals().getDataByPos<0>()); Loading
src/UnstructuredMesh/MeshElements/MeshElement.h +6 −1 Original line number Diff line number Diff line Loading @@ -276,13 +276,18 @@ private: }; template<unsigned int dim> struct _Reserve<dim, typename std::enable_if<dim == Dimension || dim == 1 || dim == 0 || (Dimension - dim - 1 > sizeof...(Reserve))>::type>{ struct _Reserve<dim, typename std::enable_if<dim == Dimension || dim == 1 || dim == 0 || (Dimension - dim > sizeof...(Reserve))>::type>{ static unsigned int constexpr value = 0; }; public: template<unsigned int dim> static unsigned int constexpr reserve() { return _Reserve<dim>::value; } using Vertex = MeshElement<Dimension, 0, IndexType, Real, 0>; using Edge = MeshElement<Dimension, 1, IndexType, Real, 0>; using Face = MeshElement<Dimension, Dimension - 1, IndexType, Real, _Reserve<Dimension - 1>::value>; Loading
src/UnstructuredMesh/MeshFunctions/CellsDistance.h 0 → 100644 +64 −0 Original line number Diff line number Diff line #ifndef CELLSDISTANCE_H #define CELLSDISTANCE_H #include "../MeshElements/MeshElement.h" #include "../MeshDataContainer/MeshDataContainer.h" #include "../../NumericStaticArray/Vector.h" #include "../../Debug/Debug.h" #include "MeshApply.h" #include <valarray> #include <set> #include <map> template <unsigned int Dimension,typename IndexType, typename Real, unsigned int ...Reserve> MeshDataContainer<Real, Dimension-1> ComputeCellsDistance(MeshElements<Dimension, IndexType, Real, Reserve...>& mesh){ MeshDataContainer<Real, Dimension-1> distances(mesh); if(mesh.getBoundaryCells().empty()){ for(auto& face : mesh.getFaces()) { if (face.getCellLeftIndex() != INVALID_INDEX(IndexType) && face.getCellRightIndex() != INVALID_INDEX(IndexType)){ distances.at(face) = (mesh.getCells().at(face.getCellLeftIndex()).getCenter() - mesh.getCells().at(face.getCellRightIndex()).getCenter()).normEukleid(); } else if(face.getCellLeftIndex() != INVALID_INDEX(IndexType) && face.getCellRightIndex() == INVALID_INDEX(IndexType)){ distances.at(face) = (mesh.getCells().at(face.getCellLeftIndex()).getCenter() - face.getCenter()).normEukleid(); } else if(face.getCellLeftIndex() == INVALID_INDEX(IndexType) && face.getCellRightIndex() != INVALID_INDEX(IndexType)){ distances.at(face) = (mesh.getCells().at(face.getCellRightIndex()).getCenter() - face.getCenter()).normEukleid(); } } } else { for(auto& face : mesh.getFaces()) { auto& cellLeft = (face.getCellLeftIndex() & BOUNDARY_INDEX(IndexType)) == BOUNDARY_INDEX(IndexType)? mesh.getBoundaryCells().at(face.getCellLeftIndex()&EXTRACTING_INDEX(IndexType)): mesh.getCells().at(face.getCellLeftIndex()); auto& cellRight = (face.getCellRightIndex() & BOUNDARY_INDEX(IndexType)) == BOUNDARY_INDEX(IndexType)? mesh.getBoundaryCells().at(face.getCellRightIndex()&EXTRACTING_INDEX(IndexType)): mesh.getCells().at(face.getCellRightIndex()); distances.at(face) = (cellLeft.getCenter() - cellRight.getCenter()).normEukleid(); } } return distances; } #endif // CELLSDISTANCE_H