-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adjust multigrid parameters for gravity solve * add prototype star cluster example * reduce reltol for poisson solve * initialize with gaussian random field * add Jeans refinement * update params * change debugging settings * move settings to runtime params * add derived var * gpu fixes * gpu fix * fix OpenBCSolver init * add StarCluster AMR params file * delete old file * refactor code * read perturbations from file * fix TableData indices * increase max_retries * fix build on Crusher * add TinyProfiler regions * rename file content * define problem_main * generate zdrv.hdf5 * update file * update file * update microp * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix spellings * reorder tests * reorder tests * run python script for starcluster test * add filename * add custom command to run python script * revert changes * use python to generate input file * copy input file to binary * reset maxtries to 4 * make Gconst a runtime parameter with a default value * copy zdrv.hdf5 to tests/ * remove StaarCluster AMR test from repo * remove sim.Gconst * updated microp * produce input file at runtime * check for h5py * synced microp; * update microp * clang-tidy comments * clang-tidy * fix bug * increase simulation time time to ~tff * set Gconst to unity --------- Co-authored-by: Ben Wibking <[email protected]> Co-authored-by: Ben Wibking <[email protected]> Co-authored-by: Piyush Sharda <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Piyush Sharda <[email protected]> Co-authored-by: Piyush Sharda <[email protected]>
- Loading branch information
1 parent
add2204
commit fb96683
Showing
17 changed files
with
934 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Microphysics
updated
4 files
+8 −2 | .github/workflows/cuda.yml | |
+3 −1 | EOS/gamma_law/actual_eos.H | |
+3 −1 | EOS/primordial_chem/actual_eos.H | |
+9 −1 | interfaces/eos_type.H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
if (AMReX_SPACEDIM EQUAL 3) | ||
# Define a custom target that runs the Python script to produce the input perturbations file | ||
|
||
add_executable(star_cluster star_cluster.cpp TurbDataReader.cpp ${QuokkaObjSources}) | ||
if(AMReX_GPU_BACKEND MATCHES "CUDA") | ||
setup_target_for_cuda_compilation(star_cluster) | ||
endif() | ||
|
||
execute_process( | ||
COMMAND Python3::Interpreter -c "h5py" | ||
RESULT_VARIABLE EXIT_CODE | ||
OUTPUT_QUIET | ||
) | ||
|
||
add_test(NAME ComputeStarClusterPerturbations COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/perturbation.py --kmin=2 --kmax=64 --size=128 --alpha=2 --f_solenoidal=1.0 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) | ||
add_test(NAME StarCluster COMMAND star_cluster StarCluster.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) | ||
set_tests_properties(ComputeStarClusterPerturbations PROPERTIES FIXTURES_SETUP StarCluster_fixture) | ||
set_tests_properties(StarCluster PROPERTIES FIXTURES_REQUIRED StarCluster_fixture) | ||
|
||
# AMR test only works on Setonix because Gadi and avatar do not have enough memory per GPU | ||
# add_test(NAME StarClusterAMR COMMAND star_cluster StarCluster_AMR.in WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
//============================================================================== | ||
// TwoMomentRad - a radiation transport library for patch-based AMR codes | ||
// Copyright 2020 Benjamin Wibking. | ||
// Released under the MIT license. See LICENSE file included in the GitHub repo. | ||
//============================================================================== | ||
/// \file TurbDataReader.cpp | ||
/// \brief Reads turbulent driving fields generated as cubic HDF5 arrays. | ||
/// | ||
|
||
#include "TurbDataReader.hpp" | ||
#include "AMReX_Arena.H" | ||
#include "AMReX_BLassert.H" | ||
#include "AMReX_Print.H" | ||
#include "AMReX_TableData.H" | ||
#include <string> | ||
|
||
auto read_dataset(hid_t &file_id, char const *dataset_name) -> amrex::Table3D<double> | ||
{ | ||
// open dataset | ||
hid_t dset_id = 0; | ||
dset_id = H5Dopen2(file_id, dataset_name, H5P_DEFAULT); | ||
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(dset_id != -1, "Can't open table!"); | ||
|
||
// get dimensions | ||
hid_t const dspace = H5Dget_space(dset_id); | ||
const int ndims = H5Sget_simple_extent_ndims(dspace); | ||
std::vector<hsize_t> dims(ndims); | ||
H5Sget_simple_extent_dims(dspace, dims.data(), nullptr); | ||
|
||
uint64_t data_size = 1; | ||
for (int idim = 0; idim < ndims; ++idim) { | ||
data_size *= dims[idim]; | ||
} | ||
|
||
// allocate array for dataset storage | ||
auto *temp_data = new double[data_size]; | ||
|
||
// read dataset | ||
herr_t status = H5Dread(dset_id, HDF5_R8, H5S_ALL, H5S_ALL, H5P_DEFAULT, temp_data); | ||
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(status != -1, "Failed to read dataset!"); | ||
|
||
// close dataset | ||
status = H5Dclose(dset_id); | ||
|
||
// WARNING: Table3D uses column-major (Fortran-order) indexing, but HDF5 | ||
// tables use row-major (C-order) indexing! | ||
amrex::GpuArray<int, 3> const lo{0, 0, 0}; | ||
amrex::GpuArray<int, 3> const hi{static_cast<int>(dims[0]), static_cast<int>(dims[1]), static_cast<int>(dims[2])}; | ||
auto table = amrex::Table3D<double>(temp_data, lo, hi); | ||
return table; | ||
} | ||
|
||
void initialize_turbdata(turb_data &data, std::string &data_file) | ||
{ | ||
amrex::Print() << "Initializing turbulence data...\n"; | ||
amrex::Print() << fmt::format("data_file: {}.\n", data_file); | ||
|
||
herr_t status = 0; | ||
herr_t const h5_error = -1; | ||
|
||
// open file | ||
hid_t file_id = 0; | ||
file_id = H5Fopen(data_file.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); | ||
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(file_id != h5_error, "Failed to open data file!"); | ||
|
||
data.dvx = read_dataset(file_id, "pertx"); | ||
data.dvy = read_dataset(file_id, "perty"); | ||
data.dvz = read_dataset(file_id, "pertz"); | ||
|
||
// close file | ||
status = H5Fclose(file_id); | ||
} | ||
|
||
auto get_tabledata(amrex::Table3D<double> &in_t) -> amrex::TableData<double, 3> | ||
{ | ||
amrex::Array<int, 3> tlo{in_t.begin[0], in_t.begin[1], in_t.begin[2]}; | ||
amrex::Array<int, 3> thi{in_t.end[0] - 1, in_t.end[1] - 1, in_t.end[2] - 1}; | ||
amrex::TableData<double, 3> tableData(tlo, thi, amrex::The_Pinned_Arena()); | ||
auto h_table = tableData.table(); | ||
|
||
amrex::Print() << "Copying tableData on indices " << tlo << " to " << thi << ".\n"; | ||
|
||
// fill tableData | ||
for (int i = tlo[0]; i <= thi[0]; ++i) { | ||
for (int j = tlo[1]; j <= thi[1]; ++j) { | ||
for (int k = tlo[2]; k <= thi[2]; ++k) { | ||
h_table(i, j, k) = in_t(i, j, k); | ||
} | ||
} | ||
} | ||
|
||
return tableData; | ||
} | ||
|
||
auto computeRms(amrex::TableData<amrex::Real, 3> &dvx, amrex::TableData<amrex::Real, 3> &dvy, amrex::TableData<amrex::Real, 3> &dvz) -> amrex::Real | ||
{ | ||
amrex::Array<int, 3> tlo = dvx.lo(); | ||
amrex::Array<int, 3> thi = dvx.hi(); | ||
auto const &dvx_table = dvx.const_table(); | ||
auto const &dvy_table = dvy.const_table(); | ||
auto const &dvz_table = dvz.const_table(); | ||
|
||
// compute rms power | ||
amrex::Real rms_sq = 0; | ||
amrex::Long N = 0; | ||
for (int i = tlo[0]; i <= thi[0]; ++i) { | ||
for (int j = tlo[1]; j <= thi[1]; ++j) { | ||
for (int k = tlo[2]; k <= thi[2]; ++k) { | ||
amrex::Real const vx = dvx_table(i, j, k); | ||
amrex::Real const vy = dvy_table(i, j, k); | ||
amrex::Real const vz = dvz_table(i, j, k); | ||
rms_sq += vx * vx + vy * vy + vz * vz; | ||
++N; | ||
} | ||
} | ||
} | ||
rms_sq /= static_cast<amrex::Real>(N); | ||
return std::sqrt(rms_sq); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef TURBDATAREADER_HPP_ // NOLINT | ||
#define TURBDATAREADER_HPP_ | ||
//============================================================================== | ||
// TwoMomentRad - a radiation transport library for patch-based AMR codes | ||
// Copyright 2020 Benjamin Wibking. | ||
// Released under the MIT license. See LICENSE file included in the GitHub repo. | ||
//============================================================================== | ||
/// \file TurbDataReader.hpp | ||
/// \brief Reads turbulent driving fields generated as cubic HDF5 arrays. | ||
/// | ||
|
||
#include <cmath> | ||
#include <cstdint> | ||
#include <cstdio> | ||
#include <iostream> | ||
#include <string> | ||
|
||
#include "fmt/core.h" | ||
#include <H5Dpublic.h> | ||
#include <H5Ppublic.h> | ||
#include <hdf5.h> | ||
|
||
#include "AMReX.H" | ||
#include "AMReX_Array.H" | ||
#include "AMReX_BLassert.H" | ||
#include "AMReX_TableData.H" | ||
|
||
/* HDF5 definitions */ | ||
|
||
#define HDF5_FILE_I4 H5T_STD_I32BE | ||
#define HDF5_FILE_I8 H5T_STD_I64BE | ||
#define HDF5_FILE_R4 H5T_IEEE_F32BE | ||
#define HDF5_FILE_R8 H5T_IEEE_F64BE | ||
#define HDF5_FILE_B8 H5T_STD_B8BE | ||
|
||
#define HDF5_I4 H5T_NATIVE_INT | ||
#define HDF5_I8 H5T_NATIVE_LLONG | ||
#define HDF5_R4 H5T_NATIVE_FLOAT | ||
#define HDF5_R8 H5T_NATIVE_DOUBLE | ||
#define HDF5_R16 H5T_NATIVE_LDOUBLE | ||
|
||
// Cooling table storage | ||
|
||
using turb_data = struct turb_data { | ||
// values | ||
amrex::Table3D<double> dvx; | ||
amrex::Table3D<double> dvy; | ||
amrex::Table3D<double> dvz; | ||
}; | ||
|
||
void initialize_turbdata(turb_data &data, std::string &data_file); | ||
|
||
auto read_dataset(hid_t &file_id, char const *dataset_name) -> amrex::Table3D<double>; | ||
|
||
auto get_tabledata(amrex::Table3D<double> &in_t) -> amrex::TableData<double, 3>; | ||
|
||
auto computeRms(amrex::TableData<amrex::Real, 3> &dvx, amrex::TableData<amrex::Real, 3> &dvy, amrex::TableData<amrex::Real, 3> &dvz) -> amrex::Real; | ||
|
||
#endif // TURBDATAREADER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
- | ||
action: "add_pipelines" | ||
pipelines: | ||
pl1: | ||
f2: | ||
type: "slice" | ||
params: | ||
point: | ||
x: 0. | ||
y: 0. | ||
z: 0. | ||
normal: | ||
x: 0.0 | ||
y: 0.0 | ||
z: 1.0 | ||
- | ||
action: "add_scenes" | ||
scenes: | ||
s1: | ||
plots: | ||
p1: | ||
type: "pseudocolor" | ||
field: "log_density" | ||
pipeline: "pl1" | ||
renders: | ||
r1: | ||
image_prefix: "dens%05d" | ||
annotations: "true" | ||
camera: | ||
zoom: 1.5 |
Oops, something went wrong.