diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 798ff428..eabde0a8 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -51,9 +51,3 @@ runs: run: | echo "MACOSX_DEPLOYMENT_TARGET=15.0" >> $GITHUB_ENV - - name: Setup vcpkg (Windows) - shell: bash - if: ${{ inputs.os == 'windows-latest' }} - run: | - git clone https://github.com/microsoft/vcpkg.git - ./vcpkg/bootstrap-vcpkg.bat diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 678b4541..390a27f2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,6 +33,7 @@ jobs: container: ${{ matrix.container }} env: + VCPKG_COMMIT: c3867e714dd3a51c272826eea77267876517ed99 VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.vcpkg-bincache name: "๐Ÿงช Test on ${{ matrix.os }} (โš™๏ธ: ${{ matrix.config }}, ๐Ÿ’ฟ: ${{ matrix.container || matrix.os }})" @@ -50,28 +51,37 @@ jobs: if: ${{ matrix.os == 'macos-latest' }} run: brew install vtk - - name: Create vcpkg binary cache dir - if: ${{ matrix.os == 'windows-latest' }} + - name: ๐Ÿ–ฅ๏ธ Setup vcpkg (Windows) shell: pwsh + if: ${{ matrix.os == 'windows-latest' }} run: | + Remove-Item Env:VCPKG_ROOT -ErrorAction SilentlyContinue + + git clone https://github.com/microsoft/vcpkg.git + git -C vcpkg checkout $env:VCPKG_COMMIT + & .\vcpkg\bootstrap-vcpkg.bat + + "VCPKG_ROOT=$($env:GITHUB_WORKSPACE)\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + New-Item -ItemType Directory -Force -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" - - name: ๐Ÿฆฅ Cache VTK vcpkg build + - name: ๐Ÿฆฅ Cache vcpkg binary (Windows) if: ${{ matrix.os == 'windows-latest' }} uses: actions/cache@v4 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: vcpkg-${{ matrix.os }}-${{ matrix.config }} + key: vcpkg-${{ matrix.os }}-${{ matrix.config }}-${{ env.VCPKG_COMMIT }} - - name: ๐Ÿ› ๏ธ Build VTK (Windows) + - name: ๐Ÿ› ๏ธ Build Dependencies (Windows) if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh run: | - ./vcpkg/vcpkg install vtk + ./vcpkg/vcpkg install --triplet x64-windows - name: ๐Ÿ—๏ธ Compile (Windows) if: ${{ matrix.os == 'windows-latest' }} run: | - cmake -DVIENNALS_BUILD_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -B build + cmake -DVIENNALS_BUILD_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -B build cmake --build build --config ${{ matrix.config }} - name: ๐Ÿ—๏ธ Compile (other) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 51d86de3..da204efb 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -30,6 +30,7 @@ jobs: container: ${{ matrix.container }} env: + VCPKG_COMMIT: c3867e714dd3a51c272826eea77267876517ed99 VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.vcpkg-bincache name: "๐Ÿ Test Bindings on ${{ matrix.os }}" @@ -43,27 +44,36 @@ jobs: with: os: ${{ matrix.os }} - - name: ๐Ÿ“‹ Install MacOS Dependencies - if: ${{ matrix.os == 'macos-latest' }} - run: brew install vtk - - - name: Create vcpkg binary cache dir - if: ${{ matrix.os == 'windows-latest' }} + - name: ๐Ÿ–ฅ๏ธ Setup vcpkg (Windows) shell: pwsh + if: ${{ matrix.os == 'windows-latest' }} run: | + Remove-Item Env:VCPKG_ROOT -ErrorAction SilentlyContinue + + git clone https://github.com/microsoft/vcpkg.git + git -C vcpkg checkout $env:VCPKG_COMMIT + & .\vcpkg\bootstrap-vcpkg.bat + + "VCPKG_ROOT=$($env:GITHUB_WORKSPACE)\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + New-Item -ItemType Directory -Force -Path "${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" - - name: ๐Ÿฆฅ Cache VTK vcpkg build + - name: ๐Ÿ“‹ Install MacOS Dependencies + if: ${{ matrix.os == 'macos-latest' }} + run: brew install vtk + + - name: ๐Ÿฆฅ Cache vcpkg binary if: ${{ matrix.os == 'windows-latest' }} uses: actions/cache@v4 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: vcpkg-${{ matrix.os }}-Release + key: vcpkg-${{ matrix.os }}-Release-${{ env.VCPKG_COMMIT }} - name: ๐Ÿ› ๏ธ Build VTK (Windows) if: ${{ matrix.os == 'windows-latest' }} + shell: pwsh run: | - ./vcpkg/vcpkg install vtk + ./vcpkg/vcpkg install --triplet x64-windows - name: ๐Ÿ› ๏ธ Disable IPO if: ${{ matrix.os == 'ubuntu-latest' }} @@ -79,7 +89,9 @@ jobs: $toolchain = "${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake".Replace('\', '/') .\venv\Scripts\python -m pip install --upgrade pip - .\venv\Scripts\python -m pip install . --config-settings=cmake.args="-DCMAKE_TOOLCHAIN_FILE=$toolchain" + .\venv\Scripts\python -m pip install . ` + --config-settings=cmake.define.CMAKE_TOOLCHAIN_FILE="$toolchain" ` + --config-settings=cmake.define.VCPKG_TARGET_TRIPLET="x64-windows" .\venv\Scripts\python -c "import viennals; print(viennals.__doc__)" - name: ๐Ÿ Build and check Python Module (Other) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8450552b..19f3c2a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR) project( ViennaLS LANGUAGES CXX - VERSION 5.7.1) + VERSION 5.7.2) # -------------------------------------------------------------------------------------------------------- # Library options @@ -111,7 +111,7 @@ include(cmake/vtk.cmake) CPMAddPackage( NAME ViennaCore - VERSION 2.1.1 + VERSION 2.1.2 GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore" OPTIONS "VIENNACORE_FORMAT_EXCLUDE build/" EXCLUDE_FROM_ALL ${VIENNALS_BUILD_PYTHON}) diff --git a/README.md b/README.md index c4d257e6..efcadc81 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ We recommend using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to consum * Installation with CPM ```cmake - CPMAddPackage("gh:viennatools/viennals@5.6.0") + CPMAddPackage("gh:viennatools/viennals@5.7.2") ``` * With a local installation diff --git a/include/viennals/lsToHullMesh.hpp b/include/viennals/lsToHullMesh.hpp index 9cba1a66..8252a826 100644 --- a/include/viennals/lsToHullMesh.hpp +++ b/include/viennals/lsToHullMesh.hpp @@ -27,6 +27,7 @@ template class ToHullMesh { SmartPointer materialMap = nullptr; bool generateSharpCorners = false; T bottomExtension = 0.0; + double minNodeDistanceFactor = 0.05; /// Generate hull mesh using ToMultiSurfaceMesh and boundary caps. /// generateSharpCorners is forwarded to the converter. Works for both @@ -71,7 +72,7 @@ template class ToHullMesh { } // Generate multi-surface mesh with sharp corners - ToMultiSurfaceMesh converter; + ToMultiSurfaceMesh converter(minNodeDistanceFactor, 1e-12); for (auto &ls : levelSets) converter.insertNextLevelSet(ls); if (materialMap) @@ -89,7 +90,7 @@ template class ToHullMesh { double rangeMin, double rangeMax) { int varyingAxis = 1 - boundaryAxis; std::vector> boundaryNodes; - double tolerance = 1e-6 * gridDelta; + const double tolerance = 1e-6 * gridDelta; for (unsigned i = 0; i < multiMesh->nodes.size(); ++i) { if (std::abs(multiMesh->nodes[i][boundaryAxis] - fixedValue) < @@ -204,7 +205,7 @@ template class ToHullMesh { using EdgeKey = std::tuple; std::map edgeToNode; std::map, unsigned> existingGridNodes; - double invGridDelta = 1.0 / gridDelta; + const double invGridDelta = 1.0 / gridDelta; for (unsigned i = 0; i < multiMesh->nodes.size(); ++i) { const auto &pos = multiMesh->nodes[i]; @@ -447,6 +448,15 @@ template class ToHullMesh { } } + void setMinNodeDistanceFactor(double factor) { + if (factor <= 0) { + VIENNACORE_LOG_WARNING("ToHullMesh: minNodeDistanceFactor must be " + "positive. Ignoring value."); + return; + } + minNodeDistanceFactor = factor; + } + void apply() { generateHull(); } }; diff --git a/include/viennals/lsVersion.hpp b/include/viennals/lsVersion.hpp index 0498f9e7..b9b33c07 100644 --- a/include/viennals/lsVersion.hpp +++ b/include/viennals/lsVersion.hpp @@ -5,10 +5,10 @@ namespace viennals { // Version information generated by CMake -inline constexpr const char *version = "5.7.1"; +inline constexpr const char *version = "5.7.2"; inline constexpr int versionMajor = 5; inline constexpr int versionMinor = 7; -inline constexpr int versionPatch = 1; +inline constexpr int versionPatch = 2; // Utility functions for version comparison inline constexpr uint32_t versionAsInteger() { diff --git a/pyproject.toml b/pyproject.toml index b4c1ccbe..33cde00a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ requires = [ build-backend = "scikit_build_core.build" [project] -version = "5.7.1" +version = "5.7.2" name = "ViennaLS" readme = "README.md" license = {file = "LICENSE"} diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index dd14b5d0..192d3e8d 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -77,7 +77,10 @@ add_dependencies(${PROJECT_NAME} ${MOD}) set(VIENNALS_LIB_FOLDER ${CMAKE_BINARY_DIR}/${PKG}.libs) -viennacore_setup_vtk_env(${MOD} ${VIENNALS_LIB_FOLDER}) +if(VIENNALS_PACKAGE_PYTHON OR MSVC) + # Copy the required libraries to the lib folder, this is required for packaging and on Windows + viennacore_setup_vtk_env(${MOD} ${VIENNALS_LIB_FOLDER}) +endif() install( DIRECTORY ${VIENNALS_LIB_FOLDER} diff --git a/python/__init__.py b/python/__init__.py index 12459eb8..351206d4 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -18,8 +18,11 @@ def _windows_dll_path(): ] for path in additional_paths: - os.add_dll_directory(path) - os.environ["PATH"] = path + os.pathsep + os.environ["PATH"] + if os.path.isdir(path): + os.add_dll_directory(path) + os.environ["PATH"] = path + os.pathsep + os.environ["PATH"] + else: + print(f"Warning: DLL path {path} does not exist.") import sys as _sys @@ -51,6 +54,7 @@ def setDimension(d: int): else: raise ValueError("Dimension must be 2 or 3.") + def getDimension() -> int: """Get the current dimension of the simulation. @@ -61,6 +65,7 @@ def getDimension() -> int: """ return PROXY_DIM + def __getattr__(name): # 1) common/top-level from _core try: diff --git a/python/viennals/__init__.pyi b/python/viennals/__init__.pyi index b174a842..889e4d0d 100644 --- a/python/viennals/__init__.pyi +++ b/python/viennals/__init__.pyi @@ -112,6 +112,6 @@ def setDimension(d: int): """ PROXY_DIM: int = 2 -__version__: str = '5.7.1' -version: str = '5.7.1' +__version__: str = '5.7.2' +version: str = '5.7.2' _C = _core diff --git a/python/viennals/_core.pyi b/python/viennals/_core.pyi index f936fe5b..d88fb643 100644 --- a/python/viennals/_core.pyi +++ b/python/viennals/_core.pyi @@ -549,6 +549,6 @@ class VoidTopSurfaceEnum(enum.IntEnum): """ def setNumThreads(arg0: typing.SupportsInt | typing.SupportsIndex) -> None: ... -__version__: str = '5.7.1' -version: str = '5.7.1' +__version__: str = '5.7.2' +version: str = '5.7.2' IntegrationSchemeEnum = SpatialSchemeEnum diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..e0408443 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "viennals-ci", + "version-string": "1.0.0", + "dependencies": [ + "vtk" + ], + "builtin-baseline": "c3867e714dd3a51c272826eea77267876517ed99" +} \ No newline at end of file