diff --git a/CMakeLists.txt b/CMakeLists.txt index 397508ba1..c303aa888 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,10 +14,6 @@ endif() include(cmake/bob.cmake) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) -set(CMAKE_MODULE_PATH - ${CMAKE_MODULE_PATH} - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") - bob_begin_package() bob_option(Omega_h_CHECK_BOUNDS "Check array bounds when running on host (makes code slow too)" OFF) 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 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 new file mode 100644 index 000000000..afedd181e --- /dev/null +++ b/meshes/square.smd @@ -0,0 +1,1345 @@ +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 + auxmm 3 +0 +0 + attributes 10 +AttDBVersion 10 8 +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 +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 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 +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 83 +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 83 +1 2 96 +0 +9 Smoothing +0 +0 0 1 +0 +0 +1 1 +0 +2 +1 2 97 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +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 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 40 +0 +11 EnforceSize +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 42 +0 +13 SmoothingType +0 +0 0 1 +0 +0 +1 1 +0 +0 +1 2 43 +0 +12 Optimization +0 +0 0 1 +0 +0 +1 1 +0 +1 +1 2 86 +0 +8 ModifyBL +0 +0 0 1 +0 +0 +1 1 +0 +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 +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 +0 0 1 +0 +0 +2 -1 +0 +3 .23 +1 3 26 +0 +17 FaceRotationLimit +0 +0 0 1 +0 +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 +
+8074 8126 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 248ab7f55..1d58037bd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,11 +108,12 @@ 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() - set(Omega_h_SOURCES ${Omega_h_SOURCES} + list(APPEND Omega_h_SOURCES Omega_h_random.cpp Omega_h_coarsen_flip.cpp ) @@ -120,14 +121,14 @@ endif() if (Omega_h_USE_CUDA) if (NOT Omega_h_USE_Kokkos) - set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_for.cpp) + list(APPEND Omega_h_SOURCES Omega_h_for.cpp) endif() else() - set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_overlay.cpp) + list(APPEND Omega_h_SOURCES Omega_h_overlay.cpp) endif() if(Omega_h_USE_libMeshb) - set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_meshb.cpp) + list(APPEND Omega_h_SOURCES Omega_h_meshb.cpp) endif() if(Omega_h_USE_EGADS) @@ -152,7 +153,7 @@ if(Omega_h_USE_EGADS) endif() message(STATUS "EGADS_INCLUDE_DIR: ${EGADS_INCLUDE_DIR}") message(STATUS "EGADS_LIBRARY: ${EGADS_LIBRARY}") - set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_egads.cpp) + list(APPEND Omega_h_SOURCES Omega_h_egads.cpp) endif() if(Omega_h_USE_SimModSuite) @@ -163,23 +164,23 @@ if(Omega_h_USE_SimModSuite) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") find_package(SimModSuite MODULE REQUIRED) 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) + list(APPEND Omega_h_SOURCES Omega_h_meshsim.cpp Omega_h_matchMeshsim.cpp + Omega_h_simModel2d.cpp) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/Omega_h_simConfig.h.in" "${CMAKE_CURRENT_BINARY_DIR}/Omega_h_simConfig.h") endif() if(Omega_h_USE_SEACASExodus) - set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_exodus.cpp) + list(APPEND Omega_h_SOURCES Omega_h_exodus.cpp) endif() if(Omega_h_USE_STK) - set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_stk.cpp) + list(APPEND Omega_h_SOURCES Omega_h_stk.cpp) endif() if(Omega_h_USE_DOLFIN) - set(Omega_h_SOURCES ${Omega_h_SOURCES} Omega_h_dolfin.cpp) + list(APPEND Omega_h_SOURCES Omega_h_dolfin.cpp) endif() if(Omega_h_USE_Kokkos) @@ -427,6 +428,16 @@ if(BUILD_TESTING) ${CMAKE_SOURCE_DIR}/meshes) osh_add_exe(periodic_test) + + osh_add_exe(simModel2dLoad) + set(TEST_EXES ${TEST_EXES} simModel2dLoad) + 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) @@ -696,15 +707,15 @@ set(Omega_h_HEADERS ) if (NOT Omega_h_USE_CUDA) - set(Omega_h_HEADERS ${Omega_h_HEADERS} Omega_h_overlay.hpp) + list(APPEND Omega_h_HEADERS Omega_h_overlay.hpp) endif() if(Omega_h_USE_DOLFIN) - set(Omega_h_HEADERS ${Omega_h_HEADERS} Omega_h_dolfin.hpp) + list(APPEND Omega_h_HEADERS Omega_h_dolfin.hpp) endif() if(Omega_h_USE_STK) - set(Omega_h_HEADERS ${Omega_h_HEADERS} Omega_h_stk.hpp) + list(APPEND Omega_h_HEADERS Omega_h_stk.hpp) endif() if(Omega_h_USE_Kokkos) 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_mesh2d.cpp b/src/Omega_h_mesh2d.cpp index c31a211a9..96202cd4b 100644 --- a/src/Omega_h_mesh2d.cpp +++ b/src/Omega_h_mesh2d.cpp @@ -12,4 +12,12 @@ void Mesh2D::set_dim(Int dim_in) { dim_ = dim_in; } -} // Omega_h \ No newline at end of file +std::optional Mesh2D::getModel() const { + return model; +} + +Model2D Mesh2D::updateModel() { + return Model2D::MeshModel2D_load(*this); +} + +} // Omega_h diff --git a/src/Omega_h_mesh2d.hpp b/src/Omega_h_mesh2d.hpp index 160744ffa..562d29a25 100644 --- a/src/Omega_h_mesh2d.hpp +++ b/src/Omega_h_mesh2d.hpp @@ -2,6 +2,8 @@ #define OMEGA_H_2DMESH_HPP #include +#include +#include namespace Omega_h { @@ -16,6 +18,17 @@ class Mesh2D final : public Mesh { OMEGA_H_CHECK(0 <= dim_ && dim_ <= 2); return dim_; } + + [[nodiscard]] std::optional getModel() const; + + /** + * update the model based on the current mesh + * and its classification + */ + Model2D updateModel(); + +private: + std::optional model; }; } // Omega_h 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_model2d.cpp b/src/Omega_h_model2d.cpp new file mode 100644 index 000000000..78bcc8dfb --- /dev/null +++ b/src/Omega_h_model2d.cpp @@ -0,0 +1,20 @@ +#include "Omega_h_model2d.hpp" +#include + +namespace Omega_h { + +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 new file mode 100644 index 000000000..985db72f7 --- /dev/null +++ b/src/Omega_h_model2d.hpp @@ -0,0 +1,52 @@ +#ifndef OMEGA_H_MODEL2D_HPP +#define OMEGA_H_MODEL2D_HPP + +#include +#include + +namespace Omega_h { + +//forward declare, avoid circular dependency +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); + void printInfo(); + //ids + 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; + Graph loopUseToEdgeUse; + LOs edgeUseToVtx; //each edgeUse has exactly two adjacent vertices + //upward adjacencies + Graph vtxToEdgeUse; + LOs edgeUseToLoopUse; //each edgeUse has one adjacent loop use + LOs loopUseToFace; //each loopUse has one adjacent face use + + //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. 1: forward, 0: backward + LOs loopUseOrientation; + + //geometry + Real vtxTol, edgeTol; + Reals vtxCoords; +private: + Model2D() = default; +}; + +} + +#endif //OMEGA_H_MODEL2D_HPP diff --git a/src/Omega_h_simModel2d.cpp b/src/Omega_h_simModel2d.cpp new file mode 100644 index 000000000..542ad877b --- /dev/null +++ b/src/Omega_h_simModel2d.cpp @@ -0,0 +1,466 @@ +#include +#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 +#include //std::fill +#include //std::exclusive_scan + +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); +} + +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); +} + +struct EntInfo { + LOs ids; + std::map idToIdx; +}; + +struct VtxInfo : public EntInfo { + using EntType = pGVertex; + Reals coords; +}; + +struct EdgeInfo : public EntInfo { + using EntType = pGEdge; +}; +struct FaceInfo : public EntInfo { + using EntType = pGFace; +}; + +struct UseInfoPrecursor { + UseInfoPrecursor() : idx(0) {} + std::map idToIdx; + std::vector ids_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) { + auto array = HostWrite(ids_h.size()); + std::copy(ids_h.begin(), ids_h.end(), array.data()); + return LOs(array); + } + UseInfo(UseInfoPrecursor& uip) { + ids = toDevice(uip.ids_h); + idToIdx = uip.idToIdx; + dir = LOs(uip.dir_h); + } +}; + +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; + 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 EdgeInfo{LOs(ids_h),idToIdx}; +} + +FaceInfo getFaceInfo(pGModel mdl) { + OMEGA_H_TIME_FUNCTION; + 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)) { + const auto id = GEN_tag(modelFace); + ids_h[idx] = id; + idToIdx[id] = idx; + idx++; + } + GFIter_delete(modelFaces); + return FaceInfo{LOs(ids_h), idToIdx}; +} + +struct CSR { + CSR(int size) { + OMEGA_H_TIME_FUNCTION; + offset = createAndInitArray(size+1); + count = createAndInitArray(size); + //values array is allocated once degree is populated + } + HostWrite offset; + 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 incrementDegree(const int entIdx) { + offset[entIdx] = offset[entIdx]+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; + count[entIdx]++; + } + private: + CSR(); +}; + +template +struct Adjacency : public CSR { + 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(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(typename SrcEntInfo::EntType srcEnt, typename DestEntInfo::EntType 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: + Adjacency(); +}; + +/* + * 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, 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)) { + op.loopUseOp(modelFace, loopUse); + auto edgeUses = GLU_edgeUseIter(loopUse); + pGEdgeUse edgeUse; + while(edgeUse=GEUIter_next(edgeUses)) { + op.edgeUseOp(loopUse, edgeUse); + } + GEUIter_delete(edgeUses); + } + GLUIter_delete(loopUses); + } //sides + } + GFIter_delete(modelFaces); +} + +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); + 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); + 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 { + Adjacency eu2v; + Adjacency e2eu; + Adjacency lu2f; + Adjacency 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) {} + + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { + adj_.lu2f.count(loopUse, modelFace); + } + + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { + auto edge = GEU_edge(edgeUse); + adj_.eu2lu.count(edgeUse, loopUse); + adj_.e2eu.count(edge,edgeUse); + auto vtx0 = GE_vertex(edge,0); + adj_.eu2v.count(edgeUse,vtx0); + auto vtx1 = GE_vertex(edge,1); + adj_.eu2v.count(edgeUse,vtx1); + } + }; + + struct SetUses { + Adjacencies& adj_; + SetUses(Adjacencies& adj) : adj_(adj) {} + + void loopUseOp(pGFace modelFace, pGLoopUse loopUse) { + adj_.lu2f.set(loopUse, modelFace); + } + + void edgeUseOp(pGLoopUse loopUse, pGEdgeUse edgeUse) { + auto edge = GEU_edge(edgeUse); + adj_.eu2lu.set(edgeUse, loopUse); + adj_.e2eu.set(edge,edgeUse); + auto vtx0 = GE_vertex(edge,0); + adj_.eu2v.set(edgeUse, vtx0); + auto vtx1 = GE_vertex(edge,1); + adj_.eu2v.set(edgeUse, vtx1); + } + }; + + 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 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(); + e2eu.degreeToOffset(); + eu2v.degreeToOffset(); + eu2lu.degreeToOffset(); + SetUses setUses(*this); + traverseUses(g, setUses); + //check degree + checkDegree(lu2f.offset, lu2fDegree); + checkDegree(eu2lu.offset, eu2luDegree); + checkDegree(eu2v.offset, eu2vDegree); + checkDegree(e2eu.offset, e2euDegree); + } +}; + +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 setLoopUseIdsAndDir(Model2D& mdl, const LoopUseInfo& loopUseInfo) { + mdl.loopUseIds = loopUseInfo.ids; + mdl.loopUseOrientation = loopUseInfo.dir; +} + +void setEdgeUseIdsAndDir(Model2D& mdl, const EdgeUseInfo& edgeUseInfo) { + mdl.edgeUseIds = edgeUseInfo.ids; + mdl.edgeUseOrientation = edgeUseInfo.dir; +} + +void setAdjInfo(Model2D& mdl, Adjacencies& adj) { + mdl.edgeToEdgeUse = Graph(LOs(adj.e2eu.offset), LOs(adj.e2eu.values)); + mdl.edgeUseToVtx = LOs(adj.eu2v.values); + mdl.loopUseToFace = LOs(adj.lu2f.values); + mdl.edgeUseToLoopUse = LOs(adj.eu2lu.values); + + //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); +} + +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"; + checkError(isModel2D(g), msg2d); + const char* msgValid = "Simmetrix GeomSim model is not valid... exiting\n"; + checkError(isValid(g), msgValid); + + //collect per entity info + const auto vtxInfo = getVtxInfo(g); + const auto edgeInfo = getEdgeInfo(g); + const auto faceInfo = getFaceInfo(g); + + // 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); + + //collect adjacency info + Adjacencies adj(g, vtxInfo, edgeInfo, faceInfo, edgeUseInfo, loopUseInfo); + + //setup model + auto mdl = Model2D(); + setVertexInfo(mdl, vtxInfo); + setEdgeIds(mdl, edgeInfo); + setFaceIds(mdl, faceInfo); + setLoopUseIdsAndDir(mdl, loopUseInfo); + setEdgeUseIdsAndDir(mdl, edgeUseInfo); + setAdjInfo(mdl, adj); + + GM_release(g); + return mdl; +} + +}//end namespace Omega_h 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(); } diff --git a/src/simModel2dLoad.cpp b/src/simModel2dLoad.cpp new file mode 100644 index 000000000..fc021ce61 --- /dev/null +++ b/src/simModel2dLoad.cpp @@ -0,0 +1,14 @@ +#include +#include + +int main(int argc, char** argv) { + auto lib = Omega_h::Library(&argc, &argv); + if( argc != 2 ) { + fprintf(stderr, "Usage: %s inputSimModel.smd\n", argv[0]); + exit(EXIT_FAILURE); + } + OMEGA_H_CHECK(argc == 2); + auto model = Omega_h::Model2D::SimModel2D_load(argv[1]); + model.printInfo(); + return 0; +} diff --git a/src/simModel2dLoad_square.cpp b/src/simModel2dLoad_square.cpp new file mode 100644 index 000000000..69dda1357 --- /dev/null +++ b/src/simModel2dLoad_square.cpp @@ -0,0 +1,79 @@ +#include +#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