# 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 ModflowGwtgwt(MFPackage):
    """
    ModflowGwtgwt defines a GWTGWT 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 "GWT6-GWT6"
        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.
    gwfmodelname1 : string
        keyword to specify name of first corresponding gwf model.  in the simulation
        name file, the gwt6-gwt6 entry contains names for gwt models (exgmnamea and
        exgmnameb).  the gwt model with the name exgmnamea must correspond to the gwf
        model with the name gwfmodelname1.
    gwfmodelname2 : string
        keyword to specify name of second corresponding gwf model.  in the simulation
        name file, the gwt6-gwt6 entry contains names for gwt models (exgmnamea and
        exgmnameb).  the gwt model with the name exgmnameb must correspond to the gwf
        model with the name gwfmodelname2.
    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 gwt-gwt 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' is provided in the description of the disu package.
        angldegx must be specified if dispersion is simulated in the connected gwt
        models.
    boundnames : keyword
        keyword to indicate that boundary names may be provided with the list of gwt
        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.
    adv_scheme : string
        scheme used to solve the advection term.  can be upstream, central, or tvd.  if
        not specified, upstream weighting is the default weighting scheme.
    dsp_xt3d_off : keyword
        deactivate the xt3d method for the dispersive flux and use the faster and less
        accurate approximation for this exchange.
    dsp_xt3d_rhs : keyword
        add xt3d dispersion terms to right-hand side, when possible, for this exchange.
    perioddata : record mvt6 filein mvt6_filename
        Contains data for the mvt package. Data can be passed as a dictionary to the
        mvt package with variable names as keys and package data as values. Data for
        the perioddata variable is also acceptable. See mvt 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 gwt-gwt 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 GWTGWT 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 GWT 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(("gwtgwt", "options", "auxiliary"))
    mvt_filerecord = ListTemplateGenerator(("gwtgwt", "options", "mvt_filerecord"))
    obs_filerecord = ListTemplateGenerator(("gwtgwt", "options", "obs_filerecord"))
    exchangedata = ListTemplateGenerator(("gwtgwt", "exchangedata", "exchangedata"))
    package_abbr = "gwtgwt"
    _package_type = "gwtgwt"
    dfn_file_name = "exg-gwtgwt.dfn"
    dfn = [
        ["header", "multi-package"],
        [
            "block options",
            "name gwfmodelname1",
            "type string",
            "reader urword",
            "optional false",
        ],
        [
            "block options",
            "name gwfmodelname2",
            "type string",
            "reader urword",
            "optional false",
        ],
        [
            "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 adv_scheme",
            "type string",
            "valid upstream central tvd",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name dsp_xt3d_off",
            "type keyword",
            "shape",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name dsp_xt3d_rhs",
            "type keyword",
            "shape",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name filein",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name mvt_filerecord",
            "type record mvt6 filein mvt6_filename",
            "shape",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package mvt",
            "construct_data perioddata",
            "parameter_name perioddata",
        ],
        [
            "block options",
            "name mvt6",
            "type keyword",
            "shape",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name mvt6_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="GWT6-GWT6",
        exgmnamea=None,
        exgmnameb=None,
        gwfmodelname1=None,
        gwfmodelname2=None,
        auxiliary=None,
        boundnames=None,
        print_input=None,
        print_flows=None,
        save_flows=None,
        adv_scheme=None,
        dsp_xt3d_off=None,
        dsp_xt3d_rhs=None,
        perioddata=None,
        observations=None,
        dev_interfacemodel_on=None,
        nexg=None,
        exchangedata=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwtgwt."""
        super().__init__(
            parent=simulation,
            package_type="gwtgwt",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

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

        self.gwfmodelname1 = self.build_mfdata("gwfmodelname1", gwfmodelname1)
        self.gwfmodelname2 = self.build_mfdata("gwfmodelname2", gwfmodelname2)
        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.adv_scheme = self.build_mfdata("adv_scheme", adv_scheme)
        self.dsp_xt3d_off = self.build_mfdata("dsp_xt3d_off", dsp_xt3d_off)
        self.dsp_xt3d_rhs = self.build_mfdata("dsp_xt3d_rhs", dsp_xt3d_rhs)
        self._mvt_filerecord = self.build_mfdata("mvt_filerecord", None)
        self._mvt_package = self.build_child_package(
            "mvt", perioddata, "perioddata", self._mvt_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
