Skip to content

Commit

Permalink
If both rhs and v are provided, the nodal solver will use rhs + div v
Browse files Browse the repository at this point in the history
as RHS.  If only v is provided, it will use div v as RHS, as before.
  • Loading branch information
WeiqunZhang committed Dec 9, 2011
1 parent d919757 commit 6e2da55
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ f/
o/
t/
TAGS

run-*/
*.org
21 changes: 21 additions & 0 deletions Src/LinearSolvers/C_to_F_MG/MGT_Solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ mgt_set_c mgt_set_cfbx_const = mgt_set_cfbx_1d_const;
mgt_set mgt_set_cfs = mgt_set_cfs_1d;
mgt_getni mgt_get_vel = mgt_get_vel_1d;
mgt_setni mgt_set_vel = mgt_set_vel_1d;
mgt_set mgt_add_rh_nodal = mgt_add_rh_nodal_1d;
#elif BL_SPACEDIM == 2
mgt_get_ng mgt_get_uu = mgt_get_uu_2d;
mgt_set mgt_set_uu = mgt_set_uu_2d;
Expand All @@ -92,6 +93,7 @@ mgt_set_c mgt_set_cfby_const = mgt_set_cfby_2d_const;
mgt_set mgt_set_cfs = mgt_set_cfs_2d;
mgt_getni mgt_get_vel = mgt_get_vel_2d;
mgt_setni mgt_set_vel = mgt_set_vel_2d;
mgt_set mgt_add_rh_nodal = mgt_add_rh_nodal_2d;
#elif BL_SPACEDIM == 3
mgt_get_ng mgt_get_uu = mgt_get_uu_3d;
mgt_set mgt_set_uu = mgt_set_uu_3d;
Expand All @@ -115,6 +117,7 @@ mgt_set_c mgt_set_cfbz_const = mgt_set_cfbz_3d_const;
mgt_set mgt_set_cfs = mgt_set_cfs_3d;
mgt_getni mgt_get_vel = mgt_get_vel_3d;
mgt_setni mgt_set_vel = mgt_set_vel_3d;
mgt_set mgt_add_rh_nodal = mgt_add_rh_nodal_3d;
#endif

MGT_Solver::MGT_Solver(const std::vector<Geometry>& geom,
Expand Down Expand Up @@ -1401,6 +1404,24 @@ MGT_Solver::nodal_project(MultiFab* p[], MultiFab* vel[], MultiFab* Rhs[], const

mgt_divu();

for ( int lev = 0; lev < m_nlevel; ++lev ) {
if (Rhs[lev] != 0) {

for (MFIter rmfi(*(Rhs[lev])); rmfi.isValid(); ++rmfi) {
int n = rmfi.index();

const int* lo = rmfi.validbox().loVect();
const int* hi = rmfi.validbox().hiVect();

const FArrayBox& rhsfab = (*(Rhs[lev]))[rmfi];
const Real* rhsd = rhsfab.dataPtr();
const int* rhslo = rhsfab.box().loVect();
const int* rhshi = rhsfab.box().hiVect();
mgt_add_rh_nodal(&lev, &n, rhsd, rhslo, rhshi, lo, hi);
}
}
}

mgt_nodal_solve(tol,abs_tol);

mgt_newu();
Expand Down
24 changes: 21 additions & 3 deletions Src/LinearSolvers/F_MG/mg_cpp_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#define mgt_set_rh_2d MGT_SET_RH_2D
#define mgt_set_rh_3d MGT_SET_RH_3D

#define mgt_add_rh_nodal_1d MGT_ADD_RH_NODAL_1D
#define mgt_add_rh_nodal_2d MGT_ADD_RH_NODAL_2D
#define mgt_add_rh_nodal_3d MGT_ADD_RH_NODAL_3D

#define mgt_set_uu_1d MGT_SET_UU_1D
#define mgt_get_uu_1d MGT_GET_UU_1D
#define mgt_set_uu_2d MGT_SET_UU_2D
Expand Down Expand Up @@ -149,6 +153,10 @@
#define mgt_set_rh_2d mgt_set_rh_2d_
#define mgt_set_rh_3d mgt_set_rh_3d_

#define mgt_add_rh_nodal_1d mgt_add_rh_nodal_1d_
#define mgt_add_rh_nodal_2d mgt_add_rh_nodal_2d_
#define mgt_add_rh_nodal_3d mgt_add_rh_nodal_3d_

#define mgt_set_uu_1d mgt_set_uu_1d_
#define mgt_get_uu_1d mgt_get_uu_1d_
#define mgt_set_uu_2d mgt_set_uu_2d_
Expand Down Expand Up @@ -254,6 +262,10 @@
#define mgt_set_rh_2d mgt_set_rh_2d__
#define mgt_set_rh_3d mgt_set_rh_3d__

#define mgt_add_rh_nodal_1d mgt_add_rh_nodal_1d__
#define mgt_add_rh_nodal_2d mgt_add_rh_nodal_2d__
#define mgt_add_rh_nodal_3d mgt_add_rh_nodal_3d__

#define mgt_set_uu_1d mgt_set_uu_1d__
#define mgt_get_uu_1d mgt_get_uu_1d__
#define mgt_set_uu_2d mgt_set_uu_2d__
Expand Down Expand Up @@ -383,7 +395,7 @@ extern "C"
const int* plo, const int* phi,
const int* lo, const int* hi);

void mgt_set_rh_1d(const int* lev, const int* n, const Real* rh,
void mgt_add_rh_nodal_1d(const int* lev, const int* n, const Real* rh,
const int* plo, const int* phi,
const int* lo, const int* hi);

Expand Down Expand Up @@ -454,10 +466,13 @@ extern "C"
const int* lo, const int* hi,
const int& nv, const int& iv);


void mgt_set_rh_2d(const int* lev, const int* n, const Real* rh,
const int* plo, const int* phi,
const int* lo, const int* hi);

void mgt_add_rh_nodal_2d(const int* lev, const int* n, const Real* rh,
const int* plo, const int* phi,
const int* lo, const int* hi);

void mgt_get_uu_2d(const int* lev, const int* n, Real* uu,
const int* plo, const int* phi,
Expand Down Expand Up @@ -537,10 +552,13 @@ extern "C"
const int* lo, const int* hi,
const int& nv, const int& iv);


void mgt_set_rh_3d(const int* lev, const int* n, const Real* rh,
const int* plo, const int* phi,
const int* lo, const int* hi);

void mgt_add_rh_nodal_3d(const int* lev, const int* n, const Real* rh,
const int* plo, const int* phi,
const int* lo, const int* hi);

void mgt_get_uu_3d(const int* lev, const int* n, Real* uu,
const int* plo, const int* phi,
Expand Down
49 changes: 49 additions & 0 deletions Src/LinearSolvers/F_MG/nodal_mg_cpp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,55 @@ subroutine mgt_get_pr_3d(lev, n, uu, plo, phi, lo, hi, np, ip)

end subroutine mgt_get_pr_3d

subroutine mgt_add_rh_nodal_1d(lev, n, rh_in, plo, phi, lo, hi)
use nodal_cpp_mg_module
implicit none
integer, intent(in) :: lev, n, lo(1), hi(1), plo(1), phi(1)
real(kind=dp_t), intent(in) :: rh_in(plo(1):phi(1))
real(kind=dp_t), pointer :: rp(:,:,:,:)
integer :: flev, fn
fn = n + 1
flev = lev+1

rp => dataptr(mgts%rh(flev), fn)
rp(lo(1):hi(1),1,1,1) = rp(lo(1):hi(1),1,1,1) + rh_in(lo(1):hi(1))

end subroutine mgt_add_rh_nodal_1d

subroutine mgt_add_rh_nodal_2d(lev, n, rh_in, plo, phi, lo, hi)
use nodal_cpp_mg_module
implicit none
integer, intent(in) :: lev, n, lo(2), hi(2), plo(2), phi(2)
real(kind=dp_t), intent(in) :: rh_in(plo(1):phi(1), plo(2):phi(2))
real(kind=dp_t), pointer :: rp(:,:,:,:)
integer :: flev, fn
fn = n + 1
flev = lev+1

rp => dataptr(mgts%rh(flev), fn)
rp(lo(1):hi(1),lo(2):hi(2),1,1) = &
rp(lo(1):hi(1),lo(2):hi(2),1,1) + &
rh_in(lo(1):hi(1),lo(2):hi(2))

end subroutine mgt_add_rh_nodal_2d

subroutine mgt_add_rh_nodal_3d(lev, n, rh_in, plo, phi, lo, hi)
use nodal_cpp_mg_module
implicit none
integer, intent(in) :: lev, n, lo(3), hi(3), plo(3), phi(3)
real(kind=dp_t), intent(in) :: rh_in(plo(1):phi(1),plo(2):phi(2),plo(3):phi(3))
real(kind=dp_t), pointer :: rp(:,:,:,:)
integer :: flev, fn
fn = n + 1
flev = lev+1

rp => dataptr(mgts%rh(flev), fn)
rp(lo(1):hi(1),lo(2):hi(2),lo(3):hi(3),1) = &
rp(lo(1):hi(1),lo(2):hi(2),lo(3):hi(3),1) + &
rh_in(lo(1):hi(1),lo(2):hi(2),lo(3):hi(3))

end subroutine mgt_add_rh_nodal_3d

subroutine mgt_nodal_dealloc()
use nodal_cpp_mg_module
implicit none
Expand Down

0 comments on commit 6e2da55

Please sign in to comment.