# 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 ControlAcousticSpectral 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

_CONTROLACOUSTICSPECTRAL_CARD0 = (
    FieldSchema("maseord", int, 0, 10, None),
    FieldSchema("masehrf", int, 10, 10, 0),
    FieldSchema("masekfl", int, 20, 10, 0),
    FieldSchema("maseigx", int, 30, 10, 1),
)

class ControlAcousticSpectral(KeywordBase):
    """DYNA CONTROL_ACOUSTIC_SPECTRAL keyword"""

    keyword = "CONTROL"
    subkeyword = "ACOUSTIC_SPECTRAL"

    def __init__(self, **kwargs):
        """Initialize the ControlAcousticSpectral class."""
        super().__init__(**kwargs)
        self._cards = [
            Card.from_field_schemas_with_defaults(
                _CONTROLACOUSTICSPECTRAL_CARD0,
                **kwargs,
            ),        ]
    @property
    def maseord(self) -> typing.Optional[int]:
        """Get or set the Spectral element integration order (2 <= MASEORD <=15). See Remark 2.
        """ # nopep8
        return self._cards[0].get_value("maseord")

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

    @property
    def masehrf(self) -> int:
        """Get or set the Optional h-refinement (see Remark 3):
        EQ.0:	No splitting unless tetrahedra or pentahedra are present
        EQ.1 : Split all elements once into hexahedra
        EQ.2 : Split each element a second time into 8 hexahedra
        EQ.3 : Split each element a second time into 27 hexahedra
        """ # nopep8
        return self._cards[0].get_value("masehrf")

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

    @property
    def masekfl(self) -> int:
        """Get or set the Dump flag for h-refined and spectral element meshes:
        EQ.1:	Dump keyword deck of acoustic mesh after h - refinement
        EQ.10 : Dump keyword deck of spectral acoustic element mesh(generated by LS - DYNA)
        EQ.11 : Dump both meshes for review.
        """ # nopep8
        return self._cards[0].get_value("masekfl")

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

    @property
    def maseigx(self) -> int:
        """Get or set the Approach to element time step calculation (see Remark 4):
        EQ.1:	Gerschgorin theorem
        EQ.2 : Maximum element eigenvalue.
        """ # nopep8
        return self._cards[0].get_value("maseigx")

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

