Skip to content

Commit

Permalink
[cpp] Remove Apache 2.0 license from REUSE
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Sep 18, 2024
1 parent a117094 commit 18be3a7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 137 deletions.
73 changes: 0 additions & 73 deletions LICENSES/Apache-2.0.txt

This file was deleted.

25 changes: 0 additions & 25 deletions src/cpp/pffdtd/hdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,4 @@ auto readH5Dataset(hid_t file, char const* dset_str, int ndims, hsize_t* dims, v
}
}

auto readH5Constant(hid_t file, char const* dset_str, void* out, DataType t) -> void {
hid_t dset = 0;
hid_t dspace = 0;

dset = H5Dopen(file, dset_str, H5P_DEFAULT);
dspace = H5Dget_space(dset);
PFFDTD_ASSERT(H5Sget_simple_extent_ndims(dspace) == 0);
herr_t status = 0;
switch (t) {
case DataType::Float64: status = H5Dread(dset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, out); break;
case DataType::Int64: status = H5Dread(dset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, out); break;
case DataType::Int8:
case DataType::Bool: status = H5Dread(dset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, out); break;
}

if (status != 0) {
raisef<std::runtime_error>("error reading dataset: {}", dset_str);
}
if (H5Dclose(dset) != 0) {
raisef<std::runtime_error>("error closing dataset: {}", dset_str);
} else {
fmt::println("read constant: {}", dset_str);
}
}

} // namespace pffdtd
1 change: 0 additions & 1 deletion src/cpp/pffdtd/hdf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,5 @@ struct H5FWriter {
};

void readH5Dataset(hid_t file, char const* dset_str, int ndims, hsize_t* dims, void** out, DataType t);
void readH5Constant(hid_t file, char const* dset_str, void* out, DataType t);

} // namespace pffdtd
64 changes: 26 additions & 38 deletions src/cpp/pffdtd/simulation_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,25 @@ namespace pffdtd {
// load the sim data from Python-written HDF5 files
[[nodiscard]] auto loadSimulation3D(std::filesystem::path const& simDir) -> Simulation3D {
// local values, to read in and attach to struct at end
int64_t Nbl = 0;
int64_t Nba = 0;
int64_t* bn_ixyz = nullptr;
int64_t* bnl_ixyz = nullptr;
int64_t* bna_ixyz = nullptr;
int8_t* Q_bna = nullptr;
int64_t* in_ixyz = nullptr;
int64_t* out_ixyz = nullptr;
int64_t* out_reorder = nullptr;
bool* adj_bn_bool = nullptr;
int8_t* K_bn = nullptr;
uint16_t* adj_bn = nullptr; // large enough for FCC
uint8_t* bn_mask = nullptr;
int8_t* mat_bn = nullptr;
int8_t* mat_bnl = nullptr;
double* saf_bn = nullptr;
Real* ssaf_bn = nullptr;
Real* ssaf_bnl = nullptr;
double* in_sigs = nullptr;
double* u_out = nullptr;
int8_t NN = 0;
int8_t* Mb = nullptr;
int8_t Nm = 0;
MatQuad<Real>* mat_quads = nullptr;
Real* mat_beta = nullptr; // one per material
int64_t* bn_ixyz = nullptr;
int64_t* bnl_ixyz = nullptr;
int64_t* bna_ixyz = nullptr;
int8_t* Q_bna = nullptr;
int64_t* in_ixyz = nullptr;
int64_t* out_ixyz = nullptr;
int64_t* out_reorder = nullptr;
bool* adj_bn_bool = nullptr;
int8_t* K_bn = nullptr;
uint16_t* adj_bn = nullptr; // large enough for FCC
uint8_t* bn_mask = nullptr;
int8_t* mat_bn = nullptr;
int8_t* mat_bnl = nullptr;
double* saf_bn = nullptr;
Real* ssaf_bn = nullptr;
Real* ssaf_bnl = nullptr;
double* in_sigs = nullptr;
double* u_out = nullptr;
int8_t* Mb = nullptr;

hsize_t dims[2]; // HDF5 type
int expected_ndims = 0;
Expand Down Expand Up @@ -100,6 +94,7 @@ namespace pffdtd {
PFFDTD_ASSERT((fcc_flag >= 0) && (fcc_flag <= 2));

// FCC (1 is CPU-based, 2 is CPU or GPU)
int8_t NN = 0;
if (fcc_flag > 0) {
PFFDTD_ASSERT(l2 <= 1.0);
PFFDTD_ASSERT(l <= 1.0);
Expand Down Expand Up @@ -133,9 +128,7 @@ namespace pffdtd {
fmt::println("NN={}", NN);

////////////////////////////////////////////////////////////////////////
//
// Read vox HDF5 dataset
//
////////////////////////////////////////////////////////////////////////
filename = simDir / "vox_out.h5";
if (not std::filesystem::exists(filename)) {
Expand Down Expand Up @@ -198,9 +191,7 @@ namespace pffdtd {
std::free(saf_bn);

////////////////////////////////////////////////////////////////////////
//
// Read signals HDF5 dataset
//
////////////////////////////////////////////////////////////////////////
filename = simDir / "signals.h5";
if (not std::filesystem::exists(filename)) {
Expand Down Expand Up @@ -253,9 +244,7 @@ namespace pffdtd {
}

////////////////////////////////////////////////////////////////////////
//
// Read materials HDF5 dataset
//
////////////////////////////////////////////////////////////////////////
filename = simDir / "materials.h5";
if (not std::filesystem::exists(filename)) {
Expand All @@ -267,7 +256,7 @@ namespace pffdtd {
//////////////////
// integers
//////////////////
readH5Constant(materials.handle(), "Nmat", (void*)&Nm, DataType::Int8);
auto const Nm = materials.read<int8_t>("Nmat");
fmt::println("Nm={}", Nm);
PFFDTD_ASSERT(Nm <= MNm);

Expand All @@ -281,6 +270,8 @@ namespace pffdtd {
//////////////////
// DEF (RLC) datasets
//////////////////
MatQuad<Real>* mat_quads = nullptr;
Real* mat_beta = nullptr; // one per material
allocate_zeros((void**)&mat_quads, static_cast<unsigned long>(Nm * MMb) * sizeof(MatQuad<Real>));
allocate_zeros((void**)&mat_beta, Nm * sizeof(Real));
for (int8_t i = 0; i < Nm; i++) {
Expand Down Expand Up @@ -323,9 +314,7 @@ namespace pffdtd {
}

////////////////////////////////////////////////////////////////////////
//
// Checks and repacking
//
////////////////////////////////////////////////////////////////////////

//////////////////
Expand Down Expand Up @@ -419,7 +408,7 @@ namespace pffdtd {
std::free(bn_mask_raw);

// count Nbl
Nbl = 0;
int64_t Nbl = 0;
for (int64_t i = 0; i < Nb; i++) {
Nbl += static_cast<int64_t>(mat_bn[i] >= 0);
}
Expand All @@ -445,9 +434,8 @@ namespace pffdtd {
fmt::println("separated non-rigid bn");

// ABC ndoes
int64_t Nyf = 0;
Nyf = (fcc_flag == 2) ? 2 * (Ny - 1) : Ny; // full Ny dim, taking into account FCC fold
Nba = 2 * (Nx * Nyf + Nx * Nz + Nyf * Nz) - 12 * (Nx + Nyf + Nz) + 56;
int64_t Nyf = (fcc_flag == 2) ? 2 * (Ny - 1) : Ny; // full Ny dim, taking into account FCC fold
int64_t Nba = 2 * (Nx * Nyf + Nx * Nz + Nyf * Nz) - 12 * (Nx + Nyf + Nz) + 56;
if (fcc_flag > 0) {
Nba /= 2;
}
Expand Down

0 comments on commit 18be3a7

Please sign in to comment.