Skip to content

Commit

Permalink
Merging develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightly Bot authored and cwsmith committed Oct 29, 2024
2 parents 24dd23e + d423332 commit 4484480
Show file tree
Hide file tree
Showing 26 changed files with 19,780 additions and 59 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -30,17 +30,27 @@ 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:
MPICH_CXX: ${{matrix.compiler.CXX}}
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
24 changes: 10 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,31 @@ include(cmake/xsdk.cmake)

option(USE_XSDK_DEFAULTS "enable the XDSK v0.3.0 default configuration" NO)

#requre c++11 without extensions
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSION OFF)
if(NOT ENABLE_CGNS)
set(CMAKE_CXX_STANDARD 11)
endif()

xsdk_begin_package()
bob_begin_package()

if(USE_XSDK_DEFAULTS)
xsdk_compiler_flags()
endif()

# require c++14
option(ENABLE_CGNS "Enable the CGNS reader: requires c++14 extensions" OFF)
message(STATUS "ENABLE_CGNS: ${ENABLE_CGNS}")
if(NOT ENABLE_CGNS)
bob_set_cxx_standard(11)
else()
message(STATUS "enabling cxx14")
bob_set_cxx_standard(14)
endif()

# Set some default compiler flags that should always be used
if(NOT USE_XSDK_DEFAULTS)
bob_set_shared_libs()
bob_begin_cxx_flags()
bob_end_cxx_flags()
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
if(ENABLE_CGNS) #takes precedence over SCOREC_ENABLE_CXX11
message(STATUS "enabling cxx14")
if(ENABLE_CGNS)
bob_cxx14_flags()
elseif(SCOREC_ENABLE_CXX11)
else()
bob_cxx11_flags()
endif()
endif()
Expand All @@ -60,6 +57,8 @@ message(STATUS "IS_TESTING: ${IS_TESTING}")

set(MESHES "${CMAKE_SOURCE_DIR}/pumi-meshes" CACHE STRING "Directory of test meshes")
message(STATUS "MESHES: ${MESHES}")
set(SMOKE_TEST_MESHES "${CMAKE_SOURCE_DIR}/smoke_test_meshes" CACHE STRING "Directory of
meshes used for smoke testing")

option(BUILD_EXES "Build executables" ON)
message(STATUS "BUILD_EXES: ${BUILD_EXES}")
Expand Down Expand Up @@ -193,9 +192,6 @@ add_library(core INTERFACE)
target_link_libraries(core INTERFACE ${SCOREC_EXPORTED_TARGETS})
if(ENABLE_CGNS)
target_link_libraries(core INTERFACE ${CMAKE_DL_LIBS}) #HDF5 uses dlopen
target_compile_features(core INTERFACE cxx_std_14)
else()
target_compile_features(core INTERFACE cxx_std_11)
endif()
scorec_export_library(core)

Expand Down
31 changes: 24 additions & 7 deletions apf_cap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

#directory containing apf_simConfig.h
target_include_directories(apf_cap PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

scorec_export_library(apf_cap)

Expand Down
92 changes: 90 additions & 2 deletions apf_cap/apfCAP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
#include <gmi.h>
#include <gmi_cap.h>
#include <cstdlib>
#include <mth.h>
#include <pcu_util.h>
#include <algorithm>
#include <lionPrint.h>

#ifdef HAVE_CAPSTONE_SIZINGMETRICTOOL
#include <CreateMG_SizingMetricTool.h>
#endif

namespace apf {

Expand Down Expand Up @@ -540,7 +545,7 @@ static MeshEntity* commonDown(Mesh2* m, MeshEntity* a, MeshEntity* b, int dim)
for (int i = 0; i < na; i++)
for (int j = 0; j < nb; j++)
if (aDown[i] == bDown[j])
return aDown[i];
return aDown[i];
return 0;
}

Expand Down Expand Up @@ -618,7 +623,7 @@ class TagCAP
{
public:
TagCAP(MeshDatabaseInterface* m,
const char* n,
const char* n,
int c):
mesh(m),
count(c),
Expand Down Expand Up @@ -942,5 +947,88 @@ 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
// Ensure input is a MeshCAP.
apf::MeshCAP* m = dynamic_cast<apf::MeshCAP*>(mesh);
if (!m) {
lion_eprint(1, "ERROR: smoothCAPAnisoSizes: mesh is not an apf::MeshCAP*\n");
return false;
}

// Extract metric tensors from MeshAdapt frames and scales.
std::vector<Metric6> 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); // Desired element lengths.
apf::getMatrix(frames, e, 0, Q); // MeshAdapt uses column vectors.
apf::Matrix3x3 L(1.0/(H[0]*H[0]), 0, 0,
0, 1.0/(H[1]*H[1]), 0,
0, 0, 1.0/(H[2]*H[2]));
apf::Matrix3x3 t = Q * L * apf::transpose(Q); // Invert orthogonal frames.
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<Metric6> 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]); // Eigenvectors in rows of Q.
PCU_DEBUG_ASSERT(n == 3);
Q = apf::transpose(Q); // Put eigenvectors back into columns for MeshAdapt.
for (int i = 0; i < 3; ++i) {
H[i] = 1.0/sqrt(H[i]);
}
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
25 changes: 25 additions & 0 deletions apf_cap/apfCAP.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,31 @@ class MeshCAP : public Mesh2
std::vector<TagCAP*> 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* scales, apf::Field* frames);

}//namespace apf

Expand Down
4 changes: 2 additions & 2 deletions cmake/FindSimModSuite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ string(REGEX REPLACE
"${SIM_VERSION}")

set(MIN_VALID_SIM_VERSION 15.0.191017)
set(MAX_VALID_SIM_VERSION 2024.1.240606)
set(MAX_VALID_SIM_VERSION 2025.0.241016)
if( ${SKIP_SIMMETRIX_VERSION_CHECK} )
message(STATUS "Skipping Simmetrix SimModSuite version check."
" This may result in undefined behavior")
Expand Down Expand Up @@ -124,7 +124,7 @@ endif()
option(SIM_PARASOLID "Use Parasolid through Simmetrix" OFF)
if (SIM_PARASOLID)
set(MIN_SIM_PARASOLID_VERSION 290)
set(MAX_SIM_PARASOLID_VERSION 361)
set(MAX_SIM_PARASOLID_VERSION 370)
foreach(version RANGE
${MAX_SIM_PARASOLID_VERSION}
${MIN_SIM_PARASOLID_VERSION} -1)
Expand Down
Loading

0 comments on commit 4484480

Please sign in to comment.