Skip to content

Commit

Permalink
nodal projection: allow compgrad to be called on supplied phi (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkuhn committed Aug 29, 2023
1 parent bc4e5f6 commit c6fed55
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Projections/hydro_NodalProjector.H
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public:
amrex::Vector< amrex::MultiFab* > getPhi () {return GetVecOfPtrs(m_phi);}
amrex::Vector< const amrex::MultiFab* > getPhiConst () const {return GetVecOfConstPtrs(m_phi);}

amrex::Vector< amrex::MultiFab* > calcGradPhi (const amrex::Vector<amrex::MultiFab*>& a_phi);

void computeRHS ( const amrex::Vector<amrex::MultiFab*>& a_rhs,
const amrex::Vector<amrex::MultiFab*>& a_vel,
const amrex::Vector<amrex::MultiFab*>& a_S_cc = {},
Expand Down
33 changes: 33 additions & 0 deletions Projections/hydro_NodalProjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,39 @@ NodalProjector::project ( const Vector<MultiFab*>& a_phi, Real a_rtol, Real a_at
}
}

amrex::Vector<amrex::MultiFab*>
NodalProjector::calcGradPhi ( const Vector<MultiFab*>& a_phi )
{
BL_PROFILE("NodalProjector::calcGradPhi");
AMREX_ALWAYS_ASSERT(!m_need_bcs);

// Copy input
AMREX_ALWAYS_ASSERT(a_phi.size()==m_phi.size());
for (int lev=0; lev < m_phi.size(); ++lev )
{
MultiFab::Copy(m_phi[lev],*a_phi[lev],0,0,1,m_phi[lev].nGrow());
}

// Set coeffs involved with fluxes
for (int lev = 0; lev < m_sigma.size(); ++lev)
{
m_linop -> setSigma(lev, *m_sigma[lev]);
}

// Perform projection
for (int lev(0); lev < m_phi.size(); ++lev)
{
// set m_fluxes = grad(phi)
m_linop->compGrad(lev,m_fluxes[lev],m_phi[lev]);
}

// Average down
averageDown(GetVecOfPtrs(m_fluxes));

// Output fluxes
return GetVecOfPtrs(m_fluxes);
}


//
// Compute RHS: div(u) + S_nd + S_cc
Expand Down

0 comments on commit c6fed55

Please sign in to comment.