ansys.dyna.core.lib.deck#

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

Classes#

Deck

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

Module Contents#

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

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

property comment_header: str | None[source]#

Comment header of the keyword database.

property title: str | None[source]#

Title of the keyword database.

property format: ansys.dyna.core.lib.format_type.format_type[source]#

Format type of the deck.

__add__(other)[source]#

Add two decks together.

clear()[source]#

Clear all keywords from the deck.

append(keyword: ansys.dyna.core.lib.keyword_base.KeywordBase | str, check=False) None[source]#

Add a keyword to the collection.

Parameters:
keywordUnion[KeywordBase, str]

Keyword. The keyword can be either an implementation of the KeywordBase instance or a string.

checkbool, optional

The default is False.

property all_keywords: List[str | ansys.dyna.core.lib.keyword_base.KeywordBase][source]#

List of all keywords.

property string_keywords: List[str][source]#

List of keywords as a raw string.

property keywords[source]#

List of processed keywords.

extend(kwlist: list) None[source]#

Add a list of keywords to the deck.

Parameters:
kwlistlist

List of keywords.

expand(cwd=None)[source]#

Get a new deck that is flat.

This method makes the include method obsolete.

dumps() str[source]#

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)[source]#

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) ansys.dyna.keywords.lib.deck_loader.DeckLoaderResult[source]#

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
validate() None[source]#

Validate the collection of keywords.

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

Get all keywords for a given type.

Parameters:
typestr

Keyword type.

Returns:
typing.Iterator[KeywordBase]

Examples

Get all SECTION keyword instances in the collection.

>>>deck.get_kwds_by_type(“SECTION”)

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

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][source]#

Get a list of keywords.

Parameters:
: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='utf-8') ansys.dyna.keywords.lib.deck_loader.DeckLoaderResult[source]#

Import a keyword file.

Parameters:
pathstr

Full path for the keyword file.

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

Export the keyword file to a new keyword file.

Parameters:
pathstr

Full path for the new keyword file.

__repr__() str[source]#

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

plot(**args)[source]#

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.