# 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 MatThermalUserDefined 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.option_card import OptionCardSet, OptionSpec
from ansys.dyna.core.lib.keyword_base import KeywordBase

_MATTHERMALUSERDEFINED_CARD0 = (
    FieldSchema("tmid", int, 0, 10, None),
    FieldSchema("ro", float, 10, 10, None),
    FieldSchema("mt", int, 20, 10, 11),
    FieldSchema("lmc", int, 30, 10, None),
    FieldSchema("nhv", int, 40, 10, None),
    FieldSchema("aopt", float, 50, 10, None),
    FieldSchema("iortho", int, 60, 10, 0),
    FieldSchema("ihve", int, 70, 10, None),
)

_MATTHERMALUSERDEFINED_CARD1 = (
    FieldSchema("xp", float, 0, 10, None),
    FieldSchema("yp", float, 10, 10, None),
    FieldSchema("zp", float, 20, 10, None),
    FieldSchema("a1", float, 30, 10, None),
    FieldSchema("a2", float, 40, 10, None),
    FieldSchema("a3", float, 50, 10, None),
)

_MATTHERMALUSERDEFINED_CARD2 = (
    FieldSchema("d1", float, 0, 10, None),
    FieldSchema("d2", float, 10, 10, None),
    FieldSchema("d3", float, 20, 10, None),
)

_MATTHERMALUSERDEFINED_OPTION0_CARD0 = (
    FieldSchema("title", str, 0, 80, None),
)

class MatThermalUserDefined(KeywordBase):
    """DYNA MAT_THERMAL_USER_DEFINED keyword"""

    keyword = "MAT"
    subkeyword = "THERMAL_USER_DEFINED"
    option_specs = [
        OptionSpec("TITLE", -1, 1),
    ]

    def __init__(self, **kwargs):
        """Initialize the MatThermalUserDefined class."""
        super().__init__(**kwargs)
        kwargs["parent"] = self
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _MATTHERMALUSERDEFINED_CARD0,
                **kwargs,
            ),            Card.from_field_schemas_with_defaults(
                _MATTHERMALUSERDEFINED_CARD1,
                **kwargs,
            ),            Card.from_field_schemas_with_defaults(
                _MATTHERMALUSERDEFINED_CARD2,
                **kwargs,
            ),            OptionCardSet(
                option_spec = MatThermalUserDefined.option_specs[0],
                cards = [
                    Card.from_field_schemas_with_defaults(
                        _MATTHERMALUSERDEFINED_OPTION0_CARD0,
                        **kwargs,
                    ),
                ],
                **kwargs
            ),
        ]
    @property
    def tmid(self) -> typing.Optional[int]:
        """Get or set the Thermal material identification. A unique number has to be specified.
        """ # nopep8
        return self._cards[0].get_value("tmid")

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

    @property
    def ro(self) -> typing.Optional[float]:
        """Get or set the Mass density.
        """ # nopep8
        return self._cards[0].get_value("ro")

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

    @property
    def mt(self) -> int:
        """Get or set the User material type (11-15 inclusive). A number between 11 and 15 has to be chosen.
        """ # nopep8
        return self._cards[0].get_value("mt")

    @mt.setter
    def mt(self, value: int) -> None:
        """Set the mt property."""
        if value not in [11, 12, 13, 14, 15, None]:
            raise Exception("""mt must be `None` or one of {11,12,13,14,15}.""")
        self._cards[0].set_value("mt", value)

    @property
    def lmc(self) -> typing.Optional[int]:
        """Get or set the Length of material constant array which is equal to the number of material constants to be input.
        """ # nopep8
        return self._cards[0].get_value("lmc")

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

    @property
    def nhv(self) -> typing.Optional[int]:
        """Get or set the Number of history variables to be stored, see also Appendix A of users manual.
        """ # nopep8
        return self._cards[0].get_value("nhv")

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

    @property
    def aopt(self) -> typing.Optional[float]:
        """Get or set the Material axes option of orthotropic materials (see MAT_OPTIONTROPIC_ELASTIC for more details). Set if IORTHO = 1.0.
        EQ.0.0:	Locally orthotropic with material axes by element nodes N1, N2and N4
        EQ.1.0 : Locally orthotropic with material axes determined by a point, Image, in spaceand global location of element center
        EQ.2.0 : Globally orthotropic with material axes determined by vectors
        EQ.3.0 : Locally orthotropic with first material axis orthogonal to element normal(defined by element nodes N1, N2 and N4) and to a vector d - Third material direction corresponds to element normal.
        EQ.4.0 : Local orthogonal in cylindrical coordinates with the material axes determined by a vector Image,and an originating point, Image, which define the centerline axis.
        LT.0.0 : The absolute value of AOPT is a coordinate system ID number(CID on * DEFINE_COORDINATE_NODES, *DEFINE_COORDINATE_SYSTEM or *DEFINE_COORDINATE_VECTOR)
        """ # nopep8
        return self._cards[0].get_value("aopt")

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

    @property
    def iortho(self) -> int:
        """Get or set the Orthtropic flag:
        EQ.0: non orthotropic material (default),
        EQ.1: orthotropic material.
        """ # nopep8
        return self._cards[0].get_value("iortho")

    @iortho.setter
    def iortho(self, value: int) -> None:
        """Set the iortho property."""
        if value not in [0, 1, None]:
            raise Exception("""iortho must be `None` or one of {0,1}.""")
        self._cards[0].set_value("iortho", value)

    @property
    def ihve(self) -> typing.Optional[int]:
        """Get or set the Address of bulk modulus in material constants array, see also Appendix A of users manual.
        """ # nopep8
        return self._cards[0].get_value("ihve")

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

    @property
    def xp(self) -> typing.Optional[float]:
        """Get or set the Coordinates of point p for AOPT = 1 and 4
        """ # nopep8
        return self._cards[1].get_value("xp")

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

    @property
    def yp(self) -> typing.Optional[float]:
        """Get or set the Coordinates of point p for AOPT = 1 and 4
        """ # nopep8
        return self._cards[1].get_value("yp")

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

    @property
    def zp(self) -> typing.Optional[float]:
        """Get or set the Coordinates of point p for AOPT = 1 and 4
        """ # nopep8
        return self._cards[1].get_value("zp")

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

    @property
    def a1(self) -> typing.Optional[float]:
        """Get or set the Components of vector a for AOPT = 2
        """ # nopep8
        return self._cards[1].get_value("a1")

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

    @property
    def a2(self) -> typing.Optional[float]:
        """Get or set the Components of vector a for AOPT = 2
        """ # nopep8
        return self._cards[1].get_value("a2")

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

    @property
    def a3(self) -> typing.Optional[float]:
        """Get or set the Components of vector a for AOPT = 2
        """ # nopep8
        return self._cards[1].get_value("a3")

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

    @property
    def d1(self) -> typing.Optional[float]:
        """Get or set the Components of vector d for AOPT = 2, 3 and 4.
        """ # nopep8
        return self._cards[2].get_value("d1")

    @d1.setter
    def d1(self, value: float) -> None:
        """Set the d1 property."""
        self._cards[2].set_value("d1", value)

    @property
    def d2(self) -> typing.Optional[float]:
        """Get or set the Components of vector d for AOPT = 2, 3 and 4.
        """ # nopep8
        return self._cards[2].get_value("d2")

    @d2.setter
    def d2(self, value: float) -> None:
        """Set the d2 property."""
        self._cards[2].set_value("d2", value)

    @property
    def d3(self) -> typing.Optional[float]:
        """Get or set the Components of vector d for AOPT = 2, 3 and 4
        """ # nopep8
        return self._cards[2].get_value("d3")

    @d3.setter
    def d3(self, value: float) -> None:
        """Set the d3 property."""
        self._cards[2].set_value("d3", value)

    @property
    def title(self) -> typing.Optional[str]:
        """Get or set the Additional title line
        """ # nopep8
        return self._cards[3].cards[0].get_value("title")

    @title.setter
    def title(self, value: str) -> None:
        """Set the title property."""
        self._cards[3].cards[0].set_value("title", value)

        if value:
            self.activate_option("TITLE")

