# 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 MFChildPackages, MFPackage


class ModflowGwfhfb(MFPackage):
    """
    ModflowGwfhfb defines a HFB package.

    Parameters
    ----------
    model
        Model that this package is a part of. Package is automatically
        added to model when it is initialized.
    loading_package : bool, default False
        Do not set this parameter. It is intended for debugging and internal
        processing purposes only.
    print_input : keyword
        keyword to indicate that the list of horizontal flow barriers will be written
        to the listing file immediately after it is read.
    maxhfb : integer
        integer value specifying the maximum number of horizontal flow barriers that
        will be entered in this input file.  the value of maxhfb is used to allocate
        memory for the horizontal flow barriers.
    stress_period_data : [(cellid1, cellid2, hydchr)]
        * cellid1 : [integer]
                identifier for the first cell.  For a structured grid that uses the DIS input
                file, CELLID1 is the layer, row, and column numbers of the cell.   For a grid
                that uses the DISV input file, CELLID1 is the layer number and CELL2D number
                for the two cells.  If the model uses the unstructured discretization (DISU)
                input file, then CELLID1 is the node numbers for the cell.  The barrier is
                located between cells designated as CELLID1 and CELLID2.  For models that use
                the DIS and DISV grid types, the layer number for CELLID1 and CELLID2 must be
                the same.  For all grid types, cells must be horizontally adjacent or the
                program will terminate with an error.
        * cellid2 : [integer]
                identifier for the second cell. See CELLID1 for description of how to specify.
        * hydchr : double precision
                is the hydraulic characteristic of the horizontal-flow barrier. The hydraulic
                characteristic is the barrier hydraulic conductivity divided by the width of
                the horizontal-flow barrier. If the hydraulic characteristic is negative, then
                the absolute value of HYDCHR acts as a multiplier to the conductance between
                the two model cells specified as containing the barrier. For example, if the
                value for HYDCHR was specified as -1.5, the conductance calculated for the two
                cells would be multiplied by 1.5.


    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`.

    """

    stress_period_data = ListTemplateGenerator(
        ("gwf6", "hfb", "period", "stress_period_data")
    )
    package_abbr = "gwfhfb"
    _package_type = "hfb"
    dfn_file_name = "gwf-hfb.dfn"
    dfn = [
        ["header"],
        [
            "block options",
            "name print_input",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block dimensions",
            "name maxhfb",
            "type integer",
            "reader urword",
            "optional false",
            "mf6internal maxbound",
        ],
        [
            "block period",
            "name iper",
            "type integer",
            "block_variable true",
            "in_record true",
            "tagged false",
            "shape",
            "valid",
            "reader urword",
            "optional false",
        ],
        [
            "block period",
            "name stress_period_data",
            "type recarray cellid1 cellid2 hydchr",
            "shape (maxhfb)",
            "reader urword",
            "mf6internal spd",
        ],
        [
            "block period",
            "name cellid1",
            "type integer",
            "shape (ncelldim)",
            "tagged false",
            "in_record true",
            "reader urword",
        ],
        [
            "block period",
            "name cellid2",
            "type integer",
            "shape (ncelldim)",
            "tagged false",
            "in_record true",
            "reader urword",
        ],
        [
            "block period",
            "name hydchr",
            "type double precision",
            "shape",
            "tagged false",
            "in_record true",
            "reader urword",
        ],
    ]

    def __init__(
        self,
        model,
        loading_package=False,
        print_input=None,
        maxhfb=None,
        stress_period_data=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwfhfb."""
        super().__init__(
            parent=model,
            package_type="hfb",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.print_input = self.build_mfdata("print_input", print_input)
        self.maxhfb = self.build_mfdata("maxhfb", maxhfb)
        self.stress_period_data = self.build_mfdata(
            "stress_period_data", stress_period_data
        )

        self._init_complete = True
