ansys.dyna.core.lib.deck.Deck#

class ansys.dyna.core.lib.deck.Deck(title: str = None, **kwargs)#

Provides a collection of keywords that can read and write to a keyword file.

property comment_header: str | None#

Comment header of the keyword database.

property title: str | None#

Title of the keyword database.

property format: ansys.dyna.core.lib.format_type.format_type#

Format type of the deck.

__add__(other)#

Add two decks together.

clear()#

Clear all keywords from the deck.

property transform_handler: ansys.dyna.core.lib.transform.TransformHandler#
register_import_handler(import_handler: ansys.dyna.core.lib.import_handler.ImportHandler) None#

Registers an ImportHandler object

property parameters: ansys.dyna.core.lib.parameters.ParameterSet#
append(keyword: ansys.dyna.core.lib.keyword_base.KeywordBase | str, check=False) None#

Add a keyword to the collection.

Parameters:
keywordUnion[KeywordBase, EncryptedKeyword, str]

Keyword. The keyword can be KeywordBase, EncryptedKeyword, or a string.

checkbool, optional

The default is False.

remove(index: int | list[int]) None#

Remove a keyword from the collection by index.

Parameters:
indexint or list of int, mandatory
property all_keywords: List[str | ansys.dyna.core.lib.keyword_base.KeywordBase | ansys.dyna.core.lib.encrypted_keyword.EncryptedKeyword]#

List of all keywords.

property string_keywords: List[str]#

List of keywords as a raw string.

property encrypted_keywords: List[str]#

List of keywords as a raw string.

property keywords#

List of processed keywords.

extend(kwlist: list) None#

Add a list of keywords to the deck.

Parameters:
kwlistlist

List of keywords.

expand(cwd=None, recurse=True)#

Get a new deck that is flattened copy of self.

A flattened deck is one where the *INCLUDE keywords are replaced by the contents of the file that is included. cwd is a working directory used to resolve the filename If recurse is true, *INCLUDE keywords within included decks are expanded, recursively.

dumps() str#

Get the keyword file representation of all keywords as a string.

Returns:
str

Keyword file representation of all keywords as a string.

write(buf: TextIO | None = None, format: ansys.dyna.core.lib.format_type.format_type | None = None)#

Write the card in the dyna keyword format.

Parameters:
bufoptional

Buffer to write to. The default is None, in which case the output is returned as a string.

formatoptional

Format to write in. The default is None.

loads(value: str, context: ansys.dyna.core.lib.import_handler.ImportContext | None = None) ansys.dyna.keywords.lib.deck_loader.DeckLoaderResult#

Load all keywords from the keyword file as a string.

When adding all keywords from the file, this method overwrites the title and user comment, if any.

Parameters:
valuestr
context: ImportContext

the context

validate() None#

Validate the collection of keywords.

get_kwds_by_type(str_type: str) Iterator[ansys.dyna.core.lib.keyword_base.KeywordBase]#

Get all keywords for a given type.

Parameters:
str_typestr

Keyword type.

Returns:
typing.Iterator[KeywordBase]

Examples

Get all *SECTION_* keywords in the deck.

>>>deck.get_kwds_by_type(“SECTION”)

get_kwds_by_full_type(str_type: str, str_subtype: str) Iterator[ansys.dyna.core.lib.keyword_base.KeywordBase]#

Get all keywords for a given full type.

Parameters:
str_typestr

Keyword type.

str_subtypestr

Keyword subtype.

Returns:
typing.Iterator[KeywordBase]

Examples

Get all *SECTION_SHELL keyword instances in the deck.

>>>deck.get_kwds_by_full_type(“SECTION”, “SHELL”)

get_section_by_id(id: int) ansys.dyna.core.lib.keyword_base.KeywordBase | None#

Get the SECTION keyword in the collection for a given section ID.

Parameters:
idint

Section ID.

Returns:
SECTION keyword or None if there is no SECTION keyword that matches the section ID.
Raises:
Exception

If multiple SECTION keywords use the given section ID.

get(**kwargs) List[ansys.dyna.core.lib.keyword_base.KeywordBase]#

Get a list of keywords.

Parameters:
- *kwargs* (``dict``) –

Keyword arguments. * type (str) – The type of keyword to get. For example, “SECTION” returns all section keywords. * filter (callable) – The filter to apply to the result. Only keywords which pass the filter will be returned.

import_file(path: str, encoding: str = 'utf-8') ansys.dyna.keywords.lib.deck_loader.DeckLoaderResult#

Import a keyword file.

Parameters:
pathstr

Full path for the keyword file.

encoding: str

String encoding used to read the keyword file.

export_file(path: str, encoding='utf-8') None#

Export the keyword file to a new keyword file.

Parameters:
pathstr

Full path for the new keyword file.

property keyword_names: List[str]#
__repr__() str#

Get a console-friendly representation of a list of all keywords in the deck.

plot(**args)#

Plot the node and element of the mesh using PyVista.

Parameters:
**args

Keyword arguments. Use * cwd (int) if the deck and include files are in a separate directory.