# 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 LoadThermalVariableBeamSet 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
from ansys.dyna.core.keywords.keyword_classes.auto.define.define_curve import DefineCurve

_LOADTHERMALVARIABLEBEAMSET_CARD0 = (
    FieldSchema("id", int, 0, 10, None),
    FieldSchema("sid", int, 10, 10, None),
    FieldSchema("ipolar", int, 20, 10, 0),
)

_LOADTHERMALVARIABLEBEAMSET_CARD1 = (
    FieldSchema("tbase", float, 0, 10, 0.0),
    FieldSchema("tscale", float, 10, 10, 1.0),
    FieldSchema("tcurve", int, 20, 10, None),
    FieldSchema("tcurdr", int, 30, 10, None),
    FieldSchema("scoor", float, 40, 10, None),
    FieldSchema("tcoor", float, 50, 10, None),
)

class LoadThermalVariableBeamSet(KeywordBase):
    """DYNA LOAD_THERMAL_VARIABLE_BEAM_SET keyword"""

    keyword = "LOAD"
    subkeyword = "THERMAL_VARIABLE_BEAM_SET"
    _link_fields = {
        "tcurve": LinkType.DEFINE_CURVE,
        "tcurdr": LinkType.DEFINE_CURVE,
        "sid": LinkType.SET_BEAM,
    }

    def __init__(self, **kwargs):
        """Initialize the LoadThermalVariableBeamSet class."""
        super().__init__(**kwargs)
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _LOADTHERMALVARIABLEBEAMSET_CARD0,
                **kwargs,
            ),            Card.from_field_schemas_with_defaults(
                _LOADTHERMALVARIABLEBEAMSET_CARD1,
                **kwargs,
            ),        ]
    @property
    def id(self) -> typing.Optional[int]:
        """Get or set the Load case ID.
        """ # 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 sid(self) -> typing.Optional[int]:
        """Get or set the Beam set ID
        """ # nopep8
        return self._cards[0].get_value("sid")

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

    @property
    def ipolar(self) -> int:
        """Get or set the GT.0: the coordinates SCOOR and TCOOR are given in polar coordinates	(see notes)
        """ # nopep8
        return self._cards[0].get_value("ipolar")

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

    @property
    def tbase(self) -> float:
        """Get or set the Base temperature
        """ # nopep8
        return self._cards[1].get_value("tbase")

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

    @property
    def tscale(self) -> float:
        """Get or set the Scale factor on temperature from load curve
        """ # nopep8
        return self._cards[1].get_value("tscale")

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

    @property
    def tcurve(self) -> typing.Optional[int]:
        """Get or set the Load curve ID for temperature vs time
        """ # nopep8
        return self._cards[1].get_value("tcurve")

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

    @property
    def tcurdr(self) -> typing.Optional[int]:
        """Get or set the Load curve ID used during dynamic relaxation
        """ # nopep8
        return self._cards[1].get_value("tcurdr")

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

    @property
    def scoor(self) -> typing.Optional[float]:
        """Get or set the Relative coordinate in local S-direction (-1.0 to +1.0)
        """ # nopep8
        return self._cards[1].get_value("scoor")

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

    @property
    def tcoor(self) -> typing.Optional[float]:
        """Get or set the Relative coordinate in local T-direction (-1.0 to +1.0)
        """ # nopep8
        return self._cards[1].get_value("tcoor")

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

    @property
    def tcurve_link(self) -> typing.Optional[DefineCurve]:
        """Get the DefineCurve object for tcurve."""
        if self.deck is None:
            return None
        for kwd in self.deck.get_kwds_by_full_type("DEFINE", "CURVE"):
            if kwd.lcid == self.tcurve:
                return kwd
        return None

    @tcurve_link.setter
    def tcurve_link(self, value: DefineCurve) -> None:
        """Set the DefineCurve object for tcurve."""
        self.tcurve = value.lcid

    @property
    def tcurdr_link(self) -> typing.Optional[DefineCurve]:
        """Get the DefineCurve object for tcurdr."""
        if self.deck is None:
            return None
        for kwd in self.deck.get_kwds_by_full_type("DEFINE", "CURVE"):
            if kwd.lcid == self.tcurdr:
                return kwd
        return None

    @tcurdr_link.setter
    def tcurdr_link(self, value: DefineCurve) -> None:
        """Set the DefineCurve object for tcurdr."""
        self.tcurdr = value.lcid

    @property
    def sid_link(self) -> typing.Optional[KeywordBase]:
        """Get the SET_BEAM_* keyword for sid."""
        return self._get_set_link("BEAM", self.sid)

    @sid_link.setter
    def sid_link(self, value: KeywordBase) -> None:
        """Set the SET_BEAM_* keyword for sid."""
        self.sid = value.sid

