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.

Overview#

clear

Clear all keywords from the deck.

register_import_handler

Registers an ImportHandler object

append

Add a keyword to the collection.

remove

Remove a keyword from the collection by index.

extend

Add a list of keywords to the deck.

expand

Get a new deck that is flattened copy of self.

dumps

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

write

Write the card in the dyna keyword format.

loads

Load all keywords from the keyword file as a string.

validate

Validate the collection of keywords.

get_kwds_by_type

Get all keywords for a given type.

get_kwds_by_full_type

Get all keywords for a given full type.

get_section_by_id

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

get

Get a list of keywords.

import_file

Import a keyword file.

export_file

Export the keyword file to a new keyword file.

plot

Plot the node and element of the mesh using PyVista.

comment_header

Comment header of the keyword database.

title

Title of the keyword database.

format

Format type of the deck.

transform_handler

parameters

all_keywords

List of all keywords.

string_keywords

List of keywords as a raw string.

encrypted_keywords

List of keywords as a raw string.

keywords

List of processed keywords.

keyword_names

__add__

Add two decks together.

__repr__

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

Import detail#

from ansys.dyna.core.lib.deck import Deck

Property detail#

property Deck.comment_header: str | None#

Comment header of the keyword database.

property Deck.title: str | None#

Title of the keyword database.

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

Format type of the deck.

property Deck.transform_handler: ansys.dyna.core.lib.transform.TransformHandler#
property Deck.parameters: ansys.dyna.core.lib.parameters.ParameterSet#
property Deck.all_keywords: List[str | ansys.dyna.core.lib.keyword_base.KeywordBase | ansys.dyna.core.lib.encrypted_keyword.EncryptedKeyword]#

List of all keywords.

property Deck.string_keywords: List[str]#

List of keywords as a raw string.

property Deck.encrypted_keywords: List[str]#

List of keywords as a raw string.

property Deck.keywords#

List of processed keywords.

property Deck.keyword_names: List[str]#

Method detail#

Deck.__add__(other)#

Add two decks together.

Deck.clear()#

Clear all keywords from the deck.

Deck.register_import_handler(import_handler: ansys.dyna.core.lib.import_handler.ImportHandler) None#

Registers an ImportHandler object

Deck.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.

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

Remove a keyword from the collection by index.

Parameters:
indexint or list of int, mandatory
Deck.extend(kwlist: list) None#

Add a list of keywords to the deck.

Parameters:
kwlistlist

List of keywords.

Deck.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.

Deck.dumps() str#

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

Returns:
str

Keyword file representation of all keywords as a string.

Deck.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.

Deck.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

Deck.validate() None#

Validate the collection of keywords.

Deck.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”)

Deck.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”)

Deck.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.

Deck.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.

Deck.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.

Deck.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.

Deck.__repr__() str#

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

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.