# Copyright (C) 2021 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Module providing the ChemistryControlHgiPart class."""
import typing
from ansys.dyna.core.lib.card import Card, Field, Flag
from ansys.dyna.core.lib.field_schema import FieldSchema
from ansys.dyna.core.lib.keyword_base import KeywordBase
from ansys.dyna.core.lib.keyword_base import LinkType

_CHEMISTRYCONTROLHGIPART_CARD0 = (
    FieldSchema("id", int, 0, 10, None),
    FieldSchema("compid", int, 10, 10, None),
    FieldSchema("exit_bc", int, 20, 10, None),
)

_CHEMISTRYCONTROLHGIPART_CARD1 = (
    FieldSchema("file", str, 0, 80, None),
)

class ChemistryControlHgiPart(KeywordBase):
    """DYNA CHEMISTRY_CONTROL_HGI_PART keyword"""

    keyword = "CHEMISTRY"
    subkeyword = "CONTROL_HGI_PART"
    _link_fields = {
        "exit_bc": LinkType.PART,
    }

    def __init__(self, **kwargs):
        """Initialize the ChemistryControlHgiPart class."""
        super().__init__(**kwargs)
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _CHEMISTRYCONTROLHGIPART_CARD0,
                **kwargs,
            ),            Card.from_field_schemas_with_defaults(
                _CHEMISTRYCONTROLHGIPART_CARD1,
                **kwargs,
            ),        ]
    @property
    def id(self) -> typing.Optional[int]:
        """Get or set the Identifier for this chemistry solver.
        """ # nopep8
        return self._cards[0].get_value("id")

    @id.setter
    def id(self, value: int) -> None:
        """Set the id property."""
        self._cards[0].set_value("id", value)

    @property
    def compid(self) -> typing.Optional[int]:
        """Get or set the Chemical composition identifier of the initial composition
        """ # nopep8
        return self._cards[0].get_value("compid")

    @compid.setter
    def compid(self, value: int) -> None:
        """Set the compid property."""
        self._cards[0].set_value("compid", value)

    @property
    def exit_bc(self) -> typing.Optional[int]:
        """Get or set the The exit boundary a surface part ID referenced in *MESH_‌SURFACE_‌ELEMENT cards (for the PART option).
        """ # nopep8
        return self._cards[0].get_value("exit_bc")

    @exit_bc.setter
    def exit_bc(self, value: int) -> None:
        """Set the exit_bc property."""
        self._cards[0].set_value("exit_bc", value)

    @property
    def file(self) -> typing.Optional[str]:
        """Get or set the Name of the lsda file in which to write the results of the inflator simulation.
        """ # nopep8
        return self._cards[1].get_value("file")

    @file.setter
    def file(self, value: str) -> None:
        """Set the file property."""
        self._cards[1].set_value("file", value)

    @property
    def exit_bc_link(self) -> typing.Optional[KeywordBase]:
        """Get the PART keyword containing the given exit_bc."""
        return self._get_link_by_attr("PART", "pid", self.exit_bc, "parts")

