Skip to content

Commit

Permalink
NodeABecLaplacian: Reuse (AMReX-Codes#3579)
Browse files Browse the repository at this point in the history
Add reuse capability to NodeABecLaplacian. More specifically, we need to
average down coefficients again.
  • Loading branch information
WeiqunZhang authored Oct 4, 2023
1 parent e470d33 commit 8755645
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 16 deletions.
1 change: 1 addition & 0 deletions .codespell-ignore-words
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ parms
pres
ptd
recuse
shft
siz
structed
te
Expand Down
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_AmrMesh.H
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public:
void SetGridEff (Real eff) noexcept { grid_eff = eff; }
void SetNProper (int n) noexcept { n_proper = n; }

//! Set ref_ratio would require rebuiling Geometry objects.
//! Set ref_ratio would require rebuilding Geometry objects.

void SetFinestLevel (int new_finest_level) noexcept { finest_level = new_finest_level; }
void SetDistributionMap (int lev, const DistributionMapping& dmap_in) noexcept;
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_CoordSys.H
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public:
BL_ASSERT(c_sys != undef); return (c_sys == RZ);
}

//! Is CoordType == cartesion?
//! Is CoordType == cartesian?
[[nodiscard]] bool IsCartesian () const noexcept {
BL_ASSERT(c_sys != undef); return (c_sys == cartesian);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_FACopyDescriptor.H
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ FabArrayCopyDescriptor<FAB>::CollectData ()
amrex::The_Arena()->free(md_recv_data);
}

// Wait and upack data
// Wait and unpack data
if (N_rcvs > 0)
{
Vector<MPI_Status> stats(N_rcvs);
Expand Down
6 changes: 3 additions & 3 deletions Src/Base/AMReX_FArrayBox.H
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class FArrayBox;
* only want to write out 32 bit FABs.
*
* With the exception of the enumeration constants, this class is
* primarily for FArrayBox implementors; i.e. user's shouldn't
* primarily for FArrayBox implementers; i.e. user's shouldn't
* call any of the member functions in this class directly.
*/

Expand Down Expand Up @@ -241,7 +241,7 @@ public:

/**
* \brief Construct an initial FAB with the data space allocated but
* not inititialized. ncomp is the number of components
* not initialized. ncomp is the number of components
* (variables) at each data point in the Box.
*/
explicit FArrayBox (const Box& b,
Expand Down Expand Up @@ -409,7 +409,7 @@ public:
/**
* \brief Set the FABio::Format in the program.
* This is the preferred way to set the output format
* in "new" FABs. When desiging new programs, this should
* in "new" FABs. When designing new programs, this should
* be the only function that needs to be called in order
* to set the format.
*/
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_IArrayBox.H
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public:

/**
* \brief Construct an initial FAB with the data space allocated but
* not inititialized. ncomp is the number of components
* not initialized. ncomp is the number of components
* (variables) at each data point in the Box.
*/
explicit IArrayBox (const Box& b,
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_NonLocalBC.H
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ struct MultiBlockCommMetaData : FabArrayBase::CommMetaData {
// [concept.FabProjection]
//

//! \brief This type trait tests if a type P is a projetion for FAB.
//! \brief This type trait tests if a type P is a projection for FAB.
template <typename P, typename FAB>
struct IsFabProjection
: IsCallableR<typename FAB::value_type, P, Array4<const typename FAB::value_type>, Dim3, int>
Expand Down
4 changes: 2 additions & 2 deletions Src/EB/AMReX_EB_StateRedistribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ MLStateRedistribute ( Box const& bx, int ncomp,

if (domain_per_grown.contains(IntVect(AMREX_D_DECL(r,s,t))))
{
// Initialize so that the slope stencil goes from -1:1 in each diretion
// Initialize so that the slope stencil goes from -1:1 in each direction
int nx = 1; int ny = 1; int nz = 1;

// Do we have enough extent in each coordinate direction to use the 3x3x3 stencil
Expand Down Expand Up @@ -511,7 +511,7 @@ StateRedistribute ( Box const& bx, int ncomp,
bool extdir_khi = (d_bcrec_ptr[n].hi(2) == amrex::BCType::ext_dir ||
d_bcrec_ptr[n].hi(2) == amrex::BCType::hoextrap);
#endif
// Initialize so that the slope stencil goes from -1:1 in each diretion
// Initialize so that the slope stencil goes from -1:1 in each direction
int nx = 1; int ny = 1; int nz = 1;

// Do we have enough extent in each coordinate direction to use the 3x3x3 stencil
Expand Down
2 changes: 1 addition & 1 deletion Src/Extern/HYPRE/AMReX_HypreNodeLap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ HypreNodeLap::HypreNodeLap (const BoxArray& grids_, const DistributionMapping& d
Int nnodes_proc = fill_local_node_id();

// At this point, local_node_id stores the ids local to each box.
// nnodes_grid stroes the number of nodes in each box. nnodes_proc is
// nnodes_grid stores the number of nodes in each box. nnodes_proc is
// the number of nodes on this MPI process. If a nodal is invalid, its
// id is invalid (i.e., a very negative number). Note that the data
// type of local_node_id is int, not HYPRE_Int for performance on GPU.
Expand Down
2 changes: 1 addition & 1 deletion Src/Extern/HYPRE/AMReX_HypreSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ HypreSolver<MSS>::HypreSolver (Vector<IndexType> const& a_index_type,
fill_local_id(a_marker);

// At this point, m_local_id stores the ids local to each box.
// m_nrows_grid stroes the number of unique points in each box.
// m_nrows_grid stores the number of unique points in each box.
// m_nrows_proc is the number of rowss for all variables on this MPI
// process. If a point is invalid, its id is invalid (i.e., a very
// negative number). Note that the data type of local_node_id is int,
Expand Down
6 changes: 6 additions & 0 deletions Src/LinearSolvers/MLMG/AMReX_MLNodeABecLaplacian.H
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ public:

void prepareForSolve () final;

[[nodiscard]] bool needsUpdate () const final { return m_needs_update; }

void update () final;

void averageDownCoeffs ();
void averageDownCoeffsToCoarseAmrLevel (int flev);
void averageDownCoeffsSameAmrLevel (int amrlev);

private:

bool m_needs_update = true;

Real m_a_scalar = std::numeric_limits<Real>::quiet_NaN();
Real m_b_scalar = std::numeric_limits<Real>::quiet_NaN();
Vector<Vector<MultiFab> > m_a_coeffs;
Expand Down
14 changes: 14 additions & 0 deletions Src/LinearSolvers/MLMG/AMReX_MLNodeABecLaplacian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,30 @@ void
MLNodeABecLaplacian::setACoeffs (int amrlev, Real a_acoef)
{
m_a_coeffs[amrlev][0].setVal(a_acoef);
m_needs_update = true;
}

void
MLNodeABecLaplacian::setACoeffs (int amrlev, const MultiFab& a_acoef)
{
const int ncomp = getNComp();
m_a_coeffs[amrlev][0].LocalCopy(a_acoef, 0, 0, ncomp, IntVect(0));
m_needs_update = true;
}

void
MLNodeABecLaplacian::setBCoeffs (int amrlev, Real a_bcoef)
{
m_b_coeffs[amrlev][0].setVal(a_bcoef);
m_needs_update = true;
}

void
MLNodeABecLaplacian::setBCoeffs (int amrlev, const MultiFab& a_bcoef)
{
const int ncomp = getNComp();
m_b_coeffs[amrlev][0].LocalCopy(a_bcoef, 0, 0, ncomp, IntVect(0));
m_needs_update = true;
}

void
Expand Down Expand Up @@ -251,6 +255,16 @@ MLNodeABecLaplacian::prepareForSolve ()
buildMasks();

averageDownCoeffs();

m_needs_update = false;
}

void
MLNodeABecLaplacian::update ()
{
BL_PROFILE("MLNodeABecLaplacian::prepareForSolve()");
averageDownCoeffs();
m_needs_update = false;
}

void
Expand Down
2 changes: 1 addition & 1 deletion Tests/HDF5Benchmark/sz.config
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ relBoundRatio = 1E-9
pw_relBoundRatio = 1E-2

#point-wise relative-error-bound segment size
#The larger this value, the lower overhead of maitaining error bound information for each segment/block, while the stricter absolute bound used to control the point-wise relative-error-bound. The block size will be M^K, where K is the # dimensions of the data and M is an integer such that (M-1)^K < segment_size <= M^K. For instance, for a 2D data, segment_size=32 means the whole data set will be split into multiple small blocks each being 6x6. For a 3D data, segment_size=32 means the whole data set is split into a lot of 4x4x4 blocks, each of which has an individual compression precision/error.
#The larger this value, the lower overhead of maintaining error bound information for each segment/block, while the stricter absolute bound used to control the point-wise relative-error-bound. The block size will be M^K, where K is the # dimensions of the data and M is an integer such that (M-1)^K < segment_size <= M^K. For instance, for a 2D data, segment_size=32 means the whole data set will be split into multiple small blocks each being 6x6. For a 3D data, segment_size=32 means the whole data set is split into a lot of 4x4x4 blocks, each of which has an individual compression precision/error.
segment_size = 32

#point-wise relative-error-bound type
Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReXBuildInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function (generate_buildinfo _target _git_dir)
configure_file( ${AMREX_BUILDINFO_IFILE}
${PROJECT_BINARY_DIR}/${_target}/AMReX_buildInfo.cpp @ONLY)

# add a re-usable target
# add a reusable target
add_library(buildInfo${_target} STATIC)
add_library(buildInfo::${_target} ALIAS buildInfo${_target})

Expand Down
2 changes: 1 addition & 1 deletion Tools/CMake/AMReXClangTidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ macro(setup_clang_tidy)
if (_tmp MATCHES "LLVM version ([0-9\.]+)")
message(STATUS "Found clang-tidy ${CMAKE_MATCH_1}")
if ("${CMAKE_MATCH_1}" VERSION_GREATER_EQUAL 12.0.0)
# Cofig file not supported in earlier versions
# Config file not supported in earlier versions
set(AMReX_CLANG_TIDY_CONFIG_FILE_NAME ${PROJECT_SOURCE_DIR}/.clang-tidy)
endif()
endif()
Expand Down
2 changes: 1 addition & 1 deletion Tools/C_scripts/mkdep
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Notes: * -I<path> defines a search path for include files
# * -DBG turn on debug flag
# + -fortran: parse fortran style include directives
# * -X<path> means disgard entries with this path (NOT IMPLEMENTED)
# * -X<path> means discard entries with this path (NOT IMPLEMENTED)
# * searches current directory only if -I. is in search
# path or #include directive uses double quotes rather
# than angle brackets.
Expand Down

0 comments on commit 8755645

Please sign in to comment.