Skip to content

Commit

Permalink
Merge branch 'use_openpmd-api' of github.com:guj/amrex into use_openp…
Browse files Browse the repository at this point in the history
…md-api
  • Loading branch information
WeiqunZhang committed Mar 28, 2024
2 parents a129a8f + 6d206ca commit 13f7ff5
Show file tree
Hide file tree
Showing 18 changed files with 27 additions and 59 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ jobs:
cd openPMD-api-0.15.2
mkdir build
cd build
cmake .. -DopenPMD_USE_PYTHON=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake .. \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DopenPMD_BUILD_EXAMPLES=OFF \
-DopenPMD_BUILD_CLI_TOOLS=OFF \
-DopenPMD_BUILD_TESTING=OFF \
-DopenPMD_USE_PYTHON=OFF \
make -j4
sudo make install
- name: Build & Test
Expand All @@ -211,7 +216,7 @@ jobs:
mkdir build
cd build
cmake .. \
-DAMReX_OPENPMD_API=ON \
-DAMReX_OPENPMD=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DAMReX_ENABLE_TESTS=ON \
-DAMReX_SPACEDIM=3 \
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_PlotFileUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <AMReX_PlotFileUtilHDF5.H>
#endif

#ifdef AMREX_USE_OPENPMD_API
#ifdef AMREX_USE_OPENPMD
#include <AMReX_PlotFileUtilOPENPMD.H>
#endif

Expand Down
2 changes: 1 addition & 1 deletion Src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ if (AMReX_HDF5)
add_subdirectory(Extern/HDF5)
endif ()

if (AMReX_OPENPMD_API)
if (AMReX_OPENPMD)
add_subdirectory(Extern/openPMD-api)
endif()

Expand Down
3 changes: 1 addition & 2 deletions Src/Extern/openPMD-api/AMReX_ParticlesOPENPMD.H
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef AMREX_PTL_OPENPMD_API_H
#define AMREX_PTL_OPENPMD_API_H

/**
* This file is included from AMReX_ParticleCounter.H
/** @file This file is included from AMReX_ParticleCounter.H
* and belongs to the class ParticleContainer_impl.
* The namespace amrex was already declared.
*
Expand Down
2 changes: 0 additions & 2 deletions Src/Extern/openPMD-api/AMReX_PlotFileOPENPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,6 @@ namespace amrex::openpmd_api {
mesh.setAttribute("fieldSmoothing", "none");
mesh_comp.resetDataset(dataset);

helper::setOpenPMDUnit( mesh, varName.m_FieldName );

auto relative_cell_pos = helper::getRelativeCellPosition(mf); // AMReX Fortran index order
std::reverse( relative_cell_pos.begin(), relative_cell_pos.end() ); // now in C order
mesh_comp.setPosition( relative_cell_pos );
Expand Down
32 changes: 1 addition & 31 deletions Src/Extern/openPMD-api/AMReX_PlotFileUtilOPENPMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <AMReX_Particles.H>
#endif

#ifdef AMREX_USE_OPENPMD_API
#ifdef AMREX_USE_OPENPMD
#include <openPMD/openPMD.hpp>
#endif

Expand All @@ -23,36 +23,6 @@ namespace amrex::openpmd_api
{
namespace helper
{
inline void
setOpenPMDUnit ( openPMD::Mesh mesh, std::string const& field_name )
{
if (field_name[0] == 'E'){
mesh.setUnitDimension({
{openPMD::UnitDimension::L, 1},
{openPMD::UnitDimension::M, 1},
{openPMD::UnitDimension::T, -3},
{openPMD::UnitDimension::I, -1},
});
} else if (field_name[0] == 'B'){
mesh.setUnitDimension({
{openPMD::UnitDimension::M, 1},
{openPMD::UnitDimension::I, -1},
{openPMD::UnitDimension::T, -2}
});
}else if (field_name[0] == 'j'){ // current
mesh.setUnitDimension({
{openPMD::UnitDimension::L, -2},
{openPMD::UnitDimension::I, 1},
});
} else if (field_name.substr(0,3) == "rho"){ // charge density
mesh.setUnitDimension({
{openPMD::UnitDimension::L, -3},
{openPMD::UnitDimension::I, 1},
{openPMD::UnitDimension::T, 1},
});
}
} // name space helper

// from warpx Utils/RelativeCellPosition.cpp
inline std::vector< double >
getRelativeCellPosition(amrex::MultiFab const& mf)
Expand Down
6 changes: 1 addition & 5 deletions Src/Extern/openPMD-api/AMReX_PlotFileUtilOPENPMD_PTLImpl.H
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef AMREX_PLOTFILE_OPENPMD_PTLS_API_H
#define AMREX_PLOTFILE_OPENPMD_PTLS_API_H

//extern std::unique_ptr< amrex::openpmd_api::AMReX_openPMDHandler > amrex::openpmd_api::m_OpenPMDHandler;
namespace amrex::openpmd_api
{
extern std::unique_ptr< amrex::openpmd_api::AMReX_openPMDHandler > m_OpenPMDHandler;
Expand All @@ -26,9 +25,6 @@ namespace amrex::openpmd_api
{
BL_PROFILE("amrex::openpmd_api::WriteParticles()");

amrex::Print()<<" Real: "<<pc.NStructReal<<" "<<pc.NumRealComps()<<"\n";
amrex::Print()<<" Int: "<<pc.NStructInt<<" "<<pc.NumIntComps()<<"\n";

if ((m_OpenPMDHandler == nullptr) || (m_OpenPMDHandler->m_Writer == nullptr)) {
return;
}
Expand Down Expand Up @@ -658,4 +654,4 @@ namespace amrex::openpmd_api

} // namespace amrex::openpmd_api

#endif // AMREX_PLOTFILE_OPENPMD_API_H
#endif // AMREX_PLOTFILE_OPENPMD_PTLS_API_H
2 changes: 1 addition & 1 deletion Src/Extern/openPMD-api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add_amrex_define(AMREX_USE_OPENPMD_API NO_LEGACY IF AMReX_OPENPMD_API)
add_amrex_define(AMREX_USE_OPENPMD NO_LEGACY IF AMReX_OPENPMD)

foreach(D IN LISTS AMReX_SPACEDIM)

Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ public:
#include "AMReX_ParticlesHDF5.H"
#endif

#ifdef AMREX_USE_OPENPMD_API
#ifdef AMREX_USE_OPENPMD
#include "AMReX_ParticlesOPENPMD.H"
#endif

Expand Down
2 changes: 1 addition & 1 deletion Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ else()
list(APPEND AMREX_TESTS_SUBDIRS HDF5Benchmark)
endif ()

if (AMReX_OPENPMD_API)
if (AMReX_OPENPMD)
list(APPEND AMREX_TESTS_SUBDIRS openPMDTests)
endif ()

Expand Down
2 changes: 1 addition & 1 deletion Tests/openPMDTests/fields/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct TestField

void saveFile(char const* fname, const InputParams& inputs, const TestField& testField)
{
#ifdef AMREX_USE_OPENPMD_API
#ifdef AMREX_USE_OPENPMD
openpmd_api::InitHandler(fname);

for (int ts = 0; ts < inputs.nplotfile; ts++)
Expand Down
2 changes: 1 addition & 1 deletion Tests/openPMDTests/ptls/warpxWriter.H
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void AMReX_warpxWriter::SetupMeshComp (openPMD::Mesh& mesh,
mesh.setAttribute("fieldSmoothing", "none");
mesh_comp.resetDataset(dataset);

amrex::openpmd_api::helper::setOpenPMDUnit( mesh, varName.m_FieldName );
//amrex::openpmd_api::helper::setOpenPMDUnit( mesh, varName.m_FieldName ); // removed this function. define in app if needed

auto relative_cell_pos = amrex::openpmd_api::helper::getRelativeCellPosition(mf); // AMReX Fortran index order
std::reverse( relative_cell_pos.begin(), relative_cell_pos.end() ); // now in C order
Expand Down
6 changes: 3 additions & 3 deletions Tools/CMake/AMReXConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ set(AMReX_PETSC_FOUND @AMReX_PETSC@)
set(AMReX_SUNDIALS_FOUND @AMReX_SUNDIALS@)
set(AMReX_HDF5_FOUND @AMReX_HDF5@)
set(AMReX_HDF5_ZFP_FOUND @AMReX_HDF5_ZFP@)
set(AMReX_OPENPMD_API_FOUND @AMReX_OPENPMD_API@)
set(AMReX_OPENPMD_FOUND @AMReX_OPENPMD@)

# Compilation options
set(AMReX_FPE_FOUND @AMReX_FPE@)
Expand Down Expand Up @@ -138,7 +138,7 @@ set(AMReX_HYPRE @AMReX_HYPRE@)
set(AMReX_PETSC @AMReX_PETSC@)
set(AMReX_HDF5 @AMReX_HDF5@)
set(AMReX_HDF5_ZFP @AMReX_HDF5_ZFP@)
set(AMReX_OPENPMD_API @AMReX_OPENPMD_API@)
set(AMReX_OPENPMD @AMReX_OPENPMD@)

# Compilation options
set(AMReX_FPE @AMReX_FPE@)
Expand Down Expand Up @@ -217,7 +217,7 @@ if (@AMReX_HYPRE@)
find_dependency(HYPRE 2.20.0 REQUIRED)
endif ()

if (@AMReX_OPENPMD_API@)
if (@AMReX_OPENPMD@)
find_dependency(openpmd REQUIRED)
endif ()

Expand Down
4 changes: 2 additions & 2 deletions Tools/CMake/AMReXOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ cmake_dependent_option(AMReX_HDF5_ZFP "Enable ZFP compression in HDF5-based IO"
print_option(AMReX_HDF5_ZFP)

# openPMD-api
option(AMReX_OPENPMD_API "Enable I/O through openPMD-api" OFF)
print_option(AMReX_OPENPMD_API)
option(AMReX_OPENPMD "Enable I/O through openPMD-api" OFF)
print_option(AMReX_OPENPMD)

# SUNDIALS
option( AMReX_SUNDIALS "Enable SUNDIALS interfaces" OFF )
Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReXSetDefines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ add_amrex_define(AMREX_USE_HDF5_ZFP NO_LEGACY IF AMReX_HDF5_ZFP)
#
# openPMD-api
#
add_amrex_define(AMREX_USE_OPENPMD_API NO_LEGACY IF AMReX_OPENPMD_API)
add_amrex_define(AMREX_USE_OPENPMD NO_LEGACY IF AMReX_OPENPMD)


#
Expand Down
4 changes: 2 additions & 2 deletions Tools/CMake/AMReXThirdPartyLibraries.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# openPMD_api related targets
# openPMD-api related targets
#
if (AMReX_OPENPMD_API)
if (AMReX_OPENPMD)
if (AMReX_MPI)
find_package(openPMD 0.14.2 CONFIG REQUIRED COMPONENTS MPI)
else ()
Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReX_Config_ND.H.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#cmakedefine AMREX_USE_HDF5
#cmakedefine AMREX_USE_HDF5_ASYNC
#cmakedefine AMREX_USE_HDF5_ZFP
#cmakedefine AMREX_USE_OPENPMD_API
#cmakedefine AMREX_USE_OPENPMD
#cmakedefine AMREX_USE_HYPRE
#cmakedefine AMREX_USE_PETSC
#cmakedefine AMREX_USE_SUNDIALS
Expand Down
2 changes: 1 addition & 1 deletion Tools/GNUMake/packages/Make.openpmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CPPFLAGS += -DAMREX_USE_OPENPMD_API
CPPFLAGS += -DAMREX_USE_OPENPMD
include $(AMREX_HOME)/Src/Extern/openPMD-api/Make.package

ifndef AMREX_OPENPMD_HOME
Expand Down

0 comments on commit 13f7ff5

Please sign in to comment.