diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 39ed4a701..445d9905e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -12,12 +12,12 @@ 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: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive @@ -30,13 +30,13 @@ 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: 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.name == '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 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 diff --git a/apf_cap/CMakeLists.txt b/apf_cap/CMakeLists.txt index d4d2a74a6..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) @@ -16,14 +20,27 @@ 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 - $) +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) +target_compile_features(apf_cap PRIVATE cxx_std_14) +endif() + +include(GNUInstallDirs) + +target_include_directories(apf_cap PUBLIC + $ + $ +) scorec_export_library(apf_cap) diff --git a/apf_cap/apfCAP.cc b/apf_cap/apfCAP.cc index 8e59797e8..ea66f83af 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,79 @@ 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]); + 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); + } + 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 diff --git a/cmake/bob.cmake b/cmake/bob.cmake index 52c312666..4cbd4f84c 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 lib - LIBRARY DESTINATION lib) + 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) @@ -173,8 +173,8 @@ endmacro(bob_end_subdir) function(bob_end_package) include(CMakePackageConfigHelpers) - set(INCLUDE_INSTALL_DIR include) - set(LIB_INSTALL_DIR lib) + set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") + 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) 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..2777caadb --- /dev/null +++ b/doc/mylibrary.h @@ -0,0 +1,4 @@ +#ifndef MYLIBRARY_H +#define MYLIBRARY_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; +} diff --git a/ma/maSnap.cc b/ma/maSnap.cc index 195dca005..d75426e8d 100644 --- a/ma/maSnap.cc +++ b/ma/maSnap.cc @@ -477,14 +477,16 @@ 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); } /* 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 @@ -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; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0de50a896..7c874b151 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -214,6 +214,9 @@ if(ENABLE_CAPSTONE) target_include_directories(capVol PRIVATE "${PROJECT_SOURCE_DIR}/capstone_clis") test_exe_func(cap_inClosureOf cap_inClosureOf.cc) test_exe_func(cap_closestPoint cap_closestPoint.cc) + 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 14bd718f8..d91f4b0f6 100644 --- a/test/testing.cmake +++ b/test/testing.cmake @@ -897,4 +897,7 @@ if(ENABLE_CAPSTONE) mpi_test(capVolCyl2 1 ./capVol -vg 4 ${MESHES}/cap/cyl_surf_only.cre) mpi_test(cap_inClosureOf 1 ./cap_inClosureOf ${MESHES}/cap/cube_surf_only.cre) mpi_test(cap_closestPoint 1 ./cap_closestPoint ${MESHES}/cap/cube_surf_only.cre) + if(HAVE_CAPSTONE_SIZINGMETRICTOOL) + mpi_test(cap_smooth 1 ./cap_smooth) + endif() endif()