Skip to content

Commit a8347e6

Browse files
feat(disu-idomain): write idomain to binary grid file for disu models (#2144)
The binary grid file written by MODFLOW 6 for DISU models did not include the IDOMAIN array. The binary grid file now includes IDOMAIN for all discretization types, including DISU.
1 parent d9e3450 commit a8347e6

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

autotest/test_gwf_disu.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def build_models(idx, test):
4747
ic = flopy.mf6.ModflowGwfic(gwf, strt=0.0)
4848
npf = flopy.mf6.ModflowGwfnpf(gwf)
4949
spd = {0: [[(0,), 1.0], [(nrow * ncol - 1), 0.0]]}
50-
chd = flopy.mf6.modflow.mfgwfchd.ModflowGwfchd(gwf, stress_period_data=spd)
50+
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=spd)
5151
return sim, None
5252

5353

@@ -59,13 +59,18 @@ def check_output(idx, test):
5959
nodes = grbobj._datadict["NODES"]
6060
ia = grbobj._datadict["IA"]
6161
ja = grbobj._datadict["JA"]
62+
idomain = grbobj._datadict["IDOMAIN"]
63+
64+
if idx == 0:
65+
assert np.array_equal(idomain, np.array(27 * [1]), int)
6266

6367
if idx == 1:
6468
assert np.array_equal(ia[0:4], np.array([1, 4, 4, 7]))
6569
assert np.array_equal(ja[:6], np.array([1, 4, 10, 3, 6, 12]))
6670
assert ia[-1] == 127
6771
assert ia.shape[0] == 28, "ia should have size of 28"
6872
assert ja.shape[0] == 126, "ja should have size of 126"
73+
assert np.array_equal(idomain, np.array([1, 0] + 25 * [1]), int)
6974

7075

7176
@pytest.mark.parametrize("idx, name", enumerate(cases))

doc/ReleaseNotes/develop.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
%\underline{NEW FUNCTIONALITY}
77
%\begin{itemize}
88
\item Support for adjusting time step lengths using the adaptive time stepping (ATS) capability was added to the GWT Advection (ADV) Package of the Groundwater Transport (GWT) Model in release 6.6.0. The same functionality that was added to GWT is now available with the Groundwater Energy Transport (GWE) Model. A description of how this functionality works and how to activate it can be found in the release notes for version 6.6.0 (Appendix A) and in the MODFLOW 6 input-output guide.
9-
% \item xxx
9+
\item The binary grid file written by MODFLOW 6 for DISU models did not include the IDOMAIN array. The binary grid file now includes IDOMAIN for all discretization types, including DISU.
1010
% \item xxx
1111
%\end{itemize}
1212

doc/mf6io/framework/binaryoutput.tex

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,16 @@ \subsubsection{DISU Grids}
157157
\noindent Definition 7: \texttt{`BOT DOUBLE NDIM 1 nodes'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
158158
\noindent Definition 8: \texttt{`IA INTEGER NDIM 1 ncells+1'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
159159
\noindent Definition 9: \texttt{`JA INTEGER NDIM 1 nja'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
160-
\noindent Definition 10: \texttt{`ICELLTYPE INTEGER NDIM 1 ncells'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
160+
\noindent Definition 10: \texttt{`IDOMAIN INTEGER NDIM 1 ncells'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
161+
\noindent Definition 11: \texttt{`ICELLTYPE INTEGER NDIM 1 ncells'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
161162

162163
\vspace{5mm}
163164
\noindent If vertices are provided in the DISU Package, then 5 additional definitions are included: \\
164-
\noindent Definition 11: \texttt{`VERTICES DOUBLE NDIM 2 2 nvert'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
165-
\noindent Definition 12: \texttt{`CELLX DOUBLE NDIM 1 nodes'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
166-
\noindent Definition 13: \texttt{`CELLY DOUBLE NDIM 1 nodes'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
167-
\noindent Definition 14: \texttt{`IAVERT INTEGER NDIM 1 nodes+1'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
168-
\noindent Definition 15: \texttt{`JAVERT INTEGER NDIM 1 njavert'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
165+
\noindent Definition 12: \texttt{`VERTICES DOUBLE NDIM 2 2 nvert'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
166+
\noindent Definition 13: \texttt{`CELLX DOUBLE NDIM 1 nodes'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
167+
\noindent Definition 14: \texttt{`CELLY DOUBLE NDIM 1 nodes'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
168+
\noindent Definition 15: \texttt{`IAVERT INTEGER NDIM 1 nodes+1'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
169+
\noindent Definition 16: \texttt{`JAVERT INTEGER NDIM 1 njavert'} {\color{red} \footnotesize{CHARACTER(LEN=LENTXT)}} \\
169170

170171
\vspace{5mm}
171172
\noindent Read \texttt{NDAT} data variables using the definitions defined above. \\
@@ -178,15 +179,16 @@ \subsubsection{DISU Grids}
178179
\noindent Record 7: \texttt{((BOT(J),J=1,NODES)} {\color{red} \footnotesize{DOUBLE PRECISION ARRAY SIZE(NODES)}} \\
179180
\noindent Record 8: \texttt{(IA(J),J=1,NODES+1)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NODES+1)}} \\
180181
\noindent Record 9: \texttt{(JA(J),J=1,NJA)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NJA)}} \\
181-
\noindent Record 10: \texttt{(ICELLTYPE(J),J=1,NCELLS)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NCELLS)}} \\
182+
\noindent Record 10: \texttt{(IDOMAIN(J),J=1,NCELLS)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NCELLS)}} \\
183+
\noindent Record 11: \texttt{(ICELLTYPE(J),J=1,NCELLS)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NCELLS)}} \\
182184

183185
\vspace{5mm}
184186
\noindent If vertices are provided in the DISU Package, then 5 additional records are included: \\
185-
\noindent Record 11: \texttt{((VERT(J,K),J=1,2),K=1,NVERT)} {\color{red} \footnotesize{DOUBLE PRECISION ARRAY SIZE(2,NVERT)}} \\
186-
\noindent Record 12: \texttt{(CELLX(J),J=1,NODES)} {\color{red} \footnotesize{DOUBLE PRECISION ARRAY SIZE(NODES)}}\\
187-
\noindent Record 13: \texttt{(CELLY(J),J=1,NODES)} {\color{red} \footnotesize{DOUBLE PRECISION ARRAY SIZE(NODES)}} \\
188-
\noindent Record 14: \texttt{(IAVERT(J),J=1,NODES+1)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NODES+1)}} \\
189-
\noindent Record 15: \texttt{(JAVERT(J),J=1,NJAVERT)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NJAVERT)}} \\
187+
\noindent Record 12: \texttt{((VERT(J,K),J=1,2),K=1,NVERT)} {\color{red} \footnotesize{DOUBLE PRECISION ARRAY SIZE(2,NVERT)}} \\
188+
\noindent Record 13: \texttt{(CELLX(J),J=1,NODES)} {\color{red} \footnotesize{DOUBLE PRECISION ARRAY SIZE(NODES)}}\\
189+
\noindent Record 14: \texttt{(CELLY(J),J=1,NODES)} {\color{red} \footnotesize{DOUBLE PRECISION ARRAY SIZE(NODES)}} \\
190+
\noindent Record 15: \texttt{(IAVERT(J),J=1,NODES+1)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NODES+1)}} \\
191+
\noindent Record 16: \texttt{(JAVERT(J),J=1,NJAVERT)} {\color{red} \footnotesize{INTEGER ARRAY SIZE(NJAVERT)}} \\
190192

191193

192194
\newpage

src/Model/Discretization/Disu.f90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ subroutine write_grb(this, icelltype)
923923
&/,6X,'UNIT NUMBER: ', I0,/,6X, 'FILE NAME: ', A)"
924924
!
925925
! -- Initialize
926-
ntxt = 10
926+
ntxt = 11
927927
if (this%nvert > 0) ntxt = ntxt + 5
928928
!
929929
! -- Open the file
@@ -975,6 +975,9 @@ subroutine write_grb(this, icelltype)
975975
write (txt, '(3a, i0)') 'JA ', 'INTEGER ', 'NDIM 1 ', this%con%nja
976976
txt(lentxt:lentxt) = new_line('a')
977977
write (iunit) txt
978+
write (txt, '(3a, i0)') 'IDOMAIN ', 'INTEGER ', 'NDIM 1 ', this%nodesuser
979+
txt(lentxt:lentxt) = new_line('a')
980+
write (iunit) txt
978981
write (txt, '(3a, i0)') 'ICELLTYPE ', 'INTEGER ', 'NDIM 1 ', this%nodesuser
979982
txt(lentxt:lentxt) = new_line('a')
980983
write (iunit) txt
@@ -1008,6 +1011,7 @@ subroutine write_grb(this, icelltype)
10081011
write (iunit) this%bot1d ! bot
10091012
write (iunit) this%con%iausr ! ia
10101013
write (iunit) this%con%jausr ! ja
1014+
write (iunit) this%idomain ! idomain
10111015
write (iunit) icelltype ! icelltype
10121016
!
10131017
! -- if vertices have been read then write additional data

0 commit comments

Comments
 (0)