Skip to content

Commit

Permalink
Merge branch 'development' of github.com:erf-model/ERF into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
ewquon committed Jan 25, 2024
2 parents 193dbd9 + 9858798 commit e177c97
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 71 deletions.
5 changes: 3 additions & 2 deletions CMake/BuildERFExe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ function(build_erf_lib erf_lib_name)

if(ERF_ENABLE_PARTICLES)
target_sources(${erf_lib_name} PRIVATE
${SRC_DIR}/Particles/TracerPC.cpp
${SRC_DIR}/Particles/HydroPC.cpp)
${SRC_DIR}/Particles/ERFPCEvolve.cpp
${SRC_DIR}/Particles/ERFPCInitializations.cpp
${SRC_DIR}/Particles/ERFTracers.cpp)
target_include_directories(${erf_lib_name} PUBLIC ${SRC_DIR}/Particles)
target_compile_definitions(${erf_lib_name} PUBLIC ERF_USE_PARTICLES)
endif()
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ if(ERF_ENABLE_MPI)
find_package(MPI REQUIRED)
endif()

configure_file(
${CMAKE_SOURCE_DIR}/Source/ERF_Config.H.in
${CMAKE_BINARY_DIR}/ERF_Config.H
)

# General information about machine, compiler, and build type
message(STATUS "ERF Information:")
message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
Expand Down
15 changes: 15 additions & 0 deletions Source/ERF_Config.H.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#ifndef ERF_CONFIG_H_
#define ERF_CONFIG_H_

// define the radiation data directory
#define RADIATION_DATA_DIR @ERF_RADIATION_DATA_DIR@

// functions to get the radiation data directory
inline
std::string getRadiationDataDir()
{
return "@ERF_RADIATION_DATA_DIR@";
}

#endif // ERF_CONFIG_H
55 changes: 43 additions & 12 deletions Source/Particles/ERFPC.H
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ struct ERFParticlesAssignor
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& dxi,
const amrex::Box& domain ) const noexcept
{
/* TODO: What is this about? */
amrex::IntVect iv(
AMREX_D_DECL( int(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0])),
int(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1])),
Expand All @@ -61,6 +60,38 @@ struct ERFParticlesAssignor
}
};

template <typename P>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void update_location_idata (P& p,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& plo,
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& dxi,
const amrex::Array4<amrex::Real const>& height_arr)
{
amrex::IntVect iv( int(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0])),
int(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1])),
p.idata(ERFParticlesIntIdx::k) );

p.idata(ERFParticlesIntIdx::i) = iv[0];
p.idata(ERFParticlesIntIdx::j) = iv[1];

amrex::Real lx = (p.pos(0)-plo[0])*dxi[0] - static_cast<amrex::Real>(iv[0]);
amrex::Real ly = (p.pos(1)-plo[1])*dxi[1] - static_cast<amrex::Real>(iv[1]);
auto zlo = height_arr(iv[0] ,iv[1] ,iv[2] ) * (1.0-lx) * (1.0-ly) +
height_arr(iv[0]+1,iv[1] ,iv[2] ) * lx * (1.0-ly) +
height_arr(iv[0] ,iv[1]+1,iv[2] ) * (1.0-lx) * ly +
height_arr(iv[0]+1,iv[1]+1,iv[2] ) * lx * ly;
auto zhi = height_arr(iv[0] ,iv[1] ,iv[2]+1) * (1.0-lx) * (1.0-ly) +
height_arr(iv[0]+1,iv[1] ,iv[2]+1) * lx * (1.0-ly) +
height_arr(iv[0] ,iv[1]+1,iv[2]+1) * (1.0-lx) * ly +
height_arr(iv[0]+1,iv[1]+1,iv[2]+1) * lx * ly;

if (p.pos(2) > zhi) {
p.idata(ERFParticlesIntIdx::k) += 1;
} else if (p.pos(2) <= zlo) {
p.idata(ERFParticlesIntIdx::k) -= 1;
}
}

class ERFPC : public amrex::ParticleContainer< ERFParticlesRealIdx::ncomps,
ERFParticlesIntIdx::ncomps,
0,
Expand Down Expand Up @@ -118,6 +149,17 @@ class ERFPC : public amrex::ParticleContainer< ERFParticlesRealIdx::ncomps,
return {AMREX_D_DECL("xvel","yvel","zvel"),"mass"};
}

/*! Uses midpoint method to advance particles using flow velocity. */
virtual void AdvectWithFlow ( amrex::MultiFab*,
int,
amrex::Real,
const std::unique_ptr<amrex::MultiFab>& );

/*! Uses midpoint method to advance particles falling under gravity. */
virtual void AdvectWithGravity ( int,
amrex::Real,
const std::unique_ptr<amrex::MultiFab>& );

/*! Specify if particles should advect with flow */
inline void setAdvectWithFlow (bool a_flag)
{
Expand All @@ -131,17 +173,6 @@ class ERFPC : public amrex::ParticleContainer< ERFParticlesRealIdx::ncomps,
m_advect_w_gravity = a_flag;
}

/*! Uses midpoint method to advance particles using flow velocity. */
void AdvectWithFlow ( amrex::MultiFab*,
int,
amrex::Real,
const std::unique_ptr<amrex::MultiFab>& );

/*! Uses midpoint method to advance particles falling under gravity. */
void AdvectWithGravity ( int,
amrex::Real,
const std::unique_ptr<amrex::MultiFab>& );

protected:

bool m_advect_w_flow; /*!< advect with flow velocity */
Expand Down
61 changes: 5 additions & 56 deletions Source/Particles/ERFPCEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ void ERFPC::AdvectWithFlow ( MultiFab* a_umac,
ParticleType& p = p_pbox[i];
if (p.id() <= 0) { return; }
ParticleReal v[AMREX_SPACEDIM];
mac_interpolate(p, plo, dxi, umacarr, v);
mac_interpolate_mapped_z(p, plo, dxi, umacarr, zheight, v);
if (ipass == 0)
{
for (int dim=0; dim < AMREX_SPACEDIM; dim++)
{
p.rdata(dim) = p.pos(dim);
p.pos(dim) += static_cast<ParticleReal>(ParticleReal(0.5)*a_dt*v[dim]);
}
// Update z-coordinate carried by the particle
update_location_idata(p,plo,dxi,zheight);
}
else
{
Expand All @@ -119,35 +121,8 @@ void ERFPC::AdvectWithFlow ( MultiFab* a_umac,
p.pos(dim) = p.rdata(dim) + static_cast<ParticleReal>(a_dt*v[dim]);
p.rdata(dim) = v[dim];
}

// Update z-coordinate carried by the particle
IntVect iv(
AMREX_D_DECL(int(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0])),
int(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1])),
p.idata(0)));
iv[0] += domain.smallEnd()[0];
iv[1] += domain.smallEnd()[1];
ParticleReal zlo, zhi;
if (use_terrain) {
Real lx = (p.pos(0)-plo[0])*dxi[0] - static_cast<Real>(iv[0]-domain.smallEnd()[0]);
Real ly = (p.pos(1)-plo[1])*dxi[1] - static_cast<Real>(iv[1]-domain.smallEnd()[1]);
zlo = zheight(iv[0] ,iv[1] ,iv[2] ) * (1.0-lx) * (1.0-ly) +
zheight(iv[0]+1,iv[1] ,iv[2] ) * lx * (1.0-ly) +
zheight(iv[0] ,iv[1]+1,iv[2] ) * (1.0-lx) * ly +
zheight(iv[0]+1,iv[1]+1,iv[2] ) * lx * ly;
zhi = zheight(iv[0] ,iv[1] ,iv[2]+1) * (1.0-lx) * (1.0-ly) +
zheight(iv[0]+1,iv[1] ,iv[2]+1) * lx * (1.0-ly) +
zheight(iv[0] ,iv[1]+1,iv[2]+1) * (1.0-lx) * ly +
zheight(iv[0]+1,iv[1]+1,iv[2]+1) * lx * ly;
} else {
zlo = iv[2] * dx[2];
zhi = (iv[2]+1) * dx[2];
}
if (p.pos(2) > zhi) { // need to be careful here
p.idata(0) += 1;
} else if (p.pos(2) <= zlo) {
p.idata(0) -= 1;
}
update_location_idata(p,plo,dxi,zheight);
}
});
}
Expand Down Expand Up @@ -223,33 +198,7 @@ void ERFPC::AdvectWithGravity ( int a_lev,
p.rdata(ERFParticlesRealIdx::vz) -= (grav - drag) * half_dt;

// also update z-coordinate here
IntVect iv(
AMREX_D_DECL(int(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0])),
int(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1])),
p.idata(0)));
iv[0] += domain.smallEnd()[0];
iv[1] += domain.smallEnd()[1];
ParticleReal zlo, zhi;
if (use_terrain) {
Real lx = (p.pos(0)-plo[0])*dxi[0] - static_cast<Real>(iv[0]-domain.smallEnd()[0]);
Real ly = (p.pos(1)-plo[1])*dxi[1] - static_cast<Real>(iv[1]-domain.smallEnd()[1]);
zlo = zheight(iv[0] ,iv[1] ,iv[2] ) * (1.0-lx) * (1.0-ly) +
zheight(iv[0]+1,iv[1] ,iv[2] ) * lx * (1.0-ly) +
zheight(iv[0] ,iv[1]+1,iv[2] ) * (1.0-lx) * ly +
zheight(iv[0]+1,iv[1]+1,iv[2] ) * lx * ly;
zhi = zheight(iv[0] ,iv[1] ,iv[2]+1) * (1.0-lx) * (1.0-ly) +
zheight(iv[0]+1,iv[1] ,iv[2]+1) * lx * (1.0-ly) +
zheight(iv[0] ,iv[1]+1,iv[2]+1) * (1.0-lx) * ly +
zheight(iv[0]+1,iv[1]+1,iv[2]+1) * lx * ly;
} else {
zlo = iv[2] * dx[2];
zhi = (iv[2]+1) * dx[2];
}
if (p.pos(2) > zhi) { // need to be careful here
p.idata(0) += 1;
} else if (p.pos(2) <= zlo) {
p.idata(0) -= 1;
}
update_location_idata(p,plo,dxi,zheight);
});
}

Expand Down
2 changes: 1 addition & 1 deletion Submodules/AMReX
Submodule AMReX updated 64 files
+8 −8 .github/workflows/apps.yml
+1 −1 .github/workflows/ascent.yml
+3 −3 .github/workflows/bittree.yml
+7 −7 .github/workflows/clang.yml
+1 −1 .github/workflows/cleanup-cache-postpr.yml
+1 −1 .github/workflows/cleanup-cache.yml
+6 −6 .github/workflows/codeql.yml
+1 −1 .github/workflows/codespell.yml
+9 −9 .github/workflows/cuda.yml
+20 −6 .github/workflows/dependencies/dependencies_codeplay.sh
+4 −2 .github/workflows/dependencies/dependencies_hip.sh
+8 −9 .github/workflows/docs.yml
+28 −28 .github/workflows/gcc.yml
+9 −9 .github/workflows/hip.yml
+7 −7 .github/workflows/hypre.yml
+17 −27 .github/workflows/intel.yml
+5 −5 .github/workflows/macos.yml
+3 −3 .github/workflows/petsc.yml
+1 −1 .github/workflows/post-pr.yml
+1 −1 .github/workflows/sensei.yml
+3 −3 .github/workflows/smoke.yml
+3 −3 .github/workflows/style.yml
+5 −5 .github/workflows/sundials.yml
+3 −3 .github/workflows/windows.yml
+1 −1 Docs/sphinx_documentation/source/EB.rst
+5 −1 Src/Base/AMReX.cpp
+18 −0 Src/Base/AMReX_Algorithm.H
+1 −1 Src/Base/AMReX_BLProfiler.H
+121 −4 Src/Base/AMReX_BaseFab.H
+12 −0 Src/Base/AMReX_Extension.H
+4 −1 Src/Base/AMReX_GpuComplex.H
+7 −2 Src/Base/AMReX_OpenMP.H
+31 −1 Src/Base/AMReX_OpenMP.cpp
+30 −2 Src/Base/AMReX_Reduce.H
+7 −14 Src/Base/AMReX_TableData.H
+14 −0 Src/Base/AMReX_Tuple.H
+48 −1 Src/Base/AMReX_TypeList.H
+406 −0 Src/LinearSolvers/AMReX_GMRES.H
+147 −0 Src/LinearSolvers/AMReX_GMRES_MLMG.H
+3 −0 Src/LinearSolvers/CMakeLists.txt
+3 −0 Src/LinearSolvers/MLMG/AMReX_MLLinOp.H
+19 −12 Src/LinearSolvers/MLMG/AMReX_MLMG.H
+4 −0 Src/LinearSolvers/MLMG/Make.package
+9 −0 Src/LinearSolvers/Make.package
+4 −0 Src/LinearSolvers/OpenBC/Make.package
+2 −2 Src/Particle/AMReX_DenseBins.H
+10 −1 Src/Particle/AMReX_Particle.H
+0 −5 Src/Particle/AMReX_ParticleContainer.H
+0 −50 Src/Particle/AMReX_ParticleContainerI.H
+56 −18 Src/Particle/AMReX_ParticleIO.H
+0 −74 Src/Particle/AMReX_Particle_mod_K.H
+357 −153 Src/Particle/AMReX_TracerParticle_mod_K.H
+25 −12 Src/Particle/AMReX_WriteBinaryParticleData.H
+3 −3 Tests/Amr/Advection_AmrCore/Source/AmrCoreAdv.H
+0 −8 Tests/Amr/Advection_AmrCore/Source/AmrCoreAdv.cpp
+1 −1 Tests/LinearSolvers/ABecLaplacian_C/GNUmakefile
+4 −0 Tests/LinearSolvers/ABecLaplacian_C/MyTest.H
+90 −1 Tests/LinearSolvers/ABecLaplacian_C/MyTest.cpp
+2 −1 Tests/LinearSolvers/ABecLaplacian_C/MyTestPlotfile.cpp
+17 −0 Tests/LinearSolvers/ABecLaplacian_C/inputs.gmres
+0 −4 Tests/Particles/AssignDensity/main.cpp
+0 −4 Tests/Particles/AssignMultiLevelDensity/main.cpp
+1 −1 Tests/Particles/CheckpointRestartSOA/main.cpp
+10 −9 Tools/Plotfile/fcompare.cpp

0 comments on commit e177c97

Please sign in to comment.