Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,9 @@ runs:
shell: bash
if: ${{ inputs.os == 'windows-latest' }}
run: |
unset VCPKG_ROOT
git clone https://github.com/microsoft/vcpkg.git
./vcpkg/bootstrap-vcpkg.bat
cd vcpkg
git checkout "$VCPKG_COMMIT"
./bootstrap-vcpkg.bat
echo "VCPKG_ROOT=${GITHUB_WORKSPACE}/vcpkg" >> "$GITHUB_ENV"
11 changes: 7 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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 }})"
Expand Down Expand Up @@ -63,17 +64,18 @@ jobs:
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 Dependencies (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
./vcpkg/vcpkg install vtk embree
./vcpkg/vcpkg install --triplet x64-windows

- name: 🏗️ Compile (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
cmake -DVIENNAPS_BUILD_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -B build
cmake -DVIENNAPS_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)
Expand All @@ -83,4 +85,5 @@ jobs:
cmake --build build --config ${{ matrix.config }}

- name: 🧪 Test
run: ctest --output-on-failure -E "Benchmark|Performance" -C ${{ matrix.config }} --test-dir build
run: |
ctest --output-on-failure -E "Benchmark|Performance" -C ${{ matrix.config }} --test-dir build
10 changes: 7 additions & 3 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
container: ${{ matrix.container }}

env:
VCPKG_COMMIT: c3867e714dd3a51c272826eea77267876517ed99
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.vcpkg-bincache

name: "🐍 Test Bindings on ${{ matrix.os }}"
Expand Down Expand Up @@ -60,12 +61,13 @@ jobs:
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 Dependencies (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: pwsh
run: |
./vcpkg/vcpkg install vtk embree
./vcpkg/vcpkg install --triplet x64-windows

- name: 🛠️ Enable GPU Bindings (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand All @@ -81,7 +83,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 viennaps; print(viennaps.__doc__)"

- name: 🐍 Build and check Python Module (Other)
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ include("cmake/cpm.cmake")

CPMAddPackage(
NAME ViennaCore
VERSION 2.1.1
GIT_TAG main
VERSION 2.1.2
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaCore"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON}
OPTIONS "VIENNACORE_USE_GPU ${VIENNAPS_USE_GPU}")
Expand All @@ -127,6 +126,7 @@ CPMAddPackage(
CPMAddPackage(
NAME ViennaLS
VERSION 5.7.1
GIT_TAG master
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaLS"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON}
OPTIONS "VIENNALS_PRECOMPILE_HEADERS ${VIENNAPS_PRECOMPILE_HEADERS}")
Expand Down
29 changes: 29 additions & 0 deletions include/viennaps/psDomainSetup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
#include "psPreCompileMacros.hpp"
#include "psUtil.hpp"

#include <cstdint>
#include <hrleGrid.hpp>
#include <vcLogger.hpp>

#include <istream>
#include <ostream>

namespace viennaps {

using namespace viennacore;
Expand Down Expand Up @@ -167,6 +171,31 @@ template <int D> class DomainSetup {
VIENNACORE_LOG_ERROR("Domain setup is not correctly initialized.");
}
}

void serialize(std::ostream &out) const {
out.write(reinterpret_cast<const char *>(&gridDelta_), sizeof(gridDelta_));

out.write(reinterpret_cast<const char *>(bounds_), sizeof(double) * 2 * D);

for (int i = 0; i < D; i++) {
const auto boundary = static_cast<int32_t>(boundaryCons_[i]);
out.write(reinterpret_cast<const char *>(&boundary), sizeof(boundary));
}
}

void deserialize(std::istream &in) {
in.read(reinterpret_cast<char *>(&gridDelta_), sizeof(gridDelta_));

in.read(reinterpret_cast<char *>(bounds_), sizeof(double) * 2 * D);

for (int i = 0; i < D; i++) {
int32_t boundary = 0;
in.read(reinterpret_cast<char *>(&boundary), sizeof(boundary));
boundaryCons_[i] = static_cast<BoundaryType>(boundary);
}

init();
}
};

} // namespace viennaps
28 changes: 23 additions & 5 deletions include/viennaps/psReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ VIENNAPS_TEMPLATE_ND(NumericType, D) class Reader {
return;
}

// Clear existing domain data
domain->clear();

// Check identifier
char identifier[8];
fin.read(identifier, 8);
Expand All @@ -76,19 +79,34 @@ VIENNAPS_TEMPLATE_ND(NumericType, D) class Reader {
// Check format version
char formatVersion;
fin.read(&formatVersion, 1);
if (formatVersion > 1) {
if (formatVersion > 2) {
VIENNACORE_LOG_ERROR("Reading domain of version " +
std::to_string(formatVersion) +
" with reader of version 1 failed.");
" with reader of version 2 failed.");
return;
}

// Clear existing domain data
domain->clear();
if (formatVersion >= 2) {
// Read dimension and check it matches the reader's dimension
char dimension;
fin.read(&dimension, 1);
if (dimension != D) {
VIENNACORE_LOG_ERROR("Reading domain failed. Domain dimension " +
std::to_string(dimension) +
" does not match reader dimension " +
std::to_string(D) + ".");
return;
}
}

// Read domain setup
typename Domain<NumericType, D>::Setup setup;
fin.read(reinterpret_cast<char *>(&setup), sizeof(setup));
if (formatVersion >= 2) {
setup.deserialize(fin);
} else {
// Legacy formats store setup as a raw object dump.
fin.read(reinterpret_cast<char *>(&setup), sizeof(setup));
}
domain->setup(setup);

// Read number of level sets
Expand Down
32 changes: 10 additions & 22 deletions include/viennaps/psWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ VIENNAPS_TEMPLATE_ND(NumericType, D) class Writer {
private:
SmartPointer<Domain<NumericType, D>> domain = nullptr;
std::string fileName;
bool meshOutput = false;

public:
Writer() = default;
Expand All @@ -44,8 +43,6 @@ VIENNAPS_TEMPLATE_ND(NumericType, D) class Writer {
fileName = std::move(passedFileName);
}

void setMeshOutput(bool meshOutputFlag) { meshOutput = meshOutputFlag; }

void apply() {
// check domain
if (domain == nullptr) {
Expand All @@ -60,8 +57,7 @@ VIENNAPS_TEMPLATE_ND(NumericType, D) class Writer {
}

if (fileName.find(".vpsd") != fileName.length() - 5) {
VIENNACORE_LOG_WARNING(
"File name does not end in '.vpsd', appending it.");
VIENNACORE_LOG_INFO("File name does not end in '.vpsd', appending it.");
fileName.append(".vpsd");
}

Expand All @@ -70,19 +66,18 @@ VIENNAPS_TEMPLATE_ND(NumericType, D) class Writer {

// Write header identifier
fout << "psDomain";
if (meshOutput) {
fout << "ForMesher";
}

// Version 1 serializes materials by stable names.
char formatVersion = 1;
// Write format version for future compatibility.
char formatVersion = 2;
fout.write(&formatVersion, 1);

// Since version 2: write dimension
char dimension = static_cast<char>(D);
fout.write(&dimension, 1);

// Write domain setup
if (!meshOutput) {
auto &setup = domain->getSetup();
fout.write(reinterpret_cast<const char *>(&setup), sizeof(setup));
}
auto &setup = domain->getSetup();
setup.serialize(fout);

// Write number of level sets
auto &levelSets = domain->getLevelSets();
Expand All @@ -108,14 +103,7 @@ VIENNAPS_TEMPLATE_ND(NumericType, D) class Writer {
// Write each material by canonical name for stable cross-run I/O.
for (size_t i = 0; i < numMaterials; i++) {
const auto material = materialMap->getMaterialAtIdx(i);
std::string materialName;
if (material.isBuiltIn()) {
materialName = MaterialMap::toString(material);
} else {
materialName =
std::string(MaterialRegistry::instance().getName(material));
}

std::string materialName = MaterialMap::toString(material);
const auto nameLength = static_cast<uint32_t>(materialName.size());
fout.write(reinterpret_cast<const char *>(&nameLength),
sizeof(uint32_t));
Expand Down
9 changes: 6 additions & 3 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,12 @@ add_dependencies(${PROJECT_NAME} ${VIENNAPS_PYTHON_MODULE_NAME})

set(VIENNAPS_LIB_FOLDER "${VIENNAPS_LIBRARY_OUTPUT_DIR}/${VIENNAPS_PYTHON_PACKAGE_NAME}.libs")

viennacore_setup_embree_env(${VIENNAPS_PYTHON_MODULE_NAME} "${VIENNAPS_LIB_FOLDER}")
viennacore_setup_vtk_env(${VIENNAPS_PYTHON_MODULE_NAME} "${VIENNAPS_LIB_FOLDER}")
viennacore_setup_tbb_env(${VIENNAPS_PYTHON_MODULE_NAME} "${VIENNAPS_LIB_FOLDER}")
if(VIENNAPS_PACKAGE_PYTHON OR MSVC)
# Copy the required libraries to the lib folder, this is required for packaging and on Windows
viennacore_setup_embree_env(${VIENNAPS_PYTHON_MODULE_NAME} "${VIENNAPS_LIB_FOLDER}")
viennacore_setup_vtk_env(${VIENNAPS_PYTHON_MODULE_NAME} "${VIENNAPS_LIB_FOLDER}")
viennacore_setup_tbb_env(${VIENNAPS_PYTHON_MODULE_NAME} "${VIENNAPS_LIB_FOLDER}")
endif()

install(
DIRECTORY ${VIENNAPS_LIB_FOLDER}
Expand Down
10 changes: 5 additions & 5 deletions python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def _windows_dll_path():
]

for path in additional_paths:
if not os.path.exists(path):
continue

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.")


def _module_ptx_path():
Expand Down
3 changes: 0 additions & 3 deletions python/pyWrapDimension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,9 +1437,6 @@ template <int D> void bindApi(py::module &module) {
"Set the domain to be written to a file.")
.def("setFileName", &Writer<T, D>::setFileName,
"Set the output file name (should end with .vpsd).")
.def("setMeshOutput", &Writer<T, D>::setMeshOutput,
"Set wether Domain should be further processed in the ViennaMesh "
"mesher.")
.def("apply", &Writer<T, D>::apply,
"Write the domain to the specified file.");

Expand Down
4 changes: 0 additions & 4 deletions python/viennaps/d2/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,3 @@ class Writer:
"""
Set the output file name (should end with .vpsd).
"""
def setMeshOutput(self, arg0: bool) -> None:
"""
Set wether Domain should be further processed in the ViennaMesh mesher.
"""
4 changes: 0 additions & 4 deletions python/viennaps/d3/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,3 @@ class Writer:
"""
Set the output file name (should end with .vpsd).
"""
def setMeshOutput(self, arg0: bool) -> None:
"""
Set wether Domain should be further processed in the ViennaMesh mesher.
"""
9 changes: 9 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "viennaps-ci",
"version-string": "4.3.0",
"dependencies": [
"vtk",
"embree"
],
"builtin-baseline": "c3867e714dd3a51c272826eea77267876517ed99"
}
Loading