Skip to content

Commit

Permalink
Merge pull request #43 from andrsd/ipol-fp
Browse files Browse the repository at this point in the history
Adding interpolated fluid properties
  • Loading branch information
andrsd authored Oct 24, 2023
2 parents e5216fc + 1bfe8f1 commit cea334c
Show file tree
Hide file tree
Showing 66 changed files with 12,538 additions and 600 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update -qq
sudo apt install lcov libfmt-dev python3-pybind11
sudo apt install lcov libfmt-dev libhdf5-dev libeigen3-dev python3-pybind11
- name: Install dependencies (macos)
if: startsWith(matrix.os, 'macos')
run: brew install cmake llvm@14 lcov fmt pybind11
run: brew install cmake llvm@14 lcov fmt hdf5 eigen pybind11

- name: Install python dependencies
run: |
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION VERSION 3.16)
cmake_minimum_required(VERSION VERSION 3.19)

project(
fprops
Expand All @@ -19,6 +19,8 @@ include(${PROJECT_SOURCE_DIR}/cmake/Sanitization.cmake)
option(FPROPS_WITH_PYTHON "Build python wrapper" YES)
option(FPROPS_BUILD_TESTS "Build tests" NO)

find_package(HDF5 1.8 COMPONENTS C HL REQUIRED)
find_package(Eigen3 3.3.4 REQUIRED)
find_package(fmt 8.0 REQUIRED)
if (FPROPS_WITH_PYTHON)
add_subdirectory(python)
Expand Down
5 changes: 5 additions & 0 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ if(FPROPS_CODE_COVERAGE)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CODE_COVERAGE_PROFRAWS}")

set(EXCLUDE_REGEX
--ignore-filename-regex=/contrib/
--ignore-filename-regex=/include/eigen3/
--ignore-filename-regex=/include/fmt/
)

set(CODE_COVERAGE_BINS
Expand Down Expand Up @@ -111,8 +114,10 @@ if(FPROPS_CODE_COVERAGE)
)

set(EXCLUDE_REGEX
--exclude=*/contrib/*
--exclude=/usr/include/*
--exclude=*/include/fmt/*
--exclude=*/include/eigen3/*
)

add_custom_target(coverage DEPENDS ${COVERAGE_INFO})
Expand Down
9 changes: 9 additions & 0 deletions contrib/h5pp/details/h5ppConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

#pragma once

namespace h5pp::constants {
static constexpr unsigned long maxSizeCompact = 32 * 1024; // Max size of compact datasets is 32 kb
static constexpr unsigned long maxSizeContiguous = 512 * 1024; // Max size of contiguous datasets is 512 kb
static constexpr unsigned long minChunkSize = 64 * 1024;
static constexpr unsigned long maxChunkSize = 256 * 1024;
}
8 changes: 8 additions & 0 deletions contrib/h5pp/details/h5ppDebug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once
namespace h5pp {
#ifdef NDEBUG
inline constexpr bool ndebug = true;
#else
inline constexpr bool ndebug = false;
#endif
}
111 changes: 111 additions & 0 deletions contrib/h5pp/details/h5ppDimensionType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#pragma once
#include "h5ppError.h"
#include "h5ppFormat.h"
#include "h5ppTypeSfinae.h"
#include <optional>
#include <utility>

namespace h5pp {
struct Options;
struct DsetInfo;
struct DataInfo;
struct TableInfo;
struct OptDimsType;
class Hyperslab;

struct DimsType {
std::vector<hsize_t> dims;
DimsType() = default;
explicit DimsType(H5D_layout_t) = delete;
explicit DimsType(hid::h5t) = delete;
explicit DimsType(hid_t) = delete;
explicit DimsType(std::string) = delete;
explicit DimsType(std::string_view) = delete;
explicit DimsType(const char *) = delete;
DimsType(h5pp::Options) = delete;
DimsType(h5pp::DsetInfo) = delete;
DimsType(h5pp::DataInfo) = delete;
DimsType(h5pp::TableInfo) = delete;
DimsType(h5pp::Hyperslab) = delete;
DimsType(const std::nullopt_t &) { throw h5pp::runtime_error("nullopt is not a valid dimension for this argument"); }
DimsType(std::initializer_list<hsize_t> &&list) { dims = std::vector<hsize_t>(std::begin(list), std::end(list)); }
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
DimsType(std::initializer_list<T> &&list) {
dims = std::vector<hsize_t>(std::begin(list), std::end(list));
}
DimsType(std::optional<std::vector<hsize_t>> otherDims) {
if(not otherDims) throw h5pp::runtime_error("Cannot initialize DimsType with nullopt");
dims = otherDims.value();
}
template<typename UnknownType>
DimsType(const UnknownType &dims_) {
if constexpr(std::is_integral_v<UnknownType>)
dims = std::vector<hsize_t>{static_cast<size_t>(dims_)};
else if constexpr(h5pp::type::sfinae::is_iterable_v<UnknownType>)
dims = std::vector<hsize_t>(std::begin(dims_), std::end(dims_));
else if constexpr(std::is_same_v<UnknownType, OptDimsType>)
if(not dims_)
throw h5pp::runtime_error("Cannot initialize DimsType with nullopt");
else
dims = dims_.value();
else if constexpr(std::is_assignable_v<UnknownType, DimsType>)
dims = dims_;
else if constexpr(std::is_array_v<UnknownType> and std::is_integral_v<std::remove_all_extents_t<UnknownType>>)
dims = std::vector<hsize_t>(std::begin(dims_), std::end(dims_));
else {
static_assert(h5pp::type::sfinae::invalid_type_v<UnknownType>, "Could not identify dimension type");
throw h5pp::runtime_error("Could not identify dimension type: {}", h5pp::type::sfinae::type_name<UnknownType>());
}
}
[[nodiscard]] operator const std::vector<hsize_t> &() const { return dims; }
[[nodiscard]] operator std::vector<hsize_t> &() { return dims; }
};

struct OptDimsType {
std::optional<std::vector<hsize_t>> dims = std::vector<hsize_t>();
OptDimsType() = default;
explicit OptDimsType(H5D_layout_t) = delete;
explicit OptDimsType(hid::h5t) = delete;
explicit OptDimsType(hid_t) = delete;
explicit OptDimsType(std::string) = delete;
explicit OptDimsType(std::string_view) = delete;
explicit OptDimsType(const char *) = delete;
OptDimsType(h5pp::Options) = delete;
OptDimsType(h5pp::DsetInfo) = delete;
OptDimsType(h5pp::DataInfo) = delete;
OptDimsType(h5pp::TableInfo) = delete;
OptDimsType(h5pp::Hyperslab) = delete;

OptDimsType(const std::nullopt_t &nullopt) { dims = nullopt; }
OptDimsType(std::initializer_list<hsize_t> &&list) { dims = std::vector<hsize_t>(std::begin(list), std::end(list)); }
template<typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
OptDimsType(std::initializer_list<T> &&list) {
dims = std::vector<hsize_t>(std::begin(list), std::end(list));
}
OptDimsType(std::optional<std::vector<hsize_t>> otherDims) : dims(std::move(otherDims)) {}
template<typename UnknownType>
OptDimsType(const UnknownType &dims_) {
if constexpr(std::is_integral_v<UnknownType>)
dims = std::vector<hsize_t>{static_cast<size_t>(dims_)};
else if constexpr(h5pp::type::sfinae::is_iterable_v<UnknownType>)
dims = std::vector<hsize_t>(std::begin(dims_), std::end(dims_));
else if constexpr(std::is_assignable_v<UnknownType, OptDimsType> or std::is_assignable_v<UnknownType, DimsType>)
dims = dims_;
else if constexpr(std::is_array_v<UnknownType> and std::is_integral_v<std::remove_all_extents_t<UnknownType>>)
dims = std::vector<hsize_t>(std::begin(dims_), std::end(dims_));
else {
static_assert(h5pp::type::sfinae::invalid_type_v<UnknownType>, "Could not identify dimension type");
throw h5pp::runtime_error("Could not identify dimension type: {}", h5pp::type::sfinae::type_name<UnknownType>());
}
}
[[nodiscard]] bool has_value() const { return dims.has_value(); }
operator bool() const { return dims.has_value(); }
[[nodiscard]] const std::vector<hsize_t> &value() const { return dims.value(); }
[[nodiscard]] std::vector<hsize_t> &value() { return dims.value(); }
[[nodiscard]] operator const std::optional<std::vector<hsize_t>> &() const { return dims; }
[[nodiscard]] operator std::optional<std::vector<hsize_t>> &() { return dims; }
auto operator->() { return dims.operator->(); }
auto operator->() const { return dims.operator->(); }
};

}
Loading

0 comments on commit cea334c

Please sign in to comment.