# autogenerated file, do not modify


from os import PathLike, curdir
from typing import Union

from flopy.mf6.data.mfdatautil import ArrayTemplateGenerator, ListTemplateGenerator
from flopy.mf6.mfpackage import MFPackage


class ModflowGwfgwf(MFPackage):
    """
    ModflowGwfgwf defines a GWFGWF package.

    Parameters
    ----------
    simulation : MFSimulation
        Simulation that this package is a part of. Package is automatically
        added to simulation when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    exgtype : str, default "GWF6-GWF6"
        The exchange type (GWF-GWF or GWF-GWT).
    exgmnamea : str, optional
        The name of the first model that is part of this exchange.
    exgmnameb : str, optional
        The name of the second model that is part of this exchange.
    auxiliary : [string]
        an array of auxiliary variable names.  there is no limit on the number of
        auxiliary variables that can be provided. most auxiliary variables will not be
        used by the gwf-gwf exchange, but they will be available for use by other parts
        of the program.  if an auxiliary variable with the name 'angldegx' is found,
        then this information will be used as the angle (provided in degrees) between
        the connection face normal and the x axis, where a value of zero indicates that
        a normal vector points directly along the positive x axis.  the connection face
        normal is a normal vector on the cell face shared between the cell in model 1
        and the cell in model 2 pointing away from the model 1 cell.  additional
        information on 'angldegx' and when it is required is provided in the
        description of the disu package.  if an auxiliary variable with the name
        'cdist' is found, then this information will be used in the calculation of
        specific discharge within model cells connected by the exchange.  for a
        horizontal connection, cdist should be specified as the horizontal distance
        between the cell centers, and should not include the vertical component.  for
        vertical connections, cdist should be specified as the difference in elevation
        between the two cell centers.  both angldegx and cdist are required if specific
        discharge is calculated for either of the groundwater models.
    boundnames : keyword
        keyword to indicate that boundary names may be provided with the list of gwf
        exchange cells.
    print_input : keyword
        keyword to indicate that the list of exchange entries will be echoed to the
        listing file immediately after it is read.
    print_flows : keyword
        keyword to indicate that the list of exchange flow rates will be printed to the
        listing file for every stress period in which 'save budget' is specified in
        output control.
    save_flows : keyword
        keyword to indicate that cell-by-cell flow terms will be written to the budget
        file for each model provided that the output control for the models are set up
        with the 'budget save file' option.
    cell_averaging : string
        is a keyword and text keyword to indicate the method that will be used for
        calculating the conductance for horizontal cell connections.  the text value
        for cell_averaging can be 'harmonic', 'logarithmic', or 'amt-lmk', which means
        'arithmetic-mean thickness and logarithmic-mean hydraulic conductivity'. if the
        user does not specify a value for cell_averaging, then the harmonic-mean method
        will be used.
    cvoptions : (variablecv, dewatered)
        none
        * variablecv : keyword
                keyword to indicate that the vertical conductance will be calculated using the
                saturated thickness and properties of the overlying cell and the thickness and
                properties of the underlying cell.  If the DEWATERED keyword is also specified,
                then the vertical conductance is calculated using only the saturated thickness
                and properties of the overlying cell if the head in the underlying cell is
                below its top.  If these keywords are not specified, then the default condition
                is to calculate the vertical conductance at the start of the simulation using
                the initial head and the cell properties.  The vertical conductance remains
                constant for the entire simulation.
        * dewatered : keyword
                If the DEWATERED keyword is specified, then the vertical conductance is
                calculated using only the saturated thickness and properties of the overlying
                cell if the head in the underlying cell is below its top.

    newton : keyword
        keyword that activates the newton-raphson formulation for groundwater flow
        between connected, convertible groundwater cells. cells will not dry when this
        option is used.
    xt3d : keyword
        keyword that activates the xt3d formulation between the cells connected with
        this gwf-gwf exchange.
    gncdata : record gnc6 filein gnc6_filename
        Contains data for the gnc package. Data can be passed as a dictionary to the
        gnc package with variable names as keys and package data as values. Data for
        the gncdata variable is also acceptable. See gnc package documentation for more
        information.
    perioddata : record mvr6 filein mvr6_filename
        Contains data for the mvr package. Data can be passed as a dictionary to the
        mvr package with variable names as keys and package data as values. Data for
        the perioddata variable is also acceptable. See mvr package documentation for
        more information.
    observations : record obs6 filein obs6_filename
        Contains data for the obs package. Data can be passed as a dictionary to the
        obs package with variable names as keys and package data as values. Data for
        the observations variable is also acceptable. See obs package documentation for
        more information.
    dev_interfacemodel_on : keyword
        activates the interface model mechanism for calculating the coefficients at
        (and possibly near) the exchange. this keyword should only be used for
        development purposes.
    nexg : integer
        keyword and integer value specifying the number of gwf-gwf exchanges.
    exchangedata : [(cellidm1, cellidm2, ihc, cl1, cl2, hwva, aux, boundname)]
        * cellidm1 : integer
                is the cellid of the cell in model 1 as specified in the simulation name file.
                For a structured grid that uses the DIS input file, CELLIDM1 is the layer, row,
                and column numbers of the cell.   For a grid that uses the DISV input file,
                CELLIDM1 is the layer number and CELL2D number for the two cells.  If the model
                uses the unstructured discretization (DISU) input file, then CELLIDM1 is the
                node number for the cell.
        * cellidm2 : integer
                is the cellid of the cell in model 2 as specified in the simulation name file.
                For a structured grid that uses the DIS input file, CELLIDM2 is the layer, row,
                and column numbers of the cell.   For a grid that uses the DISV input file,
                CELLIDM2 is the layer number and CELL2D number for the two cells.  If the model
                uses the unstructured discretization (DISU) input file, then CELLIDM2 is the
                node number for the cell.
        * ihc : integer
                is an integer flag indicating the direction between node n and all of its m
                connections. If IHC = 0 then the connection is vertical.  If IHC = 1 then the
                connection is horizontal. If IHC = 2 then the connection is horizontal for a
                vertically staggered grid.
        * cl1 : double precision
                is the distance between the center of cell 1 and the its shared face with cell
                2.
        * cl2 : double precision
                is the distance between the center of cell 2 and the its shared face with cell
                1.
        * hwva : double precision
                is the horizontal width of the flow connection between cell 1 and cell 2 if IHC
                > 0, or it is the area perpendicular to flow of the vertical connection between
                cell 1 and cell 2 if IHC = 0.
        * aux : [double precision]
                represents the values of the auxiliary variables for each GWFGWF Exchange. The
                values of auxiliary variables must be present for each exchange. The values
                must be specified in the order of the auxiliary variables specified in the
                OPTIONS block.
        * boundname : string
                name of the GWF Exchange cell.  BOUNDNAME is an ASCII character variable that
                can contain as many as 40 characters.  If BOUNDNAME contains spaces in it, then
                the entire name must be enclosed within single quotes.


    filename : str or PathLike, optional
        Name or path of file where this package is stored.
    pname : str, optional
        Package name.
    **kwargs
        Extra keywords for :class:`flopy.mf6.mfpackage.MFPackage`.

    """

    auxiliary = ArrayTemplateGenerator(("gwfgwf", "options", "auxiliary"))
    gnc_filerecord = ListTemplateGenerator(("gwfgwf", "options", "gnc_filerecord"))
    mvr_filerecord = ListTemplateGenerator(("gwfgwf", "options", "mvr_filerecord"))
    obs_filerecord = ListTemplateGenerator(("gwfgwf", "options", "obs_filerecord"))
    exchangedata = ListTemplateGenerator(("gwfgwf", "exchangedata", "exchangedata"))
    package_abbr = "gwfgwf"
    _package_type = "gwfgwf"
    dfn_file_name = "exg-gwfgwf.dfn"
    dfn = [
        ["header", "multi-package"],
        [
            "block options",
            "name auxiliary",
            "type string",
            "shape (naux)",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name boundnames",
            "type keyword",
            "shape",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name print_input",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iprpak",
        ],
        [
            "block options",
            "name print_flows",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal iprflow",
        ],
        [
            "block options",
            "name save_flows",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal ipakcb",
        ],
        [
            "block options",
            "name cell_averaging",
            "type string",
            "valid harmonic logarithmic amt-lmk",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name cvoptions",
            "type record variablecv dewatered",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name variablecv",
            "in_record true",
            "type keyword",
            "reader urword",
        ],
        [
            "block options",
            "name dewatered",
            "in_record true",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name newton",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name xt3d",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name gnc_filerecord",
            "type record gnc6 filein gnc6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package gnc",
            "construct_data gncdata",
            "parameter_name gncdata",
        ],
        [
            "block options",
            "name filein",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name gnc6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name gnc6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block options",
            "name mvr_filerecord",
            "type record mvr6 filein mvr6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package mvr",
            "construct_data perioddata",
            "parameter_name perioddata",
        ],
        [
            "block options",
            "name mvr6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name mvr6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block options",
            "name obs_filerecord",
            "type record obs6 filein obs6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package obs",
            "construct_data observations",
            "parameter_name continuous",
        ],
        [
            "block options",
            "name obs6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name obs6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block options",
            "name dev_interfacemodel_on",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal dev_ifmod_on",
        ],
        [
            "block dimensions",
            "name nexg",
            "type integer",
            "reader urword",
            "optional false",
        ],
        [
            "block exchangedata",
            "name exchangedata",
            "type recarray cellidm1 cellidm2 ihc cl1 cl2 hwva aux boundname",
            "shape (nexg)",
            "reader urword",
            "optional false",
        ],
        [
            "block exchangedata",
            "name cellidm1",
            "type integer",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
            "numeric_index true",
        ],
        [
            "block exchangedata",
            "name cellidm2",
            "type integer",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
            "numeric_index true",
        ],
        [
            "block exchangedata",
            "name ihc",
            "type integer",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block exchangedata",
            "name cl1",
            "type double precision",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block exchangedata",
            "name cl2",
            "type double precision",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block exchangedata",
            "name hwva",
            "type double precision",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block exchangedata",
            "name aux",
            "type double precision",
            "in_record true",
            "tagged false",
            "shape (naux)",
            "reader urword",
            "optional true",
            "mf6internal auxvar",
        ],
        [
            "block exchangedata",
            "name boundname",
            "type string",
            "shape",
            "tagged false",
            "in_record true",
            "reader urword",
            "optional true",
        ],
    ]

    def __init__(
        self,
        simulation,
        loading_package=False,
        exgtype="GWF6-GWF6",
        exgmnamea=None,
        exgmnameb=None,
        auxiliary=None,
        boundnames=None,
        print_input=None,
        print_flows=None,
        save_flows=None,
        cell_averaging=None,
        cvoptions=None,
        newton=None,
        xt3d=None,
        gncdata=None,
        perioddata=None,
        observations=None,
        dev_interfacemodel_on=None,
        nexg=None,
        exchangedata=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwfgwf."""
        super().__init__(
            parent=simulation,
            package_type="gwfgwf",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.exgtype = exgtype
        self.exgmnamea = exgmnamea
        self.exgmnameb = exgmnameb
        simulation.register_exchange_file(self)

        self.auxiliary = self.build_mfdata("auxiliary", auxiliary)
        self.boundnames = self.build_mfdata("boundnames", boundnames)
        self.print_input = self.build_mfdata("print_input", print_input)
        self.print_flows = self.build_mfdata("print_flows", print_flows)
        self.save_flows = self.build_mfdata("save_flows", save_flows)
        self.cell_averaging = self.build_mfdata("cell_averaging", cell_averaging)
        self.cvoptions = self.build_mfdata("cvoptions", cvoptions)
        self.newton = self.build_mfdata("newton", newton)
        self.xt3d = self.build_mfdata("xt3d", xt3d)
        self._gnc_filerecord = self.build_mfdata("gnc_filerecord", None)
        self._gnc_package = self.build_child_package(
            "gnc", gncdata, "gncdata", self._gnc_filerecord
        )
        self._mvr_filerecord = self.build_mfdata("mvr_filerecord", None)
        self._mvr_package = self.build_child_package(
            "mvr", perioddata, "perioddata", self._mvr_filerecord
        )
        self._obs_filerecord = self.build_mfdata("obs_filerecord", None)
        self._obs_package = self.build_child_package(
            "obs", observations, "continuous", self._obs_filerecord
        )
        self.dev_interfacemodel_on = self.build_mfdata(
            "dev_interfacemodel_on", dev_interfacemodel_on
        )
        self.nexg = self.build_mfdata("nexg", nexg)
        self.exchangedata = self.build_mfdata("exchangedata", exchangedata)

        self._init_complete = True
