Skip to content

Commit

Permalink
Merge branch 'development' into comments-fab
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Nov 28, 2023
2 parents 52a6f70 + 4b64003 commit 7eca7e7
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 80 deletions.
6 changes: 3 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

-- We weren't defining cent_hat out far enough (#3548)

-- Add Fortran inteface for FillCoarsePatch for face variables (#3542)
-- Add Fortran interface for FillCoarsePatch for face variables (#3542)

-- print_state/printCell: Make it work without managed memory (#3543)

Expand Down Expand Up @@ -114,7 +114,7 @@

-- Simplify filterParticles Kernel (#3510)

-- Generatize particle-to-cell assignment function (#3499)
-- Generalize particle-to-cell assignment function (#3499)
Follow-on to 3499 (#3514)
ParticleLocator: Make Assignor optional template parameter (#3515)

Expand Down Expand Up @@ -302,7 +302,7 @@

# 23.07

-- Allow users to change the default vector growth stategy (#3389)
-- Allow users to change the default vector growth strategy (#3389)

-- Communications arena implementation (#3388)

Expand Down
8 changes: 4 additions & 4 deletions Src/AmrCore/AMReX_FillPatcher.H
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ namespace amrex {
* with interpolation of the coarse data. Then it fills the fine ghost
* cells overlapping fine level valid cells with the fine level data. If
* the valid cells of the destination need to be filled, it will be done as
* well. Finally, it will fill the physical bounbary using the user
* well. Finally, it will fill the physical boundary using the user
* provided functor. The `fill` member function can be used to do the
* operations just described. Alternatively, one can also use the
* `fillCoarseFineBounary` to fill the ghost cells at the coarse/fine
* boundary only. Then one can manually call FillBoundary to fill the other
* ghost cells, and use the physical BC functor to handle the physical
* boundeary.
* boundary.
*
* The communication of the coarse data needed for spatial interpolation is
* optimized at the cost of being error-prone. One must follow the
Expand All @@ -42,7 +42,7 @@ namespace amrex {
*
* (3) When to destroy? Usually, we do time steppig on a coarse level
* first. Then we recursively do time stepping on fine levels. After the
* finer level finishes, we do reflux and averge the fine data down to the
* finer level finishes, we do reflux and average the fine data down to the
* coarse level. After that we should destroy the FillPatcher object
* associated with these two levels, because the coarse data stored in the
* object has become outdated. For AmrCore based codes, you could use
Expand Down Expand Up @@ -118,7 +118,7 @@ public:
* \param fbc for filling fine level physical BC
* \param fbccomp starting component of the fine level BC functor
* \param bcs BCRec specifying physical boundary types
* \parame bcscomp starting component of the BCRec Vector.
* \param bcscomp starting component of the BCRec Vector.
* \param pre_interp optional pre-interpolation hook for modifying the coarse data
* \param post_interp optional post-interpolation hook for modifying the fine data
*/
Expand Down
4 changes: 2 additions & 2 deletions Src/AmrCore/AMReX_InterpFaceRegister.H
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace amrex {

/**
* \brief InterpFaceRegister is a coarse/fine boundary register for
* interpolation of face data at the coarse/fine boundadry.
* interpolation of face data at the coarse/fine boundary.
*/

class InterpFaceRegister
Expand All @@ -31,7 +31,7 @@ public:
Geometry const& fgeom, IntVect const& ref_ratio);

/**
* \brief Defines an InterpFaceRegister objecct.
* \brief Defines an InterpFaceRegister object.
*
* \param fba The fine level BoxArray
* \param fdm The fine level DistributionMapping
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_BCRec.H
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public:
{}
/*
* \brief Yet another constructor. Inherits bndry types from bc_domain
* when bx lies on edge of domain otherwise gets interior Dirchlet.
* when bx lies on edge of domain otherwise gets interior Dirichlet.
*/
AMREX_GPU_HOST_DEVICE
BCRec (const Box& bx,
Expand Down
8 changes: 4 additions & 4 deletions Src/Base/AMReX_MultiFab.H
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public:
/**
* \brief Constructs an empty MultiFab.
*
* Data can be defined at a later time using the define member functions
* inherited from FabArray. If `define` is called later with a nullptr
* as MFInfo's arena, the default Arena `a` will be used. If the arena
* in MFInfo is not a nullptr, the MFInfo's arena will be used.
* Data can be defined at a later time using the define member functions.
* If `define` is called later with a nullptr as MFInfo's arena, the
* default Arena `a` will be used. If the arena in MFInfo is not a
* nullptr, the MFInfo's arena will be used.
*/
explicit MultiFab (Arena* a) noexcept;

Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_MultiFabUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ namespace amrex
auto tmptype = type;
tmptype.set(dir);
if (dir >= AMREX_SPACEDIM || !tmptype.nodeCentered()) {
amrex::Abort("average_down_edges: not face index type");
amrex::Abort("average_down_edges: not edge index type");
}
const int ncomp = crse.nComp();
if (isMFIterSafe(fine, crse))
Expand Down
4 changes: 2 additions & 2 deletions Src/Base/AMReX_iMultiFab.H
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace amrex {
* member functions are defined for I/O and simple arithmetic operations on
* these aggregate objects.
*
8 This class does NOT provide a copy constructor or assignment operator.
* This class does NOT provide a copy constructor or assignment operator.
*/
class iMultiFab
:
Expand All @@ -42,7 +42,7 @@ public:
/**
* \brief Constructs an empty iMultiFab. Data can be defined at a later
* time using the define member functions inherited from FabArray. If
* `define` is called later with a nulltpr as MFInfo's arena, the default
* `define` is called later with a nullptr as MFInfo's arena, the default
* Arena `a` will be used. If the arena in MFInfo is not a nullptr, the
* MFInfo's arena will be used.
*/
Expand Down
2 changes: 1 addition & 1 deletion Src/EB/AMReX_EB_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ facets_nearest_pt (IntVect const& ind_pt, IntVect const& ind_loop, RealVect cons
RealVect const& eb_normal, RealVect const& eb_p0,
GpuArray<Real,AMREX_SPACEDIM> const& dx)
{
// Enumerate the possible EB facet edges invovlved.
// Enumerate the possible EB facet edges involved.
int n_facets = 0;
IntVect ind_facets {AMREX_D_DECL(0, 0, 0)};
for (int d = 0; d < AMREX_SPACEDIM; ++d) {
Expand Down
2 changes: 1 addition & 1 deletion Src/F_Interfaces/Base/AMReX_parallel_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ subroutine amrex_parallel_init (comm)

if (present(comm) .and. .not.flag) then
if (comm .ne. MPI_COMM_WORLD) then
stop "MPI has not been initialized. How come we are given a communciator?"
stop "MPI has not been initialized. How come we are given a communicator?"
endif
end if

Expand Down
68 changes: 39 additions & 29 deletions Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public:

/**
* Sets alpha as a scalar field to values from a single component
* mutlifab.
* multifab.
*
* \param [in] amrlev The level of the multifab for the solver, with
* \p amrlev = 0 always being the lowest level in the
Expand All @@ -88,12 +88,12 @@ public:

/**
* Sets alpha as a single scalar constant value across
* the mutlifab.
* the multifab.
*
* \param [in] amrlev The level of the multifab for the solver, with
* \p amrlev = 0 always being the lowest level in the
* AMR hierarchy represented in the solve.
* \param [in] alpha Single scalar value to populate across mutlifab.
* \param [in] alpha Single scalar value to populate across multifab.
*/
template <typename T,
std::enable_if_t<std::is_convertible_v<T,typename MF::value_type>,
Expand All @@ -118,12 +118,12 @@ public:

/**
* Sets beta as a single scalar constant value across
* the mutlifabs (one for each dimension).
* the multifabs (one for each dimension).
*
* \param [in] amrlev The level of the multifab for the solver, with
* \p amrlev = 0 always being the lowest level in the
* AMR hierarchy represented in the solve.
* \param [in] beta Single scalar value to populate across mutlifabs.
* \param [in] beta Single scalar value to populate across multifabs.
*/
template <typename T,
std::enable_if_t<std::is_convertible_v<T,typename MF::value_type>,
Expand Down Expand Up @@ -190,15 +190,15 @@ public:
Array<FAB*,AMREX_SPACEDIM> const& flux,
FAB const& sol, int face_only, int ncomp);

protected:

bool m_needs_update = true;

RT m_a_scalar = std::numeric_limits<RT>::quiet_NaN();
RT m_b_scalar = std::numeric_limits<RT>::quiet_NaN();
Vector<Vector<MF> > m_a_coeffs;
Vector<Vector<Array<MF,AMREX_SPACEDIM> > > m_b_coeffs;

protected:

bool m_needs_update = true;

Vector<int> m_is_singular;

[[nodiscard]] bool supportRobinBC () const noexcept override { return true; }
Expand Down Expand Up @@ -474,29 +474,29 @@ MLABecLaplacianT<MF>::applyMetricTermsCoeffs ()
// \tilde{alpha}_i = alpha_i + (1-B) beta_{i+1/2} / h^2
// \tilde{rhs}_i = rhs_i + A beta_{i+1/2} / h^2
//
template <typename MF>
void
MLABecLaplacianT<MF>::applyRobinBCTermsCoeffs ()
namespace detail {
template <typename LP>
void applyRobinBCTermsCoeffs (LP& linop)
{
if (!(this->hasRobinBC())) { return; }
using RT = typename LP::RT;

const int ncomp = this->getNComp();
const int ncomp = linop.getNComp();
bool reset_alpha = false;
if (m_a_scalar == RT(0.0)) {
m_a_scalar = RT(1.0);
if (linop.m_a_scalar == RT(0.0)) {
linop.m_a_scalar = RT(1.0);
reset_alpha = true;
}
const RT bovera = m_b_scalar/m_a_scalar;
const RT bovera = linop.m_b_scalar/linop.m_a_scalar;

for (int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
for (int amrlev = 0; amrlev < linop.NAMRLevels(); ++amrlev) {
const int mglev = 0;
const Box& domain = this->m_geom[amrlev][mglev].Domain();
const RT dxi = static_cast<RT>(this->m_geom[amrlev][mglev].InvCellSize(0));
const RT dyi = static_cast<RT>((AMREX_SPACEDIM >= 2) ? this->m_geom[amrlev][mglev].InvCellSize(1) : Real(1.0));
const RT dzi = static_cast<RT>((AMREX_SPACEDIM == 3) ? this->m_geom[amrlev][mglev].InvCellSize(2) : Real(1.0));
const Box& domain = linop.Geom(amrlev,mglev).Domain();
const RT dxi = static_cast<RT>(linop.Geom(amrlev,mglev).InvCellSize(0));
const RT dyi = static_cast<RT>((AMREX_SPACEDIM >= 2) ? linop.Geom(amrlev,mglev).InvCellSize(1) : Real(1.0));
const RT dzi = static_cast<RT>((AMREX_SPACEDIM == 3) ? linop.Geom(amrlev,mglev).InvCellSize(2) : Real(1.0));

if (reset_alpha) {
m_a_coeffs[amrlev][mglev].setVal(RT(0.0));
linop.m_a_coeffs[amrlev][mglev].setVal(RT(0.0));
}

MFItInfo mfi_info;
Expand All @@ -505,20 +505,20 @@ MLABecLaplacianT<MF>::applyRobinBCTermsCoeffs ()
#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (MFIter mfi(m_a_coeffs[amrlev][mglev], mfi_info); mfi.isValid(); ++mfi)
for (MFIter mfi(linop.m_a_coeffs[amrlev][mglev], mfi_info); mfi.isValid(); ++mfi)
{
const Box& vbx = mfi.validbox();
auto const& afab = m_a_coeffs[amrlev][mglev].array(mfi);
auto const& afab = linop.m_a_coeffs[amrlev][mglev].array(mfi);
for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
auto const& bfab = m_b_coeffs[amrlev][mglev][idim].const_array(mfi);
auto const& bfab = linop.m_b_coeffs[amrlev][mglev][idim].const_array(mfi);
const Box& blo = amrex::adjCellLo(vbx,idim);
const Box& bhi = amrex::adjCellHi(vbx,idim);
bool outside_domain_lo = !(domain.contains(blo));
bool outside_domain_hi = !(domain.contains(bhi));
if ((!outside_domain_lo) && (!outside_domain_hi)) { continue; }
for (int icomp = 0; icomp < ncomp; ++icomp) {
auto const& rbc = (*(this->m_robin_bcval[amrlev]))[mfi].const_array(icomp*3);
if (this->m_lobc_orig[icomp][idim] == LinOpBCType::Robin && outside_domain_lo)
auto const& rbc = (*(linop.m_robin_bcval[amrlev]))[mfi].const_array(icomp*3);
if (linop.m_lobc_orig[icomp][idim] == LinOpBCType::Robin && outside_domain_lo)
{
if (idim == 0) {
RT fac = bovera*dxi*dxi;
Expand Down Expand Up @@ -546,7 +546,7 @@ MLABecLaplacianT<MF>::applyRobinBCTermsCoeffs ()
});
}
}
if (this->m_hibc_orig[icomp][idim] == LinOpBCType::Robin && outside_domain_hi)
if (linop.m_hibc_orig[icomp][idim] == LinOpBCType::Robin && outside_domain_hi)
{
if (idim == 0) {
RT fac = bovera*dxi*dxi;
Expand Down Expand Up @@ -579,6 +579,16 @@ MLABecLaplacianT<MF>::applyRobinBCTermsCoeffs ()
}
}
}
} // namespace detail

template <typename MF>
void
MLABecLaplacianT<MF>::applyRobinBCTermsCoeffs ()
{
if (this->hasRobinBC()) {
detail::applyRobinBCTermsCoeffs(*this);
}
}

template <typename MF>
void
Expand Down
4 changes: 2 additions & 2 deletions Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public:
RT location;
};

Vector<std::unique_ptr<MF> > m_robin_bcval;

protected:

bool m_has_metric_term = false;
Expand Down Expand Up @@ -182,8 +184,6 @@ protected:
};
Vector<Vector<std::unique_ptr<BndryCondLoc> > > m_bcondloc;

Vector<std::unique_ptr<MF> > m_robin_bcval;

// used to save interpolation coefficients of the first interior cells
mutable Vector<Vector<BndryRegisterT<MF>> > m_undrrelxr;

Expand Down
13 changes: 9 additions & 4 deletions Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.H
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public:
void getEBFluxes (const Vector<MultiFab*>& a_flux,
const Vector<MultiFab*>& a_sol) const override;

void applyRobinBCTermsCoeffs ();

#if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1)
[[nodiscard]] std::unique_ptr<Hypre> makeHypre (Hypre::Interface hypre_interface) const override;
#endif
Expand All @@ -122,6 +124,11 @@ public:
[[nodiscard]] std::unique_ptr<PETScABecLap> makePETSc () const override;
#endif

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;
Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_b_coeffs;

protected:

int m_ncomp = 1;
Expand All @@ -131,10 +138,6 @@ protected:
Location m_beta_loc; // Location of coefficients: face centers or face centroids
Location m_phi_loc; // Location of solution variable: cell centers or cell centroids

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;
Vector<Vector<Array<MultiFab,AMREX_SPACEDIM> > > m_b_coeffs;
Vector<Vector<iMultiFab> > m_cc_mask;

Vector<std::unique_ptr<MultiFab> > m_eb_phi;
Expand All @@ -154,6 +157,8 @@ protected:
const Vector<MultiFab*>& b_eb);
void averageDownCoeffs ();
void averageDownCoeffsToCoarseAmrLevel (int flev);

[[nodiscard]] bool supportRobinBC () const noexcept override { return true; }
};

}
Expand Down
10 changes: 10 additions & 0 deletions Src/LinearSolvers/MLMG/AMReX_MLEBABecLap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ MLEBABecLap::prepareForSolve ()

MLCellABecLap::prepareForSolve();

applyRobinBCTermsCoeffs();

averageDownCoeffs();

if (m_eb_phi[0]) {
Expand Down Expand Up @@ -1285,6 +1287,14 @@ MLEBABecLap::getEBFluxes (const Vector<MultiFab*>& a_flux, const Vector<MultiFab
}
}

void
MLEBABecLap::applyRobinBCTermsCoeffs ()
{
if (this->hasRobinBC()) {
detail::applyRobinBCTermsCoeffs(*this);
}
}

#if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1)
std::unique_ptr<Hypre>
MLEBABecLap::makeHypre (Hypre::Interface hypre_interface) const
Expand Down
2 changes: 1 addition & 1 deletion Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace amrex {
// where phi and rhs are nodal multifab, and sigma is a tensor constant
// with only diagonal components. The EB is assumed to be Dirichlet.
//
// del dot (simga grad phi) - alpha/r^2 phi = rhs, for RZ where alpha is a
// del dot (sigma grad phi) - alpha/r^2 phi = rhs, for RZ where alpha is a
// scalar constant that is zero by default.

class MLEBNodeFDLaplacian
Expand Down
Loading

0 comments on commit 7eca7e7

Please sign in to comment.