Loading Documentation/Examples/Debug/DebugExample.cpp 0 → 100644 +29 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <vector> #include <map> #include <string> using namespace std; struct InnerData { std::vector<char> s = {'h','e','l','l','o'}; }; MAKE_ATTRIBUTE_TRAIT(InnerData, s); struct Data { int data = 42; InnerData d; }; MAKE_ATTRIBUTE_TRAIT(Data, data, d); int main(int argc, char* argv[]) { std::vector<std::string> list = {"This is", "absolutely awesome", "debugger!"}; std::map<std::string, std::vector<int>> map = {{"odd", {1,3,5}}, {"even", {2,4,6}}}; DBGVAR(list, map, Data()); DBGCHECK; DBGMSG("Almost at the end of the program"); DBGCHECK; DBGTRY(std::vector<int>({1,2,3}).at(4)) } Documentation/Examples/UnstructuredMesh/MeshDataContainer/MeshDataContainerExample.cpp 0 → 100644 +24 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); // The flags container has internally 3 separate arrays (std::vector). // Each array is mapped to elements of different dimension (3, 2 and 1). // The data can be allocated to the mesh directly in the contructor, // also it is possible to initialize the allocated containers at once. MeshDataContainer<size_t, 3, 2, 1> flags(mesh, 1); MeshDataContainer<double, 3> cellsMeasures; // Memory allocation accoring to the mesh cellsMeasures.allocateData(mesh, 0); // Maps type int to the 3rd dimension and char to the 1st dimension MeshDataContainer<std::tuple<int, char>, 3,1> example(mesh, 0, 42); DBGVAR(example.getDataByPos<0>(), example.getDataByPos<1>()); return 0; } Documentation/Examples/UnstructuredMesh/MeshDataIO.cpp 0 → 100644 +51 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> #include <GTMesh/UnstructuredMesh/MeshDataContainer/MeshDataIO/VTKMeshDataReader.h> #include <GTMesh/UnstructuredMesh/MeshDataContainer/MeshDataIO/VTKMeshDataWriter.h> #include <GTMesh/Traits/Traits.h> #include <fstream> struct cellData{ double invVol; size_t index; }; MAKE_ATTRIBUTE_TRAIT(cellData, invVol, index); int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); MeshDataContainer<cellData, 3> meshData(mesh); mesh.initializeCenters(); auto measures = mesh.computeElementMeasures(); for (const auto& cell : mesh.getCells()){ meshData[cell].invVol = 1.0 / measures[cell]; meshData[cell].index = cell.getIndex(); } std::ofstream oFile("meshFile-out.vtk"); VTKMeshWriter<3, size_t, double> meshWriter; meshWriter.writeHeader(oFile, "mesh with data"); meshWriter.writeToStream(oFile, mesh, meshReaderFPMA->getCellTypes()); // append the data VTKMeshDataWriter<3>::writeToStream(oFile, meshData, meshWriter); // load the data back from meshFile-out UnstructuredMesh<3, size_t, double, 3> meshNew; auto meshReaderVTK = meshNew.load("meshFile-out.vtk"); MeshDataContainer<cellData, 3> meshDataNew(meshNew); std::ifstream iFile("meshFile-out.vtk", std::ios::binary); VTKMeshDataReader<3, size_t>::readFromStream(iFile, meshDataNew); // Now the meshDataNew container contains the values stored in the meshFile-out.vtk DBGVAR(meshDataNew.getDataByDim<3>()); return 0; } Documentation/Examples/UnstructuredMesh/MeshFPMALoadExample.cpp 0 → 100644 +12 −0 Original line number Original line Diff line number Diff line #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); auto writer = mesh.write("meshFile1.vtk", *meshReaderFPMA, "My first exported mesh using GTMesh"); return 0; } Documentation/Examples/UnstructuredMesh/MeshFunctionsExample.cpp 0 → 100644 +31 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // Load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); mesh.apply<3, 0>( [&](size_t cellIndex, size_t vertIndex){ DBGVAR(mesh.getVertices()[vertIndex]); } ); // Determinte the vertices connected to cells auto connections3_0 = mesh.connections<3, 0>(); // MeshDataContainer<std::vector<size_t>, 3> // Vertices connected to the fisrst cell DBGVAR(connections3_0.getDataByPos<0>()[0]); // Determine a proper coloring of vertices with respect to connection by faces auto coloring0_2 = mesh.coloring<0, 2>(); // Calculation of the mesh properties mesh.initializeCenters(); auto measures = mesh.computeElementMeasures(); auto normals = mesh.computeFaceNormals(); return 0; } Loading
Documentation/Examples/Debug/DebugExample.cpp 0 → 100644 +29 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <vector> #include <map> #include <string> using namespace std; struct InnerData { std::vector<char> s = {'h','e','l','l','o'}; }; MAKE_ATTRIBUTE_TRAIT(InnerData, s); struct Data { int data = 42; InnerData d; }; MAKE_ATTRIBUTE_TRAIT(Data, data, d); int main(int argc, char* argv[]) { std::vector<std::string> list = {"This is", "absolutely awesome", "debugger!"}; std::map<std::string, std::vector<int>> map = {{"odd", {1,3,5}}, {"even", {2,4,6}}}; DBGVAR(list, map, Data()); DBGCHECK; DBGMSG("Almost at the end of the program"); DBGCHECK; DBGTRY(std::vector<int>({1,2,3}).at(4)) }
Documentation/Examples/UnstructuredMesh/MeshDataContainer/MeshDataContainerExample.cpp 0 → 100644 +24 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); // The flags container has internally 3 separate arrays (std::vector). // Each array is mapped to elements of different dimension (3, 2 and 1). // The data can be allocated to the mesh directly in the contructor, // also it is possible to initialize the allocated containers at once. MeshDataContainer<size_t, 3, 2, 1> flags(mesh, 1); MeshDataContainer<double, 3> cellsMeasures; // Memory allocation accoring to the mesh cellsMeasures.allocateData(mesh, 0); // Maps type int to the 3rd dimension and char to the 1st dimension MeshDataContainer<std::tuple<int, char>, 3,1> example(mesh, 0, 42); DBGVAR(example.getDataByPos<0>(), example.getDataByPos<1>()); return 0; }
Documentation/Examples/UnstructuredMesh/MeshDataIO.cpp 0 → 100644 +51 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> #include <GTMesh/UnstructuredMesh/MeshDataContainer/MeshDataIO/VTKMeshDataReader.h> #include <GTMesh/UnstructuredMesh/MeshDataContainer/MeshDataIO/VTKMeshDataWriter.h> #include <GTMesh/Traits/Traits.h> #include <fstream> struct cellData{ double invVol; size_t index; }; MAKE_ATTRIBUTE_TRAIT(cellData, invVol, index); int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); MeshDataContainer<cellData, 3> meshData(mesh); mesh.initializeCenters(); auto measures = mesh.computeElementMeasures(); for (const auto& cell : mesh.getCells()){ meshData[cell].invVol = 1.0 / measures[cell]; meshData[cell].index = cell.getIndex(); } std::ofstream oFile("meshFile-out.vtk"); VTKMeshWriter<3, size_t, double> meshWriter; meshWriter.writeHeader(oFile, "mesh with data"); meshWriter.writeToStream(oFile, mesh, meshReaderFPMA->getCellTypes()); // append the data VTKMeshDataWriter<3>::writeToStream(oFile, meshData, meshWriter); // load the data back from meshFile-out UnstructuredMesh<3, size_t, double, 3> meshNew; auto meshReaderVTK = meshNew.load("meshFile-out.vtk"); MeshDataContainer<cellData, 3> meshDataNew(meshNew); std::ifstream iFile("meshFile-out.vtk", std::ios::binary); VTKMeshDataReader<3, size_t>::readFromStream(iFile, meshDataNew); // Now the meshDataNew container contains the values stored in the meshFile-out.vtk DBGVAR(meshDataNew.getDataByDim<3>()); return 0; }
Documentation/Examples/UnstructuredMesh/MeshFPMALoadExample.cpp 0 → 100644 +12 −0 Original line number Original line Diff line number Diff line #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); auto writer = mesh.write("meshFile1.vtk", *meshReaderFPMA, "My first exported mesh using GTMesh"); return 0; }
Documentation/Examples/UnstructuredMesh/MeshFunctionsExample.cpp 0 → 100644 +31 −0 Original line number Original line Diff line number Diff line #include <GTMesh/Debug/Debug.h> #include <GTMesh/UnstructuredMesh/UnstructuredMesh.h> int main () { UnstructuredMesh<3, size_t, double, 6> mesh; // Load mesh from fpma file auto meshReaderFPMA = mesh.load("meshFile.fpma"); mesh.apply<3, 0>( [&](size_t cellIndex, size_t vertIndex){ DBGVAR(mesh.getVertices()[vertIndex]); } ); // Determinte the vertices connected to cells auto connections3_0 = mesh.connections<3, 0>(); // MeshDataContainer<std::vector<size_t>, 3> // Vertices connected to the fisrst cell DBGVAR(connections3_0.getDataByPos<0>()[0]); // Determine a proper coloring of vertices with respect to connection by faces auto coloring0_2 = mesh.coloring<0, 2>(); // Calculation of the mesh properties mesh.initializeCenters(); auto measures = mesh.computeElementMeasures(); auto normals = mesh.computeFaceNormals(); return 0; }