Skip to content

Commit

Permalink
Implement more virtual functions in MLLinOp
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Feb 6, 2024
1 parent 90ddec6 commit 8ec5842
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 88 deletions.
16 changes: 0 additions & 16 deletions Src/LinearSolvers/MLMG/AMReX_MLCurlCurl.H
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,6 @@ public:

void interpolation (int amrlev, int fmglev, MF& fine, const MF& crse) const override;

void interpAssign (int amrlev, int fmglev, MF& fine, MF& crse) const override;

void interpolationAmr (int famrlev, MF& fine, const MF& crse,
IntVect const& nghost) const override;

void averageDownSolutionRHS (int camrlev, MF& crse_sol, MF& crse_rhs,
const MF& fine_sol, const MF& fine_rhs) override;

void apply (int amrlev, int mglev, MF& out, MF& in, BCMode bc_mode,
StateMode s_mode, const MLMGBndryT<MF>* bndry=nullptr) const override;

Expand All @@ -73,10 +65,6 @@ public:
const MF& b, BCMode bc_mode,
const MF* crse_bcdata=nullptr) override;

void reflux (int crse_amrlev,
MF& res, const MF& crse_sol, const MF& crse_rhs,
MF& fine_res, MF& fine_sol, const MF& fine_rhs) const override;

void prepareForSolve () override;

[[nodiscard]] bool isSingular (int /*amrlev*/) const override { return false; }
Expand All @@ -88,10 +76,6 @@ public:

void averageDownAndSync (Vector<MF>& sol) const override;

void avgDownResAmr (int clev, MF& cres, MF const& fres) const override;

void avgDownResMG (int clev, MF& cres, MF const& fres) const override;

[[nodiscard]] IntVect getNGrowVectRestriction () const override {
return IntVect(0);
}
Expand Down
42 changes: 0 additions & 42 deletions Src/LinearSolvers/MLMG/AMReX_MLCurlCurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,6 @@ void MLCurlCurl::interpolation (int amrlev, int fmglev, MF& fine,
Gpu::streamSynchronize();
}

void
MLCurlCurl::interpAssign (int amrlev, int fmglev, MF& fine, MF& crse) const
{
amrex::ignore_unused(amrlev, fmglev, fine, crse);
amrex::Abort("MLCurlCurl::interpAssign: TODO");
}

void MLCurlCurl::interpolationAmr (int famrlev, MF& fine, const MF& crse,
IntVect const& nghost) const
{
amrex::ignore_unused(famrlev, fine, crse, nghost);
amrex::Abort("MLCurlCurl::interpolationAmr: TODO");
}

void MLCurlCurl::averageDownSolutionRHS (int camrlev, MF& crse_sol, MF& crse_rhs,
const MF& fine_sol, const MF& fine_rhs)
{
amrex::ignore_unused(camrlev, crse_sol, crse_rhs, fine_sol, fine_rhs);
amrex::Abort("MLCurlCurl::averageDownSolutionRHS: TODO");
}

void
MLCurlCurl::apply (int amrlev, int mglev, MF& out, MF& in, BCMode /*bc_mode*/,
StateMode /*s_mode*/, const MLMGBndryT<MF>* /*bndry*/) const
Expand Down Expand Up @@ -311,15 +290,6 @@ void MLCurlCurl::compresid (int amrlev, int mglev, MF& resid, MF const& b) const
}
}

void MLCurlCurl::reflux (int crse_amrlev,
MF& res, const MF& crse_sol, const MF& crse_rhs,
MF& fine_res, MF& fine_sol, const MF& fine_rhs) const
{
amrex::ignore_unused(crse_amrlev, res, crse_sol, crse_rhs, fine_res,
fine_sol, fine_rhs);
amrex::Abort("MLCurlCurl::reflux: TODO");
}

void MLCurlCurl::prepareForSolve ()
{
}
Expand Down Expand Up @@ -356,18 +326,6 @@ void MLCurlCurl::averageDownAndSync (Vector<MF>& sol) const
}
}

void MLCurlCurl::avgDownResAmr (int clev, MF& cres, MF const& fres) const
{
amrex::ignore_unused(clev, cres, fres);
amrex::Abort("MLCurlCurl::avgDownResAmr: TODO");
}

void MLCurlCurl::avgDownResMG (int clev, MF& cres, MF const& fres) const
{
amrex::ignore_unused(clev, cres, fres);
amrex::Abort("MLCurlCurl::avgDownResMG: TODO");
}

void MLCurlCurl::make (Vector<Vector<MF> >& mf, IntVect const& ng) const
{
MLLinOpT<MF>::make(mf, ng);
Expand Down
6 changes: 0 additions & 6 deletions Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.H
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ public:

void restriction (int amrlev, int cmglev, MultiFab& crse, MultiFab& fine) const final;
void interpolation (int amrlev, int fmglev, MultiFab& fine, const MultiFab& crse) const final;
void averageDownSolutionRHS (int camrlev, MultiFab& crse_sol, MultiFab& crse_rhs,
const MultiFab& fine_sol, const MultiFab& fine_rhs) final;

void reflux (int crse_amrlev,
MultiFab& res, const MultiFab& crse_sol, const MultiFab& crse_rhs,
MultiFab& fine_res, MultiFab& fine_sol, const MultiFab& fine_rhs) const final;

void prepareForSolve () final;
void Fapply (int amrlev, int mglev, MultiFab& out, const MultiFab& in) const final;
Expand Down
18 changes: 0 additions & 18 deletions Src/LinearSolvers/MLMG/AMReX_MLEBNodeFDLaplacian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,6 @@ MLEBNodeFDLaplacian::interpolation (int amrlev, int fmglev, MultiFab& fine,
}
}

void
MLEBNodeFDLaplacian::averageDownSolutionRHS (int /*camrlev*/, MultiFab& /*crse_sol*/,
MultiFab& /*crse_rhs*/,
const MultiFab& /*fine_sol*/,
const MultiFab& /*fine_rhs*/)
{
amrex::Abort("MLEBNodeFDLaplacian::averageDownSolutionRHS: todo");
}

void
MLEBNodeFDLaplacian::reflux (int /*crse_amrlev*/, MultiFab& /*res*/,
const MultiFab& /*crse_sol*/, const MultiFab& /*crse_rhs*/,
MultiFab& /*fine_res*/, MultiFab& /*fine_sol*/,
const MultiFab& /*fine_rhs*/) const
{
amrex::Abort("MLEBNodeFDLaplacian::reflux: TODO");
}

void
MLEBNodeFDLaplacian::prepareForSolve ()
{
Expand Down
36 changes: 30 additions & 6 deletions Src/LinearSolvers/MLMG/AMReX_MLLinOp.H
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ public:
* \param fine fine MG level data
* \param crse coarse MG level data
*/
virtual void interpAssign (int amrlev, int fmglev, MF& fine, MF& crse) const = 0;
virtual void interpAssign (int amrlev, int fmglev, MF& fine, MF& crse) const
{
amrex::ignore_unused(amrlev, fmglev, fine, crse);
amrex::Abort("MLLinOpT::interpAssign: Must be implemented for FMG cycle");
}

/**
* \brief Interpolation between AMR levels
Expand All @@ -294,7 +298,11 @@ public:
* \param nghost number of ghost cells
*/
virtual void interpolationAmr (int famrlev, MF& fine, const MF& crse,
IntVect const& nghost) const = 0;
IntVect const& nghost) const
{
amrex::ignore_unused(famrlev, fine, crse, nghost);
amrex::Abort("MLLinOpT::interpolationAmr: Must be implemeted for composite solves across multiple AMR levels");
}

/**
* \brief Average-down data from fine AMR level to coarse AMR level.
Expand All @@ -306,7 +314,11 @@ public:
* \param fine_rhs RHS on fine AMR level
*/
virtual void averageDownSolutionRHS (int camrlev, MF& crse_sol, MF& crse_rhs,
const MF& fine_sol, const MF& fine_rhs) = 0;
const MF& fine_sol, const MF& fine_rhs)
{
amrex::ignore_unused(camrlev, crse_sol, crse_rhs, fine_sol, fine_rhs);
amrex::Abort("MLLinOpT::averageDownSolutionRHS: Must be implemeted for composite solves across multiple AMR levels");
}

/**
* \brief Apply the linear operator, out = L(in)
Expand Down Expand Up @@ -378,7 +390,12 @@ public:
*/
virtual void reflux (int crse_amrlev,
MF& res, const MF& crse_sol, const MF& crse_rhs,
MF& fine_res, MF& fine_sol, const MF& fine_rhs) const = 0;
MF& fine_res, MF& fine_sol, const MF& fine_rhs) const
{
amrex::ignore_unused(crse_amrlev, res, crse_sol, crse_rhs, fine_res,
fine_sol, fine_rhs);
amrex::Abort("MLLinOpT::reflux: Must be implemeted for composite solves across multiple AMR levels");
}

/**
* \brief Compute fluxes
Expand Down Expand Up @@ -443,7 +460,7 @@ public:
//! x dot y, used by the bottom solver
virtual RT xdoty (int amrlev, int mglev, const MF& x, const MF& y, bool local) const = 0;

virtual std::unique_ptr<MLLinOpT<MF>> makeNLinOp (int grid_size) const
virtual std::unique_ptr<MLLinOpT<MF>> makeNLinOp (int /*grid_size*/) const
{
amrex::Abort("MLLinOp::makeNLinOp: N-Solve not supported");
return nullptr;
Expand Down Expand Up @@ -497,7 +514,13 @@ public:

virtual void averageDownAndSync (Vector<MF>& sol) const = 0;

virtual void avgDownResAmr (int clev, MF& cres, MF const& fres) const = 0;
virtual void avgDownResAmr (int clev, MF& cres, MF const& fres) const
{
amrex::ignore_unused(clev, cres, fres);
amrex::Abort("MLLinOpT::avgDownResAmr: Must be implemeted for composite solves across multiple AMR levels");
}

// This function is needed for FMG cycle, but not V-cycle.
virtual void avgDownResMG (int clev, MF& cres, MF const& fres) const;

[[nodiscard]] bool isMFIterSafe (int amrlev, int mglev1, int mglev2) const;
Expand Down Expand Up @@ -1487,6 +1510,7 @@ template <typename MF>
void
MLLinOpT<MF>::avgDownResMG (int clev, MF& cres, MF const& fres) const
{
amrex::ignore_unused(clev, cres, fres);
if constexpr (amrex::IsFabArray<MF>::value) {
const int ncomp = this->getNComp();
#ifdef AMREX_USE_EB
Expand Down

0 comments on commit 8ec5842

Please sign in to comment.