From ba83cf3722b2ecb647f2ebc75868ceb87baf03fd Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 24 Apr 2023 10:57:55 -0700 Subject: [PATCH 1/4] CI: Add openPMD-validator Check created files with `openPMD-validator` to conform with the `openPMD-standard`. --- .github/workflows/dependencies/gcc-openmpi.sh | 2 ++ .github/workflows/dependencies/gcc.sh | 2 ++ .github/workflows/macos.yml | 4 ++++ .github/workflows/ubuntu.yml | 6 ++++++ .github/workflows/windows.yml | 5 +++++ 5 files changed, 19 insertions(+) diff --git a/.github/workflows/dependencies/gcc-openmpi.sh b/.github/workflows/dependencies/gcc-openmpi.sh index 8416283b4..ba4d53717 100755 --- a/.github/workflows/dependencies/gcc-openmpi.sh +++ b/.github/workflows/dependencies/gcc-openmpi.sh @@ -26,3 +26,5 @@ python3 -m pip install -U pip setuptools wheel python3 -m pip install -U cmake pytest python3 -m pip install -r requirements_mpi.txt python3 -m pip install -r examples/requirements.txt + +python3 -m pip install -U openPMD-validator diff --git a/.github/workflows/dependencies/gcc.sh b/.github/workflows/dependencies/gcc.sh index 8ebe694fe..ba32efd1f 100755 --- a/.github/workflows/dependencies/gcc.sh +++ b/.github/workflows/dependencies/gcc.sh @@ -24,3 +24,5 @@ sudo apt-get install -y \ python3 -m pip install -U pip setuptools wheel python3 -m pip install -U cmake pytest python3 -m pip install -r examples/requirements.txt + +python3 -m pip install -U openPMD-validator diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 72c342211..5c9f92e24 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -54,6 +54,7 @@ jobs: python3 -m pip install --upgrade pytest python3 -m pip install -r requirements_mpi.txt python3 -m pip install -r examples/requirements.txt + python3 -m pip install --upgrade openPMD-validator set -e - name: CCache Cache uses: actions/cache@v3 @@ -93,3 +94,6 @@ jobs: { cat Backtrace.0.0; exit 1; } impactx.MPI.OMP.DP.OPMD examples/fodo/input_fodo.in algo.particle_shape = 3 || \ { cat Backtrace.0.0; exit 1; } + + - name: validate created openPMD files + run: find build -name *.h5 | xargs -n1 -I{} openPMD_check_h5 -i {} diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index de2a1c934..7dc20b7e3 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -66,6 +66,9 @@ jobs: python3 examples/fodo/run_fodo.py + - name: validate created openPMD files + run: find build -name *.h5 | xargs -n1 -I{} openPMD_check_h5 -i {} + build_gcc_python: name: GCC w/o MPI w/ Python runs-on: ubuntu-20.04 @@ -125,3 +128,6 @@ jobs: cmake --build build --target pip_install python3 examples/fodo/run_fodo.py + + - name: validate created openPMD files + run: find build -name *.h5 | xargs -n1 -I{} openPMD_check_h5 -i {} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 939717242..85d40f3c4 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -55,6 +55,7 @@ jobs: python3 -m pip install -U pip setuptools wheel pytest python3 -m pip install -r requirements.txt python3 -m pip install -r examples/requirements.txt + python3 -m pip install -U openPMD-validator - name: Build run: | $env:HDF5_DIR = "C:/Program Files/HDF_Group/HDF5/1.12.2/cmake/" @@ -137,6 +138,7 @@ jobs: python3 -m pip install -U pip setuptools wheel pytest python3 -m pip install -r requirements.txt python3 -m pip install -r examples/requirements.txt + python3 -m pip install -U openPMD-validator - name: Build shell: cmd run: | @@ -175,3 +177,6 @@ jobs: # if errorlevel 1 exit 1 # cmake --build build --target pip_install # if errorlevel 1 exit 1 + + - name: validate created openPMD files + run: find build -name *.h5 | xargs -n1 -I{} openPMD_check_h5 -i {} From a50c702603424a528899809a6f6cb925c9a8c058 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 24 Apr 2023 14:13:36 -0700 Subject: [PATCH 2/4] openPMD: Add 0-valued positionOffset --- src/particles/elements/diagnostics/openPMD.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/particles/elements/diagnostics/openPMD.cpp b/src/particles/elements/diagnostics/openPMD.cpp index 310fae05d..136121990 100644 --- a/src/particles/elements/diagnostics/openPMD.cpp +++ b/src/particles/elements/diagnostics/openPMD.cpp @@ -253,6 +253,19 @@ namespace detail getComponentRecord(component_name).resetDataset(d_fl); } } + + // openPMD coarse position + { + using vs = std::vector; + vs const positionComponents{"x", "y", "ct"}; // TODO: generalize + for (auto currDim = 0; currDim < AMREX_SPACEDIM; currDim++) { + using namespace amrex::literals; + std::string const positionComponent = positionComponents[currDim]; + beam["positionOffset"][positionComponent].resetDataset(d_fl); + beam["positionOffset"][positionComponent].makeConstant(0_prt); // TODO: make this the reference particle position? + } + } + // AoS: Int beam["id"][scalar].resetDataset(d_ui); @@ -320,6 +333,8 @@ namespace detail auto series = std::any_cast(m_series); io::WriteIterations iterations = series.writeIterations(); io::Iteration iteration = iterations[m_step]; + + // close iteration iteration.close(); } From a4ef5e9e3e7d6e67ec2aac0d4d6c0ea82fcd2f38 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 24 Apr 2023 14:53:38 -0700 Subject: [PATCH 3/4] openPMD positionOffset: Reference Particle --- src/particles/elements/diagnostics/openPMD.H | 4 +++- src/particles/elements/diagnostics/openPMD.cpp | 17 ++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/particles/elements/diagnostics/openPMD.H b/src/particles/elements/diagnostics/openPMD.H index 7307c3d5b..0dad78094 100644 --- a/src/particles/elements/diagnostics/openPMD.H +++ b/src/particles/elements/diagnostics/openPMD.H @@ -83,11 +83,13 @@ namespace detail /** Prepare entering the element before starting push logic. * - * @param[in] pc particle container. + * @param[in] pc particle container + * @param[in] ref_part reference particle * @param[in] step global step for diagnostics */ void prepare ( PinnedContainer & pc, + RefPart const & ref_part, int step ); diff --git a/src/particles/elements/diagnostics/openPMD.cpp b/src/particles/elements/diagnostics/openPMD.cpp index 136121990..27efade83 100644 --- a/src/particles/elements/diagnostics/openPMD.cpp +++ b/src/particles/elements/diagnostics/openPMD.cpp @@ -211,6 +211,7 @@ namespace detail void BeamMonitor::prepare ( PinnedContainer & pc, + RefPart const & ref_part, int step ) { #ifdef ImpactX_USE_OPENPMD @@ -256,14 +257,12 @@ namespace detail // openPMD coarse position { - using vs = std::vector; - vs const positionComponents{"x", "y", "ct"}; // TODO: generalize - for (auto currDim = 0; currDim < AMREX_SPACEDIM; currDim++) { - using namespace amrex::literals; - std::string const positionComponent = positionComponents[currDim]; - beam["positionOffset"][positionComponent].resetDataset(d_fl); - beam["positionOffset"][positionComponent].makeConstant(0_prt); // TODO: make this the reference particle position? - } + beam["positionOffset"]["x"].resetDataset(d_fl); + beam["positionOffset"]["x"].makeConstant(ref_part.x); + beam["positionOffset"]["y"].resetDataset(d_fl); + beam["positionOffset"]["y"].makeConstant(ref_part.y); + beam["positionOffset"]["ct"].resetDataset(d_fl); + beam["positionOffset"]["ct"].makeConstant(ref_part.t); } // AoS: Int @@ -311,7 +310,7 @@ namespace detail */ // prepare element access - this->prepare(pinned_pc, step); + this->prepare(pinned_pc, ref_part, step); // loop over refinement levels int const nLevel = pinned_pc.finestLevel(); From 03769f243fa7c440cd201d093fc380c9bf03983e Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 24 Apr 2023 17:23:09 -0700 Subject: [PATCH 4/4] CI: Update Windows Powershell pipe arguments --- .github/workflows/windows.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 85d40f3c4..3c1c15e8d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -82,6 +82,8 @@ jobs: if(!$?) { Exit $LASTEXITCODE } cmake --build build --config RelWithDebInfo --target pip_install if(!$?) { Exit $LASTEXITCODE } + - name: validate created openPMD files + run: Get-ChildItem -Path build -Recurse -Filter *.h5 | %{openPMD_check_h5 -i $_} build_win_clang: name: Clang w/ OMP w/o MPI @@ -179,4 +181,4 @@ jobs: # if errorlevel 1 exit 1 - name: validate created openPMD files - run: find build -name *.h5 | xargs -n1 -I{} openPMD_check_h5 -i {} + run: Get-ChildItem -Path build -Recurse -Filter *.h5 | %{openPMD_check_h5 -i $_}