# 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 ModflowGwtdisv(MFPackage):
    """
    ModflowGwtdisv defines a DISV 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.
    length_units : string
        is the length units used for this model.  values can be 'feet', 'meters', or
        'centimeters'.  if not specified, the default is 'unknown'.
    nogrb : keyword
        keyword to deactivate writing of the binary grid file.
    grb_filerecord : (grb6_filename)
        * grb6_filename : string
                defines a binary grid output file. If this option is not provided, the output
                file will have the same name as the discretization input file, plus extension
                '.grb'.

    xorigin : double precision
        x-position of the origin used for model grid vertices.  this value should be
        provided in a real-world coordinate system.  a default value of zero is
        assigned if not specified.  the value for xorigin does not affect the model
        simulation, but it is written to the binary grid file so that postprocessors
        can locate the grid in space.
    yorigin : double precision
        y-position of the origin used for model grid vertices.  this value should be
        provided in a real-world coordinate system.  if not specified, then a default
        value equal to zero is used.  the value for yorigin does not affect the model
        simulation, but it is written to the binary grid file so that postprocessors
        can locate the grid in space.
    angrot : double precision
        counter-clockwise rotation angle (in degrees) of the model grid coordinate
        system relative to a real-world coordinate system.  if not specified, then a
        default value of 0.0 is assigned.  the value for angrot does not affect the
        model simulation, but it is written to the binary grid file so that
        postprocessors can locate the grid in space.
    export_array_ascii : keyword
        keyword that specifies input griddata arrays should be written to layered ascii
        output files.
    export_array_netcdf : keyword
        keyword that specifies input griddata arrays should be written to the model
        output netcdf file.
    packagedata : record ncf6 filein ncf6_filename
        Contains data for the ncf package. Data can be passed as a dictionary to the
        ncf package with variable names as keys and package data as values. Data for
        the packagedata variable is also acceptable. See ncf package documentation for
        more information.
    nlay : integer
        is the number of layers in the model grid.
    ncpl : integer
        is the number of cells per layer.  this is a constant value for the grid and it
        applies to all layers.
    nvert : integer
        is the total number of (x, y) vertex pairs used to characterize the horizontal
        configuration of the model grid.
    top : [double precision]
        is the top elevation for each cell in the top model layer.
    botm : [double precision]
        is the bottom elevation for each cell.
    idomain : [integer]
        is an optional array that characterizes the existence status of a cell.  if the
        idomain array is not specified, then all model cells exist within the solution.
        if the idomain value for a cell is 0, the cell does not exist in the
        simulation.  input and output values will be read and written for the cell, but
        internal to the program, the cell is excluded from the solution.  if the
        idomain value for a cell is 1, the cell exists in the simulation.  if the
        idomain value for a cell is -1, the cell does not exist in the simulation.
        furthermore, the first existing cell above will be connected to the first
        existing cell below.  this type of cell is referred to as a 'vertical pass
        through' cell.
    vertices : [(iv, xv, yv)]
        * iv : integer
                is the vertex number.  Records in the VERTICES block must be listed in
                consecutive order from 1 to NVERT.
        * xv : double precision
                is the x-coordinate for the vertex.
        * yv : double precision
                is the y-coordinate for the vertex.

    cell2d : [(icell2d, xc, yc, ncvert, icvert)]
        * icell2d : integer
                is the CELL2D number.  Records in the CELL2D block must be listed in
                consecutive order from the first to the last.
        * xc : double precision
                is the x-coordinate for the cell center.
        * yc : double precision
                is the y-coordinate for the cell center.
        * ncvert : integer
                is the number of vertices required to define the cell.  There may be a
                different number of vertices for each cell.
        * icvert : [integer]
                is an array of integer values containing vertex numbers (in the VERTICES block)
                used to define the cell.  Vertices must be listed in clockwise order.  Cells
                that are connected must share vertices.


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

    """

    grb_filerecord = ListTemplateGenerator(
        ("gwt6", "disv", "options", "grb_filerecord")
    )
    ncf_filerecord = ListTemplateGenerator(
        ("gwt6", "disv", "options", "ncf_filerecord")
    )
    top = ArrayTemplateGenerator(("gwt6", "disv", "griddata", "top"))
    botm = ArrayTemplateGenerator(("gwt6", "disv", "griddata", "botm"))
    idomain = ArrayTemplateGenerator(("gwt6", "disv", "griddata", "idomain"))
    vertices = ListTemplateGenerator(("gwt6", "disv", "vertices", "vertices"))
    cell2d = ListTemplateGenerator(("gwt6", "disv", "cell2d", "cell2d"))
    package_abbr = "gwtdisv"
    _package_type = "disv"
    dfn_file_name = "gwt-disv.dfn"
    dfn = [
        ["header"],
        [
            "block options",
            "name length_units",
            "type string",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name nogrb",
            "type keyword",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name grb_filerecord",
            "type record grb6 fileout grb6_filename",
            "reader urword",
            "tagged true",
            "optional true",
        ],
        [
            "block options",
            "name grb6",
            "type keyword",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name fileout",
            "type keyword",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name grb6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "reader urword",
            "optional false",
            "tagged false",
        ],
        [
            "block options",
            "name xorigin",
            "type double precision",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name yorigin",
            "type double precision",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name angrot",
            "type double precision",
            "reader urword",
            "optional true",
        ],
        [
            "block options",
            "name export_array_ascii",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal export_ascii",
        ],
        [
            "block options",
            "name export_array_netcdf",
            "type keyword",
            "reader urword",
            "optional true",
            "mf6internal export_nc",
            "extended true",
        ],
        [
            "block options",
            "name crs",
            "type string",
            "shape lenbigline",
            "preserve_case true",
            "reader urword",
            "optional true",
            "prerelease true",
        ],
        [
            "block options",
            "name ncf_filerecord",
            "type record ncf6 filein ncf6_filename",
            "reader urword",
            "tagged true",
            "optional true",
            "construct_package ncf",
            "construct_data packagedata",
            "parameter_name packagedata",
        ],
        [
            "block options",
            "name ncf6",
            "type keyword",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
            "extended true",
        ],
        [
            "block options",
            "name filein",
            "type keyword",
            "in_record true",
            "reader urword",
            "tagged true",
            "optional false",
        ],
        [
            "block options",
            "name ncf6_filename",
            "type string",
            "preserve_case true",
            "in_record true",
            "reader urword",
            "optional false",
            "tagged false",
            "extended true",
        ],
        [
            "block dimensions",
            "name nlay",
            "type integer",
            "reader urword",
            "optional false",
        ],
        [
            "block dimensions",
            "name ncpl",
            "type integer",
            "reader urword",
            "optional false",
        ],
        [
            "block dimensions",
            "name nvert",
            "type integer",
            "reader urword",
            "optional false",
        ],
        [
            "block griddata",
            "name top",
            "type double precision",
            "shape (ncpl)",
            "reader readarray",
            "netcdf true",
        ],
        [
            "block griddata",
            "name botm",
            "type double precision",
            "shape (ncpl, nlay)",
            "reader readarray",
            "layered true",
            "netcdf true",
        ],
        [
            "block griddata",
            "name idomain",
            "type integer",
            "shape (ncpl, nlay)",
            "reader readarray",
            "layered true",
            "netcdf true",
            "optional true",
        ],
        [
            "block vertices",
            "name vertices",
            "type recarray iv xv yv",
            "shape (nvert)",
            "reader urword",
            "optional false",
        ],
        [
            "block vertices",
            "name iv",
            "type integer",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
            "numeric_index true",
        ],
        [
            "block vertices",
            "name xv",
            "type double precision",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block vertices",
            "name yv",
            "type double precision",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block cell2d",
            "name cell2d",
            "type recarray icell2d xc yc ncvert icvert",
            "shape (ncpl)",
            "reader urword",
            "optional false",
        ],
        [
            "block cell2d",
            "name icell2d",
            "type integer",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
            "numeric_index true",
        ],
        [
            "block cell2d",
            "name xc",
            "type double precision",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block cell2d",
            "name yc",
            "type double precision",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block cell2d",
            "name ncvert",
            "type integer",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
        ],
        [
            "block cell2d",
            "name icvert",
            "type integer",
            "shape (ncvert)",
            "in_record true",
            "tagged false",
            "reader urword",
            "optional false",
            "numeric_index true",
        ],
    ]

    def __init__(
        self,
        model,
        loading_package=False,
        length_units=None,
        nogrb=None,
        grb_filerecord=None,
        xorigin=None,
        yorigin=None,
        angrot=None,
        export_array_ascii=None,
        export_array_netcdf=None,
        packagedata=None,
        nlay=None,
        ncpl=None,
        nvert=None,
        top=None,
        botm=None,
        idomain=None,
        vertices=None,
        cell2d=None,
        filename=None,
        pname=None,
        **kwargs,
    ):
        """Initialize ModflowGwtdisv."""
        super().__init__(
            parent=model,
            package_type="disv",
            filename=filename,
            pname=pname,
            loading_package=loading_package,
            **kwargs,
        )

        self.length_units = self.build_mfdata("length_units", length_units)
        self.nogrb = self.build_mfdata("nogrb", nogrb)
        self.grb_filerecord = self.build_mfdata("grb_filerecord", grb_filerecord)
        self.xorigin = self.build_mfdata("xorigin", xorigin)
        self.yorigin = self.build_mfdata("yorigin", yorigin)
        self.angrot = self.build_mfdata("angrot", angrot)
        self.export_array_ascii = self.build_mfdata(
            "export_array_ascii", export_array_ascii
        )
        self.export_array_netcdf = self.build_mfdata(
            "export_array_netcdf", export_array_netcdf
        )
        self._ncf_filerecord = self.build_mfdata("ncf_filerecord", None)
        self._ncf_package = self.build_child_package(
            "ncf", packagedata, "packagedata", self._ncf_filerecord
        )
        self.nlay = self.build_mfdata("nlay", nlay)
        self.ncpl = self.build_mfdata("ncpl", ncpl)
        self.nvert = self.build_mfdata("nvert", nvert)
        self.top = self.build_mfdata("top", top)
        self.botm = self.build_mfdata("botm", botm)
        self.idomain = self.build_mfdata("idomain", idomain)
        self.vertices = self.build_mfdata("vertices", vertices)
        self.cell2d = self.build_mfdata("cell2d", cell2d)

        self._init_complete = True
