From c5ab193d40092b78f65f37b0587b467880cc9fbd Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 30 Aug 2024 11:22:19 -0400 Subject: [PATCH 01/19] heredoc for multiline message --- ...immetrix_enabled_pr_comment_trigger_self_hosted.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/simmetrix_enabled_pr_comment_trigger_self_hosted.yml b/.github/workflows/simmetrix_enabled_pr_comment_trigger_self_hosted.yml index 58f780b9c..7a0883fc4 100644 --- a/.github/workflows/simmetrix_enabled_pr_comment_trigger_self_hosted.yml +++ b/.github/workflows/simmetrix_enabled_pr_comment_trigger_self_hosted.yml @@ -99,9 +99,13 @@ jobs: run: | mkdir -p ./pr echo "${{ github.event.issue.number }}" > ./pr/issueNumber - echo "[Build Log](https://github.com/${{github.repository}}/actions/runs/${{ github.run_id }})" >> ./pr/message - echo "Simmetrix Test Result: ${{ steps.build_sim.outcome }} " >> ./pr/message - echo "Simmetrix + CGNS Test Result: ${{ steps.build_sim_cgns.outcome }} " >> ./pr/message + message=$(cat << HEREDOC + [Build Log](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) + Simmetrix Test Result: ${{steps.build_sim.outcome}} + Simmetrix + CGNS Test Result: ${{steps.build_sim_cgns.outcome}} + HEREDOC + ) + echo "$message" > ./pr/message - name: Upload result if: ${{ !cancelled() }} #upload unless the job was cancelled From f079f68ececc4286ca58e9ebacdbfd7a3ab03370 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 16:10:14 -0400 Subject: [PATCH 02/19] complete user cmake example --- doc/{user_CMakeLists.cmake => CMakeLists.txt} | 5 +++-- doc/mylibrary.cpp | 9 +++++++++ doc/mylibrary.h | 4 ++++ doc/myprogram.cpp | 10 ++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) rename doc/{user_CMakeLists.cmake => CMakeLists.txt} (90%) create mode 100644 doc/mylibrary.cpp create mode 100644 doc/mylibrary.h create mode 100644 doc/myprogram.cpp diff --git a/doc/user_CMakeLists.cmake b/doc/CMakeLists.txt similarity index 90% rename from doc/user_CMakeLists.cmake rename to doc/CMakeLists.txt index a83281340..c218c4632 100644 --- a/doc/user_CMakeLists.cmake +++ b/doc/CMakeLists.txt @@ -31,8 +31,9 @@ else() endif() #this is just example code, do your own thing -add_executable(mylibrary mylibrary.cpp) +add_library(mylibrary mylibrary.cpp) add_executable(myprogram myprogram.cpp) +target_include_directories(myprogram PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) #for any targets that use PUMI, just use this command #to it to include the right directories and link to all @@ -40,4 +41,4 @@ add_executable(myprogram myprogram.cpp) #we recommend PUBLIC if the target is a library and #PRIVATE if the target is an executable target_link_libraries(mylibrary PUBLIC SCOREC::core) -target_link_libraries(myprogram PRIVATE SCOREC::core) +target_link_libraries(myprogram PRIVATE mylibrary) diff --git a/doc/mylibrary.cpp b/doc/mylibrary.cpp new file mode 100644 index 000000000..e20dbf63a --- /dev/null +++ b/doc/mylibrary.cpp @@ -0,0 +1,9 @@ +#include +#include +#include +#include +void makeMesh() { + gmi_register_mesh(); + apf::Mesh2* m = apf::makeMdsBox(1,1,1,1,1,1,0); + apf::destroyMesh(m); +} diff --git a/doc/mylibrary.h b/doc/mylibrary.h new file mode 100644 index 000000000..655125a61 --- /dev/null +++ b/doc/mylibrary.h @@ -0,0 +1,4 @@ +#ifndef MYLIBRARY_H +#define MYLIBRARH_H +void makeMesh(); +#endif diff --git a/doc/myprogram.cpp b/doc/myprogram.cpp new file mode 100644 index 000000000..1049a50b3 --- /dev/null +++ b/doc/myprogram.cpp @@ -0,0 +1,10 @@ +#include +#include "mylibrary.h" +int main(int argc, char** argv) { + MPI_Init(&argc,&argv); + PCU_Comm_Init(); + makeMesh(); + PCU_Comm_Free(); + MPI_Finalize(); + return 0; +} From dc3ff3cde0be75e64539a3d4241a770e8059292e Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 16:19:52 -0400 Subject: [PATCH 03/19] install and build user project --- .github/workflows/cmake.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 39ed4a701..a00e7a727 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -36,7 +36,7 @@ jobs: env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} - run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j + run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} -j --target install - name: Test env: @@ -44,3 +44,13 @@ jobs: MPICH_CC: ${{matrix.compiler.CC}} working-directory: ${{github.workspace}}/build run: ctest --output-on-failure -C ${{matrix.build_type}} + + - name: Build User Project + # only need to test with a single build config if the installed cmake config files work + if: ${{ matrix.compiler == 'GNU' }} && ${{ matrix.build_type == 'Release' }} + env: + MPICH_CXX: ${{matrix.compiler.CXX}} + MPICH_CC: ${{matrix.compiler.CC}} + run: | + cmake -S ${{github.workspace}}/doc -B ${{github.workspace}}/buildExample -DCMAKE_CXX_COMPILER=mpicxx -DSCOREC_PREFIX=${{github.workspace}}/build/install + cmake --build ${{github.workspace}}/buildExample From 3cb981e7aad9193fb3f1db7de4092980d19aa84d Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 16:25:43 -0400 Subject: [PATCH 04/19] set install path --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index a00e7a727..075a07d89 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -30,7 +30,7 @@ jobs: env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} - run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_C_COMPILER=mpicc -DCMAKE_VERBOSE_MAKEFILE=ON -DMESHES=${{github.workspace}}/pumi-meshes -DIS_TESTING=ON -DSCOREC_CXX_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} + run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_C_COMPILER=mpicc -DCMAKE_VERBOSE_MAKEFILE=ON -DMESHES=${{github.workspace}}/pumi-meshes -DIS_TESTING=ON -DSCOREC_CXX_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install - name: Build env: From 19e9453e35ea8dd6be2d68adaa4be7232d8afe23 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 16:30:18 -0400 Subject: [PATCH 05/19] fix typo --- doc/mylibrary.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/mylibrary.h b/doc/mylibrary.h index 655125a61..2777caadb 100644 --- a/doc/mylibrary.h +++ b/doc/mylibrary.h @@ -1,4 +1,4 @@ #ifndef MYLIBRARY_H -#define MYLIBRARH_H +#define MYLIBRARY_H void makeMesh(); #endif From 10de84359268f20fb8014c679a267faab5e49f57 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 16:41:14 -0400 Subject: [PATCH 06/19] fix ci conditional --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 075a07d89..68116e6f0 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -47,7 +47,7 @@ jobs: - name: Build User Project # only need to test with a single build config if the installed cmake config files work - if: ${{ matrix.compiler == 'GNU' }} && ${{ matrix.build_type == 'Release' }} + if: ${{ matrix.compiler == 'GNU' && matrix.build_type == 'Release' }} env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} From 60c94ce9860db5c9f9d58e0b907f6b78a9afb569 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 21:36:33 -0400 Subject: [PATCH 07/19] compiler comparison attempt --- .github/workflows/cmake.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 68116e6f0..8b4fe2a60 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -12,8 +12,8 @@ jobs: fail-fast: false matrix: compiler: - - { compiler: GNU, CC: gcc-10, CXX: g++-10 } - - { compiler: LLVM, CC: clang, CXX: clang++ } + - { compiler: "GNU", CC: gcc-10, CXX: g++-10 } + - { compiler: "LLVM", CC: clang, CXX: clang++ } build_type: [Debug, Release] steps: @@ -47,7 +47,7 @@ jobs: - name: Build User Project # only need to test with a single build config if the installed cmake config files work - if: ${{ matrix.compiler == 'GNU' && matrix.build_type == 'Release' }} + if: matrix.compiler == 'GNU' # && matrix.build_type == 'Release' #the compiler comparison is wrong env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} From f3e9bd31c38a4493cb4eaa293412e3df6ec12bac Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 21:51:55 -0400 Subject: [PATCH 08/19] update checkout actions --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 8b4fe2a60..306d356b0 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -17,7 +17,7 @@ jobs: build_type: [Debug, Release] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive From 88a39f6c4db82e82595c47cfc7fdfb56cbf3fec0 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Fri, 6 Sep 2024 21:56:16 -0400 Subject: [PATCH 09/19] name is a field of the compiler entry --- .github/workflows/cmake.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 306d356b0..445d9905e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -12,8 +12,8 @@ jobs: fail-fast: false matrix: compiler: - - { compiler: "GNU", CC: gcc-10, CXX: g++-10 } - - { compiler: "LLVM", CC: clang, CXX: clang++ } + - { name: GNU, CC: gcc-10, CXX: g++-10 } + - { name: LLVM, CC: clang, CXX: clang++ } build_type: [Debug, Release] steps: @@ -47,7 +47,7 @@ jobs: - name: Build User Project # only need to test with a single build config if the installed cmake config files work - if: matrix.compiler == 'GNU' # && matrix.build_type == 'Release' #the compiler comparison is wrong + if: matrix.compiler.name == 'GNU' && matrix.build_type == 'Release' env: MPICH_CXX: ${{matrix.compiler.CXX}} MPICH_CC: ${{matrix.compiler.CC}} From a1f08e5da1c120c8d7fff8c02af3c9e582ab8d2b Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Thu, 29 Aug 2024 10:23:13 -0400 Subject: [PATCH 10/19] Set bob install dir to CMAKE_LIBDIR - Fixes issues on 64bit systems when LIBDIR=lib64. CMake would relink to $ORIGIN:$ORIGIN/../lib64 and all the libs would be in lib. Signed-off-by: Aiden Woodruff --- cmake/bob.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/bob.cmake b/cmake/bob.cmake index 52c312666..eae99e9fb 100644 --- a/cmake/bob.cmake +++ b/cmake/bob.cmake @@ -156,8 +156,8 @@ endmacro(bob_public_dep) function(bob_export_target tgt_name) install(TARGETS ${tgt_name} EXPORT ${tgt_name}-target RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(EXPORT ${tgt_name}-target NAMESPACE ${PROJECT_NAME}:: DESTINATION lib/cmake/${PROJECT_NAME}) set(${PROJECT_NAME}_EXPORTED_TARGETS From 7cc2e23864cb1dc95ede55502ce7a79414db4c39 Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Fri, 6 Sep 2024 11:18:17 -0400 Subject: [PATCH 11/19] Replace other lib with LIBDIR and bin with BINDIR - Update CMake exported target install dir to CMAKE_INSTALL_LIBDIR. - Update executable destination to CMAKE_INSTALL_BINDIR. - Add quotes to directory names in case of spaces. Signed-off-by: Aiden Woodruff --- cmake/bob.cmake | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/bob.cmake b/cmake/bob.cmake index eae99e9fb..72c192a7f 100644 --- a/cmake/bob.cmake +++ b/cmake/bob.cmake @@ -155,11 +155,11 @@ endmacro(bob_public_dep) function(bob_export_target tgt_name) install(TARGETS ${tgt_name} EXPORT ${tgt_name}-target - RUNTIME DESTINATION bin - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") install(EXPORT ${tgt_name}-target NAMESPACE ${PROJECT_NAME}:: - DESTINATION lib/cmake/${PROJECT_NAME}) + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") set(${PROJECT_NAME}_EXPORTED_TARGETS ${${PROJECT_NAME}_EXPORTED_TARGETS} ${tgt_name} PARENT_SCOPE) endfunction(bob_export_target) @@ -174,7 +174,7 @@ endmacro(bob_end_subdir) function(bob_end_package) include(CMakePackageConfigHelpers) set(INCLUDE_INSTALL_DIR include) - set(LIB_INSTALL_DIR lib) + set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") set(CONFIG_CONTENT " set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION}) include(CMakeFindDependencyMacro) @@ -213,7 +213,7 @@ set(${PROJECT_NAME}_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\") ") install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - DESTINATION lib/cmake/${PROJECT_NAME}) + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") if(PROJECT_VERSION) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake @@ -224,6 +224,6 @@ set(${PROJECT_NAME}_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\") COMPATIBILITY SameMajorVersion) install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" - DESTINATION lib/cmake/${PROJECT_NAME}) + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") endif() endfunction(bob_end_package) From 7df25b303aa8ad9ff09f2cec85d85040816047ad Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Fri, 6 Sep 2024 11:30:13 -0400 Subject: [PATCH 12/19] Replace include with CMAKE_INSTALL_INCLUDEDIR Signed-off-by: Aiden Woodruff --- cmake/bob.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/bob.cmake b/cmake/bob.cmake index 72c192a7f..4cbd4f84c 100644 --- a/cmake/bob.cmake +++ b/cmake/bob.cmake @@ -173,7 +173,7 @@ endmacro(bob_end_subdir) function(bob_end_package) include(CMakePackageConfigHelpers) - set(INCLUDE_INSTALL_DIR include) + set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") set(CONFIG_CONTENT " set(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_VERSION}) From 02c41e5888e5dee601d1eea4e8dab3d9c4535a87 Mon Sep 17 00:00:00 2001 From: Aditya Joshi Date: Fri, 9 Aug 2024 16:43:14 -0400 Subject: [PATCH 13/19] Fix logic checking periodic model faces --- ma/maSnap.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ma/maSnap.cc b/ma/maSnap.cc index 195dca005..73217e73b 100644 --- a/ma/maSnap.cc +++ b/ma/maSnap.cc @@ -477,8 +477,10 @@ static void interpolateParametricCoordinatesOnRegularFace( { double range[2]; int dim = m->getModelType(g); + bool gface_isPeriodic = 0; for (int d=0; d < dim; ++d) { bool isPeriodic = m->getPeriodicRange(g,d,range); + if ((dim == 2) && (isPeriodic > 0)) gface_isPeriodic = 1; p[d] = interpolateParametricCoordinate(t,a[d],b[d],range,isPeriodic, 0); } @@ -494,6 +496,8 @@ static void interpolateParametricCoordinatesOnRegularFace( // this need to be done for faces, only if (dim != 2) return; + if (!gface_isPeriodic) + return; Vector x; bool ok; From 2e031e00036b4423240b66ef359dd2354ac7e4b7 Mon Sep 17 00:00:00 2001 From: Aditya Joshi Date: Fri, 9 Aug 2024 16:49:23 -0400 Subject: [PATCH 14/19] spell check --- ma/maSnap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ma/maSnap.cc b/ma/maSnap.cc index 73217e73b..d75426e8d 100644 --- a/ma/maSnap.cc +++ b/ma/maSnap.cc @@ -486,7 +486,7 @@ static void interpolateParametricCoordinatesOnRegularFace( /* check if the new point is inside the model. * otherwise re-run the above loop with last option - * in "interpolateParametricCoordinae" being 1. + * in "interpolateParametricCoordinate" being 1. * Notes * 1) we are assuming manifold surfaces * 2) we only check for faces that are periodic From 367396e82c7022e1fed3fd1373c9e70d963865fb Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Fri, 20 Sep 2024 17:46:57 -0400 Subject: [PATCH 15/19] Add apf::smoothCAPAnisoSizes Signed-off-by: Aiden Woodruff --- apf_cap/apfCAP.cc | 78 +++++++++++++++++++++++++++++++++++++++++++++++ apf_cap/apfCAP.h | 25 +++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/apf_cap/apfCAP.cc b/apf_cap/apfCAP.cc index 8e59797e8..8b75d9606 100644 --- a/apf_cap/apfCAP.cc +++ b/apf_cap/apfCAP.cc @@ -5,9 +5,14 @@ #include #include #include +#include #include #include +#include +#ifdef HAVE_CAPSTONE_SIZINGMETRICTOOL +#include +#endif namespace apf { @@ -942,5 +947,78 @@ Mesh2* createMesh(MeshDatabaseInterface* mdb, GeometryDatabaseInterface* gdb) return m; } +bool has_smoothCAPAnisoSizes(void) noexcept { +#ifdef HAVE_CAPSTONE_SIZINGMETRICTOOL + return true; +#else + return false; +#endif +} + +bool smoothCAPAnisoSizes(apf::Mesh2* mesh, std::string analysis, + apf::Field* scales, apf::Field* frames) { +#ifdef HAVE_CAPSTONE_SIZINGMETRICTOOL + apf::MeshCAP* m = dynamic_cast(mesh); + if (!m) { + lion_eprint(1, "ERROR: smoothCAPAnisoSizes: mesh is not an apf::MeshCAP*\n"); + return false; + } + std::vector sizing6(m->count(0)); + apf::Matrix3x3 Q; + apf::Vector3 H; + apf::MeshIterator* it = m->begin(0); + for (apf::MeshEntity* e = m->iterate(it); e; e = m->iterate(it)) { + apf::getVector(scales, e, 0, H); + apf::getMatrix(frames, e, 0, Q); + apf::Matrix3x3 L(H[0], 0, 0, 0, H[1], 0, 0, 0, H[2]); + apf::Matrix3x3 t = Q * L * apf::invert(Q); + size_t id; + MG_API_CALL(m->getMesh(), get_id(fromEntity(e), id)); + PCU_DEBUG_ASSERT(id != 0); + --id; + sizing6[id][0] = t[0][0]; + sizing6[id][1] = t[0][1]; + sizing6[id][2] = t[0][2]; + sizing6[id][3] = t[1][1]; + sizing6[id][4] = t[1][2]; + sizing6[id][5] = t[2][2]; + } + m->end(it); + auto smooth_tool = get_sizing_metric_tool(m->getMesh()->get_context(), + "CreateSmoothingBase"); + if (smooth_tool == nullptr) { + lion_eprint(1, "ERROR: Unable to find \"CreateSmoothingBase\"\n"); + return false; + } + smooth_tool->set_context(m->getMesh()->get_context()); + M_MModel mmodel; + MG_API_CALL(m->getMesh(), get_current_model(mmodel)); + smooth_tool->set_metric(mmodel, "sizing6", sizing6); + std::vector ometric; + smooth_tool->smooth_metric(mmodel, analysis, "sizing6", ometric); + it = m->begin(0); + for (apf::MeshEntity* e = m->iterate(it); e; e = m->iterate(it)) { + size_t id; + MG_API_CALL(m->getMesh(), get_id(fromEntity(e), id)); + PCU_DEBUG_ASSERT(id != 0); + --id; + const Metric6& m = ometric[id]; + apf::Matrix3x3 t(m[0], m[1], m[2], + m[1], m[3], m[4], + m[2], m[4], m[5]); + PCU_DEBUG_ASSERT(apf::eigen(t, &Q[0], &H[0]) == 3); + apf::setMatrix(frames, e, 0, Q); + apf::setVector(scales, e, 0, H); + } + m->end(it); + return true; +#else + (void) mesh; + (void) analysis; + (void) scales; + (void) frames; + apf::fail("smoothCAPAnisoSizes: Capstone does not have SizingMetricTool."); +#endif +} }//namespace apf diff --git a/apf_cap/apfCAP.h b/apf_cap/apfCAP.h index 102716bed..9b8c5005d 100644 --- a/apf_cap/apfCAP.h +++ b/apf_cap/apfCAP.h @@ -182,6 +182,31 @@ class MeshCAP : public Mesh2 std::vector tags; }; +/** + * \brief Test for smoothCAPAnisoSizes support. + * + * \return A boolean indicating whether support was compiled. False indicates + * the call would fail. + * + * \details smoothCAPAnisoSizes is only compiled if support for the underlying + * call is detected in the version of Capstone apf_cap was compiled + * against. Otherwise the call will always apf::fail. Use this + * function to programmatically test for the capability. + */ +bool has_smoothCAPAnisoSizes(void) noexcept; + +/** + * \brief Use the SizingMetricTool to smooth a size field on a Capstone mesh. + * + * \param m A Capstone mesh. + * \param analysis The Capstone analysis to use. + * \param frames An apf::Field of apf::Matrix3x3 with orthogonal basis frames. + * \param scales An apf::Field of apf::Vector3 with frame scales (eigenvalues). + * \return A boolean indicating success. + * \pre m must be an apf::MeshCAP. + */ +bool smoothCAPAnisoSizes(apf::Mesh2* m, std::string analysis, + apf::Field* frames, apf::Field* scales); }//namespace apf From 594fd521b54379139f3ef2eb3d8ddc63cde925e6 Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Fri, 20 Sep 2024 17:50:12 -0400 Subject: [PATCH 16/19] Add apf::smoothCAPAnisoSizes compile flags - If given HAVE_CAPSTONE_SIZINGMETRICTOOL, compile apf_cap with C++14 and link to framework_meshing. - Install to CMAKE_INSTALL_INCLUDEDIR. - Remove -I${CMAKE_BINARY_DIR} because there's no apf_capConfig.h.in. Signed-off-by: Aiden Woodruff --- apf_cap/CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apf_cap/CMakeLists.txt b/apf_cap/CMakeLists.txt index d4d2a74a6..5dcb4a580 100644 --- a/apf_cap/CMakeLists.txt +++ b/apf_cap/CMakeLists.txt @@ -16,14 +16,19 @@ add_library(apf_cap ${SOURCES}) target_link_libraries(apf_cap PUBLIC apf gmi_cap) target_link_libraries(apf_cap PUBLIC capstone_module framework_testing) -target_include_directories(apf_cap PUBLIC - $ - $ - ) -#directory containing apf_simConfig.h -target_include_directories(apf_cap PRIVATE - $) +if(HAVE_CAPSTONE_SIZINGMETRICTOOL) +target_compile_definitions(apf_cap PRIVATE HAVE_CAPSTONE_SIZINGMETRICTOOL) +target_link_libraries(apf_cap PRIVATE framework_meshing) +target_compile_features(apf_cap PRIVATE cxx_std_14) +endif() + +include(GNUInstallDirs) + +target_include_directories(apf_cap PUBLIC + $ + $ +) scorec_export_library(apf_cap) From 91bbfe968b454680c9453c8ae19ad00a0c65a684 Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Sat, 21 Sep 2024 20:27:24 -0400 Subject: [PATCH 17/19] Add feature test for sizing metric tool - I had to add C++14 to the check_include_file_cxx call. Signed-off-by: Aiden Woodruff --- apf_cap/CMakeLists.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apf_cap/CMakeLists.txt b/apf_cap/CMakeLists.txt index 5dcb4a580..597d6406a 100644 --- a/apf_cap/CMakeLists.txt +++ b/apf_cap/CMakeLists.txt @@ -7,6 +7,10 @@ if(NOT ENABLE_CAPSTONE) return() endif() +include(CMakePushCheckState) +include(CheckIncludeFileCXX) +cmake_policy(SET CMP0075 NEW) # Observe CMAKE_REQUIRED_LIBRARIES. + #Sources & Headers set(SOURCES apfCAP.cc) set(HEADERS apfCAP.h) @@ -17,6 +21,14 @@ target_link_libraries(apf_cap PUBLIC apf gmi_cap) target_link_libraries(apf_cap PUBLIC capstone_module framework_testing) +set(CMAKE_CXX_OLD_STANDARD "${CMAKE_CXX_STANDARD}") +cmake_push_check_state(RESET) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_REQUIRED_LIBRARIES "framework_meshing") +check_include_file_cxx("CreateMG_SizingMetricTool.h" HAVE_CAPSTONE_SIZINGMETRICTOOL) +cmake_pop_check_state() +set(CMAKE_CXX_STANDARD "${CMAKE_CXX_OLD_STANDARD}") + if(HAVE_CAPSTONE_SIZINGMETRICTOOL) target_compile_definitions(apf_cap PRIVATE HAVE_CAPSTONE_SIZINGMETRICTOOL) target_link_libraries(apf_cap PRIVATE framework_meshing) From ecc2e72ea182de0e47e25f520a32f9aff928b257 Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Sat, 21 Sep 2024 20:29:20 -0400 Subject: [PATCH 18/19] Add apf::smoothCAPAnisoSizes compilation test - Add compilation test to check that the compile definition worked. Signed-off-by: Aiden Woodruff --- test/CMakeLists.txt | 3 +++ test/cap_smooth.cc | 8 ++++++++ test/testing.cmake | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 test/cap_smooth.cc diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2495c0567..36cbaa07b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -212,6 +212,9 @@ endif() if(ENABLE_CAPSTONE) util_exe_func(capVol capVol.cc) target_include_directories(capVol PRIVATE "${PROJECT_SOURCE_DIR}/capstone_clis") + if(HAVE_CAPSTONE_SIZINGMETRICTOOL) + util_exe_func(cap_smooth cap_smooth.cc) + endif() endif() # send all the newly added utility executable targets diff --git a/test/cap_smooth.cc b/test/cap_smooth.cc new file mode 100644 index 000000000..c66cb6115 --- /dev/null +++ b/test/cap_smooth.cc @@ -0,0 +1,8 @@ +#include +#include + +int main (void) { + PCU_ALWAYS_ASSERT(apf::has_smoothCAPAnisoSizes()); + // FIXME: Test apf::smoothCAPAnisoSizes. + return 0; +} diff --git a/test/testing.cmake b/test/testing.cmake index e8b97537a..1d0e617c5 100644 --- a/test/testing.cmake +++ b/test/testing.cmake @@ -895,4 +895,7 @@ if(ENABLE_CAPSTONE) mpi_test(capVolWing 1 ./capVol -vg 2 ${MESHES}/cap/wing_surf_only.cre) mpi_test(capVolCube 1 ./capVol -vg 3 ${MESHES}/cap/cube_surf_only.cre) mpi_test(capVolCyl2 1 ./capVol -vg 4 ${MESHES}/cap/cyl_surf_only.cre) + if(HAVE_CAPSTONE_SIZINGMETRICTOOL) + mpi_test(cap_smooth 1 ./cap_smooth) + endif() endif() From ed783394864415c5fde0ab11fc538123a9a922f7 Mon Sep 17 00:00:00 2001 From: Aiden Woodruff Date: Tue, 24 Sep 2024 23:02:13 -0400 Subject: [PATCH 19/19] fix: Move function call outside of debug assert - Move std::eigen call outside of PCU_DEBUG_ASSERT so that it is called in Release mode. Signed-off-by: Aiden Woodruff --- apf_cap/apfCAP.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apf_cap/apfCAP.cc b/apf_cap/apfCAP.cc index 8b75d9606..ea66f83af 100644 --- a/apf_cap/apfCAP.cc +++ b/apf_cap/apfCAP.cc @@ -1006,7 +1006,8 @@ bool smoothCAPAnisoSizes(apf::Mesh2* mesh, std::string analysis, apf::Matrix3x3 t(m[0], m[1], m[2], m[1], m[3], m[4], m[2], m[4], m[5]); - PCU_DEBUG_ASSERT(apf::eigen(t, &Q[0], &H[0]) == 3); + int n = apf::eigen(t, &Q[0], &H[0]); + PCU_DEBUG_ASSERT(n == 3); apf::setMatrix(frames, e, 0, Q); apf::setVector(scales, e, 0, H); }