From ff1552e0defb9ded840009c68de53b40863d5cf1 Mon Sep 17 00:00:00 2001 From: Matthew McCall Date: Tue, 27 Feb 2024 12:11:45 -0500 Subject: [PATCH 01/78] Declared Model2D class --- src/CMakeLists.txt | 3 ++- src/Omega_h_model2d.cpp | 7 +++++++ src/Omega_h_model2d.hpp | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/Omega_h_model2d.cpp create mode 100644 src/Omega_h_model2d.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 248ab7f55..50eb561ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,7 +108,8 @@ set(Omega_h_SOURCES Omega_h_xml_lite.cpp Omega_h_yaml.cpp Omega_h_mesh2d.cpp - ) + Omega_h_model2d.cpp +) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") else() diff --git a/src/Omega_h_model2d.cpp b/src/Omega_h_model2d.cpp new file mode 100644 index 000000000..e691e5a50 --- /dev/null +++ b/src/Omega_h_model2d.cpp @@ -0,0 +1,7 @@ +#include "Omega_h_model2d.hpp" + +namespace Omega_h { + + + +} \ No newline at end of file diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp new file mode 100644 index 000000000..ea314db7d --- /dev/null +++ b/src/Omega_h_model2d.hpp @@ -0,0 +1,26 @@ +#ifndef OMEGA_H_MODEL2D_HPP +#define OMEGA_H_MODEL2D_HPP + +#include +#include + +namespace Omega_h { + +class Model2D { +private: + float vtxTol, edgeTol; + Write vtxIds, edgeIds, loopIds, faceIds; + Write looptoLoopUse; + Graph edgeToEdgeUse; + Graph faceToLoopUse; + Graph loopUseToEdgeUse; + Write edgeUseToVtx; + Graph vtxToEdgeUse; + Write edgeUseToLoopUse; + Write loopUseToFace; + Write vtxCoords, edgeUseOrientation, loopUseOrientation; +}; + +} + +#endif //OMEGA_H_MODEL2D_HPP From b627dc7ce096a72537a5b787295b8b516ae738a6 Mon Sep 17 00:00:00 2001 From: Matthew McCall Date: Tue, 27 Feb 2024 13:23:48 -0500 Subject: [PATCH 02/78] Switch Mesh2D members to Omega_h defined types --- src/Omega_h_model2d.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index ea314db7d..11dc9a4b8 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -9,16 +9,16 @@ namespace Omega_h { class Model2D { private: float vtxTol, edgeTol; - Write vtxIds, edgeIds, loopIds, faceIds; - Write looptoLoopUse; + LOs vtxIds, edgeIds, loopIds, faceIds; + LOs looptoLoopUse; Graph edgeToEdgeUse; Graph faceToLoopUse; Graph loopUseToEdgeUse; - Write edgeUseToVtx; + LOs edgeUseToVtx; Graph vtxToEdgeUse; - Write edgeUseToLoopUse; - Write loopUseToFace; - Write vtxCoords, edgeUseOrientation, loopUseOrientation; + LOs edgeUseToLoopUse; + LOs loopUseToFace; + LOs vtxCoords, edgeUseOrientation, loopUseOrientation; }; } From 19612f7486ce12879a8c7f0e66f7c2c16386c1b0 Mon Sep 17 00:00:00 2001 From: Matthew McCall Date: Tue, 27 Feb 2024 13:31:06 -0500 Subject: [PATCH 03/78] Begun Model-Mesh associations --- src/Omega_h_mesh2d.cpp | 9 +++++++++ src/Omega_h_mesh2d.hpp | 7 +++++++ src/Omega_h_model2d.cpp | 4 +++- src/Omega_h_model2d.hpp | 4 ++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Omega_h_mesh2d.cpp b/src/Omega_h_mesh2d.cpp index c31a211a9..6a0901abe 100644 --- a/src/Omega_h_mesh2d.cpp +++ b/src/Omega_h_mesh2d.cpp @@ -12,4 +12,13 @@ void Mesh2D::set_dim(Int dim_in) { dim_ = dim_in; } +std::optional Mesh2D::getModel() const { + return model; +} + +Model2D Mesh2D::updateModel() { + model = Model2D(*this); + return *model; +} + } // Omega_h \ No newline at end of file diff --git a/src/Omega_h_mesh2d.hpp b/src/Omega_h_mesh2d.hpp index 160744ffa..d9d13f5eb 100644 --- a/src/Omega_h_mesh2d.hpp +++ b/src/Omega_h_mesh2d.hpp @@ -2,6 +2,7 @@ #define OMEGA_H_2DMESH_HPP #include +#include namespace Omega_h { @@ -16,6 +17,12 @@ class Mesh2D final : public Mesh { OMEGA_H_CHECK(0 <= dim_ && dim_ <= 2); return dim_; } + + [[nodiscard]] std::optional getModel() const; + Model2D updateModel(); + +private: + std::optional model; }; } // Omega_h diff --git a/src/Omega_h_model2d.cpp b/src/Omega_h_model2d.cpp index e691e5a50..bdca2c922 100644 --- a/src/Omega_h_model2d.cpp +++ b/src/Omega_h_model2d.cpp @@ -2,6 +2,8 @@ namespace Omega_h { +Model2D::Model2D(Mesh2D& mesh) { +} -} \ No newline at end of file +} // namespace Omega_h \ No newline at end of file diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 11dc9a4b8..15f987cbe 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -3,10 +3,14 @@ #include #include +#include namespace Omega_h { class Model2D { +public: + explicit Model2D(Mesh2D& mesh); + private: float vtxTol, edgeTol; LOs vtxIds, edgeIds, loopIds, faceIds; From d2ec145741fea6890e8afb0f73f4424c9efc58b0 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 12 Mar 2024 13:53:45 -0400 Subject: [PATCH 04/78] static loader funcs --- src/CMakeLists.txt | 1 + src/Omega_h_model2d.cpp | 4 ++-- src/Omega_h_model2d.hpp | 8 ++++++-- src/Omega_h_simModel2d.cpp | 11 +++++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/Omega_h_simModel2d.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50eb561ba..0830ee4b2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,6 +166,7 @@ if(Omega_h_USE_SimModSuite) set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH}) set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_meshsim.cpp) set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_matchMeshsim.cpp) + set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_simModel2d.cpp) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/Omega_h_simConfig.h.in" "${CMAKE_CURRENT_BINARY_DIR}/Omega_h_simConfig.h") diff --git a/src/Omega_h_model2d.cpp b/src/Omega_h_model2d.cpp index bdca2c922..c90e62099 100644 --- a/src/Omega_h_model2d.cpp +++ b/src/Omega_h_model2d.cpp @@ -2,8 +2,8 @@ namespace Omega_h { -Model2D::Model2D(Mesh2D& mesh) { +Model2D Model2D::MeshModel2D_load(Mesh2D& mesh) { } -} // namespace Omega_h \ No newline at end of file +} // namespace Omega_h diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 15f987cbe..b982dc8f0 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -9,9 +9,11 @@ namespace Omega_h { class Model2D { public: - explicit Model2D(Mesh2D& mesh); +#ifdef OMEGA_H_USE_SIMMODSUITE + static Model2D SimModel2D_load(std::string const& filename); +#endif + static Model2D MeshModel2D_load(Mesh& mesh); -private: float vtxTol, edgeTol; LOs vtxIds, edgeIds, loopIds, faceIds; LOs looptoLoopUse; @@ -23,6 +25,8 @@ class Model2D { LOs edgeUseToLoopUse; LOs loopUseToFace; LOs vtxCoords, edgeUseOrientation, loopUseOrientation; +private: + Model2D(); }; } diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp new file mode 100644 index 000000000..d627fa3c8 --- /dev/null +++ b/src/Omega_h_simModel2d.cpp @@ -0,0 +1,11 @@ +#include +#include +#include "Omega_h_model2d.hpp" + +namespace Omega_h { + +Model2D Model2D::SimModel2D_load(std::string const& filename) { +} + +}; +}//end namespace Omega_h From b3393c27c5bdcbe028abeb1c316a00f593622fdb Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 12 Mar 2024 21:33:41 -0400 Subject: [PATCH 05/78] compiles --- src/Omega_h_mesh2d.cpp | 4 ++-- src/Omega_h_mesh2d.hpp | 6 ++++++ src/Omega_h_model2d.cpp | 2 +- src/Omega_h_model2d.hpp | 8 +++++--- src/Omega_h_simModel2d.cpp | 1 + 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Omega_h_mesh2d.cpp b/src/Omega_h_mesh2d.cpp index 6a0901abe..8c48d3346 100644 --- a/src/Omega_h_mesh2d.cpp +++ b/src/Omega_h_mesh2d.cpp @@ -17,8 +17,8 @@ std::optional Mesh2D::getModel() const { } Model2D Mesh2D::updateModel() { - model = Model2D(*this); + model = Model2D::MeshModel2D_load(*this); return *model; } -} // Omega_h \ No newline at end of file +} // Omega_h diff --git a/src/Omega_h_mesh2d.hpp b/src/Omega_h_mesh2d.hpp index d9d13f5eb..562d29a25 100644 --- a/src/Omega_h_mesh2d.hpp +++ b/src/Omega_h_mesh2d.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace Omega_h { @@ -19,6 +20,11 @@ class Mesh2D final : public Mesh { } [[nodiscard]] std::optional getModel() const; + + /** + * update the model based on the current mesh + * and its classification + */ Model2D updateModel(); private: diff --git a/src/Omega_h_model2d.cpp b/src/Omega_h_model2d.cpp index c90e62099..4b92a8c2e 100644 --- a/src/Omega_h_model2d.cpp +++ b/src/Omega_h_model2d.cpp @@ -3,7 +3,7 @@ namespace Omega_h { Model2D Model2D::MeshModel2D_load(Mesh2D& mesh) { - + return Model2D(); } } // namespace Omega_h diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index b982dc8f0..282f1bd69 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -3,16 +3,18 @@ #include #include -#include namespace Omega_h { +//forward declare, avoid circular dependency +class Mesh2D; + class Model2D { public: #ifdef OMEGA_H_USE_SIMMODSUITE static Model2D SimModel2D_load(std::string const& filename); #endif - static Model2D MeshModel2D_load(Mesh& mesh); + static Model2D MeshModel2D_load(Mesh2D& mesh); float vtxTol, edgeTol; LOs vtxIds, edgeIds, loopIds, faceIds; @@ -26,7 +28,7 @@ class Model2D { LOs loopUseToFace; LOs vtxCoords, edgeUseOrientation, loopUseOrientation; private: - Model2D(); + Model2D() = default; }; } diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index d627fa3c8..7f51721ae 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -5,6 +5,7 @@ namespace Omega_h { Model2D Model2D::SimModel2D_load(std::string const& filename) { + return Model2D(); } }; From 000a9111eca8e2fe40be63978432ce038b0f4069 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 12 Mar 2024 21:41:00 -0400 Subject: [PATCH 06/78] compiles with sim enabled --- src/Omega_h_simModel2d.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 7f51721ae..a94b388ce 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -8,5 +8,4 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { return Model2D(); } -}; }//end namespace Omega_h From c0651a3aed30403cc96ca7ee83b54cb5a77a5be8 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 12:49:02 -0400 Subject: [PATCH 07/78] initialize simModSuite with library --- src/Omega_h_library.cpp | 16 ++++++++++++++++ src/Omega_h_meshsim.cpp | 15 --------------- src/Omega_h_simModel2d.cpp | 1 + src/mixed_writeMesh.cpp | 6 ------ 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Omega_h_library.cpp b/src/Omega_h_library.cpp index 4d49b8655..c8363eb60 100644 --- a/src/Omega_h_library.cpp +++ b/src/Omega_h_library.cpp @@ -12,6 +12,11 @@ #include #include +#if defined(OMEGA_H_USE_SIMMODSUITE) +#include "MeshSim.h" +#include "SimDiscrete.h" +#endif + #ifdef OMEGA_H_DBG Omega_h::Comm *DBG_COMM = 0; bool dbg_print_global = false; @@ -175,6 +180,12 @@ void Library::initialize(char const* head_desc, int* argc, char*** argv cudaFree(nullptr); #endif if (cmdline.parsed("--osh-pool")) enable_pooling(); +#if defined(OMEGA_H_USE_SIMMODSUITE) + MS_init(); + SimModel_start(); + Sim_readLicenseFile(NULL); + SimDiscrete_start(0); +#endif } Library::Library(Library const& other) @@ -220,6 +231,11 @@ Library::~Library() { OMEGA_H_CHECK(MPI_SUCCESS == MPI_Finalize()); we_called_mpi_init = false; } +#endif +#if defined(OMEGA_H_USE_SIMMODSUITE) + MS_exit(); + SimDiscrete_stop(0); + SimModel_stop(); #endif delete[] Omega_h::max_memory_stacktrace; } diff --git a/src/Omega_h_meshsim.cpp b/src/Omega_h_meshsim.cpp index 50df67a86..283694e93 100644 --- a/src/Omega_h_meshsim.cpp +++ b/src/Omega_h_meshsim.cpp @@ -636,9 +636,6 @@ void read_internal(pMesh m, Mesh* mesh, pMeshNex numbering, SimMeshInfo info) { MixedMesh readMixedImpl(filesystem::path const& mesh_fname, filesystem::path const& mdl_fname, CommPtr comm) { - SimModel_start(); - Sim_readLicenseFile(NULL); - SimDiscrete_start(0); pNativeModel nm = NULL; pProgress p = NULL; pGModel g = GM_load(mdl_fname.c_str(), nm, p); @@ -649,16 +646,11 @@ MixedMesh readMixedImpl(filesystem::path const& mesh_fname, meshsim::readMixed_internal(m, &mesh, simMeshInfo); M_release(m); GM_release(g); - SimDiscrete_stop(0); - SimModel_stop(); return mesh; } Mesh readImpl(filesystem::path const& mesh_fname, filesystem::path const& mdl_fname, filesystem::path const& numbering_fname, CommPtr comm) { - SimModel_start(); - Sim_readLicenseFile(NULL); - SimDiscrete_start(0); pNativeModel nm = NULL; pProgress p = NULL; pGModel g = GM_load(mdl_fname.c_str(), nm, p); @@ -673,15 +665,10 @@ Mesh readImpl(filesystem::path const& mesh_fname, filesystem::path const& mdl_fn if(hasNumbering) MeshNex_delete(numbering); M_release(m); GM_release(g); - SimDiscrete_stop(0); - SimModel_stop(); return mesh; } bool isMixed(filesystem::path const& mesh_fname, filesystem::path const& mdl_fname) { - SimModel_start(); - Sim_readLicenseFile(NULL); - SimDiscrete_start(0); pNativeModel nm = NULL; pProgress p = NULL; pGModel g = GM_load(mdl_fname.c_str(), nm, p); @@ -689,8 +676,6 @@ bool isMixed(filesystem::path const& mesh_fname, filesystem::path const& mdl_fna auto simMeshInfo = getSimMeshInfo(m); M_release(m); GM_release(g); - SimDiscrete_stop(0); - SimModel_stop(); bool isMixed = (!simMeshInfo.is_simplex && !simMeshInfo.is_hypercube); return isMixed; } diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index a94b388ce..58698926b 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -5,6 +5,7 @@ namespace Omega_h { Model2D Model2D::SimModel2D_load(std::string const& filename) { + return Model2D(); } diff --git a/src/mixed_writeMesh.cpp b/src/mixed_writeMesh.cpp index 511bac86a..1ed127ea1 100644 --- a/src/mixed_writeMesh.cpp +++ b/src/mixed_writeMesh.cpp @@ -45,10 +45,7 @@ void finalize_write(int numVerts, const double *coords, int numElems, pEntity *eReturn, const char *mesh_path, const char *model_path) { Sim_logOn("importData1.log"); - MS_init(); - Sim_readLicenseFile(0); pMesh meshtest; - SimDiscrete_start(0); Sim_setMessageHandler(messageHandler); pProgress progress = Progress_new(); Progress_setDefaultCallback(progress); @@ -81,9 +78,6 @@ void finalize_write(int numVerts, const double *coords, int numElems, M_release(meshtest); GM_release(modeltest); Progress_delete(progress); - SimDiscrete_stop(0); - Sim_unregisterAllKeys(); - MS_exit(); Sim_logOff(); } From 84bc5bb8eaf0e2ded945ba2dfb45db7ad8c64f08 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 13:52:07 -0400 Subject: [PATCH 08/78] add sim model2d load test --- meshes/longPlate.smd | 441 +++++++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 5 + src/Omega_h_simModel2d.cpp | 4 +- 3 files changed, 449 insertions(+), 1 deletion(-) create mode 100644 meshes/longPlate.smd diff --git a/meshes/longPlate.smd b/meshes/longPlate.smd new file mode 100644 index 000000000..d0b3cde7b --- /dev/null +++ b/meshes/longPlate.smd @@ -0,0 +1,441 @@ +smi 5 0 + smd 34 +simple 34 1 +* +-1 +-1.1102230246251559e-16 0 -0.050000000000000003 +2.0000000000000004 1 0.050000000000000003 +1 1007 9 0 +0 0 0 0 +-1.1102230246251559e-16 0 -0.050000000000000003 +2.0000000000000004 1 0.050000000000000003 +_sim_empty +-1 +0 0 0 0 +0 + +0 +1 6 12 8 +0 0 0 0 +0 0 0 0 +0 0 0 0 +2 +7 4 1 +11 4 1 +1 0 9 0 200 0 2 +7 11 +_sim_empty +-1 +-1.1102230246251559e-16 1 0.050000000000000003 +-1.1102230246251559e-16 1 0.050000000000000003 +0 +38 4 2 +45 4 2 +2 0 9 0 200 0 2 +38 45 +_sim_empty +-1 +2 1 0.050000000000000003 +2 1 0.050000000000000003 +0 +22 4 3 +29 4 3 +3 0 9 0 200 0 2 +22 29 +_sim_empty +-1 +2 0 0.050000000000000003 +2 0 0.050000000000000003 +0 +6 4 4 +13 4 4 +4 0 9 0 200 0 2 +6 13 +_sim_empty +-1 +0 0 0.050000000000000003 +0 0 0.050000000000000003 +0 +1 4 5 +10 4 5 +5 0 9 0 200 0 2 +1 10 +_sim_empty +-1 +-1.1102230246251559e-16 1 -0.050000000000000003 +-1.1102230246251559e-16 1 -0.050000000000000003 +0 +36 4 6 +48 4 6 +6 0 9 0 200 0 2 +36 48 +_sim_empty +-1 +2 1 -0.050000000000000003 +2 1 -0.050000000000000003 +0 +20 4 7 +32 4 7 +7 0 9 0 200 0 2 +20 32 +_sim_empty +-1 +2 0 -0.050000000000000003 +2 0 -0.050000000000000003 +0 +4 4 8 +16 4 8 +8 0 9 0 200 0 2 +4 16 +_sim_empty +-1 +0 0 -0.050000000000000003 +0 0 -0.050000000000000003 +0 +2 5 1 6 4 +7 5 1 13 16 +1 1 9 0 210 0 2 4 8 +2 7 +_sim_empty +-1 +1 0.050000000000000003 0 0 0 +1e-08 +1 0 +0 0.10000000000000001 +0 0 0.050000000000000003 +0 0 -0.94999999999999996 +10 5 2 22 20 +15 5 2 29 32 +2 1 9 0 210 0 2 3 7 +10 15 +_sim_empty +-1 +1 0.050000000000000003 2 0 0 +1e-08 +1 0 +0 0.10000000000000001 +2 0 0.050000000000000003 +2 0 -0.94999999999999996 +18 5 3 38 36 +23 5 3 45 48 +3 1 9 0 210 0 2 2 6 +18 23 +_sim_empty +-1 +1 0.050000000000000003 2 1 0 +1e-08 +1 0 +0 0.10000000000000001 +2 1 0.050000000000000003 +2 1 -0.94999999999999996 +4 5 4 7 1 +5 5 4 11 10 +4 1 9 0 210 0 2 1 5 +4 5 +_sim_empty +-1 +1 0.050000000000000003 -1.1102230246251559e-16 1 0 +1e-08 +1 0 +0 0.10000000000000001 +-1.1102230246251559e-16 1 0.050000000000000003 +-1.1102230246251559e-16 1 -0.94999999999999996 +27 5 5 38 7 +30 5 5 45 11 +5 1 9 0 210 0 2 2 1 +27 30 +_sim_empty +-1 +1 -1.0000000000000002 0.99999999999999989 1 0.050000000000000003 +1e-08 +1 0 +-2.0000000000000004 0 +-1.1102230246251559e-16 1 0.050000000000000003 +-1 1 0.050000000000000003 +19 5 6 22 38 +22 5 6 29 45 +6 1 9 0 210 0 2 3 2 +19 22 +_sim_empty +-1 +1 -0.5 2 0.5 0.050000000000000003 +1e-08 +1 0 +-1 0 +2 1 0.050000000000000003 +1.9999999999999996 2 0.050000000000000003 +11 5 7 6 22 +14 5 7 13 29 +7 1 9 0 210 0 2 4 3 +11 14 +_sim_empty +-1 +1 1 1 0 0.050000000000000003 +1e-08 +1 0 +0 2 +0 0 0.050000000000000003 +1 0 0.050000000000000003 +3 5 8 7 6 +6 5 8 11 13 +8 1 9 0 210 0 2 1 4 +3 6 +_sim_empty +-1 +1 0.5 -5.5511151231257796e-17 0.5 0.050000000000000003 +1e-08 +1 0 +0 1 +-1.1102230246251559e-16 1 0.050000000000000003 +0 0 0.050000000000000003 +25 5 9 36 1 +32 5 9 48 10 +9 1 9 0 210 0 2 6 5 +25 32 +_sim_empty +-1 +1 -1.0000000000000002 0.99999999999999989 1 -0.050000000000000003 +1e-08 +1 0 +-2.0000000000000004 0 +-1.1102230246251559e-16 1 -0.050000000000000003 +-1 1 -0.050000000000000003 +17 5 10 20 36 +24 5 10 32 48 +10 1 9 0 210 0 2 7 6 +17 24 +_sim_empty +-1 +1 -0.5 2 0.5 -0.050000000000000003 +1e-08 +1 0 +-1 0 +2 1 -0.050000000000000003 +1.9999999999999996 2 -0.050000000000000003 +9 5 11 4 20 +16 5 11 16 32 +11 1 9 0 210 0 2 8 7 +9 16 +_sim_empty +-1 +1 1 1 0 -0.050000000000000003 +1e-08 +1 0 +0 2 +0 0 -0.050000000000000003 +1 0 -0.050000000000000003 +1 5 12 1 4 +8 5 12 10 16 +12 1 9 0 210 0 2 5 8 +1 8 +_sim_empty +-1 +1 0.5 -5.5511151231257796e-17 0.5 -0.050000000000000003 +1e-08 +1 0 +0 1 +-1.1102230246251559e-16 1 -0.050000000000000003 +0 0 -0.050000000000000003 +1 6 1 1 0 2 +4 12 1 1 1 2 0 8 3 0 4 4 1 2 6 1 0 0 1 +4 4 5 0 8 6 1 1 7 1 12 8 0 1 2 9 0 203 0 +1 1 +0 + + 1 2 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +-1 0 +-1.1102230246251559e-16 1 0.050000000000000003 +-1.1102230246251559e-16 1 0 +0 0 1 +1 1 1 +3 6 2 1 0 4 +4 11 9 1 2 10 0 7 11 0 1 2 1 4 6 2 0 0 3 +4 1 7 0 7 14 1 2 15 1 11 16 0 2 2 9 0 203 0 +1 3 +0 + + 1 4 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +-1 0 +0 0 0.050000000000000003 +0 0 1 +1 0 0 +1 1 1 +5 6 3 1 0 6 +4 10 17 1 3 18 0 6 19 0 2 10 1 6 6 3 0 0 5 +4 2 15 0 6 22 1 3 23 1 10 24 0 3 2 9 0 203 0 +1 5 +0 + + 1 6 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +-1 0 +2 1 0.050000000000000003 +4.4408920985006262e-16 -1 0 +0 0 1 +1 1 1 +7 6 4 1 0 8 +4 9 25 1 4 4 0 5 27 0 3 18 1 8 6 4 0 0 7 +4 3 23 0 5 30 1 4 5 1 9 32 0 4 2 9 0 203 0 +1 7 +0 + + 1 8 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +-1 0 +-1.1102230246251559e-16 1 0.050000000000000003 +1 -1.1102230246251565e-16 0 +0 0 1 +1 1 1 +9 6 5 1 0 10 +4 8 3 1 7 11 1 6 19 1 5 27 1 10 6 5 0 0 9 +4 5 30 0 6 22 0 7 14 0 8 6 0 5 2 9 0 203 0 +1 9 +0 + + 1 10 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +1 0 +0 0 0.050000000000000003 +1 0 0 +0 1 0 +1 1 1 +11 6 6 1 0 12 +4 12 1 0 9 25 0 10 17 0 11 9 0 12 6 6 0 0 11 +4 11 16 1 10 24 1 9 32 1 12 8 1 6 2 9 0 203 0 +1 11 +0 + + 1 12 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +-1 0 +0 0 -0.050000000000000003 +1 0 0 +0 1 0 +1 1 1 +1 8 1 6 +1 0 2 0 3 0 4 0 5 0 6 0 1 3 9 0 205 0 1 +1 +0 +0 +_sim_empty +-1 +0 -1 +3 8 2 6 +1 1 4 1 3 1 2 1 5 1 6 1 2 3 8 0 303 0 1 +3 +0 +0 +_sim_empty +-1 +0 +0 -1 +0 -1 +0 -1 +0 -1 +0 -1 + auxmm 3 +0 +0 + nativeatts 1 +4 2 +0 +0 +4 +7 Sim_Red0.792156862745098 +9 Sim_Green0.81960784313725499 +8 Sim_Blue0.93333333333333302 +9 Sim_Alpha0 +6 2 +0 +0 +4 +7 Sim_Red0.792156862745098 +9 Sim_Green0.81960784313725499 +8 Sim_Blue0.93333333333333302 +9 Sim_Alpha0 +3 2 +0 +0 +4 +7 Sim_Red0.792156862745098 +9 Sim_Green0.81960784313725499 +8 Sim_Blue0.93333333333333302 +9 Sim_Alpha0 +2 2 +0 +0 +4 +7 Sim_Red0.792156862745098 +9 Sim_Green0.81960784313725499 +8 Sim_Blue0.93333333333333302 +9 Sim_Alpha0 +5 2 +0 +0 +4 +7 Sim_Red0.792156862745098 +9 Sim_Green0.81960784313725499 +8 Sim_Blue0.93333333333333302 +9 Sim_Alpha0 +1 2 +0 +0 +4 +7 Sim_Red0.792156862745098 +9 Sim_Green0.81960784313725499 +8 Sim_Blue0.93333333333333302 +9 Sim_Alpha0 +0 -1 + +3 +smd 8 +auxmm 5030 +nativeatts 5049 + +
+4 +67 file:///lore/cwsmith/geometries/pumi-meshes/faceExtrusion/plate.smd24 model.nonmanifold.simple6 # 1 0 0 +2 +10 unitsScale1 1 +5 units1 m +0 +
+5740 5792 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0830ee4b2..1e0ae165f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -429,6 +429,11 @@ if(BUILD_TESTING) ${CMAKE_SOURCE_DIR}/meshes) osh_add_exe(periodic_test) + + osh_add_exe(simModel2dLoad) + set(TEST_EXES ${TEST_EXES} simModel2dLoad) + test_func(simModel2dLoad 1 ./simModel2dLoad + ${CMAKE_SOURCE_DIR}/meshes/longPlate.smd) endif() osh_add_exe(load_2d) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 58698926b..f6fdb7963 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -5,7 +5,9 @@ namespace Omega_h { Model2D Model2D::SimModel2D_load(std::string const& filename) { - + pNativeModel nm = NULL; + pProgress p = NULL; + pGModel g = GM_load(filename.c_str(), nm, p); return Model2D(); } From 6bc481bdae65f802e786b20e06e9a300be096970 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 14:31:22 -0400 Subject: [PATCH 09/78] check if 2d --- meshes/longPlate.smd | 441 ------------------------------------- meshes/square.smd | 305 +++++++++++++++++++++++++ src/CMakeLists.txt | 6 +- src/Omega_h_simModel2d.cpp | 6 + 4 files changed, 315 insertions(+), 443 deletions(-) delete mode 100644 meshes/longPlate.smd create mode 100644 meshes/square.smd diff --git a/meshes/longPlate.smd b/meshes/longPlate.smd deleted file mode 100644 index d0b3cde7b..000000000 --- a/meshes/longPlate.smd +++ /dev/null @@ -1,441 +0,0 @@ -smi 5 0 - smd 34 -simple 34 1 -* --1 --1.1102230246251559e-16 0 -0.050000000000000003 -2.0000000000000004 1 0.050000000000000003 -1 1007 9 0 -0 0 0 0 --1.1102230246251559e-16 0 -0.050000000000000003 -2.0000000000000004 1 0.050000000000000003 -_sim_empty --1 -0 0 0 0 -0 - -0 -1 6 12 8 -0 0 0 0 -0 0 0 0 -0 0 0 0 -2 -7 4 1 -11 4 1 -1 0 9 0 200 0 2 -7 11 -_sim_empty --1 --1.1102230246251559e-16 1 0.050000000000000003 --1.1102230246251559e-16 1 0.050000000000000003 -0 -38 4 2 -45 4 2 -2 0 9 0 200 0 2 -38 45 -_sim_empty --1 -2 1 0.050000000000000003 -2 1 0.050000000000000003 -0 -22 4 3 -29 4 3 -3 0 9 0 200 0 2 -22 29 -_sim_empty --1 -2 0 0.050000000000000003 -2 0 0.050000000000000003 -0 -6 4 4 -13 4 4 -4 0 9 0 200 0 2 -6 13 -_sim_empty --1 -0 0 0.050000000000000003 -0 0 0.050000000000000003 -0 -1 4 5 -10 4 5 -5 0 9 0 200 0 2 -1 10 -_sim_empty --1 --1.1102230246251559e-16 1 -0.050000000000000003 --1.1102230246251559e-16 1 -0.050000000000000003 -0 -36 4 6 -48 4 6 -6 0 9 0 200 0 2 -36 48 -_sim_empty --1 -2 1 -0.050000000000000003 -2 1 -0.050000000000000003 -0 -20 4 7 -32 4 7 -7 0 9 0 200 0 2 -20 32 -_sim_empty --1 -2 0 -0.050000000000000003 -2 0 -0.050000000000000003 -0 -4 4 8 -16 4 8 -8 0 9 0 200 0 2 -4 16 -_sim_empty --1 -0 0 -0.050000000000000003 -0 0 -0.050000000000000003 -0 -2 5 1 6 4 -7 5 1 13 16 -1 1 9 0 210 0 2 4 8 -2 7 -_sim_empty --1 -1 0.050000000000000003 0 0 0 -1e-08 -1 0 -0 0.10000000000000001 -0 0 0.050000000000000003 -0 0 -0.94999999999999996 -10 5 2 22 20 -15 5 2 29 32 -2 1 9 0 210 0 2 3 7 -10 15 -_sim_empty --1 -1 0.050000000000000003 2 0 0 -1e-08 -1 0 -0 0.10000000000000001 -2 0 0.050000000000000003 -2 0 -0.94999999999999996 -18 5 3 38 36 -23 5 3 45 48 -3 1 9 0 210 0 2 2 6 -18 23 -_sim_empty --1 -1 0.050000000000000003 2 1 0 -1e-08 -1 0 -0 0.10000000000000001 -2 1 0.050000000000000003 -2 1 -0.94999999999999996 -4 5 4 7 1 -5 5 4 11 10 -4 1 9 0 210 0 2 1 5 -4 5 -_sim_empty --1 -1 0.050000000000000003 -1.1102230246251559e-16 1 0 -1e-08 -1 0 -0 0.10000000000000001 --1.1102230246251559e-16 1 0.050000000000000003 --1.1102230246251559e-16 1 -0.94999999999999996 -27 5 5 38 7 -30 5 5 45 11 -5 1 9 0 210 0 2 2 1 -27 30 -_sim_empty --1 -1 -1.0000000000000002 0.99999999999999989 1 0.050000000000000003 -1e-08 -1 0 --2.0000000000000004 0 --1.1102230246251559e-16 1 0.050000000000000003 --1 1 0.050000000000000003 -19 5 6 22 38 -22 5 6 29 45 -6 1 9 0 210 0 2 3 2 -19 22 -_sim_empty --1 -1 -0.5 2 0.5 0.050000000000000003 -1e-08 -1 0 --1 0 -2 1 0.050000000000000003 -1.9999999999999996 2 0.050000000000000003 -11 5 7 6 22 -14 5 7 13 29 -7 1 9 0 210 0 2 4 3 -11 14 -_sim_empty --1 -1 1 1 0 0.050000000000000003 -1e-08 -1 0 -0 2 -0 0 0.050000000000000003 -1 0 0.050000000000000003 -3 5 8 7 6 -6 5 8 11 13 -8 1 9 0 210 0 2 1 4 -3 6 -_sim_empty --1 -1 0.5 -5.5511151231257796e-17 0.5 0.050000000000000003 -1e-08 -1 0 -0 1 --1.1102230246251559e-16 1 0.050000000000000003 -0 0 0.050000000000000003 -25 5 9 36 1 -32 5 9 48 10 -9 1 9 0 210 0 2 6 5 -25 32 -_sim_empty --1 -1 -1.0000000000000002 0.99999999999999989 1 -0.050000000000000003 -1e-08 -1 0 --2.0000000000000004 0 --1.1102230246251559e-16 1 -0.050000000000000003 --1 1 -0.050000000000000003 -17 5 10 20 36 -24 5 10 32 48 -10 1 9 0 210 0 2 7 6 -17 24 -_sim_empty --1 -1 -0.5 2 0.5 -0.050000000000000003 -1e-08 -1 0 --1 0 -2 1 -0.050000000000000003 -1.9999999999999996 2 -0.050000000000000003 -9 5 11 4 20 -16 5 11 16 32 -11 1 9 0 210 0 2 8 7 -9 16 -_sim_empty --1 -1 1 1 0 -0.050000000000000003 -1e-08 -1 0 -0 2 -0 0 -0.050000000000000003 -1 0 -0.050000000000000003 -1 5 12 1 4 -8 5 12 10 16 -12 1 9 0 210 0 2 5 8 -1 8 -_sim_empty --1 -1 0.5 -5.5511151231257796e-17 0.5 -0.050000000000000003 -1e-08 -1 0 -0 1 --1.1102230246251559e-16 1 -0.050000000000000003 -0 0 -0.050000000000000003 -1 6 1 1 0 2 -4 12 1 1 1 2 0 8 3 0 4 4 1 2 6 1 0 0 1 -4 4 5 0 8 6 1 1 7 1 12 8 0 1 2 9 0 203 0 -1 1 -0 - - 1 2 -0 - -0 -_sim_empty --1 -0 0 0 0 0 0 -0 --1 0 --1.1102230246251559e-16 1 0.050000000000000003 --1.1102230246251559e-16 1 0 -0 0 1 -1 1 1 -3 6 2 1 0 4 -4 11 9 1 2 10 0 7 11 0 1 2 1 4 6 2 0 0 3 -4 1 7 0 7 14 1 2 15 1 11 16 0 2 2 9 0 203 0 -1 3 -0 - - 1 4 -0 - -0 -_sim_empty --1 -0 0 0 0 0 0 -0 --1 0 -0 0 0.050000000000000003 -0 0 1 -1 0 0 -1 1 1 -5 6 3 1 0 6 -4 10 17 1 3 18 0 6 19 0 2 10 1 6 6 3 0 0 5 -4 2 15 0 6 22 1 3 23 1 10 24 0 3 2 9 0 203 0 -1 5 -0 - - 1 6 -0 - -0 -_sim_empty --1 -0 0 0 0 0 0 -0 --1 0 -2 1 0.050000000000000003 -4.4408920985006262e-16 -1 0 -0 0 1 -1 1 1 -7 6 4 1 0 8 -4 9 25 1 4 4 0 5 27 0 3 18 1 8 6 4 0 0 7 -4 3 23 0 5 30 1 4 5 1 9 32 0 4 2 9 0 203 0 -1 7 -0 - - 1 8 -0 - -0 -_sim_empty --1 -0 0 0 0 0 0 -0 --1 0 --1.1102230246251559e-16 1 0.050000000000000003 -1 -1.1102230246251565e-16 0 -0 0 1 -1 1 1 -9 6 5 1 0 10 -4 8 3 1 7 11 1 6 19 1 5 27 1 10 6 5 0 0 9 -4 5 30 0 6 22 0 7 14 0 8 6 0 5 2 9 0 203 0 -1 9 -0 - - 1 10 -0 - -0 -_sim_empty --1 -0 0 0 0 0 0 -0 -1 0 -0 0 0.050000000000000003 -1 0 0 -0 1 0 -1 1 1 -11 6 6 1 0 12 -4 12 1 0 9 25 0 10 17 0 11 9 0 12 6 6 0 0 11 -4 11 16 1 10 24 1 9 32 1 12 8 1 6 2 9 0 203 0 -1 11 -0 - - 1 12 -0 - -0 -_sim_empty --1 -0 0 0 0 0 0 -0 --1 0 -0 0 -0.050000000000000003 -1 0 0 -0 1 0 -1 1 1 -1 8 1 6 -1 0 2 0 3 0 4 0 5 0 6 0 1 3 9 0 205 0 1 -1 -0 -0 -_sim_empty --1 -0 -1 -3 8 2 6 -1 1 4 1 3 1 2 1 5 1 6 1 2 3 8 0 303 0 1 -3 -0 -0 -_sim_empty --1 -0 -0 -1 -0 -1 -0 -1 -0 -1 -0 -1 - auxmm 3 -0 -0 - nativeatts 1 -4 2 -0 -0 -4 -7 Sim_Red0.792156862745098 -9 Sim_Green0.81960784313725499 -8 Sim_Blue0.93333333333333302 -9 Sim_Alpha0 -6 2 -0 -0 -4 -7 Sim_Red0.792156862745098 -9 Sim_Green0.81960784313725499 -8 Sim_Blue0.93333333333333302 -9 Sim_Alpha0 -3 2 -0 -0 -4 -7 Sim_Red0.792156862745098 -9 Sim_Green0.81960784313725499 -8 Sim_Blue0.93333333333333302 -9 Sim_Alpha0 -2 2 -0 -0 -4 -7 Sim_Red0.792156862745098 -9 Sim_Green0.81960784313725499 -8 Sim_Blue0.93333333333333302 -9 Sim_Alpha0 -5 2 -0 -0 -4 -7 Sim_Red0.792156862745098 -9 Sim_Green0.81960784313725499 -8 Sim_Blue0.93333333333333302 -9 Sim_Alpha0 -1 2 -0 -0 -4 -7 Sim_Red0.792156862745098 -9 Sim_Green0.81960784313725499 -8 Sim_Blue0.93333333333333302 -9 Sim_Alpha0 -0 -1 - -3 -smd 8 -auxmm 5030 -nativeatts 5049 - -
-4 -67 file:///lore/cwsmith/geometries/pumi-meshes/faceExtrusion/plate.smd24 model.nonmanifold.simple6 # 1 0 0 -2 -10 unitsScale1 1 -5 units1 m -0 -
-5740 5792 diff --git a/meshes/square.smd b/meshes/square.smd new file mode 100644 index 000000000..48dc0d123 --- /dev/null +++ b/meshes/square.smd @@ -0,0 +1,305 @@ +smi 5 0 + smd 19 +simple 19 1 +* +1 +-0.050500327767110803 0 -0.074036391139533697 +-0.048638948182520902 0.10000000000000001 0.025946283689868951 +1 1007 9 0 +0 0 -0.050500327767110803 0 -0.074036391139533697 +-0.048638948182520902 0.10000000000000001 0.025946283689868951 +_sim_empty +-1 +0 0 0 0 + +0 +0 1 4 4 +0 0 0 0 +1 +7 4 5 +5 0 9 0 200 0 1 +7 +_sim_empty +-1 +-0.048638948182520902 0 -0.074036391139533697 +-0.048638948182520902 0 -0.074036391139533697 +5 4 2 +2 0 9 0 200 0 1 +5 +_sim_empty +-1 +-0.050500327767110803 0 0.025946283689868951 +-0.050500327767110803 0 0.025946283689868951 +2 4 20 +20 0 9 0 200 0 1 +2 +_sim_empty +-1 +-0.048638948182520902 0.10000000000000001 -0.074036391139533697 +-0.048638948182520902 0.10000000000000001 -0.074036391139533697 +4 4 22 +22 0 9 0 200 0 1 +4 +_sim_empty +-1 +-0.050500327767110803 0.10000000000000001 0.025946283689868951 +-0.050500327767110803 0.10000000000000001 0.025946283689868951 +4 5 27 7 2 +27 1 9 0 210 0 1 5 20 +4 +_sim_empty +-1 +1 0.5 -0.048638948182520902 0.050000000000000003 -0.074036391139533697 +1 1 +2 2 0 1e-08 +-0.048638948182520902 0 -0.074036391139533697 +-0.048638948182520902 0.10000000000000001 -0.074036391139533697 +0 0 1 1 +3 5 6 5 7 +6 1 9 0 210 0 1 2 5 +3 +_sim_empty +-1 +1 0.5 -0.049569637974815839 0 -0.024045053724832399 +1 1 +2 2 0 1e-08 +-0.050500327767110803 0 0.025946283689868951 +-0.048638948182520868 0 -0.074036391139533753 +0 0 1 1 +2 5 28 5 4 +28 1 9 0 210 0 1 2 22 +2 +_sim_empty +-1 +1 0.5 -0.050500327767110803 0.050000000000000003 0.025946283689868951 +1 1 +2 2 0 1e-08 +-0.050500327767110803 0 0.025946283689868951 +-0.050500327767110803 0.10000000000000001 0.025946283689868951 +0 0 1 1 +1 5 16 4 2 +16 1 9 0 210 0 1 22 20 +1 +_sim_empty +-1 +1 0.5 -0.049569637974815839 0.10000000000000001 -0.024045053724832399 +1 1 +2 2 0 1e-08 +-0.050500327767110803 0.10000000000000001 0.025946283689868951 +-0.048638948182520868 0.10000000000000001 -0.074036391139533753 +0 0 1 1 +1 6 30 1 0 2 +4 16 1 0 28 2 0 6 3 1 27 4 1 2 6 30 0 0 1 +4 27 4 0 6 3 0 28 2 1 16 1 1 30 2 9 0 203 0 +1 1 + + 1 2 + +0 +_sim_empty +-1 +1 0.00011238968005049493 0.42516224571744082 -0.050500118567254837 0.042516224571744143 0.025935046669034279 +0 +1 1 +2 2 2 2 0 0 0 0.0001 + -0.050500327767110803 0 0.025946283689868951 -0.050500327767110803 0.10000000000000014 0.025946283689868951 + -0.048638948182520868 0 -0.074036391139533753 -0.048638948182520868 0.10000000000000014 -0.074036391139533753 + 0 0 1 1 + 0 0 1 1 +0 -1 +2 8 1 2 +30 0 30 1 1 3 8 0 303 0 1 +2 +0 +0 +_sim_empty +-1 +0 +0 -1 +0 -1 +0 -1 + auxmm 3 +0 +0 + attributes 10 +AttDBVersion 10 8 +0 1 0 16 17 +1 2 7 +0 +16 EnforceGradation +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 3 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +2 +1 2 4 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 5 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 6 +0 +16 FixIntersections +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 3 8 +0 +17 FaceRotationLimit +0 +0 0 1 +0 +0 +2 1 +0 +15 +1 2 9 +0 +12 DiscreteSnap +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 2 +0 +13 SurfaceMesher +0 +0 0 1 +0 +7 3 4 5 6 7 8 9 +1 2 15 +0 +8 ModifyBL +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 11 +0 +11 EnforceSize +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 10 16 +1 * +6 simple +0 +0 0 1 +0 +0 +1 +4 +76 file:///users/cwsmith/develop/geometries/sheet/simModel/translated-model.smd24 model.nonmanifold.simple6 # 1 0 0 1 2 13 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 14 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 12 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 7 10 +0 +12 VolumeMesher +0 +0 0 1 +0 +5 11 12 13 14 15 +1 3 17 +0 +8 MeshSize +8 Relative +0 0 1 +0 +0 +2 -1 +0 +4 0.75 +3 1 1 +5 case1 +7 Meshing +0 +6 0 1 +0 +3 2 10 17 +16 +1 2 +2 +1 +9 1 1 17 + +3 +smd 8 +auxmm 2492 +attributes 2511 + +
+4 +76 file:///users/cwsmith/develop/geometries/sheet/simModel/translated-model.smd24 model.nonmanifold.simple6 # 1 0 0 +1 +14 FromVoxelModel0 +0 +
+3517 3569 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e0ae165f..7ed49c024 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -432,8 +432,10 @@ if(BUILD_TESTING) osh_add_exe(simModel2dLoad) set(TEST_EXES ${TEST_EXES} simModel2dLoad) - test_func(simModel2dLoad 1 ./simModel2dLoad - ${CMAKE_SOURCE_DIR}/meshes/longPlate.smd) + test_func(simModel2dLoad_square 1 ./simModel2dLoad + ${CMAKE_SOURCE_DIR}/meshes/square.smd) + will_fail_test_func(simModel2dLoad_3d 1 ./simModel2dLoad + ${CMAKE_SOURCE_DIR}/meshes/Example_hex.smd) endif() osh_add_exe(load_2d) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index f6fdb7963..a793137fd 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -4,10 +4,16 @@ namespace Omega_h { +bool isModel2D(pGModel mdl) { + return (GM_numRegions(mdl) == 0); +} + Model2D Model2D::SimModel2D_load(std::string const& filename) { pNativeModel nm = NULL; pProgress p = NULL; pGModel g = GM_load(filename.c_str(), nm, p); + const char* msg = "Simmetrix GeomSim model is not 2D... exiting\n"; + OMEGA_H_CHECK_MSG(isModel2D(g), msg); return Model2D(); } From c13401d558144bfc5f357a556ec5d037a92a0f92 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 14:33:02 -0400 Subject: [PATCH 10/78] dbl precision tolerance --- src/Omega_h_model2d.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 282f1bd69..094f6ee39 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -16,7 +16,7 @@ class Model2D { #endif static Model2D MeshModel2D_load(Mesh2D& mesh); - float vtxTol, edgeTol; + Real vtxTol, edgeTol; LOs vtxIds, edgeIds, loopIds, faceIds; LOs looptoLoopUse; Graph edgeToEdgeUse; From 8fdbc8381b681f28b14841e98dca1424c346df9a Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 14:57:59 -0400 Subject: [PATCH 11/78] check if valid, start vtxIds --- src/Omega_h_simModel2d.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index a793137fd..a1d26c94b 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -8,13 +8,30 @@ bool isModel2D(pGModel mdl) { return (GM_numRegions(mdl) == 0); } +bool isValid(pGModel mdl, bool checkGeo = false) { + const auto maxCheckLevel = 2; //may be expensive + auto geoCheck = checkGeo ? maxCheckLevel : 0; + pPList errList = NULL; + const auto valid = 1; + return (GM_isValid(mdl,geoCheck,errList) == valid); +} + +LOs getVtxIds(pGModel mdl) { + auto vtxIds = LOs(GM_numVertices(mdl)); + return vtxIds; +} + Model2D Model2D::SimModel2D_load(std::string const& filename) { pNativeModel nm = NULL; pProgress p = NULL; pGModel g = GM_load(filename.c_str(), nm, p); - const char* msg = "Simmetrix GeomSim model is not 2D... exiting\n"; - OMEGA_H_CHECK_MSG(isModel2D(g), msg); - return Model2D(); + const char* msg2d = "Simmetrix GeomSim model is not 2D... exiting\n"; + OMEGA_H_CHECK_MSG(isModel2D(g), msg2d); + const char* msgValid = "Simmetrix GeomSim model is not valid... exiting\n"; + OMEGA_H_CHECK_MSG(isValid(g), msgValid); + auto mdl = Model2D(); + mdl.vtxIds = getVtxIds(g); + return mdl; } }//end namespace Omega_h From adf0c229c4dc8fab33e5b1842cc8bbe0bb9d6e9a Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 15:17:41 -0400 Subject: [PATCH 12/78] get ids and coords --- src/Omega_h_model2d.hpp | 3 ++- src/Omega_h_simModel2d.cpp | 30 ++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 094f6ee39..3e9713c59 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -17,6 +17,7 @@ class Model2D { static Model2D MeshModel2D_load(Mesh2D& mesh); Real vtxTol, edgeTol; + Reals vtxCoords; LOs vtxIds, edgeIds, loopIds, faceIds; LOs looptoLoopUse; Graph edgeToEdgeUse; @@ -26,7 +27,7 @@ class Model2D { Graph vtxToEdgeUse; LOs edgeUseToLoopUse; LOs loopUseToFace; - LOs vtxCoords, edgeUseOrientation, loopUseOrientation; + LOs edgeUseOrientation, loopUseOrientation; private: Model2D() = default; }; diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index a1d26c94b..dadb7b186 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -16,9 +16,29 @@ bool isValid(pGModel mdl, bool checkGeo = false) { return (GM_isValid(mdl,geoCheck,errList) == valid); } -LOs getVtxIds(pGModel mdl) { - auto vtxIds = LOs(GM_numVertices(mdl)); - return vtxIds; +struct VtxIdsAndCoords { + LOs ids; + Reals coords; +}; + +VtxIdsAndCoords getVtxIdsAndCoords(pGModel mdl) { + const auto numSpatialDims = 3; + auto numVtx = GM_numVertices(mdl); + auto vtxIds_h = HostWrite(numVtx); + auto vtxCoords_h = HostWrite(numVtx*numSpatialDims); + GVIter modelVertices = GM_vertexIter(mdl); + int idx = 0; + pGVertex modelVertex; + double vpoint[3]; + while(modelVertex=GVIter_next(modelVertices)) { + vtxIds_h[idx] = GEN_tag(modelVertex); + GV_point(modelVertex, vpoint); + for(int i=0; i Date: Wed, 13 Mar 2024 22:53:24 -0400 Subject: [PATCH 13/78] reorganize data members, remove loops simmetrix does not store loops, only loop uses, remove them for now --- src/Omega_h_model2d.hpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 3e9713c59..33e64fa97 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -11,23 +11,28 @@ class Mesh2D; class Model2D { public: + //constructors #ifdef OMEGA_H_USE_SIMMODSUITE static Model2D SimModel2D_load(std::string const& filename); #endif static Model2D MeshModel2D_load(Mesh2D& mesh); - - Real vtxTol, edgeTol; - Reals vtxCoords; - LOs vtxIds, edgeIds, loopIds, faceIds; - LOs looptoLoopUse; + //ids + LOs vtxIds /*x*/, edgeIds /*x*/, faceIds /*x*/; + //equal order adjacencies Graph edgeToEdgeUse; + //downward adjacencies Graph faceToLoopUse; Graph loopUseToEdgeUse; LOs edgeUseToVtx; + //upward adjacencies Graph vtxToEdgeUse; LOs edgeUseToLoopUse; LOs loopUseToFace; + //use orientation LOs edgeUseOrientation, loopUseOrientation; + //geometry + Real vtxTol, edgeTol; + Reals vtxCoords; //x private: Model2D() = default; }; From e60514ed0c96af7b8621ce1a916f2b8a99987dcf Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 22:58:37 -0400 Subject: [PATCH 14/78] face and edge ids, initial uses --- src/Omega_h_simModel2d.cpp | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index dadb7b186..a51b34f27 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -21,6 +21,59 @@ struct VtxIdsAndCoords { Reals coords; }; +LOs getFaceIds(pGModel mdl) { + auto numFaces = GM_numFaces(mdl); + auto ids_h = HostWrite(numFaces); + GFIter modelFaces = GM_faceIter(mdl); + int idx = 0; + pGFace modelFace; + while(modelFace=GFIter_next(modelFaces)) { + ids_h[idx++] = GEN_tag(modelFace); + } + GFIter_delete(modelFaces); + return LOs(ids_h); +} + +LOs getUses(pGModel mdl) { + GFIter modelFaces = GM_faceIter(mdl); + int idx = 0; + pGFace modelFace; + while(modelFace=GFIter_next(modelFaces)) { + for(int side=0; side<2; side++) { + auto faceUse = GF_use(modelFace,side); + auto numLoops = GF_numLoops(modelFace); + auto loopUses = GFU_loopIter(faceUse); + pGLoopUse loopUse; + while(loopUse=GLUIter_next(loopUses)) { + auto edgeUses = GLU_edgeUseIter(loopUse); + pGEdgeUse edgeUse; + while(edgeUse=GEUIter_next(edgeUses)) { + auto edge = GEU_edge(edgeUse); + auto vtx0 = GE_vertex(edge,0); + auto vtx1 = GE_vertex(edge,1); + } + GEUIter_delete(edgeUses); + } + GLUIter_delete(loopUses); + } //sides + } + GFIter_delete(modelFaces); + return LOs(); +} + +LOs getEdgeIds(pGModel mdl) { + auto numEdges = GM_numEdges(mdl); + auto ids_h = HostWrite(numEdges); + GEIter modelEdges = GM_edgeIter(mdl); + int idx = 0; + pGEdge modelEdge; + while(modelEdge=GEIter_next(modelEdges)) { + ids_h[idx++] = GEN_tag(modelEdge); + } + GEIter_delete(modelEdges); + return LOs(ids_h); +} + VtxIdsAndCoords getVtxIdsAndCoords(pGModel mdl) { const auto numSpatialDims = 3; auto numVtx = GM_numVertices(mdl); @@ -53,6 +106,9 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { auto vtxInfo = getVtxIdsAndCoords(g); mdl.vtxIds = vtxInfo.ids; mdl.vtxCoords = vtxInfo.coords; + mdl.edgeIds = getEdgeIds(g); + mdl.faceIds = getFaceIds(g); + getUses(g); return mdl; } From 998a7d1343de07e27bee4afa5e0e32d209cdd97c Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 13 Mar 2024 23:09:50 -0400 Subject: [PATCH 15/78] fix leak --- src/Omega_h_simModel2d.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index a51b34f27..eb389dfd0 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -109,6 +109,7 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.edgeIds = getEdgeIds(g); mdl.faceIds = getFaceIds(g); getUses(g); + GM_release(g); return mdl; } From 17fe55bdc767555d7a7f42e2673259efbbb57cb1 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 14 Mar 2024 13:11:02 -0400 Subject: [PATCH 16/78] need id to idx map --- src/Omega_h_simModel2d.cpp | 39 ++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index eb389dfd0..5934b1b36 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -1,6 +1,7 @@ #include #include #include "Omega_h_model2d.hpp" +#include namespace Omega_h { @@ -21,6 +22,11 @@ struct VtxIdsAndCoords { Reals coords; }; +struct EdgeInfo { + LOs ids; + std::map idToIdx; +}; + LOs getFaceIds(pGModel mdl) { auto numFaces = GM_numFaces(mdl); auto ids_h = HostWrite(numFaces); @@ -34,7 +40,16 @@ LOs getFaceIds(pGModel mdl) { return LOs(ids_h); } -LOs getUses(pGModel mdl) { +/* + * retreive the entity-to-use adjacencies + * + * SimModSuite has a limited set of APIs for accessing + * this info ... I've prepared some spaghetti below + */ +LOs getUses(pGModel mdl, const EdgeInfo& edgeInfo) { + const auto numEdges = GM_numEdges(mdl); + auto edgeToEdgeUseDegree = HostWrite(numEdges); + for( int i=0; i idToIdx; + const auto numEdges = GM_numEdges(mdl); auto ids_h = HostWrite(numEdges); GEIter modelEdges = GM_edgeIter(mdl); int idx = 0; pGEdge modelEdge; while(modelEdge=GEIter_next(modelEdges)) { - ids_h[idx++] = GEN_tag(modelEdge); + const auto id =GEN_tag(modelEdge); + ids_h[idx] = id; + idToIdx[id] = idx; + idx++; } GEIter_delete(modelEdges); - return LOs(ids_h); + return EdgeInfo{LOs(ids_h),idToIdx}; } VtxIdsAndCoords getVtxIdsAndCoords(pGModel mdl) { @@ -103,12 +125,13 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const char* msgValid = "Simmetrix GeomSim model is not valid... exiting\n"; OMEGA_H_CHECK_MSG(isValid(g), msgValid); auto mdl = Model2D(); - auto vtxInfo = getVtxIdsAndCoords(g); + const auto vtxInfo = getVtxIdsAndCoords(g); mdl.vtxIds = vtxInfo.ids; mdl.vtxCoords = vtxInfo.coords; - mdl.edgeIds = getEdgeIds(g); + const auto edgeInfo = getEdgeIds(g); + mdl.edgeIds = edgeInfo.ids; mdl.faceIds = getFaceIds(g); - getUses(g); + getUses(g,edgeInfo); GM_release(g); return mdl; } From b4e6a6004c05f7397c328bb3a4b6446121173ea2 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 14 Mar 2024 14:29:05 -0400 Subject: [PATCH 17/78] vtx id-to-idx map, helper funcs --- src/Omega_h_simModel2d.cpp | 45 +++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 5934b1b36..329f90eeb 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -17,9 +17,10 @@ bool isValid(pGModel mdl, bool checkGeo = false) { return (GM_isValid(mdl,geoCheck,errList) == valid); } -struct VtxIdsAndCoords { +struct VtxInfo { LOs ids; Reals coords; + std::map idToIdx; }; struct EdgeInfo { @@ -40,16 +41,31 @@ LOs getFaceIds(pGModel mdl) { return LOs(ids_h); } +void incrementDegree(HostWrite& degree, std::map idToIdx, pGEntity ent) { + const auto id = GEN_tag(ent); + const auto idx = idToIdx.at(id); + degree[idx] = degree[idx]+1; +} + +HostWrite createArray(size_t size, const LO init=0) { + auto array = HostWrite(size); + for( int i=0; i(numEdges); - for( int i=0; i(numVtx); auto vtxCoords_h = HostWrite(numVtx*numSpatialDims); + std::map idToIdx; GVIter modelVertices = GM_vertexIter(mdl); int idx = 0; pGVertex modelVertex; double vpoint[3]; while(modelVertex=GVIter_next(modelVertices)) { - vtxIds_h[idx] = GEN_tag(modelVertex); + const auto id = GEN_tag(modelVertex); + vtxIds_h[idx] = id; + idToIdx[id] = idx; GV_point(modelVertex, vpoint); for(int i=0; i Date: Thu, 14 Mar 2024 15:49:13 -0400 Subject: [PATCH 18/78] common entinfo struct, need face map --- src/Omega_h_simModel2d.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 329f90eeb..8f83706f0 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -17,28 +17,30 @@ bool isValid(pGModel mdl, bool checkGeo = false) { return (GM_isValid(mdl,geoCheck,errList) == valid); } -struct VtxInfo { +struct EntInfo { LOs ids; - Reals coords; std::map idToIdx; }; -struct EdgeInfo { - LOs ids; - std::map idToIdx; +struct VtxInfo : public EntInfo { + Reals coords; }; -LOs getFaceIds(pGModel mdl) { +EntInfo getFaceIds(pGModel mdl) { + std::map idToIdx; auto numFaces = GM_numFaces(mdl); auto ids_h = HostWrite(numFaces); GFIter modelFaces = GM_faceIter(mdl); int idx = 0; pGFace modelFace; while(modelFace=GFIter_next(modelFaces)) { - ids_h[idx++] = GEN_tag(modelFace); + const auto id = GEN_tag(modelFace); + ids_h[idx] = id; + idToIdx[id] = idx; + idx++; } GFIter_delete(modelFaces); - return LOs(ids_h); + return EntInfo{LOs(ids_h), idToIdx}; } void incrementDegree(HostWrite& degree, std::map idToIdx, pGEntity ent) { @@ -59,13 +61,17 @@ HostWrite createArray(size_t size, const LO init=0) { * SimModSuite has a limited set of APIs for accessing * this info ... I've prepared some spaghetti below */ -LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, const EdgeInfo& edgeInfo) { +LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, + const EntInfo& edgeInfo, const EntInfo& faceInfo) { const auto numEdges = GM_numEdges(mdl); auto edgeToEdgeUseDegree = createArray(numEdges); const auto numVtx = GM_numVertices(mdl); auto vtxToEdgeUseDegree = createArray(numVtx); + const auto numFaces = GM_numFaces(mdl); + auto faceToLoopUseDegree = createArray(numFaces); + GFIter modelFaces = GM_faceIter(mdl); int idx = 0; pGFace modelFace; @@ -76,6 +82,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, const EdgeInfo& edgeInfo) { auto loopUses = GFU_loopIter(faceUse); pGLoopUse loopUse; while(loopUse=GLUIter_next(loopUses)) { + incrementDegree(faceToLoopUseDegree, faceInfo.idToIdx, modelFace); auto edgeUses = GLU_edgeUseIter(loopUse); pGEdgeUse edgeUse; while(edgeUse=GEUIter_next(edgeUses)) { @@ -95,7 +102,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, const EdgeInfo& edgeInfo) { return LOs(); } -EdgeInfo getEdgeIds(pGModel mdl) { +EntInfo getEdgeIds(pGModel mdl) { std::map idToIdx; const auto numEdges = GM_numEdges(mdl); auto ids_h = HostWrite(numEdges); @@ -109,7 +116,7 @@ EdgeInfo getEdgeIds(pGModel mdl) { idx++; } GEIter_delete(modelEdges); - return EdgeInfo{LOs(ids_h),idToIdx}; + return EntInfo{LOs(ids_h),idToIdx}; } VtxInfo getVtxInfo(pGModel mdl) { @@ -132,7 +139,7 @@ VtxInfo getVtxInfo(pGModel mdl) { idx++; } GVIter_delete(modelVertices); - return VtxInfo{LOs(vtxIds_h), Reals(vtxCoords_h), idToIdx}; + return VtxInfo{LOs(vtxIds_h), idToIdx, Reals(vtxCoords_h)}; } Model2D Model2D::SimModel2D_load(std::string const& filename) { @@ -149,10 +156,11 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.vtxCoords = vtxInfo.coords; const auto edgeInfo = getEdgeIds(g); mdl.edgeIds = edgeInfo.ids; - mdl.faceIds = getFaceIds(g); - getUses(g,vtxInfo,edgeInfo); + const auto faceInfo = getFaceIds(g); + mdl.faceIds = faceInfo.ids; + getUses(g,vtxInfo,edgeInfo,faceInfo); GM_release(g); return mdl; } - + }//end namespace Omega_h From 2a6011dc51c62d6a4ad3f592a2ca46f73fd72473 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 14 Mar 2024 23:29:44 -0400 Subject: [PATCH 19/78] wip --- src/Omega_h_simModel2d.cpp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 8f83706f0..c0e81d403 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -49,20 +49,40 @@ void incrementDegree(HostWrite& degree, std::map idToIdx, pGEntity degree[idx] = degree[idx]+1; } +void setUse() { +} + HostWrite createArray(size_t size, const LO init=0) { auto array = HostWrite(size); for( int i=0; i f2luDeg; + template + void countOrSet(pGEntity face, pGLoopUse use) { + static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); + if constexpr (mode == 0 ) { + incrementDegree(f2luDeg, faceInfo.idToIdx, face); + } else { + std::cout << "mode 1\n"; //TODO + } + } +}; + /* * retrieve the entity-to-use adjacencies * * SimModSuite has a limited set of APIs for accessing * this info ... I've prepared some spaghetti below */ +template LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, const EntInfo& edgeInfo, const EntInfo& faceInfo) { + static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); + const auto numEdges = GM_numEdges(mdl); auto edgeToEdgeUseDegree = createArray(numEdges); @@ -71,6 +91,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, const auto numFaces = GM_numFaces(mdl); auto faceToLoopUseDegree = createArray(numFaces); + FaceToLoopUse f2lu{faceInfo, createArray(numFaces)}; GFIter modelFaces = GM_faceIter(mdl); int idx = 0; @@ -82,7 +103,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, auto loopUses = GFU_loopIter(faceUse); pGLoopUse loopUse; while(loopUse=GLUIter_next(loopUses)) { - incrementDegree(faceToLoopUseDegree, faceInfo.idToIdx, modelFace); + f2lu.countOrSet(modelFace,loopUse); auto edgeUses = GLU_edgeUseIter(loopUse); pGEdgeUse edgeUse; while(edgeUse=GEUIter_next(edgeUses)) { @@ -99,6 +120,11 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, } //sides } GFIter_delete(modelFaces); + + if constexpr (mode==0) { + std::cout << "converting degree to offset and alloc array\n"; //TODO + } + return LOs(); } @@ -158,7 +184,8 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.edgeIds = edgeInfo.ids; const auto faceInfo = getFaceIds(g); mdl.faceIds = faceInfo.ids; - getUses(g,vtxInfo,edgeInfo,faceInfo); + getUses<0>(g,vtxInfo,edgeInfo,faceInfo); + getUses<1>(g,vtxInfo,edgeInfo,faceInfo); GM_release(g); return mdl; } From f173f04abc3a79f9ee77a94699c642f69d2fa62d Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 11:40:13 -0400 Subject: [PATCH 20/78] two passes to construct uses compiles and executes --- src/Omega_h_simModel2d.cpp | 70 +++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index c0e81d403..5a2789c17 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -2,6 +2,8 @@ #include #include "Omega_h_model2d.hpp" #include +#include //std::fill +#include //std::exclusive_scan namespace Omega_h { @@ -49,27 +51,60 @@ void incrementDegree(HostWrite& degree, std::map idToIdx, pGEntity degree[idx] = degree[idx]+1; } -void setUse() { -} - -HostWrite createArray(size_t size, const LO init=0) { +HostWrite createAndInitArray(size_t size, const LO init=0) { auto array = HostWrite(size); - for( int i=0; i createArray(size_t size) { + return HostWrite(size); +} + +struct CSR { + CSR(int size) { + degree = createAndInitArray(size+1); + offset = createArray(size+1); + count = createAndInitArray(size); + //values array is allocated once degree is populated + } + HostWrite degree; + HostWrite offset; + HostWrite count; + HostWrite values; + void degreeToOffset() { + std::exclusive_scan(degree.data(), degree.data()+degree.size(), offset.data(), 0); + values = createArray(offset[offset.size()]); + }; + void setValue(int entIdx, LO value) { + const auto adjIdx = offset[entIdx]; + const auto adjCount = count[entIdx]; + values[adjIdx+adjCount] = value; + count[entIdx]++; + } + private: + CSR(); +}; + +struct FaceToLoopUse : public CSR { + FaceToLoopUse(int size, const EntInfo& faceInfo_in) + : faceInfo(faceInfo_in), CSR(size) {} const EntInfo& faceInfo; - HostWrite f2luDeg; template void countOrSet(pGEntity face, pGLoopUse use) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); if constexpr (mode == 0 ) { - incrementDegree(f2luDeg, faceInfo.idToIdx, face); + incrementDegree(degree, faceInfo.idToIdx, face); } else { - std::cout << "mode 1\n"; //TODO + const auto faceId = GEN_tag(face); + const auto faceIdx = faceInfo.idToIdx.at(faceId); + const auto loopUseId = GEN_tag(use); + const auto loopUseIdx = 0; //FIXME + setValue(faceIdx, loopUseIdx); } } + private: + FaceToLoopUse(); }; /* @@ -80,7 +115,7 @@ struct FaceToLoopUse { */ template LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, - const EntInfo& edgeInfo, const EntInfo& faceInfo) { + const EntInfo& edgeInfo, FaceToLoopUse& f2lu) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); const auto numEdges = GM_numEdges(mdl); @@ -89,9 +124,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, const auto numVtx = GM_numVertices(mdl); auto vtxToEdgeUseDegree = createArray(numVtx); - const auto numFaces = GM_numFaces(mdl); - auto faceToLoopUseDegree = createArray(numFaces); - FaceToLoopUse f2lu{faceInfo, createArray(numFaces)}; +; GFIter modelFaces = GM_faceIter(mdl); int idx = 0; @@ -122,9 +155,8 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, GFIter_delete(modelFaces); if constexpr (mode==0) { - std::cout << "converting degree to offset and alloc array\n"; //TODO + f2lu.degreeToOffset(); } - return LOs(); } @@ -184,8 +216,12 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.edgeIds = edgeInfo.ids; const auto faceInfo = getFaceIds(g); mdl.faceIds = faceInfo.ids; - getUses<0>(g,vtxInfo,edgeInfo,faceInfo); - getUses<1>(g,vtxInfo,edgeInfo,faceInfo); + + const auto numFaces = GM_numFaces(g); + auto faceToLoopUseDegree = createArray(numFaces); + FaceToLoopUse f2lu(numFaces, faceInfo); + getUses<0>(g,vtxInfo,edgeInfo,f2lu); + getUses<1>(g,vtxInfo,edgeInfo,f2lu); GM_release(g); return mdl; } From 601beae6c355935c38dbab7165e185d7cee33019 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 13:35:07 -0400 Subject: [PATCH 21/78] fix sizes, offset init --- src/Omega_h_simModel2d.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 5a2789c17..0af7083a9 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -63,7 +63,7 @@ HostWrite createArray(size_t size) { struct CSR { CSR(int size) { - degree = createAndInitArray(size+1); + degree = createAndInitArray(size); offset = createArray(size+1); count = createAndInitArray(size); //values array is allocated once degree is populated @@ -73,7 +73,8 @@ struct CSR { HostWrite count; HostWrite values; void degreeToOffset() { - std::exclusive_scan(degree.data(), degree.data()+degree.size(), offset.data(), 0); + offset[0] = 0; + std::exclusive_scan(degree.data(), degree.data()+degree.size(), offset.data()+1, 0); values = createArray(offset[offset.size()]); }; void setValue(int entIdx, LO value) { From 5e0b5b71389c3f4f719923399f78cfa17fcee8fb Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 13:53:01 -0400 Subject: [PATCH 22/78] only use offset array no leaks or errors under valgrind --- src/Omega_h_simModel2d.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 0af7083a9..3462a1ac8 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -63,19 +63,16 @@ HostWrite createArray(size_t size) { struct CSR { CSR(int size) { - degree = createAndInitArray(size); - offset = createArray(size+1); + offset = createAndInitArray(size+1); count = createAndInitArray(size); //values array is allocated once degree is populated } - HostWrite degree; HostWrite offset; HostWrite count; HostWrite values; void degreeToOffset() { - offset[0] = 0; - std::exclusive_scan(degree.data(), degree.data()+degree.size(), offset.data()+1, 0); - values = createArray(offset[offset.size()]); + std::exclusive_scan(offset.data(), offset.data()+offset.size(), offset.data(), 0); + values = createArray(offset[offset.size()-1]); }; void setValue(int entIdx, LO value) { const auto adjIdx = offset[entIdx]; @@ -95,7 +92,7 @@ struct FaceToLoopUse : public CSR { void countOrSet(pGEntity face, pGLoopUse use) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); if constexpr (mode == 0 ) { - incrementDegree(degree, faceInfo.idToIdx, face); + incrementDegree(offset, faceInfo.idToIdx, face); } else { const auto faceId = GEN_tag(face); const auto faceIdx = faceInfo.idToIdx.at(faceId); From 071b4782e55be50caa007dc64dc13851f0d36078 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 14:09:34 -0400 Subject: [PATCH 23/78] add edgeToEdgeUse --- src/Omega_h_simModel2d.cpp | 42 ++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 3462a1ac8..d8575b2af 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -105,6 +105,29 @@ struct FaceToLoopUse : public CSR { FaceToLoopUse(); }; +struct EdgeToEdgeUse : public CSR { + EdgeToEdgeUse(int size, const EntInfo& edgeInfo_in) + : edgeInfo(edgeInfo_in), CSR(size) {} + const EntInfo& edgeInfo; + template + void countOrSet(pGEntity edge, pGEdgeUse use) { + static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); + if constexpr (mode == 0 ) { + incrementDegree(offset, edgeInfo.idToIdx, edge); + } else { + const auto entId = GEN_tag(edge); + const auto entIdx = edgeInfo.idToIdx.at(entId); + const auto useId = GEN_tag(use); + const auto useIdx = 0; //FIXME + setValue(entIdx, useIdx); + } + } + private: + EdgeToEdgeUse(); +}; + + + /* * retrieve the entity-to-use adjacencies * @@ -113,17 +136,12 @@ struct FaceToLoopUse : public CSR { */ template LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, - const EntInfo& edgeInfo, FaceToLoopUse& f2lu) { + EdgeToEdgeUse& e2eu, FaceToLoopUse& f2lu) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); - const auto numEdges = GM_numEdges(mdl); - auto edgeToEdgeUseDegree = createArray(numEdges); - const auto numVtx = GM_numVertices(mdl); auto vtxToEdgeUseDegree = createArray(numVtx); -; - GFIter modelFaces = GM_faceIter(mdl); int idx = 0; pGFace modelFace; @@ -139,7 +157,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, pGEdgeUse edgeUse; while(edgeUse=GEUIter_next(edgeUses)) { auto edge = GEU_edge(edgeUse); - incrementDegree(edgeToEdgeUseDegree, edgeInfo.idToIdx, edge); + e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); incrementDegree(vtxToEdgeUseDegree, vtxInfo.idToIdx, vtx0); auto vtx1 = GE_vertex(edge,1); @@ -154,6 +172,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, if constexpr (mode==0) { f2lu.degreeToOffset(); + e2eu.degreeToOffset(); } return LOs(); } @@ -215,11 +234,16 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto faceInfo = getFaceIds(g); mdl.faceIds = faceInfo.ids; + const auto numEdges = GM_numEdges(g); + auto edgeToEdgeUseDegree = createArray(numEdges); + EdgeToEdgeUse e2eu(numEdges, edgeInfo); + const auto numFaces = GM_numFaces(g); auto faceToLoopUseDegree = createArray(numFaces); FaceToLoopUse f2lu(numFaces, faceInfo); - getUses<0>(g,vtxInfo,edgeInfo,f2lu); - getUses<1>(g,vtxInfo,edgeInfo,f2lu); + + getUses<0>(g,vtxInfo,e2eu,f2lu); + getUses<1>(g,vtxInfo,e2eu,f2lu); GM_release(g); return mdl; } From 823744f4861cd6db8d98b15905e0d1ca9fce4bfe Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 14:32:58 -0400 Subject: [PATCH 24/78] add vtxToEdgeUse --- src/Omega_h_simModel2d.cpp | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index d8575b2af..fc807bfb9 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -126,6 +126,26 @@ struct EdgeToEdgeUse : public CSR { EdgeToEdgeUse(); }; +struct VtxToEdgeUse : public CSR { + VtxToEdgeUse(int size, const EntInfo& vtxInfo_in) + : vtxInfo(vtxInfo_in), CSR(size) {} + const EntInfo& vtxInfo; + template + void countOrSet(pGEntity vtx, pGEdgeUse use) { + static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); + if constexpr (mode == 0 ) { + incrementDegree(offset, vtxInfo.idToIdx, vtx); + } else { + const auto entId = GEN_tag(vtx); + const auto entIdx = vtxInfo.idToIdx.at(entId); + const auto useId = GEN_tag(use); + const auto useIdx = 0; //FIXME + setValue(entIdx, useIdx); + } + } + private: + VtxToEdgeUse(); +}; /* @@ -135,13 +155,10 @@ struct EdgeToEdgeUse : public CSR { * this info ... I've prepared some spaghetti below */ template -LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, +LOs getUses(pGModel mdl, VtxToEdgeUse& v2eu, EdgeToEdgeUse& e2eu, FaceToLoopUse& f2lu) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); - const auto numVtx = GM_numVertices(mdl); - auto vtxToEdgeUseDegree = createArray(numVtx); - GFIter modelFaces = GM_faceIter(mdl); int idx = 0; pGFace modelFace; @@ -159,9 +176,9 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, auto edge = GEU_edge(edgeUse); e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); - incrementDegree(vtxToEdgeUseDegree, vtxInfo.idToIdx, vtx0); + v2eu.countOrSet(vtx0,edgeUse); auto vtx1 = GE_vertex(edge,1); - incrementDegree(vtxToEdgeUseDegree, vtxInfo.idToIdx, vtx1); + v2eu.countOrSet(vtx1,edgeUse); } GEUIter_delete(edgeUses); } @@ -173,6 +190,7 @@ LOs getUses(pGModel mdl, const VtxInfo& vtxInfo, if constexpr (mode==0) { f2lu.degreeToOffset(); e2eu.degreeToOffset(); + v2eu.degreeToOffset(); } return LOs(); } @@ -234,6 +252,10 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto faceInfo = getFaceIds(g); mdl.faceIds = faceInfo.ids; + const auto numVtx = GM_numVertices(g); + auto vtxToEdgeUseDegree = createArray(numVtx); + VtxToEdgeUse v2eu(numVtx, vtxInfo); + const auto numEdges = GM_numEdges(g); auto edgeToEdgeUseDegree = createArray(numEdges); EdgeToEdgeUse e2eu(numEdges, edgeInfo); @@ -242,8 +264,8 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { auto faceToLoopUseDegree = createArray(numFaces); FaceToLoopUse f2lu(numFaces, faceInfo); - getUses<0>(g,vtxInfo,e2eu,f2lu); - getUses<1>(g,vtxInfo,e2eu,f2lu); + getUses<0>(g,v2eu,e2eu,f2lu); + getUses<1>(g,v2eu,e2eu,f2lu); GM_release(g); return mdl; } From 08c5d7d69e348e5f0cf407794c2641c92ef59bfb Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 14:59:53 -0400 Subject: [PATCH 25/78] common struct for entToAdjUse --- src/Omega_h_simModel2d.cpp | 76 +++++++++----------------------------- 1 file changed, 18 insertions(+), 58 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index fc807bfb9..0f3911612 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -84,70 +84,28 @@ struct CSR { CSR(); }; -struct FaceToLoopUse : public CSR { - FaceToLoopUse(int size, const EntInfo& faceInfo_in) - : faceInfo(faceInfo_in), CSR(size) {} - const EntInfo& faceInfo; +template +struct EntToAdjUse : public CSR { + EntToAdjUse(int size, const EntInfo& entInfo_in) + : entInfo(entInfo_in), CSR(size) {} + const EntInfo& entInfo; template - void countOrSet(pGEntity face, pGLoopUse use) { - static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); + void countOrSet(pGEntity ent, UseType use) { + static_assert((mode == 0 || mode == 1), "countOrSet called with invalid mode"); if constexpr (mode == 0 ) { - incrementDegree(offset, faceInfo.idToIdx, face); + incrementDegree(offset, entInfo.idToIdx, ent); } else { - const auto faceId = GEN_tag(face); - const auto faceIdx = faceInfo.idToIdx.at(faceId); - const auto loopUseId = GEN_tag(use); - const auto loopUseIdx = 0; //FIXME - setValue(faceIdx, loopUseIdx); - } - } - private: - FaceToLoopUse(); -}; - -struct EdgeToEdgeUse : public CSR { - EdgeToEdgeUse(int size, const EntInfo& edgeInfo_in) - : edgeInfo(edgeInfo_in), CSR(size) {} - const EntInfo& edgeInfo; - template - void countOrSet(pGEntity edge, pGEdgeUse use) { - static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); - if constexpr (mode == 0 ) { - incrementDegree(offset, edgeInfo.idToIdx, edge); - } else { - const auto entId = GEN_tag(edge); - const auto entIdx = edgeInfo.idToIdx.at(entId); + const auto entId = GEN_tag(ent); + const auto entIdx = entInfo.idToIdx.at(entId); const auto useId = GEN_tag(use); const auto useIdx = 0; //FIXME setValue(entIdx, useIdx); } } private: - EdgeToEdgeUse(); + EntToAdjUse(); }; -struct VtxToEdgeUse : public CSR { - VtxToEdgeUse(int size, const EntInfo& vtxInfo_in) - : vtxInfo(vtxInfo_in), CSR(size) {} - const EntInfo& vtxInfo; - template - void countOrSet(pGEntity vtx, pGEdgeUse use) { - static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); - if constexpr (mode == 0 ) { - incrementDegree(offset, vtxInfo.idToIdx, vtx); - } else { - const auto entId = GEN_tag(vtx); - const auto entIdx = vtxInfo.idToIdx.at(entId); - const auto useId = GEN_tag(use); - const auto useIdx = 0; //FIXME - setValue(entIdx, useIdx); - } - } - private: - VtxToEdgeUse(); -}; - - /* * retrieve the entity-to-use adjacencies * @@ -155,8 +113,10 @@ struct VtxToEdgeUse : public CSR { * this info ... I've prepared some spaghetti below */ template -LOs getUses(pGModel mdl, VtxToEdgeUse& v2eu, - EdgeToEdgeUse& e2eu, FaceToLoopUse& f2lu) { +LOs getUses(pGModel mdl, + EntToAdjUse& v2eu, + EntToAdjUse& e2eu, + EntToAdjUse& f2lu) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); GFIter modelFaces = GM_faceIter(mdl); @@ -254,15 +214,15 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto numVtx = GM_numVertices(g); auto vtxToEdgeUseDegree = createArray(numVtx); - VtxToEdgeUse v2eu(numVtx, vtxInfo); + EntToAdjUse v2eu(numVtx, vtxInfo); const auto numEdges = GM_numEdges(g); auto edgeToEdgeUseDegree = createArray(numEdges); - EdgeToEdgeUse e2eu(numEdges, edgeInfo); + EntToAdjUse e2eu(numEdges, edgeInfo); const auto numFaces = GM_numFaces(g); auto faceToLoopUseDegree = createArray(numFaces); - FaceToLoopUse f2lu(numFaces, faceInfo); + EntToAdjUse f2lu(numFaces, faceInfo); getUses<0>(g,v2eu,e2eu,f2lu); getUses<1>(g,v2eu,e2eu,f2lu); From 1106f2d5060e6a607636731be3341d42782c79e2 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 15:02:36 -0400 Subject: [PATCH 26/78] remove unused arrays --- src/Omega_h_simModel2d.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 0f3911612..9b02f1a66 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -213,15 +213,12 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.faceIds = faceInfo.ids; const auto numVtx = GM_numVertices(g); - auto vtxToEdgeUseDegree = createArray(numVtx); EntToAdjUse v2eu(numVtx, vtxInfo); const auto numEdges = GM_numEdges(g); - auto edgeToEdgeUseDegree = createArray(numEdges); EntToAdjUse e2eu(numEdges, edgeInfo); const auto numFaces = GM_numFaces(g); - auto faceToLoopUseDegree = createArray(numFaces); EntToAdjUse f2lu(numFaces, faceInfo); getUses<0>(g,v2eu,e2eu,f2lu); From 7696528f004763a0e49d0c82fcb17f008ea7d0de Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 15 Mar 2024 15:06:35 -0400 Subject: [PATCH 27/78] more cleanup --- src/Omega_h_simModel2d.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 9b02f1a66..a6f49b4cd 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -86,8 +86,8 @@ struct CSR { template struct EntToAdjUse : public CSR { - EntToAdjUse(int size, const EntInfo& entInfo_in) - : entInfo(entInfo_in), CSR(size) {} + EntToAdjUse(const EntInfo& entInfo_in) + : entInfo(entInfo_in), CSR(entInfo_in.ids.size()) {} const EntInfo& entInfo; template void countOrSet(pGEntity ent, UseType use) { @@ -212,14 +212,9 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto faceInfo = getFaceIds(g); mdl.faceIds = faceInfo.ids; - const auto numVtx = GM_numVertices(g); - EntToAdjUse v2eu(numVtx, vtxInfo); - - const auto numEdges = GM_numEdges(g); - EntToAdjUse e2eu(numEdges, edgeInfo); - - const auto numFaces = GM_numFaces(g); - EntToAdjUse f2lu(numFaces, faceInfo); + EntToAdjUse v2eu(vtxInfo); + EntToAdjUse e2eu(edgeInfo); + EntToAdjUse f2lu(faceInfo); getUses<0>(g,v2eu,e2eu,f2lu); getUses<1>(g,v2eu,e2eu,f2lu); From 7a7c2a6bbc226a127dbec7f36ede15451db1c77c Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 13:26:21 -0400 Subject: [PATCH 28/78] generalize CSR --- src/Omega_h_simModel2d.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index a6f49b4cd..bb23e50ab 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -84,13 +84,13 @@ struct CSR { CSR(); }; -template +template struct EntToAdjUse : public CSR { EntToAdjUse(const EntInfo& entInfo_in) : entInfo(entInfo_in), CSR(entInfo_in.ids.size()) {} const EntInfo& entInfo; template - void countOrSet(pGEntity ent, UseType use) { + void countOrSet(EntType ent, UseType use) { static_assert((mode == 0 || mode == 1), "countOrSet called with invalid mode"); if constexpr (mode == 0 ) { incrementDegree(offset, entInfo.idToIdx, ent); @@ -114,9 +114,9 @@ struct EntToAdjUse : public CSR { */ template LOs getUses(pGModel mdl, - EntToAdjUse& v2eu, - EntToAdjUse& e2eu, - EntToAdjUse& f2lu) { + EntToAdjUse& v2eu, + EntToAdjUse& e2eu, + EntToAdjUse& f2lu) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); GFIter modelFaces = GM_faceIter(mdl); @@ -212,9 +212,9 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto faceInfo = getFaceIds(g); mdl.faceIds = faceInfo.ids; - EntToAdjUse v2eu(vtxInfo); - EntToAdjUse e2eu(edgeInfo); - EntToAdjUse f2lu(faceInfo); + EntToAdjUse v2eu(vtxInfo); + EntToAdjUse e2eu(edgeInfo); + EntToAdjUse f2lu(faceInfo); getUses<0>(g,v2eu,e2eu,f2lu); getUses<1>(g,v2eu,e2eu,f2lu); From 5bfec5a58b0c88b20e352b7f4670b504baebf361 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 13:26:55 -0400 Subject: [PATCH 29/78] WIP: loopUse CSR --- src/Omega_h_simModel2d.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index bb23e50ab..af8d8019d 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -106,6 +106,32 @@ struct EntToAdjUse : public CSR { EntToAdjUse(); }; +EntInfo getLoopUseInfo(pGModel mdl) { + std::map idToIdx; + std::vector ids_h; + int numLoopUses = 0; + GFIter modelFaces = GM_faceIter(mdl); + int idx = 0; + pGFace modelFace; + while(modelFace=GFIter_next(modelFaces)) { + for(int side=0; side<2; side++) { + auto faceUse = GF_use(modelFace,side); + auto loopUses = GFU_loopIter(faceUse); + pGLoopUse loopUse; + while(loopUse=GLUIter_next(loopUses)) { + numLoopUses++; + const auto id = GEN_tag(loopUse); + ids_h.push_back(id); + idToIdx[id] = idx; + idx++; + } + GLUIter_delete(loopUses); + } //sides + } + GFIter_delete(modelFaces); + return EntInfo(); +} + /* * retrieve the entity-to-use adjacencies * @@ -125,7 +151,6 @@ LOs getUses(pGModel mdl, while(modelFace=GFIter_next(modelFaces)) { for(int side=0; side<2; side++) { auto faceUse = GF_use(modelFace,side); - auto numLoops = GF_numLoops(modelFace); auto loopUses = GFU_loopIter(faceUse); pGLoopUse loopUse; while(loopUse=GLUIter_next(loopUses)) { @@ -133,6 +158,7 @@ LOs getUses(pGModel mdl, auto edgeUses = GLU_edgeUseIter(loopUse); pGEdgeUse edgeUse; while(edgeUse=GEUIter_next(edgeUses)) { + //lu2eu.countOrSet(loopUse,edgeUse); auto edge = GEU_edge(edgeUse); e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); @@ -216,6 +242,9 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { EntToAdjUse e2eu(edgeInfo); EntToAdjUse f2lu(faceInfo); + const auto loopUseInfo = getLoopUseInfo(g); + //Graph loopUseToEdgeUse; + getUses<0>(g,v2eu,e2eu,f2lu); getUses<1>(g,v2eu,e2eu,f2lu); GM_release(g); From 4cb3050b5eacc043a6ff66f308cd8c0126254783 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 14:15:54 -0400 Subject: [PATCH 30/78] loopUse to edgeUse compiles and executes --- src/Omega_h_simModel2d.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index af8d8019d..22c50572f 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -108,7 +108,7 @@ struct EntToAdjUse : public CSR { EntInfo getLoopUseInfo(pGModel mdl) { std::map idToIdx; - std::vector ids_h; + std::vector ids; int numLoopUses = 0; GFIter modelFaces = GM_faceIter(mdl); int idx = 0; @@ -121,7 +121,7 @@ EntInfo getLoopUseInfo(pGModel mdl) { while(loopUse=GLUIter_next(loopUses)) { numLoopUses++; const auto id = GEN_tag(loopUse); - ids_h.push_back(id); + ids.push_back(id); idToIdx[id] = idx; idx++; } @@ -129,7 +129,9 @@ EntInfo getLoopUseInfo(pGModel mdl) { } //sides } GFIter_delete(modelFaces); - return EntInfo(); + HostWrite ids_h(ids.size()); + for(int i=0; i LOs getUses(pGModel mdl, EntToAdjUse& v2eu, EntToAdjUse& e2eu, - EntToAdjUse& f2lu) { + EntToAdjUse& f2lu, + EntToAdjUse& lu2eu) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); GFIter modelFaces = GM_faceIter(mdl); @@ -158,7 +161,7 @@ LOs getUses(pGModel mdl, auto edgeUses = GLU_edgeUseIter(loopUse); pGEdgeUse edgeUse; while(edgeUse=GEUIter_next(edgeUses)) { - //lu2eu.countOrSet(loopUse,edgeUse); + lu2eu.countOrSet(loopUse,edgeUse); auto edge = GEU_edge(edgeUse); e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); @@ -173,11 +176,6 @@ LOs getUses(pGModel mdl, } GFIter_delete(modelFaces); - if constexpr (mode==0) { - f2lu.degreeToOffset(); - e2eu.degreeToOffset(); - v2eu.degreeToOffset(); - } return LOs(); } @@ -237,16 +235,19 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.edgeIds = edgeInfo.ids; const auto faceInfo = getFaceIds(g); mdl.faceIds = faceInfo.ids; + const auto loopUseInfo = getLoopUseInfo(g); EntToAdjUse v2eu(vtxInfo); EntToAdjUse e2eu(edgeInfo); EntToAdjUse f2lu(faceInfo); - - const auto loopUseInfo = getLoopUseInfo(g); - //Graph loopUseToEdgeUse; - - getUses<0>(g,v2eu,e2eu,f2lu); - getUses<1>(g,v2eu,e2eu,f2lu); + EntToAdjUse lu2eu(loopUseInfo); + + getUses<0>(g,v2eu,e2eu,f2lu,lu2eu); + f2lu.degreeToOffset(); + e2eu.degreeToOffset(); + v2eu.degreeToOffset(); + lu2eu.degreeToOffset(); + getUses<1>(g,v2eu,e2eu,f2lu,lu2eu); GM_release(g); return mdl; } From 7d0e733db2cf0ea4065be1b82d5e07fcfd9e4dd0 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 14:38:24 -0400 Subject: [PATCH 31/78] useId to array index --- src/Omega_h_simModel2d.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 22c50572f..cb6bd6b57 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -87,8 +87,11 @@ struct CSR { template struct EntToAdjUse : public CSR { EntToAdjUse(const EntInfo& entInfo_in) - : entInfo(entInfo_in), CSR(entInfo_in.ids.size()) {} + : entInfo(entInfo_in), useCount(0), + CSR(entInfo_in.ids.size()) {} const EntInfo& entInfo; + std::map useIdToIdx; + int useCount; template void countOrSet(EntType ent, UseType use) { static_assert((mode == 0 || mode == 1), "countOrSet called with invalid mode"); @@ -98,7 +101,10 @@ struct EntToAdjUse : public CSR { const auto entId = GEN_tag(ent); const auto entIdx = entInfo.idToIdx.at(entId); const auto useId = GEN_tag(use); - const auto useIdx = 0; //FIXME + if( ! useIdToIdx.count(useId) ) { + useIdToIdx[useId] = useCount++; + } + const auto useIdx = useIdToIdx[useId]; setValue(entIdx, useIdx); } } From db82d30cccc96b69cd04bfe48af752a8d075684f Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 15:21:42 -0400 Subject: [PATCH 32/78] add timers --- src/Omega_h_simModel2d.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index cb6bd6b57..b28ac02e1 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -1,6 +1,7 @@ #include #include #include "Omega_h_model2d.hpp" +#include "Omega_h_profile.hpp" #include #include //std::fill #include //std::exclusive_scan @@ -29,6 +30,7 @@ struct VtxInfo : public EntInfo { }; EntInfo getFaceIds(pGModel mdl) { + OMEGA_H_TIME_FUNCTION; std::map idToIdx; auto numFaces = GM_numFaces(mdl); auto ids_h = HostWrite(numFaces); @@ -63,6 +65,7 @@ HostWrite createArray(size_t size) { struct CSR { CSR(int size) { + OMEGA_H_TIME_FUNCTION; offset = createAndInitArray(size+1); count = createAndInitArray(size); //values array is allocated once degree is populated @@ -71,10 +74,12 @@ struct CSR { HostWrite count; HostWrite values; void degreeToOffset() { + OMEGA_H_TIME_FUNCTION; std::exclusive_scan(offset.data(), offset.data()+offset.size(), offset.data(), 0); values = createArray(offset[offset.size()-1]); }; void setValue(int entIdx, LO value) { + OMEGA_H_TIME_FUNCTION; const auto adjIdx = offset[entIdx]; const auto adjCount = count[entIdx]; values[adjIdx+adjCount] = value; @@ -95,9 +100,12 @@ struct EntToAdjUse : public CSR { template void countOrSet(EntType ent, UseType use) { static_assert((mode == 0 || mode == 1), "countOrSet called with invalid mode"); + OMEGA_H_TIME_FUNCTION; if constexpr (mode == 0 ) { + ScopedTimer timer("EntToAdjUse::set"); incrementDegree(offset, entInfo.idToIdx, ent); } else { + ScopedTimer timer("EntToAdjUse::count"); const auto entId = GEN_tag(ent); const auto entIdx = entInfo.idToIdx.at(entId); const auto useId = GEN_tag(use); @@ -113,6 +121,7 @@ struct EntToAdjUse : public CSR { }; EntInfo getLoopUseInfo(pGModel mdl) { + OMEGA_H_TIME_FUNCTION; std::map idToIdx; std::vector ids; int numLoopUses = 0; @@ -153,6 +162,7 @@ LOs getUses(pGModel mdl, EntToAdjUse& f2lu, EntToAdjUse& lu2eu) { static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); + OMEGA_H_TIME_FUNCTION; GFIter modelFaces = GM_faceIter(mdl); int idx = 0; @@ -186,6 +196,7 @@ LOs getUses(pGModel mdl, } EntInfo getEdgeIds(pGModel mdl) { + OMEGA_H_TIME_FUNCTION; std::map idToIdx; const auto numEdges = GM_numEdges(mdl); auto ids_h = HostWrite(numEdges); @@ -203,6 +214,7 @@ EntInfo getEdgeIds(pGModel mdl) { } VtxInfo getVtxInfo(pGModel mdl) { + OMEGA_H_TIME_FUNCTION; const auto numSpatialDims = 3; auto numVtx = GM_numVertices(mdl); auto vtxIds_h = HostWrite(numVtx); @@ -226,6 +238,7 @@ VtxInfo getVtxInfo(pGModel mdl) { } Model2D Model2D::SimModel2D_load(std::string const& filename) { + OMEGA_H_TIME_FUNCTION; pNativeModel nm = NULL; pProgress p = NULL; pGModel g = GM_load(filename.c_str(), nm, p); From 880100823ec96a230326d73a5e9a2e5a5fb48688 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 15:31:38 -0400 Subject: [PATCH 33/78] group like functions --- src/Omega_h_simModel2d.cpp | 142 ++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index b28ac02e1..0bd5df577 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -29,6 +29,48 @@ struct VtxInfo : public EntInfo { Reals coords; }; +VtxInfo getVtxInfo(pGModel mdl) { + OMEGA_H_TIME_FUNCTION; + const auto numSpatialDims = 3; + auto numVtx = GM_numVertices(mdl); + auto vtxIds_h = HostWrite(numVtx); + auto vtxCoords_h = HostWrite(numVtx*numSpatialDims); + std::map idToIdx; + GVIter modelVertices = GM_vertexIter(mdl); + int idx = 0; + pGVertex modelVertex; + double vpoint[3]; + while(modelVertex=GVIter_next(modelVertices)) { + const auto id = GEN_tag(modelVertex); + vtxIds_h[idx] = id; + idToIdx[id] = idx; + GV_point(modelVertex, vpoint); + for(int i=0; i idToIdx; + const auto numEdges = GM_numEdges(mdl); + auto ids_h = HostWrite(numEdges); + GEIter modelEdges = GM_edgeIter(mdl); + int idx = 0; + pGEdge modelEdge; + while(modelEdge=GEIter_next(modelEdges)) { + const auto id =GEN_tag(modelEdge); + ids_h[idx] = id; + idToIdx[id] = idx; + idx++; + } + GEIter_delete(modelEdges); + return EntInfo{LOs(ids_h),idToIdx}; +} + EntInfo getFaceIds(pGModel mdl) { OMEGA_H_TIME_FUNCTION; std::map idToIdx; @@ -47,6 +89,35 @@ EntInfo getFaceIds(pGModel mdl) { return EntInfo{LOs(ids_h), idToIdx}; } +EntInfo getLoopUseInfo(pGModel mdl) { + OMEGA_H_TIME_FUNCTION; + std::map idToIdx; + std::vector ids; + int numLoopUses = 0; + GFIter modelFaces = GM_faceIter(mdl); + int idx = 0; + pGFace modelFace; + while(modelFace=GFIter_next(modelFaces)) { + for(int side=0; side<2; side++) { + auto faceUse = GF_use(modelFace,side); + auto loopUses = GFU_loopIter(faceUse); + pGLoopUse loopUse; + while(loopUse=GLUIter_next(loopUses)) { + numLoopUses++; + const auto id = GEN_tag(loopUse); + ids.push_back(id); + idToIdx[id] = idx; + idx++; + } + GLUIter_delete(loopUses); + } //sides + } + GFIter_delete(modelFaces); + HostWrite ids_h(ids.size()); + for(int i=0; i& degree, std::map idToIdx, pGEntity ent) { const auto id = GEN_tag(ent); const auto idx = idToIdx.at(id); @@ -120,35 +191,6 @@ struct EntToAdjUse : public CSR { EntToAdjUse(); }; -EntInfo getLoopUseInfo(pGModel mdl) { - OMEGA_H_TIME_FUNCTION; - std::map idToIdx; - std::vector ids; - int numLoopUses = 0; - GFIter modelFaces = GM_faceIter(mdl); - int idx = 0; - pGFace modelFace; - while(modelFace=GFIter_next(modelFaces)) { - for(int side=0; side<2; side++) { - auto faceUse = GF_use(modelFace,side); - auto loopUses = GFU_loopIter(faceUse); - pGLoopUse loopUse; - while(loopUse=GLUIter_next(loopUses)) { - numLoopUses++; - const auto id = GEN_tag(loopUse); - ids.push_back(id); - idToIdx[id] = idx; - idx++; - } - GLUIter_delete(loopUses); - } //sides - } - GFIter_delete(modelFaces); - HostWrite ids_h(ids.size()); - for(int i=0; i idToIdx; - const auto numEdges = GM_numEdges(mdl); - auto ids_h = HostWrite(numEdges); - GEIter modelEdges = GM_edgeIter(mdl); - int idx = 0; - pGEdge modelEdge; - while(modelEdge=GEIter_next(modelEdges)) { - const auto id =GEN_tag(modelEdge); - ids_h[idx] = id; - idToIdx[id] = idx; - idx++; - } - GEIter_delete(modelEdges); - return EntInfo{LOs(ids_h),idToIdx}; -} - -VtxInfo getVtxInfo(pGModel mdl) { - OMEGA_H_TIME_FUNCTION; - const auto numSpatialDims = 3; - auto numVtx = GM_numVertices(mdl); - auto vtxIds_h = HostWrite(numVtx); - auto vtxCoords_h = HostWrite(numVtx*numSpatialDims); - std::map idToIdx; - GVIter modelVertices = GM_vertexIter(mdl); - int idx = 0; - pGVertex modelVertex; - double vpoint[3]; - while(modelVertex=GVIter_next(modelVertices)) { - const auto id = GEN_tag(modelVertex); - vtxIds_h[idx] = id; - idToIdx[id] = idx; - GV_point(modelVertex, vpoint); - for(int i=0; i Date: Mon, 18 Mar 2024 15:32:33 -0400 Subject: [PATCH 34/78] consistent names --- src/Omega_h_simModel2d.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 0bd5df577..9787a9342 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -53,7 +53,7 @@ VtxInfo getVtxInfo(pGModel mdl) { return VtxInfo{LOs(vtxIds_h), idToIdx, Reals(vtxCoords_h)}; } -EntInfo getEdgeIds(pGModel mdl) { +EntInfo getEdgeInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; std::map idToIdx; const auto numEdges = GM_numEdges(mdl); @@ -71,7 +71,7 @@ EntInfo getEdgeIds(pGModel mdl) { return EntInfo{LOs(ids_h),idToIdx}; } -EntInfo getFaceIds(pGModel mdl) { +EntInfo getFaceInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; std::map idToIdx; auto numFaces = GM_numFaces(mdl); @@ -250,9 +250,9 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto vtxInfo = getVtxInfo(g); mdl.vtxIds = vtxInfo.ids; mdl.vtxCoords = vtxInfo.coords; - const auto edgeInfo = getEdgeIds(g); + const auto edgeInfo = getEdgeInfo(g); mdl.edgeIds = edgeInfo.ids; - const auto faceInfo = getFaceIds(g); + const auto faceInfo = getFaceInfo(g); mdl.faceIds = faceInfo.ids; const auto loopUseInfo = getLoopUseInfo(g); From 30b1c0965f0f6d42a6fbdd715e33bf760d1cc7ab Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 15:40:50 -0400 Subject: [PATCH 35/78] wrong name --- src/Omega_h_simModel2d.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 9787a9342..a706c7bee 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -173,10 +173,10 @@ struct EntToAdjUse : public CSR { static_assert((mode == 0 || mode == 1), "countOrSet called with invalid mode"); OMEGA_H_TIME_FUNCTION; if constexpr (mode == 0 ) { - ScopedTimer timer("EntToAdjUse::set"); + ScopedTimer timer("EntToAdjUse::count"); incrementDegree(offset, entInfo.idToIdx, ent); } else { - ScopedTimer timer("EntToAdjUse::count"); + ScopedTimer timer("EntToAdjUse::set"); const auto entId = GEN_tag(ent); const auto entIdx = entInfo.idToIdx.at(entId); const auto useId = GEN_tag(use); From 66e0534fd1ef6d48a0ddf86a91601f79dd3919ce Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 15:45:43 -0400 Subject: [PATCH 36/78] don't copy the map... --- src/Omega_h_simModel2d.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index a706c7bee..d4480385c 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -118,11 +118,7 @@ EntInfo getLoopUseInfo(pGModel mdl) { return EntInfo{LOs(ids_h),idToIdx}; } -void incrementDegree(HostWrite& degree, std::map idToIdx, pGEntity ent) { - const auto id = GEN_tag(ent); - const auto idx = idToIdx.at(id); - degree[idx] = degree[idx]+1; -} + HostWrite createAndInitArray(size_t size, const LO init=0) { auto array = HostWrite(size); @@ -149,6 +145,9 @@ struct CSR { std::exclusive_scan(offset.data(), offset.data()+offset.size(), offset.data(), 0); values = createArray(offset[offset.size()-1]); }; + void incrementDegree(const int entIdx) { + offset[entIdx] = offset[entIdx]+1; + } void setValue(int entIdx, LO value) { OMEGA_H_TIME_FUNCTION; const auto adjIdx = offset[entIdx]; @@ -174,7 +173,9 @@ struct EntToAdjUse : public CSR { OMEGA_H_TIME_FUNCTION; if constexpr (mode == 0 ) { ScopedTimer timer("EntToAdjUse::count"); - incrementDegree(offset, entInfo.idToIdx, ent); + const auto entId = GEN_tag(ent); + const auto entIdx = entInfo.idToIdx.at(entId); + incrementDegree(entIdx); } else { ScopedTimer timer("EntToAdjUse::set"); const auto entId = GEN_tag(ent); From bfd5378ac1366e921482e2736f793202b20d3559 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 18 Mar 2024 16:34:23 -0400 Subject: [PATCH 37/78] initial info printing func --- src/Omega_h_model2d.cpp | 11 +++++++++++ src/Omega_h_model2d.hpp | 2 ++ src/Omega_h_simModel2d.cpp | 2 ++ 3 files changed, 15 insertions(+) diff --git a/src/Omega_h_model2d.cpp b/src/Omega_h_model2d.cpp index 4b92a8c2e..78bcc8dfb 100644 --- a/src/Omega_h_model2d.cpp +++ b/src/Omega_h_model2d.cpp @@ -1,4 +1,5 @@ #include "Omega_h_model2d.hpp" +#include namespace Omega_h { @@ -6,4 +7,14 @@ Model2D Model2D::MeshModel2D_load(Mesh2D& mesh) { return Model2D(); } +void Model2D::printInfo() { + std::cout << "==Model2d Info==\n"; + std::cout << "model entity type, count\n"; + std::cout << "vertices, " << vtxIds.size() << "\n"; + std::cout << "edges, " << edgeIds.size() << "\n"; + std::cout << "faces, " << faceIds.size() << "\n"; + std::cout << "edge use, " << edgeUseIds.size() << "\n"; + std::cout << "loop use, " << loopUseIds.size() << "\n"; +} + } // namespace Omega_h diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 33e64fa97..8c2f008be 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -16,8 +16,10 @@ class Model2D { static Model2D SimModel2D_load(std::string const& filename); #endif static Model2D MeshModel2D_load(Mesh2D& mesh); + void printInfo(); //ids LOs vtxIds /*x*/, edgeIds /*x*/, faceIds /*x*/; + LOs edgeUseIds, loopUseIds; //equal order adjacencies Graph edgeToEdgeUse; //downward adjacencies diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index d4480385c..e409b5359 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -256,6 +256,8 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto faceInfo = getFaceInfo(g); mdl.faceIds = faceInfo.ids; const auto loopUseInfo = getLoopUseInfo(g); + mdl.loopUseIds = loopUseInfo.ids; + mdl.edgeUseIds = LOs(0); //FIXME EntToAdjUse v2eu(vtxInfo); EntToAdjUse e2eu(edgeInfo); From 8c581e01b2befd03477d777209d0a682add8b656 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 19 Mar 2024 10:50:03 -0400 Subject: [PATCH 38/78] remove unused return --- src/Omega_h_simModel2d.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index e409b5359..ece8f2eda 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -199,7 +199,7 @@ struct EntToAdjUse : public CSR { * this info ... I've prepared some spaghetti below */ template -LOs getUses(pGModel mdl, +void getUses(pGModel mdl, EntToAdjUse& v2eu, EntToAdjUse& e2eu, EntToAdjUse& f2lu, @@ -234,8 +234,6 @@ LOs getUses(pGModel mdl, } //sides } GFIter_delete(modelFaces); - - return LOs(); } Model2D Model2D::SimModel2D_load(std::string const& filename) { From 947464963b777c7a2cca1ddfbc6e730e1493cc1c Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 19 Mar 2024 11:00:41 -0400 Subject: [PATCH 39/78] enum for modes --- src/Omega_h_simModel2d.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index ece8f2eda..3b889b645 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -159,6 +159,12 @@ struct CSR { CSR(); }; +enum GetUsesMode { + StoreIds = 0, + CountAdj = 1, + SetAdj = 2 +}; + template struct EntToAdjUse : public CSR { EntToAdjUse(const EntInfo& entInfo_in) @@ -167,11 +173,12 @@ struct EntToAdjUse : public CSR { const EntInfo& entInfo; std::map useIdToIdx; int useCount; - template + template void countOrSet(EntType ent, UseType use) { - static_assert((mode == 0 || mode == 1), "countOrSet called with invalid mode"); + static_assert((mode == GetUsesMode::CountAdj || mode == GetUsesMode::SetAdj), + "countOrSet called with invalid mode"); OMEGA_H_TIME_FUNCTION; - if constexpr (mode == 0 ) { + if constexpr (mode == GetUsesMode::CountAdj) { ScopedTimer timer("EntToAdjUse::count"); const auto entId = GEN_tag(ent); const auto entIdx = entInfo.idToIdx.at(entId); @@ -198,13 +205,15 @@ struct EntToAdjUse : public CSR { * SimModSuite has a limited set of APIs for accessing * this info ... I've prepared some spaghetti below */ -template +template void getUses(pGModel mdl, EntToAdjUse& v2eu, EntToAdjUse& e2eu, EntToAdjUse& f2lu, EntToAdjUse& lu2eu) { - static_assert((mode == 0 || mode == 1), "getUses called with invalid mode"); + static_assert((mode == GetUsesMode::StoreIds || + mode == GetUsesMode::CountAdj || + mode == GetUsesMode::SetAdj), "getUses called with invalid mode"); OMEGA_H_TIME_FUNCTION; GFIter modelFaces = GM_faceIter(mdl); @@ -262,12 +271,12 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { EntToAdjUse f2lu(faceInfo); EntToAdjUse lu2eu(loopUseInfo); - getUses<0>(g,v2eu,e2eu,f2lu,lu2eu); + getUses(g,v2eu,e2eu,f2lu,lu2eu); f2lu.degreeToOffset(); e2eu.degreeToOffset(); v2eu.degreeToOffset(); lu2eu.degreeToOffset(); - getUses<1>(g,v2eu,e2eu,f2lu,lu2eu); + getUses(g,v2eu,e2eu,f2lu,lu2eu); GM_release(g); return mdl; } From f1a0c0d7c1c4053d00bb283dde05d8a30f17809f Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 19 Mar 2024 14:34:25 -0400 Subject: [PATCH 40/78] visitor pattern WIP compiles, test segfaults --- src/Omega_h_simModel2d.cpp | 124 ++++++++++++++++++++++--------------- 1 file changed, 75 insertions(+), 49 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 3b889b645..00902bc6a 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -5,6 +5,7 @@ #include #include //std::fill #include //std::exclusive_scan +#include //std::visit, std::variant namespace Omega_h { @@ -29,6 +30,12 @@ struct VtxInfo : public EntInfo { Reals coords; }; +struct UseInfo : public EntInfo { + UseInfo() : idx(0) {} + std::vector ids; + int idx; +}; + VtxInfo getVtxInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; const auto numSpatialDims = 3; @@ -89,37 +96,6 @@ EntInfo getFaceInfo(pGModel mdl) { return EntInfo{LOs(ids_h), idToIdx}; } -EntInfo getLoopUseInfo(pGModel mdl) { - OMEGA_H_TIME_FUNCTION; - std::map idToIdx; - std::vector ids; - int numLoopUses = 0; - GFIter modelFaces = GM_faceIter(mdl); - int idx = 0; - pGFace modelFace; - while(modelFace=GFIter_next(modelFaces)) { - for(int side=0; side<2; side++) { - auto faceUse = GF_use(modelFace,side); - auto loopUses = GFU_loopIter(faceUse); - pGLoopUse loopUse; - while(loopUse=GLUIter_next(loopUses)) { - numLoopUses++; - const auto id = GEN_tag(loopUse); - ids.push_back(id); - idToIdx[id] = idx; - idx++; - } - GLUIter_delete(loopUses); - } //sides - } - GFIter_delete(modelFaces); - HostWrite ids_h(ids.size()); - for(int i=0; i createAndInitArray(size_t size, const LO init=0) { auto array = HostWrite(size); std::fill(array.data(), array.data()+array.size(), init); @@ -199,6 +175,63 @@ struct EntToAdjUse : public CSR { EntToAdjUse(); }; +struct Adjacencies { + EntToAdjUse& v2eu; + EntToAdjUse& e2eu; + EntToAdjUse& f2lu; + EntToAdjUse& lu2eu; +}; + +using VisitorTypes = std::variant< Adjacencies, UseInfo >; + +template +struct LoopUseVisitor { + LoopUseVisitor(pGFace modelFace, pGLoopUse loopUse) : + modelFace_(modelFace), loopUse_(loopUse) {} + void operator()(Adjacencies& adj) { + if constexpr ( Mode == GetUsesMode::CountAdj || Mode == GetUsesMode::SetAdj ) { //FIXME + adj.f2lu.countOrSet(modelFace_, loopUse_); + } else { + void(); + } + } + void operator()(UseInfo& useInfo) { + const auto id = GEN_tag(loopUse_); + useInfo.ids.push_back(id); + useInfo.idToIdx[id] = useInfo.idx; + useInfo.idx++; + } + pGFace modelFace_; + pGLoopUse loopUse_; +}; + +template +struct EdgeUseVisitor { + EdgeUseVisitor(pGLoopUse loopUse, pGEdgeUse edgeUse) : + loopUse_(loopUse), edgeUse_(edgeUse) {} + void operator()(Adjacencies& adj) { + if constexpr ( Mode == GetUsesMode::CountAdj || Mode == GetUsesMode::SetAdj ) { //FIXME + auto edge = GEU_edge(edgeUse_); + adj.lu2eu.countOrSet(loopUse_,edgeUse_); + adj.e2eu.countOrSet(edge,edgeUse_); + auto vtx0 = GE_vertex(edge,0); + adj.v2eu.countOrSet(vtx0,edgeUse_); + auto vtx1 = GE_vertex(edge,1); + adj.v2eu.countOrSet(vtx1,edgeUse_); + } else { + void(); + } + } + void operator()(UseInfo& useInfo) { + const auto id = GEN_tag(edgeUse_); + useInfo.ids.push_back(id); + useInfo.idToIdx[id] = useInfo.idx; + useInfo.idx++; + } + pGLoopUse loopUse_; + pGEdgeUse edgeUse_; +}; + /* * retrieve the entity-to-use adjacencies * @@ -206,11 +239,7 @@ struct EntToAdjUse : public CSR { * this info ... I've prepared some spaghetti below */ template -void getUses(pGModel mdl, - EntToAdjUse& v2eu, - EntToAdjUse& e2eu, - EntToAdjUse& f2lu, - EntToAdjUse& lu2eu) { +void traverseUses(pGModel mdl, VisitorTypes visitorTypes) { static_assert((mode == GetUsesMode::StoreIds || mode == GetUsesMode::CountAdj || mode == GetUsesMode::SetAdj), "getUses called with invalid mode"); @@ -225,17 +254,11 @@ void getUses(pGModel mdl, auto loopUses = GFU_loopIter(faceUse); pGLoopUse loopUse; while(loopUse=GLUIter_next(loopUses)) { - f2lu.countOrSet(modelFace,loopUse); + std::visit(LoopUseVisitor{modelFace, loopUse}, visitorTypes); auto edgeUses = GLU_edgeUseIter(loopUse); pGEdgeUse edgeUse; while(edgeUse=GEUIter_next(edgeUses)) { - lu2eu.countOrSet(loopUse,edgeUse); - auto edge = GEU_edge(edgeUse); - e2eu.countOrSet(edge,edgeUse); - auto vtx0 = GE_vertex(edge,0); - v2eu.countOrSet(vtx0,edgeUse); - auto vtx1 = GE_vertex(edge,1); - v2eu.countOrSet(vtx1,edgeUse); + std::visit(EdgeUseVisitor{loopUse, edgeUse}, visitorTypes); } GEUIter_delete(edgeUses); } @@ -262,21 +285,24 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.edgeIds = edgeInfo.ids; const auto faceInfo = getFaceInfo(g); mdl.faceIds = faceInfo.ids; - const auto loopUseInfo = getLoopUseInfo(g); - mdl.loopUseIds = loopUseInfo.ids; - mdl.edgeUseIds = LOs(0); //FIXME + auto loopUseInfo = UseInfo(); + traverseUses(g,VisitorTypes{loopUseInfo}); + auto edgeUseInfo = UseInfo(); + traverseUses(g,VisitorTypes{edgeUseInfo}); EntToAdjUse v2eu(vtxInfo); EntToAdjUse e2eu(edgeInfo); EntToAdjUse f2lu(faceInfo); EntToAdjUse lu2eu(loopUseInfo); + Adjacencies adj{v2eu, e2eu, f2lu, lu2eu}; - getUses(g,v2eu,e2eu,f2lu,lu2eu); + VisitorTypes adjType{adj}; + traverseUses(g,adjType); f2lu.degreeToOffset(); e2eu.degreeToOffset(); v2eu.degreeToOffset(); lu2eu.degreeToOffset(); - getUses(g,v2eu,e2eu,f2lu,lu2eu); + traverseUses(g,adjType); GM_release(g); return mdl; } From 5f830dadaf4833ef09b9b8f3e7da1344e2a6da5f Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 20 Mar 2024 15:06:12 -0400 Subject: [PATCH 41/78] distinguish between edge and loop, value semantics not preserving state --- src/Omega_h_simModel2d.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 00902bc6a..ee319bbe2 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -36,6 +36,12 @@ struct UseInfo : public EntInfo { int idx; }; +struct LoopUseInfo : public UseInfo { +}; + +struct EdgeUseInfo : public UseInfo { +}; + VtxInfo getVtxInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; const auto numSpatialDims = 3; @@ -182,7 +188,7 @@ struct Adjacencies { EntToAdjUse& lu2eu; }; -using VisitorTypes = std::variant< Adjacencies, UseInfo >; +using VisitorTypes = std::variant< Adjacencies, LoopUseInfo, EdgeUseInfo >; template struct LoopUseVisitor { @@ -195,12 +201,14 @@ struct LoopUseVisitor { void(); } } - void operator()(UseInfo& useInfo) { + void operator()(LoopUseInfo& useInfo) { const auto id = GEN_tag(loopUse_); useInfo.ids.push_back(id); useInfo.idToIdx[id] = useInfo.idx; useInfo.idx++; } + void operator()(EdgeUseInfo&) { + } pGFace modelFace_; pGLoopUse loopUse_; }; @@ -222,12 +230,14 @@ struct EdgeUseVisitor { void(); } } - void operator()(UseInfo& useInfo) { + void operator()(EdgeUseInfo& useInfo) { const auto id = GEN_tag(edgeUse_); useInfo.ids.push_back(id); useInfo.idToIdx[id] = useInfo.idx; useInfo.idx++; } + void operator()(LoopUseInfo&) { + } pGLoopUse loopUse_; pGEdgeUse edgeUse_; }; @@ -285,9 +295,9 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { mdl.edgeIds = edgeInfo.ids; const auto faceInfo = getFaceInfo(g); mdl.faceIds = faceInfo.ids; - auto loopUseInfo = UseInfo(); + auto loopUseInfo = LoopUseInfo(); traverseUses(g,VisitorTypes{loopUseInfo}); - auto edgeUseInfo = UseInfo(); + auto edgeUseInfo = EdgeUseInfo(); traverseUses(g,VisitorTypes{edgeUseInfo}); EntToAdjUse v2eu(vtxInfo); From 11a1953fe18bd35ed17eeb6141fde9f48c757bfd Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 10:52:18 -0400 Subject: [PATCH 42/78] use template-based method instead of visitor there is an overhead for the virtual functions, since this is called once it isn't critical --- src/Omega_h_simModel2d.cpp | 206 ++++++++++++++++++++----------------- 1 file changed, 113 insertions(+), 93 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index ee319bbe2..d11bdbb7b 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -32,15 +32,20 @@ struct VtxInfo : public EntInfo { struct UseInfo : public EntInfo { UseInfo() : idx(0) {} - std::vector ids; + std::vector ids_h; int idx; + void idsToDevice() { + auto array = HostWrite(ids_h.size()); + std::copy(ids_h.begin(), ids_h.end(), array.data()); +// for(int i=0; i& v2eu; EntToAdjUse& e2eu; @@ -188,95 +252,47 @@ struct Adjacencies { EntToAdjUse& lu2eu; }; -using VisitorTypes = std::variant< Adjacencies, LoopUseInfo, EdgeUseInfo >; +struct CountUses : public ITraverseUses { + Adjacencies& adj_; + CountUses(Adjacencies& adj) : adj_(adj) {} -template -struct LoopUseVisitor { - LoopUseVisitor(pGFace modelFace, pGLoopUse loopUse) : - modelFace_(modelFace), loopUse_(loopUse) {} - void operator()(Adjacencies& adj) { - if constexpr ( Mode == GetUsesMode::CountAdj || Mode == GetUsesMode::SetAdj ) { //FIXME - adj.f2lu.countOrSet(modelFace_, loopUse_); - } else { - void(); - } + void loopUseOperator(pGFace modelFace, pGLoopUse loopUse) override { + const auto Mode = GetUsesMode::CountAdj; + adj_.f2lu.countOrSet(modelFace, loopUse); } - void operator()(LoopUseInfo& useInfo) { - const auto id = GEN_tag(loopUse_); - useInfo.ids.push_back(id); - useInfo.idToIdx[id] = useInfo.idx; - useInfo.idx++; - } - void operator()(EdgeUseInfo&) { - } - pGFace modelFace_; - pGLoopUse loopUse_; -}; -template -struct EdgeUseVisitor { - EdgeUseVisitor(pGLoopUse loopUse, pGEdgeUse edgeUse) : - loopUse_(loopUse), edgeUse_(edgeUse) {} - void operator()(Adjacencies& adj) { - if constexpr ( Mode == GetUsesMode::CountAdj || Mode == GetUsesMode::SetAdj ) { //FIXME - auto edge = GEU_edge(edgeUse_); - adj.lu2eu.countOrSet(loopUse_,edgeUse_); - adj.e2eu.countOrSet(edge,edgeUse_); - auto vtx0 = GE_vertex(edge,0); - adj.v2eu.countOrSet(vtx0,edgeUse_); - auto vtx1 = GE_vertex(edge,1); - adj.v2eu.countOrSet(vtx1,edgeUse_); - } else { - void(); - } - } - void operator()(EdgeUseInfo& useInfo) { - const auto id = GEN_tag(edgeUse_); - useInfo.ids.push_back(id); - useInfo.idToIdx[id] = useInfo.idx; - useInfo.idx++; - } - void operator()(LoopUseInfo&) { + virtual void edgeUseOperator(pGLoopUse loopUse, pGEdgeUse edgeUse) override { + const auto Mode = GetUsesMode::CountAdj; + auto edge = GEU_edge(edgeUse); + adj_.lu2eu.countOrSet(loopUse,edgeUse); + adj_.e2eu.countOrSet(edge,edgeUse); + auto vtx0 = GE_vertex(edge,0); + adj_.v2eu.countOrSet(vtx0,edgeUse); + auto vtx1 = GE_vertex(edge,1); + adj_.v2eu.countOrSet(vtx1,edgeUse); } - pGLoopUse loopUse_; - pGEdgeUse edgeUse_; }; -/* - * retrieve the entity-to-use adjacencies - * - * SimModSuite has a limited set of APIs for accessing - * this info ... I've prepared some spaghetti below - */ -template -void traverseUses(pGModel mdl, VisitorTypes visitorTypes) { - static_assert((mode == GetUsesMode::StoreIds || - mode == GetUsesMode::CountAdj || - mode == GetUsesMode::SetAdj), "getUses called with invalid mode"); - OMEGA_H_TIME_FUNCTION; +struct SetUses : public ITraverseUses { + Adjacencies& adj_; + SetUses(Adjacencies& adj) : adj_(adj) {} - GFIter modelFaces = GM_faceIter(mdl); - int idx = 0; - pGFace modelFace; - while(modelFace=GFIter_next(modelFaces)) { - for(int side=0; side<2; side++) { - auto faceUse = GF_use(modelFace,side); - auto loopUses = GFU_loopIter(faceUse); - pGLoopUse loopUse; - while(loopUse=GLUIter_next(loopUses)) { - std::visit(LoopUseVisitor{modelFace, loopUse}, visitorTypes); - auto edgeUses = GLU_edgeUseIter(loopUse); - pGEdgeUse edgeUse; - while(edgeUse=GEUIter_next(edgeUses)) { - std::visit(EdgeUseVisitor{loopUse, edgeUse}, visitorTypes); - } - GEUIter_delete(edgeUses); - } - GLUIter_delete(loopUses); - } //sides + void loopUseOperator(pGFace modelFace, pGLoopUse loopUse) override { + const auto Mode = GetUsesMode::SetAdj; + adj_.f2lu.countOrSet(modelFace, loopUse); } - GFIter_delete(modelFaces); -} + + virtual void edgeUseOperator(pGLoopUse loopUse, pGEdgeUse edgeUse) override { + const auto Mode = GetUsesMode::SetAdj; + auto edge = GEU_edge(edgeUse); + adj_.lu2eu.countOrSet(loopUse,edgeUse); + adj_.e2eu.countOrSet(edge,edgeUse); + auto vtx0 = GE_vertex(edge,0); + adj_.v2eu.countOrSet(vtx0,edgeUse); + auto vtx1 = GE_vertex(edge,1); + adj_.v2eu.countOrSet(vtx1,edgeUse); + } +}; Model2D Model2D::SimModel2D_load(std::string const& filename) { OMEGA_H_TIME_FUNCTION; @@ -296,9 +312,11 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto faceInfo = getFaceInfo(g); mdl.faceIds = faceInfo.ids; auto loopUseInfo = LoopUseInfo(); - traverseUses(g,VisitorTypes{loopUseInfo}); auto edgeUseInfo = EdgeUseInfo(); - traverseUses(g,VisitorTypes{edgeUseInfo}); + SetUseIds setUseIds(loopUseInfo, edgeUseInfo); + setUseIds.run(g); + loopUseInfo.idsToDevice(); + edgeUseInfo.idsToDevice(); EntToAdjUse v2eu(vtxInfo); EntToAdjUse e2eu(edgeInfo); @@ -306,13 +324,15 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { EntToAdjUse lu2eu(loopUseInfo); Adjacencies adj{v2eu, e2eu, f2lu, lu2eu}; - VisitorTypes adjType{adj}; - traverseUses(g,adjType); + CountUses countUses(adj); + countUses.run(g); f2lu.degreeToOffset(); e2eu.degreeToOffset(); v2eu.degreeToOffset(); lu2eu.degreeToOffset(); - traverseUses(g,adjType); + SetUses setUses(adj); + setUses.run(g); + GM_release(g); return mdl; } From 4ef8665687b2cdd706684be7cc9d07f487c3ef76 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 11:56:03 -0400 Subject: [PATCH 43/78] set use ids --- src/Omega_h_simModel2d.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index d11bdbb7b..3ea29ae8b 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -317,6 +317,8 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { setUseIds.run(g); loopUseInfo.idsToDevice(); edgeUseInfo.idsToDevice(); + mdl.loopUseIds = loopUseInfo.ids; + mdl.edgeUseIds = edgeUseInfo.ids; EntToAdjUse v2eu(vtxInfo); EntToAdjUse e2eu(edgeInfo); From 84d21b405c7ef15151c3dd8e5838131767742df3 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 13:42:04 -0400 Subject: [PATCH 44/78] set model info WIP need beeter interface --- src/Omega_h_simModel2d.cpp | 51 ++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 3ea29ae8b..02572b94b 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -30,6 +30,9 @@ struct VtxInfo : public EntInfo { Reals coords; }; +struct EdgeInfo : public EntInfo {}; +struct FaceInfo : public EntInfo {}; + struct UseInfo : public EntInfo { UseInfo() : idx(0) {} std::vector ids_h; @@ -71,7 +74,7 @@ VtxInfo getVtxInfo(pGModel mdl) { return VtxInfo{LOs(vtxIds_h), idToIdx, Reals(vtxCoords_h)}; } -EntInfo getEdgeInfo(pGModel mdl) { +EdgeInfo getEdgeInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; std::map idToIdx; const auto numEdges = GM_numEdges(mdl); @@ -86,10 +89,10 @@ EntInfo getEdgeInfo(pGModel mdl) { idx++; } GEIter_delete(modelEdges); - return EntInfo{LOs(ids_h),idToIdx}; + return EdgeInfo{LOs(ids_h),idToIdx}; } -EntInfo getFaceInfo(pGModel mdl) { +FaceInfo getFaceInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; std::map idToIdx; auto numFaces = GM_numFaces(mdl); @@ -104,7 +107,7 @@ EntInfo getFaceInfo(pGModel mdl) { idx++; } GFIter_delete(modelFaces); - return EntInfo{LOs(ids_h), idToIdx}; + return FaceInfo{LOs(ids_h), idToIdx}; } HostWrite createAndInitArray(size_t size, const LO init=0) { @@ -294,6 +297,30 @@ struct SetUses : public ITraverseUses { } }; +void setVertexInfo(Model2D& mdl, const VtxInfo& vtxInfo) { + mdl.vtxIds = vtxInfo.ids; + mdl.vtxCoords = vtxInfo.coords; +} + +void setEdgeIds(Model2D& mdl, const EdgeInfo& edgeInfo) { + mdl.edgeIds = edgeInfo.ids; +} + +void setFaceIds(Model2D& mdl, const FaceInfo& faceInfo) { + mdl.faceIds = faceInfo.ids; +} + +void setLoopUseIds(Model2D& mdl, const LoopUseInfo& loopUseInfo) { + mdl.loopUseIds = loopUseInfo.ids; +} + +void setEdgeUseIds(Model2D& mdl, const EdgeUseInfo& edgeUseInfo) { + mdl.edgeUseIds = edgeUseInfo.ids; +} + +void setAdjInfo(Model2D& mdl, Adjacencies& adj) { +} + Model2D Model2D::SimModel2D_load(std::string const& filename) { OMEGA_H_TIME_FUNCTION; pNativeModel nm = NULL; @@ -303,22 +330,15 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { OMEGA_H_CHECK_MSG(isModel2D(g), msg2d); const char* msgValid = "Simmetrix GeomSim model is not valid... exiting\n"; OMEGA_H_CHECK_MSG(isValid(g), msgValid); - auto mdl = Model2D(); const auto vtxInfo = getVtxInfo(g); - mdl.vtxIds = vtxInfo.ids; - mdl.vtxCoords = vtxInfo.coords; const auto edgeInfo = getEdgeInfo(g); - mdl.edgeIds = edgeInfo.ids; const auto faceInfo = getFaceInfo(g); - mdl.faceIds = faceInfo.ids; auto loopUseInfo = LoopUseInfo(); auto edgeUseInfo = EdgeUseInfo(); SetUseIds setUseIds(loopUseInfo, edgeUseInfo); setUseIds.run(g); loopUseInfo.idsToDevice(); edgeUseInfo.idsToDevice(); - mdl.loopUseIds = loopUseInfo.ids; - mdl.edgeUseIds = edgeUseInfo.ids; EntToAdjUse v2eu(vtxInfo); EntToAdjUse e2eu(edgeInfo); @@ -335,6 +355,15 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { SetUses setUses(adj); setUses.run(g); + //setup model + auto mdl = Model2D(); + setVertexInfo(mdl, vtxInfo); + setEdgeIds(mdl, edgeInfo); + setFaceIds(mdl, faceInfo); + setLoopUseIds(mdl, loopUseInfo); + setEdgeUseIds(mdl, edgeUseInfo); + setAdjInfo(mdl, adj); + GM_release(g); return mdl; } From 7c587b62f81a331efabbdbaf34b188b0c4898c5a Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 14:16:29 -0400 Subject: [PATCH 45/78] templates w/ check for required funcs this is policy method like, but limits the ducktyping with a static assert to check for the required functions. This has no virtual function call overhead like the prior solution --- src/Omega_h_simModel2d.cpp | 80 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 02572b94b..372f99183 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -194,53 +194,51 @@ struct EntToAdjUse : public CSR { * SimModSuite has a limited set of APIs for accessing * this info ... I've prepared some spaghetti below */ -struct ITraverseUses { - // abstract operators - virtual void loopUseOperator(pGFace modelFace, pGLoopUse loopUse) = 0; - virtual void edgeUseOperator(pGLoopUse loopUse, pGEdgeUse edgeUse) = 0; - - // algorithm that calls abstract operators - virtual void run(pGModel mdl) final { - OMEGA_H_TIME_FUNCTION; +template +void traverseUses(pGModel mdl, Operator& op) { + static_assert( std::is_invocable_v ); + static_assert( std::is_invocable_v ); + OMEGA_H_TIME_FUNCTION; - GFIter modelFaces = GM_faceIter(mdl); - int idx = 0; - pGFace modelFace; - while(modelFace=GFIter_next(modelFaces)) { - for(int side=0; side<2; side++) { - auto faceUse = GF_use(modelFace,side); - auto loopUses = GFU_loopIter(faceUse); - pGLoopUse loopUse; - while(loopUse=GLUIter_next(loopUses)) { - loopUseOperator(modelFace, loopUse); - auto edgeUses = GLU_edgeUseIter(loopUse); - pGEdgeUse edgeUse; - while(edgeUse=GEUIter_next(edgeUses)) { - edgeUseOperator(loopUse, edgeUse); - } - GEUIter_delete(edgeUses); + GFIter modelFaces = GM_faceIter(mdl); + int idx = 0; + pGFace modelFace; + while(modelFace=GFIter_next(modelFaces)) { + for(int side=0; side<2; side++) { + auto faceUse = GF_use(modelFace,side); + auto loopUses = GFU_loopIter(faceUse); + pGLoopUse loopUse; + while(loopUse=GLUIter_next(loopUses)) { + op.loopUseOp(modelFace, loopUse); + auto edgeUses = GLU_edgeUseIter(loopUse); + pGEdgeUse edgeUse; + while(edgeUse=GEUIter_next(edgeUses)) { + op.edgeUseOp(loopUse, edgeUse); } - GLUIter_delete(loopUses); - } //sides - } - GFIter_delete(modelFaces); + GEUIter_delete(edgeUses); + } + GLUIter_delete(loopUses); + } //sides } -}; + GFIter_delete(modelFaces); +} -struct SetUseIds : public ITraverseUses { +struct SetUseIds { LoopUseInfo& loopUseInfo_; EdgeUseInfo& edgeUseInfo_; SetUseIds(LoopUseInfo& loopUseInfo, EdgeUseInfo& edgeUseInfo) : loopUseInfo_(loopUseInfo), edgeUseInfo_(edgeUseInfo) {} - void loopUseOperator(pGFace modelFace, pGLoopUse loopUse) override { + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto id = GEN_tag(loopUse); loopUseInfo_.ids_h.push_back(id); loopUseInfo_.idToIdx[id] = loopUseInfo_.idx; loopUseInfo_.idx++; } - virtual void edgeUseOperator(pGLoopUse loopUse, pGEdgeUse edgeUse) override { + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto id = GEN_tag(edgeUse); edgeUseInfo_.ids_h.push_back(id); edgeUseInfo_.idToIdx[id] = edgeUseInfo_.idx; @@ -255,16 +253,16 @@ struct Adjacencies { EntToAdjUse& lu2eu; }; -struct CountUses : public ITraverseUses { +struct CountUses { Adjacencies& adj_; CountUses(Adjacencies& adj) : adj_(adj) {} - void loopUseOperator(pGFace modelFace, pGLoopUse loopUse) override { + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto Mode = GetUsesMode::CountAdj; adj_.f2lu.countOrSet(modelFace, loopUse); } - virtual void edgeUseOperator(pGLoopUse loopUse, pGEdgeUse edgeUse) override { + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto Mode = GetUsesMode::CountAdj; auto edge = GEU_edge(edgeUse); adj_.lu2eu.countOrSet(loopUse,edgeUse); @@ -276,16 +274,16 @@ struct CountUses : public ITraverseUses { } }; -struct SetUses : public ITraverseUses { +struct SetUses { Adjacencies& adj_; SetUses(Adjacencies& adj) : adj_(adj) {} - void loopUseOperator(pGFace modelFace, pGLoopUse loopUse) override { + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto Mode = GetUsesMode::SetAdj; adj_.f2lu.countOrSet(modelFace, loopUse); } - virtual void edgeUseOperator(pGLoopUse loopUse, pGEdgeUse edgeUse) override { + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto Mode = GetUsesMode::SetAdj; auto edge = GEU_edge(edgeUse); adj_.lu2eu.countOrSet(loopUse,edgeUse); @@ -336,7 +334,7 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { auto loopUseInfo = LoopUseInfo(); auto edgeUseInfo = EdgeUseInfo(); SetUseIds setUseIds(loopUseInfo, edgeUseInfo); - setUseIds.run(g); + traverseUses(g, setUseIds); loopUseInfo.idsToDevice(); edgeUseInfo.idsToDevice(); @@ -347,13 +345,13 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { Adjacencies adj{v2eu, e2eu, f2lu, lu2eu}; CountUses countUses(adj); - countUses.run(g); + traverseUses(g, countUses); f2lu.degreeToOffset(); e2eu.degreeToOffset(); v2eu.degreeToOffset(); lu2eu.degreeToOffset(); SetUses setUses(adj); - setUses.run(g); + traverseUses(g, setUses); //setup model auto mdl = Model2D(); From 3ea06c865683aa022ce500f4e2e4968821fb21ef Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 14:31:59 -0400 Subject: [PATCH 46/78] create omegah graphs --- src/Omega_h_simModel2d.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 372f99183..953ff9ef1 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -317,6 +317,16 @@ void setEdgeUseIds(Model2D& mdl, const EdgeUseInfo& edgeUseInfo) { } void setAdjInfo(Model2D& mdl, Adjacencies& adj) { + mdl.vtxToEdgeUse = Graph(LOs(adj.v2eu.offset), LOs(adj.v2eu.values)); + mdl.edgeToEdgeUse = Graph(LOs(adj.e2eu.offset), LOs(adj.e2eu.values)); + mdl.faceToLoopUse = Graph(LOs(adj.f2lu.offset), LOs(adj.f2lu.values)); + mdl.loopUseToEdgeUse = Graph(LOs(adj.lu2eu.offset), LOs(adj.lu2eu.values)); + //TODO + //LOs edgeUseToVtx + //LOs edgeUseToLoopUse + //LOs loopUseToFace + //LOs edgeUseOrientation + //LOs loopUseOrientation } Model2D Model2D::SimModel2D_load(std::string const& filename) { From 33fbe73bff386b71ea8d13d7d7362f3f593d6b91 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 16:28:36 -0400 Subject: [PATCH 47/78] inversions WIP --- src/Omega_h_model2d.hpp | 2 +- src/Omega_h_simModel2d.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 8c2f008be..a2dd71e46 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -25,7 +25,7 @@ class Model2D { //downward adjacencies Graph faceToLoopUse; Graph loopUseToEdgeUse; - LOs edgeUseToVtx; + LOs edgeUseToVtx; //each edgeUse has exactly two adjacent vertices //upward adjacencies Graph vtxToEdgeUse; LOs edgeUseToLoopUse; diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 953ff9ef1..67a862648 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -2,6 +2,8 @@ #include #include "Omega_h_model2d.hpp" #include "Omega_h_profile.hpp" +#include "Omega_h_map.hpp" // invert_map_by_atomics +#include "Omega_h_array_ops.hpp" // operator==(LOs,LOs) #include #include //std::fill #include //std::exclusive_scan @@ -321,8 +323,20 @@ void setAdjInfo(Model2D& mdl, Adjacencies& adj) { mdl.edgeToEdgeUse = Graph(LOs(adj.e2eu.offset), LOs(adj.e2eu.values)); mdl.faceToLoopUse = Graph(LOs(adj.f2lu.offset), LOs(adj.f2lu.values)); mdl.loopUseToEdgeUse = Graph(LOs(adj.lu2eu.offset), LOs(adj.lu2eu.values)); + + LOs two(deg.size(),2); + const auto eu2v = invert_map_by_atomics(mdl.vtxToEdgeUse.ab2b, mdl.edgeUseIds.size()); + LOs deg = get_degrees(eu2v.a2ab); + assert(deg == two); + mdl.edgeUseToVtx = eu2v.ab2b; + + const auto eu2lu = invert_map_by_atomics(mdl.loopUseToEdgeUse.ab2b, mdl.edgeUseIds.size()); + LOs deg = get_degrees(eu2lu.a2ab); + assert(deg == two); //HERE FIXME + mdl.edgeUseToVtx = eu2v.ab2b; + + //TODO - //LOs edgeUseToVtx //LOs edgeUseToLoopUse //LOs loopUseToFace //LOs edgeUseOrientation From 62721c0537b44092a006e534b7e0c903999c8ad6 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 20:49:31 -0400 Subject: [PATCH 48/78] comments noting degree for adjacencies --- src/Omega_h_model2d.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index a2dd71e46..811ae401b 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -28,8 +28,8 @@ class Model2D { LOs edgeUseToVtx; //each edgeUse has exactly two adjacent vertices //upward adjacencies Graph vtxToEdgeUse; - LOs edgeUseToLoopUse; - LOs loopUseToFace; + LOs edgeUseToLoopUse; //each edgeUse has one adjacent loop use + LOs loopUseToFace; //each loopUse has one adjacent face use //use orientation LOs edgeUseOrientation, loopUseOrientation; //geometry From 2add3c99ad0f73e845f93d64fd49f6f2beb77eeb Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 20:50:33 -0400 Subject: [PATCH 49/78] remaining adjacencies --- src/Omega_h_simModel2d.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 67a862648..268339eb3 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -324,21 +324,22 @@ void setAdjInfo(Model2D& mdl, Adjacencies& adj) { mdl.faceToLoopUse = Graph(LOs(adj.f2lu.offset), LOs(adj.f2lu.values)); mdl.loopUseToEdgeUse = Graph(LOs(adj.lu2eu.offset), LOs(adj.lu2eu.values)); - LOs two(deg.size(),2); const auto eu2v = invert_map_by_atomics(mdl.vtxToEdgeUse.ab2b, mdl.edgeUseIds.size()); LOs deg = get_degrees(eu2v.a2ab); - assert(deg == two); + assert(deg == LOs(deg.size(),2)); mdl.edgeUseToVtx = eu2v.ab2b; const auto eu2lu = invert_map_by_atomics(mdl.loopUseToEdgeUse.ab2b, mdl.edgeUseIds.size()); - LOs deg = get_degrees(eu2lu.a2ab); - assert(deg == two); //HERE FIXME - mdl.edgeUseToVtx = eu2v.ab2b; + deg = get_degrees(eu2lu.a2ab); + assert(deg == LOs(deg.size(),1)); + mdl.edgeUseToLoopUse = eu2lu.ab2b; + const auto lu2f = invert_map_by_atomics(mdl.faceToLoopUse.ab2b, mdl.loopUseIds.size()); + deg = get_degrees(lu2f.a2ab); + assert(deg == LOs(deg.size(),1)); + mdl.loopUseToFace = lu2f.ab2b; //TODO - //LOs edgeUseToLoopUse - //LOs loopUseToFace //LOs edgeUseOrientation //LOs loopUseOrientation } From be298f3f7fec3c3d5b94b33f43ebbd8e789bbe00 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 21:23:07 -0400 Subject: [PATCH 50/78] unused header --- src/Omega_h_simModel2d.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 268339eb3..78981294e 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -7,7 +7,6 @@ #include #include //std::fill #include //std::exclusive_scan -#include //std::visit, std::variant namespace Omega_h { From 9d5d8d751aad5fa52c0ca0e02784e12edabdba40 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 21:23:44 -0400 Subject: [PATCH 51/78] documentation for orientation arrays --- src/Omega_h_model2d.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 811ae401b..a19343b28 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -30,8 +30,12 @@ class Model2D { Graph vtxToEdgeUse; LOs edgeUseToLoopUse; //each edgeUse has one adjacent loop use LOs loopUseToFace; //each loopUse has one adjacent face use - //use orientation - LOs edgeUseOrientation, loopUseOrientation; + //for each edgeUse, indicates which vertex in the associated edge + //is the 'head’ vertex + LOs edgeUseOrientation; + //for each loopUse, indicates forward or backward traversal order + //of the edgeUses belonging to the loop + LOs loopUseOrientation; //geometry Real vtxTol, edgeTol; Reals vtxCoords; //x From 30386daa0d10021bc9677a535dcd16afa07e72b8 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 21 Mar 2024 21:29:28 -0400 Subject: [PATCH 52/78] remove commented code --- src/Omega_h_simModel2d.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 78981294e..c395a2d3b 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -41,9 +41,6 @@ struct UseInfo : public EntInfo { void idsToDevice() { auto array = HostWrite(ids_h.size()); std::copy(ids_h.begin(), ids_h.end(), array.data()); -// for(int i=0; i Date: Thu, 21 Mar 2024 22:24:37 -0400 Subject: [PATCH 53/78] edge use dir needs refactor --- src/Omega_h_simModel2d.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index c395a2d3b..de379c432 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -45,8 +45,13 @@ struct UseInfo : public EntInfo { } }; -struct LoopUseInfo : public UseInfo {}; -struct EdgeUseInfo : public UseInfo {}; +struct LoopUseInfo : public UseInfo { + HostWrite ludir; +}; + +struct EdgeUseInfo : public UseInfo { + HostWrite eudir; +}; VtxInfo getVtxInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; @@ -244,6 +249,25 @@ struct SetUseIds { } }; +struct SetUseDir { + LoopUseInfo& loopUseInfo_; + EdgeUseInfo& edgeUseInfo_; + SetUseDir(LoopUseInfo& loopUseInfo, EdgeUseInfo& edgeUseInfo) + : loopUseInfo_(loopUseInfo), edgeUseInfo_(edgeUseInfo) {} + + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { + //FIXME + } + + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { + const auto id = GEN_tag(edgeUse); + const auto idx = edgeUseInfo_.idToIdx.at(id); + const auto edge = GEU_edge(edgeUse); + const int dir = GE_geomDir(edge); + edgeUseInfo_.eudir[idx] = dir; + } +}; + struct Adjacencies { EntToAdjUse& v2eu; EntToAdjUse& e2eu; @@ -336,7 +360,6 @@ void setAdjInfo(Model2D& mdl, Adjacencies& adj) { mdl.loopUseToFace = lu2f.ab2b; //TODO - //LOs edgeUseOrientation //LOs loopUseOrientation } @@ -359,10 +382,16 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { loopUseInfo.idsToDevice(); edgeUseInfo.idsToDevice(); + edgeUseInfo.eudir = createArray(edgeUseInfo.ids.size()); //FIXME + SetUseDir setUseDir(loopUseInfo, edgeUseInfo); + traverseUses(g, setUseDir); + EntToAdjUse v2eu(vtxInfo); EntToAdjUse e2eu(edgeInfo); EntToAdjUse f2lu(faceInfo); EntToAdjUse lu2eu(loopUseInfo); + auto eudir = createArray(edgeUseInfo.ids.size()); + auto ludir = createArray(loopUseInfo.ids.size()); Adjacencies adj{v2eu, e2eu, f2lu, lu2eu}; CountUses countUses(adj); @@ -381,6 +410,7 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { setFaceIds(mdl, faceInfo); setLoopUseIds(mdl, loopUseInfo); setEdgeUseIds(mdl, edgeUseInfo); + mdl.edgeUseOrientation = LOs(edgeUseInfo.eudir); //FIXME setAdjInfo(mdl, adj); GM_release(g); From aafda30813316d8b77cedc439bdad67f23f377c1 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 22 Mar 2024 12:38:42 -0400 Subject: [PATCH 54/78] move adj work into ctor --- src/Omega_h_simModel2d.cpp | 113 +++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index de379c432..a00d89505 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -269,51 +269,64 @@ struct SetUseDir { }; struct Adjacencies { - EntToAdjUse& v2eu; - EntToAdjUse& e2eu; - EntToAdjUse& f2lu; - EntToAdjUse& lu2eu; -}; + EntToAdjUse v2eu; + EntToAdjUse e2eu; + EntToAdjUse f2lu; + EntToAdjUse lu2eu; + + struct CountUses { + Adjacencies& adj_; + CountUses(Adjacencies& adj) : adj_(adj) {} + + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { + const auto Mode = GetUsesMode::CountAdj; + adj_.f2lu.countOrSet(modelFace, loopUse); + } -struct CountUses { - Adjacencies& adj_; - CountUses(Adjacencies& adj) : adj_(adj) {} + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { + const auto Mode = GetUsesMode::CountAdj; + auto edge = GEU_edge(edgeUse); + adj_.lu2eu.countOrSet(loopUse,edgeUse); + adj_.e2eu.countOrSet(edge,edgeUse); + auto vtx0 = GE_vertex(edge,0); + adj_.v2eu.countOrSet(vtx0,edgeUse); + auto vtx1 = GE_vertex(edge,1); + adj_.v2eu.countOrSet(vtx1,edgeUse); + } + }; - void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { - const auto Mode = GetUsesMode::CountAdj; - adj_.f2lu.countOrSet(modelFace, loopUse); - } + struct SetUses { + Adjacencies& adj_; + SetUses(Adjacencies& adj) : adj_(adj) {} - void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { - const auto Mode = GetUsesMode::CountAdj; - auto edge = GEU_edge(edgeUse); - adj_.lu2eu.countOrSet(loopUse,edgeUse); - adj_.e2eu.countOrSet(edge,edgeUse); - auto vtx0 = GE_vertex(edge,0); - adj_.v2eu.countOrSet(vtx0,edgeUse); - auto vtx1 = GE_vertex(edge,1); - adj_.v2eu.countOrSet(vtx1,edgeUse); - } -}; - -struct SetUses { - Adjacencies& adj_; - SetUses(Adjacencies& adj) : adj_(adj) {} + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { + const auto Mode = GetUsesMode::SetAdj; + adj_.f2lu.countOrSet(modelFace, loopUse); + } - void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { - const auto Mode = GetUsesMode::SetAdj; - adj_.f2lu.countOrSet(modelFace, loopUse); - } + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { + const auto Mode = GetUsesMode::SetAdj; + auto edge = GEU_edge(edgeUse); + adj_.lu2eu.countOrSet(loopUse,edgeUse); + adj_.e2eu.countOrSet(edge,edgeUse); + auto vtx0 = GE_vertex(edge,0); + adj_.v2eu.countOrSet(vtx0,edgeUse); + auto vtx1 = GE_vertex(edge,1); + adj_.v2eu.countOrSet(vtx1,edgeUse); + } + }; - void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { - const auto Mode = GetUsesMode::SetAdj; - auto edge = GEU_edge(edgeUse); - adj_.lu2eu.countOrSet(loopUse,edgeUse); - adj_.e2eu.countOrSet(edge,edgeUse); - auto vtx0 = GE_vertex(edge,0); - adj_.v2eu.countOrSet(vtx0,edgeUse); - auto vtx1 = GE_vertex(edge,1); - adj_.v2eu.countOrSet(vtx1,edgeUse); + Adjacencies(pGModel g, const VtxInfo& vi, const EdgeInfo& ei, + const FaceInfo& fi, const LoopUseInfo& lui) : + v2eu(vi), e2eu(ei), f2lu(fi), lu2eu(lui) { + CountUses countUses(*this); + traverseUses(g, countUses); + f2lu.degreeToOffset(); + e2eu.degreeToOffset(); + v2eu.degreeToOffset(); + lu2eu.degreeToOffset(); + SetUses setUses(*this); + traverseUses(g, setUses); } }; @@ -372,6 +385,8 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { OMEGA_H_CHECK_MSG(isModel2D(g), msg2d); const char* msgValid = "Simmetrix GeomSim model is not valid... exiting\n"; OMEGA_H_CHECK_MSG(isValid(g), msgValid); + + //collect per entity info const auto vtxInfo = getVtxInfo(g); const auto edgeInfo = getEdgeInfo(g); const auto faceInfo = getFaceInfo(g); @@ -386,22 +401,8 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { SetUseDir setUseDir(loopUseInfo, edgeUseInfo); traverseUses(g, setUseDir); - EntToAdjUse v2eu(vtxInfo); - EntToAdjUse e2eu(edgeInfo); - EntToAdjUse f2lu(faceInfo); - EntToAdjUse lu2eu(loopUseInfo); - auto eudir = createArray(edgeUseInfo.ids.size()); - auto ludir = createArray(loopUseInfo.ids.size()); - Adjacencies adj{v2eu, e2eu, f2lu, lu2eu}; - - CountUses countUses(adj); - traverseUses(g, countUses); - f2lu.degreeToOffset(); - e2eu.degreeToOffset(); - v2eu.degreeToOffset(); - lu2eu.degreeToOffset(); - SetUses setUses(adj); - traverseUses(g, setUses); + //collect adjacency info + Adjacencies adj(g, vtxInfo, edgeInfo, faceInfo, loopUseInfo); //setup model auto mdl = Model2D(); From fdcd9442bb6a9436e5c3fc8411f7188e100fdfe0 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 22 Mar 2024 13:16:01 -0400 Subject: [PATCH 55/78] cleanup useinfo setup collect edge use direction during use id traversal. loopuse dir is WIP --- src/Omega_h_simModel2d.cpp | 72 ++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 42 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index a00d89505..69bd1f980 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -34,24 +34,30 @@ struct VtxInfo : public EntInfo { struct EdgeInfo : public EntInfo {}; struct FaceInfo : public EntInfo {}; -struct UseInfo : public EntInfo { - UseInfo() : idx(0) {} +struct UseInfoPrecursor { + UseInfoPrecursor() : idx(0) {} + std::map idToIdx; std::vector ids_h; + std::vector dir_h; int idx; - void idsToDevice() { +}; + +struct UseInfo : public EntInfo { + LOs dir; + LOs toDevice(const std::vector& ids_h) { auto array = HostWrite(ids_h.size()); std::copy(ids_h.begin(), ids_h.end(), array.data()); - ids = LOs(array); + return LOs(array); + } + UseInfo(UseInfoPrecursor& uip) { + ids = toDevice(uip.ids_h); + idToIdx = uip.idToIdx; + dir = toDevice(uip.dir_h); } }; -struct LoopUseInfo : public UseInfo { - HostWrite ludir; -}; - -struct EdgeUseInfo : public UseInfo { - HostWrite eudir; -}; +using LoopUseInfo = UseInfo; +using EdgeUseInfo = UseInfo; VtxInfo getVtxInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; @@ -228,10 +234,10 @@ void traverseUses(pGModel mdl, Operator& op) { GFIter_delete(modelFaces); } -struct SetUseIds { - LoopUseInfo& loopUseInfo_; - EdgeUseInfo& edgeUseInfo_; - SetUseIds(LoopUseInfo& loopUseInfo, EdgeUseInfo& edgeUseInfo) +struct SetUseIdsAndDir { + UseInfoPrecursor& loopUseInfo_; + UseInfoPrecursor& edgeUseInfo_; + SetUseIdsAndDir(UseInfoPrecursor& loopUseInfo, UseInfoPrecursor& edgeUseInfo) : loopUseInfo_(loopUseInfo), edgeUseInfo_(edgeUseInfo) {} void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { @@ -246,25 +252,9 @@ struct SetUseIds { edgeUseInfo_.ids_h.push_back(id); edgeUseInfo_.idToIdx[id] = edgeUseInfo_.idx; edgeUseInfo_.idx++; - } -}; - -struct SetUseDir { - LoopUseInfo& loopUseInfo_; - EdgeUseInfo& edgeUseInfo_; - SetUseDir(LoopUseInfo& loopUseInfo, EdgeUseInfo& edgeUseInfo) - : loopUseInfo_(loopUseInfo), edgeUseInfo_(edgeUseInfo) {} - - void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { - //FIXME - } - - void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { - const auto id = GEN_tag(edgeUse); - const auto idx = edgeUseInfo_.idToIdx.at(id); const auto edge = GEU_edge(edgeUse); const int dir = GE_geomDir(edge); - edgeUseInfo_.eudir[idx] = dir; + edgeUseInfo_.dir_h.push_back(dir); } }; @@ -390,16 +380,14 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto vtxInfo = getVtxInfo(g); const auto edgeInfo = getEdgeInfo(g); const auto faceInfo = getFaceInfo(g); - auto loopUseInfo = LoopUseInfo(); - auto edgeUseInfo = EdgeUseInfo(); - SetUseIds setUseIds(loopUseInfo, edgeUseInfo); - traverseUses(g, setUseIds); - loopUseInfo.idsToDevice(); - edgeUseInfo.idsToDevice(); - edgeUseInfo.eudir = createArray(edgeUseInfo.ids.size()); //FIXME - SetUseDir setUseDir(loopUseInfo, edgeUseInfo); - traverseUses(g, setUseDir); + // use info requires a traveral + auto loopUsePre = UseInfoPrecursor(); + auto edgeUsePre = UseInfoPrecursor(); + SetUseIdsAndDir setUseIdsAndDir(loopUsePre, edgeUsePre); + traverseUses(g, setUseIdsAndDir); + auto edgeUseInfo = EdgeUseInfo(edgeUsePre); + auto loopUseInfo = LoopUseInfo(loopUsePre); //collect adjacency info Adjacencies adj(g, vtxInfo, edgeInfo, faceInfo, loopUseInfo); @@ -411,7 +399,7 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { setFaceIds(mdl, faceInfo); setLoopUseIds(mdl, loopUseInfo); setEdgeUseIds(mdl, edgeUseInfo); - mdl.edgeUseOrientation = LOs(edgeUseInfo.eudir); //FIXME + mdl.edgeUseOrientation = edgeUseInfo.dir; //FIXME setAdjInfo(mdl, adj); GM_release(g); From de0ef89392f1386997f2e7f21d84447640e5c6d0 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 22 Mar 2024 13:25:57 -0400 Subject: [PATCH 56/78] set model use dir when setting ids --- src/Omega_h_simModel2d.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 69bd1f980..c211b8f8c 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -245,6 +245,7 @@ struct SetUseIdsAndDir { loopUseInfo_.ids_h.push_back(id); loopUseInfo_.idToIdx[id] = loopUseInfo_.idx; loopUseInfo_.idx++; + //TODO add loop use dir } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { @@ -333,12 +334,14 @@ void setFaceIds(Model2D& mdl, const FaceInfo& faceInfo) { mdl.faceIds = faceInfo.ids; } -void setLoopUseIds(Model2D& mdl, const LoopUseInfo& loopUseInfo) { +void setLoopUseIdsAndDir(Model2D& mdl, const LoopUseInfo& loopUseInfo) { mdl.loopUseIds = loopUseInfo.ids; + //mdl.loopUseOrientation = loopUseInfo.dir; } -void setEdgeUseIds(Model2D& mdl, const EdgeUseInfo& edgeUseInfo) { +void setEdgeUseIdsAndDir(Model2D& mdl, const EdgeUseInfo& edgeUseInfo) { mdl.edgeUseIds = edgeUseInfo.ids; + mdl.edgeUseOrientation = edgeUseInfo.dir; } void setAdjInfo(Model2D& mdl, Adjacencies& adj) { @@ -397,9 +400,8 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { setVertexInfo(mdl, vtxInfo); setEdgeIds(mdl, edgeInfo); setFaceIds(mdl, faceInfo); - setLoopUseIds(mdl, loopUseInfo); - setEdgeUseIds(mdl, edgeUseInfo); - mdl.edgeUseOrientation = edgeUseInfo.dir; //FIXME + setLoopUseIdsAndDir(mdl, loopUseInfo); + setEdgeUseIdsAndDir(mdl, edgeUseInfo); setAdjInfo(mdl, adj); GM_release(g); From b0603dc4fee77220d5d459c6cc2533651a89673d Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 06:20:19 -0400 Subject: [PATCH 57/78] update comments --- src/Omega_h_model2d.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index a19343b28..387038ada 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -18,7 +18,7 @@ class Model2D { static Model2D MeshModel2D_load(Mesh2D& mesh); void printInfo(); //ids - LOs vtxIds /*x*/, edgeIds /*x*/, faceIds /*x*/; + LOs vtxIds, edgeIds , faceIds; LOs edgeUseIds, loopUseIds; //equal order adjacencies Graph edgeToEdgeUse; @@ -30,15 +30,18 @@ class Model2D { Graph vtxToEdgeUse; LOs edgeUseToLoopUse; //each edgeUse has one adjacent loop use LOs loopUseToFace; //each loopUse has one adjacent face use - //for each edgeUse, indicates which vertex in the associated edge - //is the 'head’ vertex + + //For each edgeUse, indicates the direction of the edge use + //relative to its owning edge. 1: same dir, 0: opposite dir LOs edgeUseOrientation; - //for each loopUse, indicates forward or backward traversal order - //of the edgeUses belonging to the loop + + //For each loopUse, indicates forward or backward traversal order + //of the edgeUses belonging to the loop. 1: forward, 0: backward LOs loopUseOrientation; + //geometry Real vtxTol, edgeTol; - Reals vtxCoords; //x + Reals vtxCoords; private: Model2D() = default; }; From 168951ac3a35ca7f3f92bb2fbbdf746de14da5f5 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 06:32:50 -0400 Subject: [PATCH 58/78] need traversal for edge and loop dir --- src/Omega_h_simModel2d.cpp | 109 +++++++++++++++++++++++++------------ 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index c211b8f8c..6028e3cf5 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -10,6 +10,16 @@ namespace Omega_h { +HostWrite createAndInitArray(size_t size, const LO init=0) { + auto array = HostWrite(size); + std::fill(array.data(), array.data()+array.size(), init); + return array; +} + +HostWrite createArray(size_t size) { + return HostWrite(size); +} + bool isModel2D(pGModel mdl) { return (GM_numRegions(mdl) == 0); } @@ -38,10 +48,29 @@ struct UseInfoPrecursor { UseInfoPrecursor() : idx(0) {} std::map idToIdx; std::vector ids_h; - std::vector dir_h; + HostWrite dir_h; int idx; + virtual void initDir() { + assert(ids_h.size() > 0); + dir_h = createArray(ids_h.size()); + } }; +struct LoopUseInfoPrecursor : public UseInfoPrecursor { + static const int DirUndefined = -1; + LoopUseInfoPrecursor() = default; + void initDir() override { + dir_h = createAndInitArray(ids_h.size(), DirUndefined); + } + void setDir(const int luIdx, const int dir) { + if ( dir_h[luIdx] == DirUndefined ) { + dir_h[luIdx] = dir; + } + } +}; + +using EdgeUseInfoPrecursor = UseInfoPrecursor; + struct UseInfo : public EntInfo { LOs dir; LOs toDevice(const std::vector& ids_h) { @@ -52,7 +81,7 @@ struct UseInfo : public EntInfo { UseInfo(UseInfoPrecursor& uip) { ids = toDevice(uip.ids_h); idToIdx = uip.idToIdx; - dir = toDevice(uip.dir_h); + dir = LOs(uip.dir_h); } }; @@ -119,16 +148,6 @@ FaceInfo getFaceInfo(pGModel mdl) { return FaceInfo{LOs(ids_h), idToIdx}; } -HostWrite createAndInitArray(size_t size, const LO init=0) { - auto array = HostWrite(size); - std::fill(array.data(), array.data()+array.size(), init); - return array; -} - -HostWrite createArray(size_t size) { - return HostWrite(size); -} - struct CSR { CSR(int size) { OMEGA_H_TIME_FUNCTION; @@ -234,31 +253,48 @@ void traverseUses(pGModel mdl, Operator& op) { GFIter_delete(modelFaces); } -struct SetUseIdsAndDir { - UseInfoPrecursor& loopUseInfo_; - UseInfoPrecursor& edgeUseInfo_; - SetUseIdsAndDir(UseInfoPrecursor& loopUseInfo, UseInfoPrecursor& edgeUseInfo) - : loopUseInfo_(loopUseInfo), edgeUseInfo_(edgeUseInfo) {} +struct SetUseIds { + LoopUseInfoPrecursor& loopUsePre_; + EdgeUseInfoPrecursor& edgeUsePre_; + SetUseIds(LoopUseInfoPrecursor& loopUsePre, EdgeUseInfoPrecursor& edgeUsePre) + : loopUsePre_(loopUsePre), edgeUsePre_(edgeUsePre) {} void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto id = GEN_tag(loopUse); - loopUseInfo_.ids_h.push_back(id); - loopUseInfo_.idToIdx[id] = loopUseInfo_.idx; - loopUseInfo_.idx++; - //TODO add loop use dir + loopUsePre_.ids_h.push_back(id); + loopUsePre_.idToIdx[id] = loopUsePre_.idx; + loopUsePre_.idx++; } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto id = GEN_tag(edgeUse); - edgeUseInfo_.ids_h.push_back(id); - edgeUseInfo_.idToIdx[id] = edgeUseInfo_.idx; - edgeUseInfo_.idx++; - const auto edge = GEU_edge(edgeUse); - const int dir = GE_geomDir(edge); - edgeUseInfo_.dir_h.push_back(dir); + edgeUsePre_.ids_h.push_back(id); + edgeUsePre_.idToIdx[id] = edgeUsePre_.idx; + edgeUsePre_.idx++; } }; +struct SetUseDir { + LoopUseInfoPrecursor& loopUsePre_; + EdgeUseInfoPrecursor& edgeUsePre_; + SetUseDir(LoopUseInfoPrecursor& loopUsePre, EdgeUseInfoPrecursor& edgeUsePre) + : loopUsePre_(loopUsePre), edgeUsePre_(edgeUsePre) {} + + void loopUseOp(pGFace, pGLoopUse) {} + + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { + const auto euId = GEN_tag(edgeUse); + const auto euIdx = edgeUsePre_.idToIdx.at(euId); + const int dir = GEU_dir(edgeUse); + edgeUsePre_.dir_h[euIdx] = dir; + + const auto luId = GEN_tag(loopUse); + const auto luIdx = loopUsePre_.idToIdx.at(luId); + loopUsePre_.setDir(luIdx, dir); + } +}; + + struct Adjacencies { EntToAdjUse v2eu; EntToAdjUse e2eu; @@ -336,7 +372,7 @@ void setFaceIds(Model2D& mdl, const FaceInfo& faceInfo) { void setLoopUseIdsAndDir(Model2D& mdl, const LoopUseInfo& loopUseInfo) { mdl.loopUseIds = loopUseInfo.ids; - //mdl.loopUseOrientation = loopUseInfo.dir; + mdl.loopUseOrientation = loopUseInfo.dir; } void setEdgeUseIdsAndDir(Model2D& mdl, const EdgeUseInfo& edgeUseInfo) { @@ -364,9 +400,6 @@ void setAdjInfo(Model2D& mdl, Adjacencies& adj) { deg = get_degrees(lu2f.a2ab); assert(deg == LOs(deg.size(),1)); mdl.loopUseToFace = lu2f.ab2b; - - //TODO - //LOs loopUseOrientation } Model2D Model2D::SimModel2D_load(std::string const& filename) { @@ -384,11 +417,15 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { const auto edgeInfo = getEdgeInfo(g); const auto faceInfo = getFaceInfo(g); - // use info requires a traveral - auto loopUsePre = UseInfoPrecursor(); - auto edgeUsePre = UseInfoPrecursor(); - SetUseIdsAndDir setUseIdsAndDir(loopUsePre, edgeUsePre); - traverseUses(g, setUseIdsAndDir); + // use info requires traverals + auto loopUsePre = LoopUseInfoPrecursor(); + auto edgeUsePre = EdgeUseInfoPrecursor(); + SetUseIds setUseIds(loopUsePre, edgeUsePre); + traverseUses(g, setUseIds); + loopUsePre.initDir(); + edgeUsePre.initDir(); + SetUseDir setUseDir(loopUsePre, edgeUsePre); + traverseUses(g, setUseDir); auto edgeUseInfo = EdgeUseInfo(edgeUsePre); auto loopUseInfo = LoopUseInfo(loopUsePre); From cfc9846f22daa2ae338c36cf8d4525cf344b1201 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 11:30:08 -0400 Subject: [PATCH 59/78] model and mesh in x,y plane 2d models/meshes in omegah have to be on the x,y plane --- meshes/square-tri8.sms | 218 +++++++ meshes/square.smd | 1234 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 1355 insertions(+), 97 deletions(-) create mode 100644 meshes/square-tri8.sms diff --git a/meshes/square-tri8.sms b/meshes/square-tri8.sms new file mode 100644 index 000000000..a8f0c4c1c --- /dev/null +++ b/meshes/square-tri8.sms @@ -0,0 +1,218 @@ +smi 5 0 + smd 34 +simple 34 1 +* +1 +0 0 0 +1 1 0 +1 1007 9 0 +0 0 0 0 +0 0 0 +1 1 0 +_sim_empty +-1 +0 0 0 0 +0 + +0 +0 1 4 4 +0 0 0 0 +0 0 0 0 +0 0 0 0 +1 +7 4 19 +19 0 9 0 200 0 1 +7 +_sim_empty +-1 +1 1 0 +1 1 0 +0 +5 4 15 +15 0 9 0 200 0 1 +5 +_sim_empty +-1 +1 0 0 +1 0 0 +0 +3 4 11 +11 0 9 0 200 0 1 +3 +_sim_empty +-1 +0 0 0 +0 0 0 +0 +1 4 10 +10 0 9 0 200 0 1 +1 +_sim_empty +-1 +0 1 0 +0 1 0 +0 +1 5 6 1 3 +6 1 9 0 210 0 1 10 11 +1 +_sim_empty +-1 +1 0.5 0 0.5 0 +0 +1 1 +0 1 +2 2 0 1e-08 +0 1 0 +0 0 0 +0 0 1 1 +2 5 12 3 5 +12 1 9 0 210 0 1 11 15 +2 +_sim_empty +-1 +1 0.5 0.5 0 0 +0 +1 1 +0 1 +2 2 0 1e-08 +0 0 0 +1 0 0 +0 0 1 1 +3 5 16 5 7 +16 1 9 0 210 0 1 15 19 +3 +_sim_empty +-1 +1 0.5 1 0.5 0 +0 +1 1 +0 1 +2 2 0 1e-08 +1 0 0 +1 1 0 +0 0 1 1 +4 5 20 7 1 +20 1 9 0 210 0 1 19 10 +4 +_sim_empty +-1 +1 0.5 0.5 1 0 +0 +1 1 +0 1 +2 2 0 1e-08 +1 1 0 +0 1 0 +0 0 1 1 +1 6 2 1 0 2 +4 6 1 1 12 2 1 16 3 1 20 4 1 2 6 2 0 0 1 +4 20 4 0 16 3 0 12 2 0 6 1 0 2 2 9 0 203 0 +1 1 +0 + + 1 2 +0 + +0 +_sim_empty +-1 +1 0.00011238968005049493 0.42516224571744082 0.00011238968005049493 0.42516224571744088 0 +0 +1 1 +2 2 2 2 0 0 0 0.0 + 0 0 0 0 1 0 + 1 0 0 1 1 0 + 0 0 1 1 + 0 0 1 1 +0 -1 +2 8 1 2 +2 0 2 1 1 3 8 0 303 0 1 +2 +0 +0 +_sim_empty +-1 +0 +0 -1 +0 -1 +0 -1 +0 -1 +0 -1 + sms 14 +sms 14 0 +0 0 +0 8 16 9 9 +1e-08 1e-14 +j 0 03 +0 1 1 0 +0 +0.77999997138977051 +f 0 03 +0 1 0 0 +0 +0.77999997138977051 +b 0 03 +0 0 0 0 +0 +0.77999997138977051 +a 0 03 +0 0 1 0 +0 +0.77999997138977051 +6 0 13 +0 0 0.5 0 0.5 +0 +0.77999997138977051 +c 0 13 +0 0.5 0 0 0.5 +0 +0.77999997138977051 +g 0 13 +0 1 0.5 0 0.5 +0 +0.77999997138977051 +k 0 13 +0 0.5 1 0 0.5 +0 +0.77999997138977051 +2 0 28 +0 0.5 0.5 0 0.5 0.5 +0.77999997138977051 +6 0 11 3 4 +6 0 11 4 2 +c 0 11 2 5 +c 0 11 5 1 +g 0 11 1 6 +g 0 11 6 0 +k 0 11 0 7 +k 0 11 7 3 +2 0 22 7 8 +2 0 22 3 8 +2 0 22 4 8 +2 0 22 2 8 +2 0 22 5 8 +2 0 22 1 8 +2 0 22 6 8 +2 0 22 0 8 +2 0 23-9+8+a +2 0 23-a+1+b +2 0 23-b+2+c +2 0 23-c+3+d +2 0 23-d+4+e +2 0 23-e+5+f +2 0 23-f+6+g +2 0 23-g+7+9 + +2 +smd 8 +sms 1170 + +
+4 +77 file:///space/cwsmith/compassLandice/omegahDev/omega_h/meshes/square-tri8.sms9 mesh.full6 # 1 0 0 +0 +1 +5 model4 +12 ./square.smd24 model.nonmanifold.simple6 # 1 0 0 +
+1867 1901 diff --git a/meshes/square.smd b/meshes/square.smd index 48dc0d123..afedd181e 100644 --- a/meshes/square.smd +++ b/meshes/square.smd @@ -1,114 +1,132 @@ smi 5 0 - smd 19 -simple 19 1 + smd 34 +simple 34 1 * 1 --0.050500327767110803 0 -0.074036391139533697 --0.048638948182520902 0.10000000000000001 0.025946283689868951 +0 0 0 +1 1 0 1 1007 9 0 -0 0 -0.050500327767110803 0 -0.074036391139533697 --0.048638948182520902 0.10000000000000001 0.025946283689868951 +0 0 0 0 +0 0 0 +1 1 0 _sim_empty -1 0 0 0 0 +0 0 0 1 4 4 0 0 0 0 +0 0 0 0 +0 0 0 0 1 -7 4 5 -5 0 9 0 200 0 1 +7 4 19 +19 0 9 0 200 0 1 7 _sim_empty -1 --0.048638948182520902 0 -0.074036391139533697 --0.048638948182520902 0 -0.074036391139533697 -5 4 2 -2 0 9 0 200 0 1 +1 1 0 +1 1 0 +0 +5 4 15 +15 0 9 0 200 0 1 5 _sim_empty -1 --0.050500327767110803 0 0.025946283689868951 --0.050500327767110803 0 0.025946283689868951 -2 4 20 -20 0 9 0 200 0 1 -2 +1 0 0 +1 0 0 +0 +3 4 11 +11 0 9 0 200 0 1 +3 _sim_empty -1 --0.048638948182520902 0.10000000000000001 -0.074036391139533697 --0.048638948182520902 0.10000000000000001 -0.074036391139533697 -4 4 22 -22 0 9 0 200 0 1 -4 +0 0 0 +0 0 0 +0 +1 4 10 +10 0 9 0 200 0 1 +1 _sim_empty -1 --0.050500327767110803 0.10000000000000001 0.025946283689868951 --0.050500327767110803 0.10000000000000001 0.025946283689868951 -4 5 27 7 2 -27 1 9 0 210 0 1 5 20 -4 +0 1 0 +0 1 0 +0 +1 5 6 1 3 +6 1 9 0 210 0 1 10 11 +1 _sim_empty -1 -1 0.5 -0.048638948182520902 0.050000000000000003 -0.074036391139533697 +1 0.5 0 0.5 0 +0 1 1 +0 1 2 2 0 1e-08 --0.048638948182520902 0 -0.074036391139533697 --0.048638948182520902 0.10000000000000001 -0.074036391139533697 +0 1 0 +0 0 0 0 0 1 1 -3 5 6 5 7 -6 1 9 0 210 0 1 2 5 -3 +2 5 12 3 5 +12 1 9 0 210 0 1 11 15 +2 _sim_empty -1 -1 0.5 -0.049569637974815839 0 -0.024045053724832399 +1 0.5 0.5 0 0 +0 1 1 +0 1 2 2 0 1e-08 --0.050500327767110803 0 0.025946283689868951 --0.048638948182520868 0 -0.074036391139533753 +0 0 0 +1 0 0 0 0 1 1 -2 5 28 5 4 -28 1 9 0 210 0 1 2 22 -2 +3 5 16 5 7 +16 1 9 0 210 0 1 15 19 +3 _sim_empty -1 -1 0.5 -0.050500327767110803 0.050000000000000003 0.025946283689868951 +1 0.5 1 0.5 0 +0 1 1 +0 1 2 2 0 1e-08 --0.050500327767110803 0 0.025946283689868951 --0.050500327767110803 0.10000000000000001 0.025946283689868951 +1 0 0 +1 1 0 0 0 1 1 -1 5 16 4 2 -16 1 9 0 210 0 1 22 20 -1 +4 5 20 7 1 +20 1 9 0 210 0 1 19 10 +4 _sim_empty -1 -1 0.5 -0.049569637974815839 0.10000000000000001 -0.024045053724832399 +1 0.5 0.5 1 0 +0 1 1 +0 1 2 2 0 1e-08 --0.050500327767110803 0.10000000000000001 0.025946283689868951 --0.048638948182520868 0.10000000000000001 -0.074036391139533753 +1 1 0 +0 1 0 0 0 1 1 -1 6 30 1 0 2 -4 16 1 0 28 2 0 6 3 1 27 4 1 2 6 30 0 0 1 -4 27 4 0 6 3 0 28 2 1 16 1 1 30 2 9 0 203 0 +1 6 2 1 0 2 +4 6 1 1 12 2 1 16 3 1 20 4 1 2 6 2 0 0 1 +4 20 4 0 16 3 0 12 2 0 6 1 0 2 2 9 0 203 0 1 1 +0 1 2 +0 0 _sim_empty -1 -1 0.00011238968005049493 0.42516224571744082 -0.050500118567254837 0.042516224571744143 0.025935046669034279 +1 0.00011238968005049493 0.42516224571744082 0.00011238968005049493 0.42516224571744088 0 0 1 1 -2 2 2 2 0 0 0 0.0001 - -0.050500327767110803 0 0.025946283689868951 -0.050500327767110803 0.10000000000000014 0.025946283689868951 - -0.048638948182520868 0 -0.074036391139533753 -0.048638948182520868 0.10000000000000014 -0.074036391139533753 +2 2 2 2 0 0 0 0.0 + 0 0 0 0 1 0 + 1 0 0 1 1 0 0 0 1 1 0 0 1 1 0 -1 2 8 1 2 -30 0 30 1 1 3 8 0 303 0 1 +2 0 2 1 1 3 8 0 303 0 1 2 0 0 @@ -118,12 +136,101 @@ _sim_empty 0 -1 0 -1 0 -1 +0 -1 +0 -1 auxmm 3 0 0 attributes 10 AttDBVersion 10 8 -0 1 0 16 17 +0 6 0 114 132 +1 2 68 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +2 +1 2 69 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 70 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 71 +0 +16 FixIntersections +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 72 +0 +16 EnforceGradation +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 3 73 +0 +17 FaceRotationLimit +0 +0 0 1 +0 +0 +2 1 +0 +15 +1 2 89 +0 +12 DiscreteSnap +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 67 +0 +13 SurfaceMesher +0 +0 0 1 +0 +7 68 69 70 71 72 73 89 +1 3 110 +0 +8 MeshSize +8 Relative +0 0 1 +0 +0 +2 -1 +0 +6 0.1666 1 2 7 0 16 EnforceGradation @@ -144,6 +251,45 @@ AttDBVersion 10 8 1 1 0 2 +1 2 100 +0 +16 EnforceGradation +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 23 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 10 109 +1 * +6 simple +0 +0 0 1 +0 +0 +1 +4 +57 file:///lore/cwsmith/geometries/svnMeshes/plate/plate.smd24 model.nonmanifold.simple6 # 1 0 0 1 2 41 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +1 1 2 4 0 13 SmoothingType @@ -184,7 +330,7 @@ AttDBVersion 10 8 2 1 0 15 -1 2 9 +1 2 83 0 12 DiscreteSnap 0 @@ -200,10 +346,20 @@ AttDBVersion 10 8 0 0 0 1 0 -7 3 4 5 6 7 8 9 -1 2 15 +7 3 4 5 6 7 8 83 +1 2 96 0 -8 ModifyBL +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +2 +1 2 97 +0 +13 SmoothingType 0 0 0 1 0 @@ -211,7 +367,54 @@ AttDBVersion 10 8 1 1 0 0 -1 2 11 +1 2 98 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 99 +0 +16 FixIntersections +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 3 101 +0 +17 FaceRotationLimit +0 +0 0 1 +0 +0 +2 1 +0 +15 +1 2 102 +0 +12 DiscreteSnap +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 94 +0 +13 SurfaceMesher +0 +0 0 1 +0 +7 96 97 98 99 100 101 102 +1 2 75 0 11 EnforceSize 0 @@ -221,16 +424,17 @@ AttDBVersion 10 8 1 1 0 0 -1 10 16 -1 * -6 simple +1 2 40 +0 +11 EnforceSize 0 0 0 1 0 0 -1 -4 -76 file:///users/cwsmith/develop/geometries/sheet/simModel/translated-model.smd24 model.nonmanifold.simple6 # 1 0 0 1 2 13 +1 1 +0 +0 +1 2 42 0 13 SmoothingType 0 @@ -240,7 +444,7 @@ AttDBVersion 10 8 1 1 0 0 -1 2 14 +1 2 43 0 12 Optimization 0 @@ -250,24 +454,54 @@ AttDBVersion 10 8 1 1 0 1 -1 2 12 +1 2 86 0 -9 Smoothing +8 ModifyBL 0 0 0 1 0 0 1 1 0 -1 -1 7 10 +0 +1 2 129 +0 +16 MeshingByGRegion +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 39 0 12 VolumeMesher 0 0 0 1 0 -5 11 12 13 14 15 -1 3 17 +6 40 41 42 43 86 129 +1 3 38 +0 +17 FaceRotationLimit +0 +0 0 1 +0 +0 +2 1 +0 +15 +1 2 130 +0 +16 MeshingByGRegion +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 3 62 0 8 MeshSize 8 Relative @@ -276,30 +510,836 @@ AttDBVersion 10 8 0 2 -1 0 -4 0.75 -3 1 1 -5 case1 -7 Meshing +3 .23 +1 3 26 +0 +17 FaceRotationLimit 0 -6 0 1 +0 0 1 0 -3 2 10 17 -16 -1 2 -2 -1 -9 1 1 17 - -3 -smd 8 -auxmm 2492 -attributes 2511 - -
-4 -76 file:///users/cwsmith/develop/geometries/sheet/simModel/translated-model.smd24 model.nonmanifold.simple6 # 1 0 0 -1 +0 +2 1 +0 +15 +1 2 121 +0 +11 EnforceSize +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 122 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 123 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 124 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 125 +0 +8 ModifyBL +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 132 +0 +16 MeshingByGRegion +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 113 +0 +12 VolumeMesher +0 +0 0 1 +0 +6 121 122 123 124 125 132 +1 2 116 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 3 15 +0 +8 MeshSize +8 Absolute +0 0 1 +0 +0 +2 -1 +0 +3 .78 +1 2 103 +0 +11 EnforceSize +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 84 +0 +8 ModifyBL +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 111 +0 +15 SurfaceMeshType +0 +0 0 1 +0 +0 +1 1 +0 +3 +1 10 91 +1 * +6 simple +0 +0 0 1 +0 +0 +1 +4 +57 file:///lore/cwsmith/geometries/svnMeshes/plate/plate.smd24 model.nonmanifold.simple6 # 1 0 0 1 2 76 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 104 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 105 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 106 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 107 +0 +8 ModifyBL +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 131 +0 +16 MeshingByGRegion +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 95 +0 +12 VolumeMesher +0 +0 0 1 +0 +6 103 104 105 106 107 131 +1 2 77 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 78 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 88 +0 +8 ModifyBL +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 74 +0 +12 VolumeMesher +0 +0 0 1 +0 +6 75 76 77 78 88 130 +1 5 61 +0 +11 destination +0 +0 0 1 +0 +0 +4 1 +0 +1 2 2 1 2 36 +0 +16 FixIntersections +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 29 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 30 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 11 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 10 +0 +11 EnforceSize +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 12 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 13 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 82 +0 +8 ModifyBL +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 127 +0 +16 MeshingByGRegion +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 9 +0 +12 VolumeMesher +0 +0 0 1 +0 +6 10 11 12 13 82 127 +1 2 56 +0 +6 blends +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 3 18 +0 +8 MeshSize +8 Relative +0 0 1 +0 +0 +2 -1 +0 +4 .110 +1 2 55 +0 +13 mixedElements +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 57 +0 +11 propagation +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 3 58 +0 +14 relativeHeight +0 +0 0 1 +0 +0 +2 1 +0 +1 +1 3 59 +0 +9 numLayers +0 +0 0 1 +0 +0 +2 1 +0 +4 +1 7 54 +0 +15 2dBoundaryLayer +5 Type4 +0 0 1 +0 +6 55 56 57 58 59 61 +1 10 79 +1 * +6 simple +0 +0 0 1 +0 +0 +1 +4 +57 file:///lore/cwsmith/geometries/svnMeshes/plate/plate.smd24 model.nonmanifold.simple6 # 1 0 0 1 2 33 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +4 +1 3 80 +0 +8 MeshSize +8 Relative +0 0 1 +0 +0 +2 -1 +0 +4 0.25 +1 2 21 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +2 +1 10 14 +1 * +6 simple +0 +0 0 1 +0 +0 +1 +4 +72 file:///space/cwsmith/compassLandice/omegahDev/omega_h/meshes/square.smd24 model.nonmanifold.simple6 # 1 0 0 1 2 126 +0 +12 ElementOrder +0 +0 0 1 +0 +0 +1 1 +0 +2 +1 2 37 +0 +16 EnforceGradation +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 24 +0 +16 FixIntersections +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 128 +0 +16 MeshingByGRegion +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 34 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 35 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 87 +0 +12 DiscreteSnap +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 32 +0 +13 SurfaceMesher +0 +0 0 1 +0 +7 33 34 35 36 37 38 87 +1 2 28 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 120 +0 +12 DiscreteSnap +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 27 +0 +11 EnforceSize +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 7 20 +0 +12 VolumeMesher +0 +0 0 1 +0 +6 27 28 29 30 84 128 +1 2 115 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 22 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 118 +0 +16 EnforceGradation +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 3 119 +0 +17 FaceRotationLimit +0 +0 0 1 +0 +0 +2 1 +0 +15 +1 2 114 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +2 +1 2 81 +0 +15 SurfaceMeshType +0 +0 0 1 +0 +0 +1 1 +0 +3 +1 2 25 +0 +16 EnforceGradation +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 117 +0 +16 FixIntersections +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 7 112 +0 +13 SurfaceMesher +0 +0 0 1 +0 +7 114 115 116 117 118 119 120 +1 10 17 +1 * +6 simple +0 +0 0 1 +0 +0 +1 +4 +52 file:///users/riverc7/meshGen/meshes/plate/plate.smd24 model.nonmanifold.simple6 # 1 0 0 1 3 92 +0 +8 MeshSize +8 Relative +0 0 1 +0 +0 +2 -1 +0 +6 0.1666 +1 2 85 +0 +12 DiscreteSnap +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 93 +0 +15 SurfaceMeshType +0 +0 0 1 +0 +0 +1 1 +0 +3 +1 10 44 +1 * +6 simple +0 +0 0 1 +0 +0 +1 +4 +57 file:///lore/cwsmith/geometries/svnMeshes/plate/plate.smd24 model.nonmanifold.simple6 # 1 0 0 1 7 19 +0 +13 SurfaceMesher +0 +0 0 1 +0 +7 21 22 23 24 25 26 85 +1 2 65 +0 +15 SurfaceMeshType +0 +0 0 1 +0 +0 +1 1 +0 +2 +3 1 1 +4 tri8 +7 Meshing +0 +10 0 1 +0 +3 2 9 15 +14 +1 1 +1 +1 +9 1 1 15 +3 1 16 +6 tri224 +7 Meshing +0 +10 0 1 +0 +3 19 20 18 +17 +1 1 +1 +1 +9 1 1 18 +3 1 31 +6 Quad24 +7 Meshing +0 +10 0 1 +0 +5 32 39 54 62 65 +44 +3 9 +4 +1 +1 12 1 54 +6 +1 +9 1 1 62 +9 +1 +9 1 1 65 +3 1 66 +7 Quad 16 +7 Meshing +0 +10 0 1 +0 +4 67 74 80 81 +79 +2 2 +1 +1 +9 1 1 80 +2 +1 +9 1 1 81 +3 1 90 +6 quad36 +7 Meshing +0 +10 0 1 +0 +4 94 95 92 93 +91 +2 2 +1 +1 +9 1 1 92 +2 +1 +9 1 1 93 +3 1 108 +13 quad36_curved +7 Meshing +0 +10 0 1 +0 +5 112 113 110 111 126 +109 +3 3 +1 +1 +9 1 1 110 +2 +1 +9 1 1 111 +3 +1 +9 1 1 126 + +3 +smd 8 +auxmm 1170 +attributes 1189 + +
+4 +72 file:///space/cwsmith/compassLandice/omegahDev/omega_h/meshes/square.smd24 model.nonmanifold.simple6 # 1 0 0 +2 14 FromVoxelModel0 +5 units0 0
-3517 3569 +8074 8126 From 8d14ac9097ebfb9ac59a015243d191c0baa5f981 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 11:32:02 -0400 Subject: [PATCH 60/78] simModel2d loading test forgot to commit this... --- src/simModel2dLoad.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/simModel2dLoad.cpp diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp new file mode 100644 index 000000000..54715d98b --- /dev/null +++ b/src/simModel2dLoad.cpp @@ -0,0 +1,62 @@ +#include +#include +#include // operator==(LOs,LOs) +#include // operator==(LOs,LOs) + +void printGraph(const Omega_h::Graph& g, std::string_view name) { + std::cout << name << " {\n"; + Omega_h::HostRead offsets(g.a2ab); + Omega_h::HostRead vals(g.ab2b); + for(int i=0; i a(arr); + for(int i=0; i Date: Tue, 26 Mar 2024 16:07:38 -0400 Subject: [PATCH 61/78] doc string --- src/Omega_h_model2d.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Omega_h_model2d.hpp b/src/Omega_h_model2d.hpp index 387038ada..985db72f7 100644 --- a/src/Omega_h_model2d.hpp +++ b/src/Omega_h_model2d.hpp @@ -21,6 +21,7 @@ class Model2D { LOs vtxIds, edgeIds , faceIds; LOs edgeUseIds, loopUseIds; //equal order adjacencies + //each edge will have at most two uses, edges bounding a single face will only have one Graph edgeToEdgeUse; //downward adjacencies Graph faceToLoopUse; From 3c0d94b48f0e92f9aa84d9f59058e18d0d0a1ade Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 16:07:59 -0400 Subject: [PATCH 62/78] fixme --- src/Omega_h_simModel2d.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 6028e3cf5..5cc941007 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -2,7 +2,7 @@ #include #include "Omega_h_model2d.hpp" #include "Omega_h_profile.hpp" -#include "Omega_h_map.hpp" // invert_map_by_atomics +#include "Omega_h_adj.hpp" // invert_adj #include "Omega_h_array_ops.hpp" // operator==(LOs,LOs) #include #include //std::fill @@ -386,7 +386,10 @@ void setAdjInfo(Model2D& mdl, Adjacencies& adj) { mdl.faceToLoopUse = Graph(LOs(adj.f2lu.offset), LOs(adj.f2lu.values)); mdl.loopUseToEdgeUse = Graph(LOs(adj.lu2eu.offset), LOs(adj.lu2eu.values)); - const auto eu2v = invert_map_by_atomics(mdl.vtxToEdgeUse.ab2b, mdl.edgeUseIds.size()); + //FIXME - vtxToEdgeUse, loopUseToEdgeUse, and faceToLoopUse are not degree one in + // there 'source' set of nodes (vtx, loop, face) + // invert_map_by_atomic requires degree=1 of items in set A + const auto eu2v = invert_adj(mdl.vtxToEdgeUse.ab2b, mdl.edgeUseIds.size()); LOs deg = get_degrees(eu2v.a2ab); assert(deg == LOs(deg.size(),2)); mdl.edgeUseToVtx = eu2v.ab2b; From e63b7d6832cbb51eca89e45adbe2130e7310109f Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 16:08:22 -0400 Subject: [PATCH 63/78] more checks --- src/simModel2dLoad.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp index 54715d98b..1f2630796 100644 --- a/src/simModel2dLoad.cpp +++ b/src/simModel2dLoad.cpp @@ -1,6 +1,7 @@ #include #include #include // operator==(LOs,LOs) +#include "Omega_h_map.hpp" // invert_map_by_atomics #include // operator==(LOs,LOs) void printGraph(const Omega_h::Graph& g, std::string_view name) { @@ -40,13 +41,8 @@ int main(int argc, char** argv) { OMEGA_H_CHECK(model.edgeIds == expectedEdgeIds); Omega_h::LOs expectedFaceIds = {2}; OMEGA_H_CHECK(model.faceIds == expectedFaceIds); - //TODO check adjs - printGraph(model.vtxToEdgeUse, "vtxToEdgeUse"); - //Omega_h::Graph expected_v2e = Omega_h::Graph({0,2,4,6,8},{3,4,2,5,1,6,0,7}); - //OMEGA_H_CHECK(model.edgeToEdgeUse == expected_e2eu); - - //use ids and adjacencies are **not** accessible in SimModeler + //use ids and their adjacencies are **not** accessible in SimModeler Omega_h::LOs expectedEdgeUseIds = {8,6,4,2,1,3,5,7}; OMEGA_H_CHECK(model.edgeUseIds == expectedEdgeUseIds); Omega_h::LOs expectedLoopUseIds = {2,1}; @@ -58,5 +54,20 @@ int main(int argc, char** argv) { Omega_h::Graph expected_lu2eu = Omega_h::Graph({0,4,8},{0,1,2,3,4,5,6,7}); OMEGA_H_CHECK(model.loopUseToEdgeUse == expected_lu2eu); + Omega_h::Graph expected_v2eu = Omega_h::Graph({0,4,8,12,16}, + {0,1,6,7, + 1,2,5,6, + 2,3,4,5, + 0,3,4,7}); + OMEGA_H_CHECK(model.vtxToEdgeUse == expected_v2eu); + + printLOs(model.edgeUseToVtx, "edgeUseToVtx"); //something wrong here, idx > 3 + //OMEGA_H_CHECK(model.edgeUseToVtx == Omega_h::invert_map_by_atomics(expected_v2eu.ab2b, model.vtxIds.size()).ab2b); + + Omega_h::Graph expected_f2lu = Omega_h::Graph({0,2},{0,1}); + OMEGA_H_CHECK(model.faceToLoopUse == expected_f2lu); + + printGraph(model.faceToLoopUse, "faceToLoopUse"); + return 0; } From b716383dd8d501f9d8d7cd3fbd1cd2bffab908c1 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 16:17:33 -0400 Subject: [PATCH 64/78] fixme --- src/Omega_h_simModel2d.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 5cc941007..5c46a7f12 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -307,18 +307,18 @@ struct Adjacencies { void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto Mode = GetUsesMode::CountAdj; - adj_.f2lu.countOrSet(modelFace, loopUse); + adj_.f2lu.countOrSet(modelFace, loopUse); //FIXME - switch to lu2f } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto Mode = GetUsesMode::CountAdj; auto edge = GEU_edge(edgeUse); - adj_.lu2eu.countOrSet(loopUse,edgeUse); + adj_.lu2eu.countOrSet(loopUse,edgeUse); //FIXME - switch to eu2lu adj_.e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); - adj_.v2eu.countOrSet(vtx0,edgeUse); + adj_.v2eu.countOrSet(vtx0,edgeUse); //FIXME - switch to eu2v auto vtx1 = GE_vertex(edge,1); - adj_.v2eu.countOrSet(vtx1,edgeUse); + adj_.v2eu.countOrSet(vtx1,edgeUse); //FIXME - switch to eu2v } }; @@ -328,18 +328,18 @@ struct Adjacencies { void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto Mode = GetUsesMode::SetAdj; - adj_.f2lu.countOrSet(modelFace, loopUse); + adj_.f2lu.countOrSet(modelFace, loopUse); //FIXME - switch to lu2f } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto Mode = GetUsesMode::SetAdj; auto edge = GEU_edge(edgeUse); - adj_.lu2eu.countOrSet(loopUse,edgeUse); + adj_.lu2eu.countOrSet(loopUse,edgeUse); //FIXME - switch to eu2lu adj_.e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); - adj_.v2eu.countOrSet(vtx0,edgeUse); + adj_.v2eu.countOrSet(vtx0,edgeUse); //FIXME - switch to eu2v auto vtx1 = GE_vertex(edge,1); - adj_.v2eu.countOrSet(vtx1,edgeUse); + adj_.v2eu.countOrSet(vtx1,edgeUse); //FIXME - switch to eu2v } }; From 8be08ac5356da5a96af039f30f9ce9fd975a9cbe Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 22:45:18 -0400 Subject: [PATCH 65/78] wip: computing uniform adj need to invert --- src/Omega_h_simModel2d.cpp | 76 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 5c46a7f12..1e15a5464 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -38,6 +38,7 @@ struct EntInfo { }; struct VtxInfo : public EntInfo { + using EntType = pGVertex; Reals coords; }; @@ -177,11 +178,12 @@ struct CSR { CSR(); }; -enum GetUsesMode { +enum GetUsesMode { //FIXME - remove this CountAdj = 1, SetAdj = 2 }; +//TODO determine EntType from EntInfo... they need to match template struct EntToAdjUse : public CSR { EntToAdjUse(const EntInfo& entInfo_in) @@ -190,8 +192,8 @@ struct EntToAdjUse : public CSR { const EntInfo& entInfo; std::map useIdToIdx; int useCount; - template - void countOrSet(EntType ent, UseType use) { + template //FIXME - remove this + void countOrSet(EntType ent, UseType use) { //split into two functions: count and set static_assert((mode == GetUsesMode::CountAdj || mode == GetUsesMode::SetAdj), "countOrSet called with invalid mode"); OMEGA_H_TIME_FUNCTION; @@ -296,10 +298,10 @@ struct SetUseDir { struct Adjacencies { - EntToAdjUse v2eu; + EntToAdjUse eu2v; EntToAdjUse e2eu; - EntToAdjUse f2lu; - EntToAdjUse lu2eu; + EntToAdjUse lu2f; + EntToAdjUse eu2lu; struct CountUses { Adjacencies& adj_; @@ -307,18 +309,18 @@ struct Adjacencies { void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto Mode = GetUsesMode::CountAdj; - adj_.f2lu.countOrSet(modelFace, loopUse); //FIXME - switch to lu2f + adj_.lu2f.countOrSet(loopUse, modelFace); } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto Mode = GetUsesMode::CountAdj; auto edge = GEU_edge(edgeUse); - adj_.lu2eu.countOrSet(loopUse,edgeUse); //FIXME - switch to eu2lu + adj_.eu2lu.countOrSet(edgeUse, loopUse); adj_.e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); - adj_.v2eu.countOrSet(vtx0,edgeUse); //FIXME - switch to eu2v + adj_.eu2v.countOrSet(edgeUse,vtx0); auto vtx1 = GE_vertex(edge,1); - adj_.v2eu.countOrSet(vtx1,edgeUse); //FIXME - switch to eu2v + adj_.eu2v.countOrSet(edgeUse,vtx1); } }; @@ -328,32 +330,38 @@ struct Adjacencies { void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { const auto Mode = GetUsesMode::SetAdj; - adj_.f2lu.countOrSet(modelFace, loopUse); //FIXME - switch to lu2f + adj_.lu2f.countOrSet(loopUse, modelFace); } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { const auto Mode = GetUsesMode::SetAdj; auto edge = GEU_edge(edgeUse); - adj_.lu2eu.countOrSet(loopUse,edgeUse); //FIXME - switch to eu2lu + adj_.eu2lu.countOrSet(edgeUse, loopUse); adj_.e2eu.countOrSet(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); - adj_.v2eu.countOrSet(vtx0,edgeUse); //FIXME - switch to eu2v + adj_.eu2v.countOrSet(edgeUse, vtx0); auto vtx1 = GE_vertex(edge,1); - adj_.v2eu.countOrSet(vtx1,edgeUse); //FIXME - switch to eu2v + adj_.eu2v.countOrSet(edgeUse, vtx1); } }; - Adjacencies(pGModel g, const VtxInfo& vi, const EdgeInfo& ei, - const FaceInfo& fi, const LoopUseInfo& lui) : - v2eu(vi), e2eu(ei), f2lu(fi), lu2eu(lui) { + Adjacencies(pGModel g, const EdgeInfo& ei, const EdgeUseInfo& eui, + const LoopUseInfo& lui) : + eu2v(eui), e2eu(ei), lu2f(lui), eu2lu(eui) { CountUses countUses(*this); traverseUses(g, countUses); - f2lu.degreeToOffset(); + lu2f.degreeToOffset(); e2eu.degreeToOffset(); - v2eu.degreeToOffset(); - lu2eu.degreeToOffset(); + eu2v.degreeToOffset(); + eu2lu.degreeToOffset(); SetUses setUses(*this); traverseUses(g, setUses); + //TODO check degree + //lu2f.deg == 1 + //eu2lu.deg == 1 + //eu2v.deg == 2 + //max(e2eu.deg) == 2 + //min(e2eu.deg) == 1 } }; @@ -381,28 +389,20 @@ void setEdgeUseIdsAndDir(Model2D& mdl, const EdgeUseInfo& edgeUseInfo) { } void setAdjInfo(Model2D& mdl, Adjacencies& adj) { - mdl.vtxToEdgeUse = Graph(LOs(adj.v2eu.offset), LOs(adj.v2eu.values)); mdl.edgeToEdgeUse = Graph(LOs(adj.e2eu.offset), LOs(adj.e2eu.values)); - mdl.faceToLoopUse = Graph(LOs(adj.f2lu.offset), LOs(adj.f2lu.values)); - mdl.loopUseToEdgeUse = Graph(LOs(adj.lu2eu.offset), LOs(adj.lu2eu.values)); + mdl.edgeUseToVtx = LOs(adj.eu2v.values); + mdl.loopUseToFace = LOs(adj.lu2f.values); + mdl.edgeUseToLoopUse = LOs(adj.eu2lu.values); //FIXME - vtxToEdgeUse, loopUseToEdgeUse, and faceToLoopUse are not degree one in // there 'source' set of nodes (vtx, loop, face) // invert_map_by_atomic requires degree=1 of items in set A - const auto eu2v = invert_adj(mdl.vtxToEdgeUse.ab2b, mdl.edgeUseIds.size()); - LOs deg = get_degrees(eu2v.a2ab); - assert(deg == LOs(deg.size(),2)); - mdl.edgeUseToVtx = eu2v.ab2b; - - const auto eu2lu = invert_map_by_atomics(mdl.loopUseToEdgeUse.ab2b, mdl.edgeUseIds.size()); - deg = get_degrees(eu2lu.a2ab); - assert(deg == LOs(deg.size(),1)); - mdl.edgeUseToLoopUse = eu2lu.ab2b; - - const auto lu2f = invert_map_by_atomics(mdl.faceToLoopUse.ab2b, mdl.loopUseIds.size()); - deg = get_degrees(lu2f.a2ab); - assert(deg == LOs(deg.size(),1)); - mdl.loopUseToFace = lu2f.ab2b; + //mdl.vtxToEdgeUse = invert_adj(Adj(mdl.edgeUseToVtx), 2, + // mdl.vtxIds.size(), 1, 0) + //mdl.loopUseToEdgeUse = invert_adj(Adj(mdl.edgeUseToLoopUse), 1, + // mdl.loopUseIds.size(), 1, 1); + //mdl.faceToLoopUse = invert_adj(Adj(mdl.loopUseToFace), 1, + // mdl.faceIds.size(), 1, 2); } Model2D Model2D::SimModel2D_load(std::string const& filename) { @@ -433,7 +433,7 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { auto loopUseInfo = LoopUseInfo(loopUsePre); //collect adjacency info - Adjacencies adj(g, vtxInfo, edgeInfo, faceInfo, loopUseInfo); + Adjacencies adj(g, edgeInfo, edgeUseInfo, loopUseInfo); //setup model auto mdl = Model2D(); From 7a6f245d6593624d1ccdf470dc1777ce9214cf42 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 26 Mar 2024 23:32:23 -0400 Subject: [PATCH 66/78] check degree --- src/Omega_h_simModel2d.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 1e15a5464..66aaac121 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -2,6 +2,7 @@ #include #include "Omega_h_model2d.hpp" #include "Omega_h_profile.hpp" +#include "Omega_h_map.hpp" // get_degrees #include "Omega_h_adj.hpp" // invert_adj #include "Omega_h_array_ops.hpp" // operator==(LOs,LOs) #include @@ -345,6 +346,12 @@ struct Adjacencies { } }; + void checkDegree(const HostWrite& offset, int degree) { + const auto deg = get_degrees(LOs(offset)); + const auto exp_deg = LOs(deg.size(), degree); + OMEGA_H_CHECK(deg == exp_deg); + } + Adjacencies(pGModel g, const EdgeInfo& ei, const EdgeUseInfo& eui, const LoopUseInfo& lui) : eu2v(eui), e2eu(ei), lu2f(lui), eu2lu(eui) { @@ -356,12 +363,11 @@ struct Adjacencies { eu2lu.degreeToOffset(); SetUses setUses(*this); traverseUses(g, setUses); - //TODO check degree - //lu2f.deg == 1 - //eu2lu.deg == 1 - //eu2v.deg == 2 - //max(e2eu.deg) == 2 - //min(e2eu.deg) == 1 + //check degree + checkDegree(lu2f.offset, 1); + checkDegree(eu2lu.offset, 1); + checkDegree(eu2v.offset, 2); + checkDegree(e2eu.offset, 2); } }; From 8f65c916aa09cbeeea434597db96a532549be942 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 28 Mar 2024 11:46:30 -0400 Subject: [PATCH 67/78] compiles --- src/Omega_h_simModel2d.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 66aaac121..9131fffd8 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -304,6 +304,11 @@ struct Adjacencies { EntToAdjUse lu2f; EntToAdjUse eu2lu; + static const int e2euDegree = 2; + static const int eu2vDegree = 2; + static const int eu2luDegree = 1; + static const int lu2fDegree = 1; + struct CountUses { Adjacencies& adj_; CountUses(Adjacencies& adj) : adj_(adj) {} @@ -364,10 +369,10 @@ struct Adjacencies { SetUses setUses(*this); traverseUses(g, setUses); //check degree - checkDegree(lu2f.offset, 1); - checkDegree(eu2lu.offset, 1); - checkDegree(eu2v.offset, 2); - checkDegree(e2eu.offset, 2); + checkDegree(lu2f.offset, lu2fDegree); + checkDegree(eu2lu.offset, eu2luDegree); + checkDegree(eu2v.offset, eu2vDegree); + checkDegree(e2eu.offset, e2euDegree); } }; @@ -400,15 +405,18 @@ void setAdjInfo(Model2D& mdl, Adjacencies& adj) { mdl.loopUseToFace = LOs(adj.lu2f.values); mdl.edgeUseToLoopUse = LOs(adj.eu2lu.values); - //FIXME - vtxToEdgeUse, loopUseToEdgeUse, and faceToLoopUse are not degree one in - // there 'source' set of nodes (vtx, loop, face) - // invert_map_by_atomic requires degree=1 of items in set A - //mdl.vtxToEdgeUse = invert_adj(Adj(mdl.edgeUseToVtx), 2, - // mdl.vtxIds.size(), 1, 0) - //mdl.loopUseToEdgeUse = invert_adj(Adj(mdl.edgeUseToLoopUse), 1, - // mdl.loopUseIds.size(), 1, 1); - //mdl.faceToLoopUse = invert_adj(Adj(mdl.loopUseToFace), 1, - // mdl.faceIds.size(), 1, 2); + //The last two arguments to 'invert_adj(...)' are 'high' and 'low' entity + //dimensions and are used to define names for the graph arrays. They have no + //impact on the graph inversion. + mdl.vtxToEdgeUse = invert_adj(Adj(mdl.edgeUseToVtx), + Adjacencies::eu2vDegree, + mdl.vtxIds.size(), 1, 0); + mdl.loopUseToEdgeUse = invert_adj(Adj(mdl.edgeUseToLoopUse), + Adjacencies::eu2luDegree, + mdl.loopUseIds.size(), 1, 1); + mdl.faceToLoopUse = invert_adj(Adj(mdl.loopUseToFace), + Adjacencies::lu2fDegree, + mdl.faceIds.size(), 1, 2); } Model2D Model2D::SimModel2D_load(std::string const& filename) { From e70e1dbaca6e64125571f3d4df5d01c5179376ab Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 28 Mar 2024 11:48:53 -0400 Subject: [PATCH 68/78] passes, checks need work --- src/simModel2dLoad.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp index 1f2630796..bf3fe9e5e 100644 --- a/src/simModel2dLoad.cpp +++ b/src/simModel2dLoad.cpp @@ -54,15 +54,15 @@ int main(int argc, char** argv) { Omega_h::Graph expected_lu2eu = Omega_h::Graph({0,4,8},{0,1,2,3,4,5,6,7}); OMEGA_H_CHECK(model.loopUseToEdgeUse == expected_lu2eu); - Omega_h::Graph expected_v2eu = Omega_h::Graph({0,4,8,12,16}, - {0,1,6,7, - 1,2,5,6, - 2,3,4,5, - 0,3,4,7}); - OMEGA_H_CHECK(model.vtxToEdgeUse == expected_v2eu); + //Omega_h::Graph expected_v2eu = Omega_h::Graph({0,4,8,12,16}, + // {0,1,6,7, + // 1,2,5,6, + // 2,3,4,5, + // 0,3,4,7}); + //OMEGA_H_CHECK(model.vtxToEdgeUse == expected_v2eu); //FIXME - printLOs(model.edgeUseToVtx, "edgeUseToVtx"); //something wrong here, idx > 3 - //OMEGA_H_CHECK(model.edgeUseToVtx == Omega_h::invert_map_by_atomics(expected_v2eu.ab2b, model.vtxIds.size()).ab2b); + printLOs(model.edgeUseToVtx, "edgeUseToVtx"); + //FIXME add check for eu2v Omega_h::Graph expected_f2lu = Omega_h::Graph({0,2},{0,1}); OMEGA_H_CHECK(model.faceToLoopUse == expected_f2lu); From c8aa57955580559f76d6f2aba0712dcb74e821b8 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 1 Apr 2024 13:27:09 -0400 Subject: [PATCH 69/78] eu2v had bad vtx indices --- src/Omega_h_simModel2d.cpp | 41 ++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 9131fffd8..5af2972eb 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -185,34 +185,31 @@ enum GetUsesMode { //FIXME - remove this }; //TODO determine EntType from EntInfo... they need to match -template +template struct EntToAdjUse : public CSR { - EntToAdjUse(const EntInfo& entInfo_in) - : entInfo(entInfo_in), useCount(0), - CSR(entInfo_in.ids.size()) {} + EntToAdjUse(const EntInfo& entInfo_in, const EntInfo& destEntInfo_in) + : entInfo(entInfo_in), + CSR(entInfo_in.ids.size()), + destEntIdToIdx(destEntInfo_in.idToIdx) {} const EntInfo& entInfo; - std::map useIdToIdx; - int useCount; + const std::map& destEntIdToIdx; template //FIXME - remove this - void countOrSet(EntType ent, UseType use) { //split into two functions: count and set + void countOrSet(SrcEntType srcEnt, DestEntType destEnt) { //split into two functions: count and set static_assert((mode == GetUsesMode::CountAdj || mode == GetUsesMode::SetAdj), "countOrSet called with invalid mode"); OMEGA_H_TIME_FUNCTION; if constexpr (mode == GetUsesMode::CountAdj) { ScopedTimer timer("EntToAdjUse::count"); - const auto entId = GEN_tag(ent); - const auto entIdx = entInfo.idToIdx.at(entId); - incrementDegree(entIdx); + const auto srcEntId = GEN_tag(srcEnt); + const auto srcEntIdx = entInfo.idToIdx.at(srcEntId); + incrementDegree(srcEntIdx); } else { ScopedTimer timer("EntToAdjUse::set"); - const auto entId = GEN_tag(ent); - const auto entIdx = entInfo.idToIdx.at(entId); - const auto useId = GEN_tag(use); - if( ! useIdToIdx.count(useId) ) { - useIdToIdx[useId] = useCount++; - } - const auto useIdx = useIdToIdx[useId]; - setValue(entIdx, useIdx); + const auto srcEntId = GEN_tag(srcEnt); + const auto srcEntIdx = entInfo.idToIdx.at(srcEntId); + const auto destEntId = GEN_tag(destEnt); + const auto destEntIdx = destEntIdToIdx.at(destEntId); + setValue(srcEntIdx, destEntIdx); } } private: @@ -357,9 +354,9 @@ struct Adjacencies { OMEGA_H_CHECK(deg == exp_deg); } - Adjacencies(pGModel g, const EdgeInfo& ei, const EdgeUseInfo& eui, - const LoopUseInfo& lui) : - eu2v(eui), e2eu(ei), lu2f(lui), eu2lu(eui) { + Adjacencies(pGModel g, const VtxInfo& vi, const EdgeInfo& ei, const FaceInfo& fi, + const EdgeUseInfo& eui, const LoopUseInfo& lui) : + eu2v(eui, vi), e2eu(ei, eui), lu2f(lui, fi), eu2lu(eui, lui) { CountUses countUses(*this); traverseUses(g, countUses); lu2f.degreeToOffset(); @@ -447,7 +444,7 @@ Model2D Model2D::SimModel2D_load(std::string const& filename) { auto loopUseInfo = LoopUseInfo(loopUsePre); //collect adjacency info - Adjacencies adj(g, edgeInfo, edgeUseInfo, loopUseInfo); + Adjacencies adj(g, vtxInfo, edgeInfo, faceInfo, edgeUseInfo, loopUseInfo); //setup model auto mdl = Model2D(); From 8d686e2712d3187839457fbef0f5fa2c03234a24 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 1 Apr 2024 13:33:06 -0400 Subject: [PATCH 70/78] better debug print --- src/simModel2dLoad.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp index bf3fe9e5e..dcef9d719 100644 --- a/src/simModel2dLoad.cpp +++ b/src/simModel2dLoad.cpp @@ -17,11 +17,13 @@ void printGraph(const Omega_h::Graph& g, std::string_view name) { std::cout << "}\n"; } -void printLOs(const Omega_h::LOs& arr, std::string_view name) { - std::cout << name << " { "; +void printLOs(const Omega_h::LOs& arr, const int degree, std::string_view name) { + std::cout << name << " {\n"; Omega_h::HostRead a(arr); - for(int i=0; i Date: Mon, 1 Apr 2024 14:11:40 -0400 Subject: [PATCH 71/78] add remaining checks --- src/simModel2dLoad.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp index dcef9d719..01b2ed702 100644 --- a/src/simModel2dLoad.cpp +++ b/src/simModel2dLoad.cpp @@ -44,32 +44,33 @@ int main(int argc, char** argv) { Omega_h::LOs expectedFaceIds = {2}; OMEGA_H_CHECK(model.faceIds == expectedFaceIds); - //use ids and their adjacencies are **not** accessible in SimModeler + //In SimModeler, use ids and their adjacencies are **not** accessible/visible Omega_h::LOs expectedEdgeUseIds = {8,6,4,2,1,3,5,7}; OMEGA_H_CHECK(model.edgeUseIds == expectedEdgeUseIds); Omega_h::LOs expectedLoopUseIds = {2,1}; OMEGA_H_CHECK(model.loopUseIds == expectedLoopUseIds); + //check adjacencies Omega_h::Graph expected_e2eu = Omega_h::Graph({0,2,4,6,8},{3,4,2,5,1,6,0,7}); OMEGA_H_CHECK(model.edgeToEdgeUse == expected_e2eu); + Omega_h::LOs expected_eu2lu = {0,0,0,0,1,1,1,1}; + OMEGA_H_CHECK(model.edgeUseToLoopUse == expected_eu2lu); Omega_h::Graph expected_lu2eu = Omega_h::Graph({0,4,8},{0,1,2,3,4,5,6,7}); OMEGA_H_CHECK(model.loopUseToEdgeUse == expected_lu2eu); - //Omega_h::Graph expected_v2eu = Omega_h::Graph({0,4,8,12,16}, - // {0,1,6,7, - // 1,2,5,6, - // 2,3,4,5, - // 0,3,4,7}); - //OMEGA_H_CHECK(model.vtxToEdgeUse == expected_v2eu); //FIXME - - printLOs(model.edgeUseToVtx, 2, "edgeUseToVtx"); - //FIXME add check for eu2v + Omega_h::LOs expected_eu2v = {0,3,1,0,2,1,3,2,3,2,2,1,1,0,0,3}; + OMEGA_H_CHECK(model.edgeUseToVtx == expected_eu2v); + Omega_h::Graph expected_v2eu = Omega_h::Graph({0,4,8,12,16}, + {0,1,6,7, + 1,2,5,6, + 2,3,4,5, + 0,3,4,7}); + OMEGA_H_CHECK(model.vtxToEdgeUse == expected_v2eu); + Omega_h::LOs expected_lu2f = {0,0}; + OMEGA_H_CHECK(model.loopUseToFace == expected_lu2f); Omega_h::Graph expected_f2lu = Omega_h::Graph({0,2},{0,1}); OMEGA_H_CHECK(model.faceToLoopUse == expected_f2lu); - - printGraph(model.faceToLoopUse, "faceToLoopUse"); - return 0; } From 8a5da3435e1695d00c6fbb42f302c31a56f0a5ad Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 1 Apr 2024 14:48:01 -0400 Subject: [PATCH 72/78] unused header --- src/simModel2dLoad.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp index 01b2ed702..6cfc4ccdf 100644 --- a/src/simModel2dLoad.cpp +++ b/src/simModel2dLoad.cpp @@ -1,7 +1,6 @@ #include #include #include // operator==(LOs,LOs) -#include "Omega_h_map.hpp" // invert_map_by_atomics #include // operator==(LOs,LOs) void printGraph(const Omega_h::Graph& g, std::string_view name) { From 2945773e6aaadaff6ab25712b3e4ef39c1dccf38 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 1 Apr 2024 15:16:20 -0400 Subject: [PATCH 73/78] add 3d geomsim model --- meshes/Example_hex.smd | 384 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 384 insertions(+) create mode 100644 meshes/Example_hex.smd diff --git a/meshes/Example_hex.smd b/meshes/Example_hex.smd new file mode 100644 index 000000000..8a20634dc --- /dev/null +++ b/meshes/Example_hex.smd @@ -0,0 +1,384 @@ +smi 5 0 + smd 34 +discrete 34 1 +* +-1 +0 0 0 +1 1 1 +1 1007 2 0 +0 0 0 0 +0 0 0 +1 1 1 +_sim_empty +-1 +0 0 0 0 +0 + +0 +1 6 12 8 +0 0 0 0 +0 0 0 0 +0 0 0 0 +-1 +1 4 1 +9 4 1 +1 0 2 0 0 0 2 +1 9 +_sim_empty +-1 +0 0 0 +0 +0 +3 4 2 +16 4 2 +2 0 2 0 0 0 2 +3 16 +_sim_empty +-1 +0 1 0 +0 +0 +5 4 3 +14 4 3 +3 0 2 0 0 0 2 +5 14 +_sim_empty +-1 +1 1 0 +0 +0 +8 4 4 +12 4 4 +4 0 2 0 0 0 2 +8 12 +_sim_empty +-1 +1 0 0 +0 +0 +21 4 5 +30 4 5 +5 0 2 0 0 0 2 +21 30 +_sim_empty +-1 +1 0 1 +0 +0 +24 4 6 +28 4 6 +6 0 2 0 0 0 2 +24 28 +_sim_empty +-1 +0 0 1 +0 +0 +38 4 7 +46 4 7 +7 0 2 0 0 0 2 +38 46 +_sim_empty +-1 +1 1 1 +0 +0 +54 4 8 +62 4 8 +8 0 2 0 0 0 2 +54 62 +_sim_empty +-1 +0 1 1 +0 +0 +1 5 1 1 3 +8 5 1 9 16 +1 1 2 0 1 0 2 1 2 +1 8 +_sim_empty +-1 +1 0.5 0 0.5 0 +0 +0 +4 5 2 1 8 +5 5 2 9 12 +2 1 2 0 1 0 2 1 4 +4 5 +_sim_empty +-1 +1 0.5 0.5 0 0 +0 +0 +12 5 3 1 24 +13 5 3 9 28 +3 1 2 0 1 0 2 1 6 +12 13 +_sim_empty +-1 +1 0.5 0 0 0.5 +0 +0 +2 5 4 3 5 +7 5 4 16 14 +4 1 2 0 1 0 2 2 3 +2 7 +_sim_empty +-1 +1 0.5 0.5 1 0 +0 +0 +26 5 5 3 54 +31 5 5 16 62 +5 1 2 0 1 0 2 2 8 +26 31 +_sim_empty +-1 +1 0.5 0 1 0.5 +0 +0 +3 5 6 5 8 +6 5 6 14 12 +6 1 2 0 1 0 2 3 4 +3 6 +_sim_empty +-1 +1 0.5 1 0.5 0 +0 +0 +18 5 7 5 38 +23 5 7 14 46 +7 1 2 0 1 0 2 3 7 +18 23 +_sim_empty +-1 +1 0.5 1 1 0.5 +0 +0 +10 5 8 8 21 +15 5 8 12 30 +8 1 2 0 1 0 2 4 5 +10 15 +_sim_empty +-1 +1 0.5 1 0 0.5 +0 +0 +11 5 9 21 24 +14 5 9 30 28 +9 1 2 0 1 0 2 5 6 +11 14 +_sim_empty +-1 +1 0.5 0.5 0 1 +0 +0 +19 5 10 21 38 +22 5 10 30 46 +10 1 2 0 1 0 2 5 7 +19 22 +_sim_empty +-1 +1 0.5 1 0.5 1 +0 +0 +35 5 11 24 54 +38 5 11 28 62 +11 1 2 0 1 0 2 6 8 +35 38 +_sim_empty +-1 +1 0.5 0 0.5 1 +0 +0 +27 5 12 38 54 +30 5 12 46 62 +12 1 2 0 1 0 2 7 8 +27 30 +_sim_empty +-1 +1 0.5 0.5 1 1 +0 +0 +1 6 1 1 0 2 +4 1 1 1 4 2 1 6 3 1 2 4 0 2 6 1 0 0 1 +4 2 5 1 6 6 0 4 7 0 1 8 0 1 2 2 0 2 0 +1 1 +0 + + 1 2 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +0 +3 6 2 1 0 4 +4 2 4 1 8 10 1 9 11 1 3 12 0 4 6 2 0 0 3 +4 3 13 1 9 14 0 8 15 0 2 5 0 2 2 2 0 2 0 +1 3 +0 + + 1 4 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +0 +5 6 3 1 0 6 +4 6 3 0 7 18 1 10 19 0 8 10 0 6 6 3 0 0 5 +4 8 15 1 10 22 1 7 23 0 6 6 1 3 2 2 0 2 0 +1 5 +0 + + 1 6 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +0 +7 6 4 1 0 8 +4 4 2 0 5 26 1 12 27 0 7 18 0 8 6 4 0 0 7 +4 7 23 1 12 30 1 5 31 0 4 7 1 4 2 2 0 2 0 +1 7 +0 + + 1 8 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +0 +9 6 5 1 0 10 +4 1 1 0 3 12 1 11 35 1 5 26 0 10 6 5 0 0 9 +4 5 31 1 11 38 0 3 13 0 1 8 1 5 2 2 0 2 0 +1 9 +0 + + 1 10 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +0 +11 6 6 1 0 12 +4 9 11 0 10 19 1 12 27 1 11 35 0 12 6 6 0 0 11 +4 11 38 1 12 30 0 10 22 0 9 14 1 6 2 2 0 2 0 +1 11 +0 + + 1 12 +0 + +0 +_sim_empty +-1 +0 0 0 0 0 0 +0 +0 +1 8 1 6 +1 0 2 0 3 0 4 0 5 0 6 0 1 3 2 0 3 0 1 +1 +0 +0 +_sim_empty +-1 +0 -1 +2 8 -1 6 +1 1 5 1 4 1 3 1 2 1 6 1 -1 3 8 0 303 0 1 +2 +0 +0 +_sim_empty +-1 +0 +0 -1 +0 -1 +0 -1 +0 -1 +0 -1 + auxmm 3 +0 +0 + sms 14 +sms 14 0 +0 0 +0 6 12 8 8 +5.0000000000000002e-11 1e-14 +1 10 03 +0 0 0 0 +0 +1 +2 10 03 +0 0 1 0 +0 +1 +3 10 03 +0 1 1 0 +0 +1 +4 10 03 +0 1 0 0 +0 +1 +5 10 03 +0 1 0 1 +0 +1 +6 10 03 +0 0 0 1 +0 +1 +7 10 03 +0 1 1 1 +0 +1 +8 10 03 +0 0 1 1 +0 +1 +1 10 12 0 1 +2 10 12 0 3 +3 10 12 0 5 +4 10 12 1 2 +5 10 12 1 7 +6 10 12 2 3 +7 10 12 2 6 +8 10 12 3 4 +9 10 12 4 5 +a 10 12 4 6 +b 10 12 5 7 +c 10 12 6 7 +1 10 24+1+4+6-2 +2 10 24+2+8+9-3 +3 10 24-6+7-a-8 +4 10 24-4+5-c-7 +5 10 24-1+3+b-5 +6 10 24-9+a+c-b + +3 +smd 8 +auxmm 2660 +sms 2679 + +
+4 +77 file:///space/cwsmith/compassLandice/omegahDev/omega_h/meshes/Example_hex.smd26 model.nonmanifold.discrete6 # 1 0 0 +0 +0 +
+3146 3191 From ad6b7e025d2fe25290b2d96427a505d14d3aac19 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 1 Apr 2024 15:25:17 -0400 Subject: [PATCH 74/78] split loader: general and a square model test --- src/CMakeLists.txt | 7 +++- src/simModel2dLoad.cpp | 61 --------------------------- src/simModel2dLoad_square.cpp | 79 +++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 63 deletions(-) create mode 100644 src/simModel2dLoad_square.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ed49c024..22eaf135f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -432,10 +432,13 @@ if(BUILD_TESTING) osh_add_exe(simModel2dLoad) set(TEST_EXES ${TEST_EXES} simModel2dLoad) - test_func(simModel2dLoad_square 1 ./simModel2dLoad - ${CMAKE_SOURCE_DIR}/meshes/square.smd) will_fail_test_func(simModel2dLoad_3d 1 ./simModel2dLoad ${CMAKE_SOURCE_DIR}/meshes/Example_hex.smd) + + osh_add_exe(simModel2dLoad_square) + set(TEST_EXES ${TEST_EXES} simModel2dLoad_square) + test_func(simModel2dLoad_square 1 ./simModel2dLoad_square + ${CMAKE_SOURCE_DIR}/meshes/square.smd) endif() osh_add_exe(load_2d) diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp index 6cfc4ccdf..fc021ce61 100644 --- a/src/simModel2dLoad.cpp +++ b/src/simModel2dLoad.cpp @@ -1,30 +1,5 @@ #include #include -#include // operator==(LOs,LOs) -#include // operator==(LOs,LOs) - -void printGraph(const Omega_h::Graph& g, std::string_view name) { - std::cout << name << " {\n"; - Omega_h::HostRead offsets(g.a2ab); - Omega_h::HostRead vals(g.ab2b); - for(int i=0; i a(arr); - for(int i=0; i +#include +#include // operator==(LOs,LOs) +#include + +void printGraph(const Omega_h::Graph& g, std::string_view name) { + std::cout << name << " {\n"; + Omega_h::HostRead offsets(g.a2ab); + Omega_h::HostRead vals(g.ab2b); + for(int i=0; i a(arr); + for(int i=0; i Date: Tue, 2 Apr 2024 12:54:28 -0400 Subject: [PATCH 75/78] enable check for release build OMEGA_H_CHECK is a no-op when NDEBUG is defined --- src/Omega_h_simModel2d.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 5af2972eb..77dba5e08 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -416,15 +416,22 @@ void setAdjInfo(Model2D& mdl, Adjacencies& adj) { mdl.faceIds.size(), 1, 2); } +void checkError(bool cond, std::string_view msg) { + if( !cond ) { + std::cerr << msg; + exit(EXIT_FAILURE); + } +} + Model2D Model2D::SimModel2D_load(std::string const& filename) { OMEGA_H_TIME_FUNCTION; pNativeModel nm = NULL; pProgress p = NULL; pGModel g = GM_load(filename.c_str(), nm, p); const char* msg2d = "Simmetrix GeomSim model is not 2D... exiting\n"; - OMEGA_H_CHECK_MSG(isModel2D(g), msg2d); + checkError(isModel2D(g), msg2d); const char* msgValid = "Simmetrix GeomSim model is not valid... exiting\n"; - OMEGA_H_CHECK_MSG(isValid(g), msgValid); + checkError(isValid(g), msgValid); //collect per entity info const auto vtxInfo = getVtxInfo(g); From cce0697c054d463905b818d672891789195ad840 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 2 Apr 2024 13:33:01 -0400 Subject: [PATCH 76/78] cleanup [skip ci] --- src/Omega_h_simModel2d.cpp | 79 ++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 46 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 77dba5e08..3184b2477 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -179,41 +179,32 @@ struct CSR { CSR(); }; -enum GetUsesMode { //FIXME - remove this - CountAdj = 1, - SetAdj = 2 -}; - //TODO determine EntType from EntInfo... they need to match template -struct EntToAdjUse : public CSR { - EntToAdjUse(const EntInfo& entInfo_in, const EntInfo& destEntInfo_in) - : entInfo(entInfo_in), - CSR(entInfo_in.ids.size()), +struct Adjacency : public CSR { + Adjacency(const EntInfo& srcEntInfo_in, const EntInfo& destEntInfo_in) + : CSR(srcEntInfo_in.ids.size()), + srcEntIdToIdx(srcEntInfo_in.idToIdx), destEntIdToIdx(destEntInfo_in.idToIdx) {} - const EntInfo& entInfo; + const std::map& srcEntIdToIdx; const std::map& destEntIdToIdx; - template //FIXME - remove this - void countOrSet(SrcEntType srcEnt, DestEntType destEnt) { //split into two functions: count and set - static_assert((mode == GetUsesMode::CountAdj || mode == GetUsesMode::SetAdj), - "countOrSet called with invalid mode"); + void count(SrcEntType srcEnt, DestEntType destEnt) { OMEGA_H_TIME_FUNCTION; - if constexpr (mode == GetUsesMode::CountAdj) { - ScopedTimer timer("EntToAdjUse::count"); - const auto srcEntId = GEN_tag(srcEnt); - const auto srcEntIdx = entInfo.idToIdx.at(srcEntId); - incrementDegree(srcEntIdx); - } else { - ScopedTimer timer("EntToAdjUse::set"); - const auto srcEntId = GEN_tag(srcEnt); - const auto srcEntIdx = entInfo.idToIdx.at(srcEntId); - const auto destEntId = GEN_tag(destEnt); - const auto destEntIdx = destEntIdToIdx.at(destEntId); - setValue(srcEntIdx, destEntIdx); - } + ScopedTimer timer("Adjacency::count"); + const auto srcEntId = GEN_tag(srcEnt); + const auto srcEntIdx = srcEntIdToIdx.at(srcEntId); + incrementDegree(srcEntIdx); + } + void set(SrcEntType srcEnt, DestEntType destEnt) { + ScopedTimer timer("Adjacency::set"); + const auto srcEntId = GEN_tag(srcEnt); + const auto srcEntIdx = srcEntIdToIdx.at(srcEntId); + const auto destEntId = GEN_tag(destEnt); + const auto destEntIdx = destEntIdToIdx.at(destEntId); + setValue(srcEntIdx, destEntIdx); } private: - EntToAdjUse(); + Adjacency(); }; /* @@ -296,10 +287,10 @@ struct SetUseDir { struct Adjacencies { - EntToAdjUse eu2v; - EntToAdjUse e2eu; - EntToAdjUse lu2f; - EntToAdjUse eu2lu; + Adjacency eu2v; + Adjacency e2eu; + Adjacency lu2f; + Adjacency eu2lu; static const int e2euDegree = 2; static const int eu2vDegree = 2; @@ -311,19 +302,17 @@ struct Adjacencies { CountUses(Adjacencies& adj) : adj_(adj) {} void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { - const auto Mode = GetUsesMode::CountAdj; - adj_.lu2f.countOrSet(loopUse, modelFace); + adj_.lu2f.count(loopUse, modelFace); } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { - const auto Mode = GetUsesMode::CountAdj; auto edge = GEU_edge(edgeUse); - adj_.eu2lu.countOrSet(edgeUse, loopUse); - adj_.e2eu.countOrSet(edge,edgeUse); + adj_.eu2lu.count(edgeUse, loopUse); + adj_.e2eu.count(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); - adj_.eu2v.countOrSet(edgeUse,vtx0); + adj_.eu2v.count(edgeUse,vtx0); auto vtx1 = GE_vertex(edge,1); - adj_.eu2v.countOrSet(edgeUse,vtx1); + adj_.eu2v.count(edgeUse,vtx1); } }; @@ -332,19 +321,17 @@ struct Adjacencies { SetUses(Adjacencies& adj) : adj_(adj) {} void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { - const auto Mode = GetUsesMode::SetAdj; - adj_.lu2f.countOrSet(loopUse, modelFace); + adj_.lu2f.set(loopUse, modelFace); } void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { - const auto Mode = GetUsesMode::SetAdj; auto edge = GEU_edge(edgeUse); - adj_.eu2lu.countOrSet(edgeUse, loopUse); - adj_.e2eu.countOrSet(edge,edgeUse); + adj_.eu2lu.set(edgeUse, loopUse); + adj_.e2eu.set(edge,edgeUse); auto vtx0 = GE_vertex(edge,0); - adj_.eu2v.countOrSet(edgeUse, vtx0); + adj_.eu2v.set(edgeUse, vtx0); auto vtx1 = GE_vertex(edge,1); - adj_.eu2v.countOrSet(edgeUse, vtx1); + adj_.eu2v.set(edgeUse, vtx1); } }; From 779f57bb4f6c7cc31ef70f6d22936b80bc7baea5 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Tue, 2 Apr 2024 14:14:05 -0400 Subject: [PATCH 77/78] better type safety --- src/Omega_h_simModel2d.cpp | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp index 3184b2477..542ad877b 100644 --- a/src/Omega_h_simModel2d.cpp +++ b/src/Omega_h_simModel2d.cpp @@ -43,8 +43,12 @@ struct VtxInfo : public EntInfo { Reals coords; }; -struct EdgeInfo : public EntInfo {}; -struct FaceInfo : public EntInfo {}; +struct EdgeInfo : public EntInfo { + using EntType = pGEdge; +}; +struct FaceInfo : public EntInfo { + using EntType = pGFace; +}; struct UseInfoPrecursor { UseInfoPrecursor() : idx(0) {} @@ -87,8 +91,15 @@ struct UseInfo : public EntInfo { } }; -using LoopUseInfo = UseInfo; -using EdgeUseInfo = UseInfo; +struct LoopUseInfo : public UseInfo { + LoopUseInfo(UseInfoPrecursor& uip) : UseInfo(uip) {} + using EntType = pGLoopUse; +}; + +struct EdgeUseInfo : public UseInfo { + EdgeUseInfo(UseInfoPrecursor& uip) : UseInfo(uip) {} + using EntType = pGEdgeUse; +}; VtxInfo getVtxInfo(pGModel mdl) { OMEGA_H_TIME_FUNCTION; @@ -179,23 +190,22 @@ struct CSR { CSR(); }; -//TODO determine EntType from EntInfo... they need to match -template +template struct Adjacency : public CSR { - Adjacency(const EntInfo& srcEntInfo_in, const EntInfo& destEntInfo_in) + Adjacency(const SrcEntInfo& srcEntInfo_in, const DestEntInfo& destEntInfo_in) : CSR(srcEntInfo_in.ids.size()), srcEntIdToIdx(srcEntInfo_in.idToIdx), destEntIdToIdx(destEntInfo_in.idToIdx) {} const std::map& srcEntIdToIdx; const std::map& destEntIdToIdx; - void count(SrcEntType srcEnt, DestEntType destEnt) { + void count(typename SrcEntInfo::EntType srcEnt, typename DestEntInfo::EntType destEnt) { OMEGA_H_TIME_FUNCTION; ScopedTimer timer("Adjacency::count"); const auto srcEntId = GEN_tag(srcEnt); const auto srcEntIdx = srcEntIdToIdx.at(srcEntId); incrementDegree(srcEntIdx); } - void set(SrcEntType srcEnt, DestEntType destEnt) { + void set(typename SrcEntInfo::EntType srcEnt, typename DestEntInfo::EntType destEnt) { ScopedTimer timer("Adjacency::set"); const auto srcEntId = GEN_tag(srcEnt); const auto srcEntIdx = srcEntIdToIdx.at(srcEntId); @@ -287,10 +297,10 @@ struct SetUseDir { struct Adjacencies { - Adjacency eu2v; - Adjacency e2eu; - Adjacency lu2f; - Adjacency eu2lu; + Adjacency eu2v; + Adjacency e2eu; + Adjacency lu2f; + Adjacency eu2lu; static const int e2euDegree = 2; static const int eu2vDegree = 2; From 86e2b4accd2d13abb46e2f2e256632231e6d2054 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Thu, 4 Apr 2024 20:32:15 -0400 Subject: [PATCH 78/78] return by value --- src/Omega_h_mesh2d.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Omega_h_mesh2d.cpp b/src/Omega_h_mesh2d.cpp index 8c48d3346..96202cd4b 100644 --- a/src/Omega_h_mesh2d.cpp +++ b/src/Omega_h_mesh2d.cpp @@ -17,8 +17,7 @@ std::optional Mesh2D::getModel() const { } Model2D Mesh2D::updateModel() { - model = Model2D::MeshModel2D_load(*this); - return *model; + return Model2D::MeshModel2D_load(*this); } } // Omega_h