Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(NumericalSolution): refactor csv output #395

Merged
merged 2 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor(NumericalSolution): refactor csv output
Refactor csv output to save at the end of the each outer iteration. Add
options to save separate outer and inner iteration data.

closes #172
  • Loading branch information
jdhughes-usgs committed Apr 10, 2020
commit 340b615dc3a432f965cd891fdfd9f37ba74c2247
12 changes: 9 additions & 3 deletions autotest/test_gwf_npf02_rewet.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@ def get_model(idx, dir):
# create tdis package
tdis = flopy.mf6.ModflowTdis(sim, time_units='DAYS',
nper=nper, perioddata=tdis_rc)
# set ims csv files
csv0 = '{}.outer.ims.csv'.format(name)
csv1 = '{}.inner.ims.csv'.format(name)

# create iterative model solution and register the gwf model with it
ims = flopy.mf6.ModflowIms(sim, print_option='SUMMARY',
ims = flopy.mf6.ModflowIms(sim,
print_option='ALL',
csv_outer_output_filerecord=csv0,
csv_inner_output_filerecord=csv1,
outer_hclose=hclose,
outer_maximum=nouter,
under_relaxation='NONE',
Expand Down Expand Up @@ -197,9 +203,9 @@ def build_models():

def eval_hds(sim):
print('evaluating rewet heads...')

hdata01lay = [[1.000000000000000000e+02, 9.491194675652451451e+01,
8.963852784804279850e+01, 8.415783779990768210e+01,
8.963852784804279850e+01, 8.415783779990768210e+01,
7.844327192271720151e+01, 7.246197081412121577e+01,
6.617253666303386694e+01, 5.952154998933371388e+01,
5.243800267025346074e+01, 4.482387942676999870e+01,
Expand Down
14 changes: 10 additions & 4 deletions autotest/test_gwf_rch01.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ def get_model(idx, dir):
tdis = flopy.mf6.ModflowTdis(sim, time_units='DAYS',
nper=nper, perioddata=tdis_rc)

# create gwf model
gwf = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)
# set ims csv files
csv0 = '{}.outer.ims.csv'.format(name)
csv1 = '{}.inner.ims.csv'.format(name)

# create iterative model solution and register the gwf model with it
ims = flopy.mf6.ModflowIms(sim, print_option='SUMMARY',
ims = flopy.mf6.ModflowIms(sim,
print_option='ALL',
csv_outer_output_filerecord=csv0,
csv_inner_output_filerecord=csv1,
outer_hclose=hclose,
outer_maximum=nouter,
under_relaxation='DBD',
Expand All @@ -83,7 +87,9 @@ def get_model(idx, dir):
scaling_method='NONE',
reordering_method='NONE',
relaxation_factor=relax)
sim.register_ims_package(ims, [gwf.name])

# create gwf model
gwf = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)

dis = flopy.mf6.ModflowGwfdis(gwf, nlay=nlay, nrow=nrow, ncol=ncol,
delr=delr, delc=delc,
Expand Down
12 changes: 9 additions & 3 deletions src/Solution/NumericalSolution.f90
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ module NumericalSolutionModule
integer(I4B), pointer :: ibcount => NULL()
integer(I4B), pointer :: icnvg => NULL()
integer(I4B), pointer :: itertot => NULL() ! total nr. of linear solves per call to sln_ca
integer(I4B), pointer :: innertot => NULL() ! total nr. of inner iterations for simulation
integer(I4B), pointer :: mxiter => NULL()
integer(I4B), pointer :: linmeth => NULL()
integer(I4B), pointer :: nonmeth => NULL()
Expand Down Expand Up @@ -255,6 +256,7 @@ subroutine allocate_scalars(this, solutionname)
call mem_allocate(this%ibcount, 'IBCOUNT', solutionname)
call mem_allocate(this%icnvg, 'ICNVG', solutionname)
call mem_allocate(this%itertot, 'ITERTOT', solutionname)
call mem_allocate(this%innertot, 'INNERTOT', solutionname)
call mem_allocate(this%mxiter, 'MXITER', solutionname)
call mem_allocate(this%linmeth, 'LINMETH', solutionname)
call mem_allocate(this%nonmeth, 'NONMETH', solutionname)
Expand Down Expand Up @@ -300,6 +302,7 @@ subroutine allocate_scalars(this, solutionname)
this%ibcount = 0
this%icnvg = 0
this%itertot = 0
this%innertot = 0
this%mxiter = 0
this%linmeth = 1
this%nonmeth = 0
Expand Down Expand Up @@ -1065,6 +1068,7 @@ subroutine sln_da(this)
call mem_deallocate(this%ibcount)
call mem_deallocate(this%icnvg)
call mem_deallocate(this%itertot)
call mem_deallocate(this%innertot)
call mem_deallocate(this%mxiter)
call mem_deallocate(this%linmeth)
call mem_deallocate(this%nonmeth)
Expand Down Expand Up @@ -1385,7 +1389,7 @@ subroutine doIteration(this, kiter)
! -- code
!
! -- initialize local variables
icsv0 = max(1, this%itertot + 1)
icsv0 = max(1, this%innertot + 1)
!
! -- create header for outer iteration table
if (this%iprims > 0) then
Expand Down Expand Up @@ -1491,8 +1495,10 @@ subroutine doIteration(this, kiter)
CALL this%sln_ls(kiter, kstp, kper, iter, iptc, ptcf)
call code_timer(1, ttsoln, this%ttsoln)
!
! -- increment the counter storing the total number of linear iterations
! -- increment counters storing the total number of linear iterations
! for this timestep and all timesteps
this%itertot = this%itertot + iter
this%innertot = this%innertot + iter
!
! -- save matrix to a file
! to enable set itestmat to 1 and recompile
Expand Down Expand Up @@ -1716,7 +1722,7 @@ subroutine doIteration(this, kiter)
!
! -- write line
write(this%icsvouterout, '(*(G0,:,","))') &
this%itertot, totim, kper, kstp, kiter, iter, &
this%innertot, totim, kper, kstp, kiter, iter, &
outer_hncg, im, trim(cpak), nodeu
end if
!
Expand Down