mesh

Module Contents

The mesh module contains classes that store node and element data.

class mesh.Node(dataline='', label=None, data=None, elements=None, _joinS=', ', _ParamInInp=False, preserveSpacing=True, useDecimal=True)

Bases: object

The Node class stores nodal information from a single node (i.e. one dataline from a *NODE keyword block).

__init__(dataline='', elements=None, _ParamInInp=False, preserveSpacing=True, useDecimal=True)
__init__(label=None, data=None, elements=None, _joinS=', ') None

Initializes attributes of the Node.

In most cases, this will be used by _parseDataNode(). That function will handle creating the inputs to this class from the string corresponding to the node dataline. See that function for an example of instancing this class. If you are instancing this class manually, there are two recommended options.

First, specify the dataline parameter and the other related parameters if you know them prior to creating the Node instance and/or do not wish to use the default values. dataline will be parsed, and label and data will be populated from the parsed information.

Here’s an example using the default settings, which will use inpInt, inpDecimal.inpDecimal, and inpString to store data items and preserve the exact spacing:

>>> from mesh import Node
>>> dataline = '   21, 70.00,   0.00'
>>> node = Node(dataline)
>>> node
Node(label=inpInt('   21'), data=[inpInt('   21'), inpDecimal(' 70.00'), inpDecimal('   0.00')], elements=[])

The repr() of an Node instance is consistent across the different methods to instantiate the class. If you wish to see how the Node will be written out, you can use a function to call its string representation. For example:

>>> print(node)
   21, 70.00,   0.00

Here’s an example of turning off the mechanisms for preserving the exact spacing (for a performance benefit):

>>> node = Node(dataline, preserveSpacing=False, useDecimal=False)
>>> print(node)
21, 70.0, 0.0

We can also specify a custom separator to join the parsed strings when we create a string of the node. This will only be applied if preserveSpacing and useDecimal are False. Example:

>>> node = Node(dataline, _joinS = ',__', preserveSpacing=False, useDecimal=False)
>>> print(node)
21,__70.0,__0.0

If an item in dataline could be a *PARAMETER reference, either _ParamInInp or preserveSpacing must be True, or else a ValueError will be raised. Example:

>>> dataline = '   21, <coord>,   0.00'
>>> node = Node(dataline, preserveSpacing=False, useDecimal=False)
Traceback (most recent call last):
    ...
ValueError: could not convert string to float: ' <coord>'

The second option is to specify label and data instead of dataline. Those items should be formatted properly prior to instancing Node. Example:

>>> label = 21
>>> data = [21, 70.0, 0.00]
>>> node = Node(label=label, data=data)
>>> print(node)
21, 70.0, 0.0

Using either method, elements can be specified if the user knows the list of elements which connect to the node. In most cases, this should not be specified, and the elements connected to the node should instead be added using setConnectedNodes().

Parameters:
  • dataline (str) – The string which contains the entire dataline for the node. Will be parsed to populate the node's attributes. Defaults to ‘’

  • label (int) – The label for the node. Defaults to None.

  • data (list) – The data for the node. This will be a parsed dataline. The format should be [int, float, float, …]. Defaults to None.

  • elements (list) – The elements which are connected to the Node instance. Defaults to None.

  • _joinS (str) – The string used to join the data items together when creating strings of the Node instance. Defaults ‘, ‘.

  • _ParamInInp (bool) – Indicates if *PARAMETER is in the input file, which would mean that the dataline items could be strings instead of exclusively integers. Defaults to False.

  • preserveSpacing (bool) – If True, the exact spacing of all items will be preserved by using inpInt. In most cases when creating new Element instances, you will want to use the same value that the rest of the input file was parsed with. Defaults to True.

  • useDecimal (bool) – If True, any floating point numbers will be parsed as Decimal or inpDecimal. In most cases when creating new Element instances, you will want to use the same value that the rest of the input file was parsed with. Defaults to True.

_ParamInInp

Indicates if *PARAMETER is in the input file. If True, data items could be references to *PARAMETER functions, and the datalines might be strings, so the :func:’~eval2.eval2’ function must be used when parsing data items instead of assuming they must be integers. Defaults to False.

Type:

bool

preserveSpacing

If True, the exact spacing of all items will be preserved by using inpInt instead of int. _joinS will be set to ‘,’ if preserveSpacing is True, as the spacing will be stored in the data objects. Defaults to True.

Type:

bool

useDecimal

If True, any floating point numbers will be parsed as Decimal or inpDecimal. Defaults to True.

_joinS

The string used to join data items together when creating a string for the entire dataline. Defaults to ‘, ‘, which will be sufficient for most cases.

Type:

str

label

The node label.

Type:

int

data

A list containing the parsed data items.

Type:

list

elements

Will store the elements that reference this Node. This is populated by Element.setConnectedNodes().

Type:

list

_parseDataLine(dataline)

Populates the Node instance by parsing the dataline string.

This function will be called automatically when Node is initialized if datalines is specified.

Example usage:

>>> from mesh import Node
>>> node = Node()
>>> node._parseDataLine('   21, 70.00,   0.00')
>>> node
Node(label=inpInt('   21'), data=[inpInt('   21'), inpDecimal(' 70.00'), inpDecimal('   0.00')], elements=[])
Parameters:

dataline (str) – A string containing the information for the entire dataline.

_mergeElementData(other)

Currently unused

updateElements(ed)

Checks if each element in elements exists in ed. Returns 0 if elements is empty, 1 if elements have been removed, or 2 if no changes were made.

Parameters:

ed (TotalMesh) – This is the TotalMesh instance containing elements in which to check for elements.

Returns:

0 if elements is now empty, 1 if elements was modified, 2 if elements is unchanged.

Return type:

int

__repr__()

Produces a repr of the Node.

Example

>>> from mesh import Node
>>> Node('   21, 70.00,   0.00')
Node(label=inpInt('   21'), data=[inpInt('   21'), inpDecimal(' 70.00'), inpDecimal('   0.00')], elements=[])
__str__()

Produces a str of the dataline for the Node.

Example

>>> from mesh import Node
>>> node = Node('   21, 70.00,   0.00')
>>> print(node)
   21, 70.00,   0.00
__weakref__

list of weak references to the object (if defined)

class mesh.Element(eltype, numNodes=None, datalines=None, label=None, data=None, _lineEnd=None, _npll=None, _joinS=', ', _ParamInInp=False, preserveSpacing=True, useDecimal=True, _checkNumNodes=True, _nl='\n')

Bases: object

The Element class stores element information from a single element (i.e. one dataline from a *ELEMENT keyword block).

__init__(eltype, numNodes=None, datalines=None, ', _ParamInInp=False, preserveSpacing=True, useDecimal=True, _checkNumNodes=True, _nl='\n')
__init__(eltype, numNodes=None, label=None, data=None, _lineEnd=None, _npll=None, _joinS=', ') None

Initializes attributes of the Element.

In most cases, this will be used by _parseDataElement(). That function will handle creating the inputs to this class from the string corresponding to the element dataline. See that function for more details. If you are instancing this class manually, you can omit specifying the private parameters. The default values should be sufficient.

All parameters are optional except eltype, but there are two recommend methods to create an instance of this class. The first method is to specify datalines and allow Element to parse these datalines to populate label and data. Here is an example of this use case with a CPS4R element:

>>> from mesh import Element
>>> datalines = ' 1, 1, 2, 102, 101'
>>> element = Element(eltype='CPS4R', datalines=datalines)
>>> element
Element(label=inpInt(' 1'), data=[inpInt(' 1'), inpInt(' 1'), inpInt(' 2'), inpInt(' 102'), inpInt(' 101')], eltype='CPS4R', numNodes=4)

The repr() of an Element instance is consistent across the different methods to instantiate the class. If you wish to see how the Element will be written out, you can use a function to call its string representation. For example:

>>> print(element)
 1, 1, 2, 102, 101

Here’s a similar example with an element defined over multiple lines:

>>> datalines = [' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,',
... '      96,  98,  97,  99, 100']
>>> Element(eltype='C3D20', datalines=datalines)
Element(label=inpInt(' 1'), data=[inpInt(' 1'), inpInt('  16'), inpInt('   4'), inpInt('  24'), inpInt('  57'), inpInt('  13'), inpInt('   1'), inpInt('  32'), inpInt('  66'), inpInt('  92'), inpInt('  91'), inpInt('  90'), inpInt('  89'), inpInt('  93'), inpInt('  94'), inpInt('  95'), inpInt('      96'), inpInt('  98'), inpInt('  97'), inpInt('  99'), inpInt(' 100')], eltype='C3D20', numNodes=20)

We can also specify datalines as a single string with newline characters. Example:

>>> datalines = ' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,\n     96,  98,  97,  99, 100'
>>> Element(eltype='C3D20', datalines=datalines)
Element(label=inpInt(' 1'), data=[inpInt(' 1'), inpInt('  16'), inpInt('   4'), inpInt('  24'), inpInt('  57'), inpInt('  13'), inpInt('   1'), inpInt('  32'), inpInt('  66'), inpInt('  92'), inpInt('  91'), inpInt('  90'), inpInt('  89'), inpInt('  93'), inpInt('  94'), inpInt('  95'), inpInt('     96'), inpInt('  98'), inpInt('  97'), inpInt('  99'), inpInt(' 100')], eltype='C3D20', numNodes=20)

If we set preserveSpacing, useDecimal, and _ParamInInp all to False, we gain some performance at the expense of some formatting accuracy. See the difference below:

>>> datalines = ' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,\n     96,  98,  97,  99, 100'
>>> print(Element(eltype='C3D20', datalines=datalines, preserveSpacing=False, useDecimal=False))
1, 16, 4, 24, 57, 13, 1, 32, 66, 92, 91, 90, 89, 93, 94, 95,
96, 98, 97, 99, 100
>>> print(Element(eltype='C3D20', datalines=datalines))
 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,
     96,  98,  97,  99, 100

The second method is to instead specify label and data directly. We will need to get the data into a suitable form prior to inserting it into the Element instance. You will use this option most often if you are creating new elements and do not start with a string containing the entire element definition. Example usage:

>>> label = 1
>>> data = [1, 16, 4, 24, 57, 13, 1, 32, 66, 92, 91, 90, 89, 93, 94, 95, 96, 98, 97, 99, 100]
>>> element = Element(eltype='C3D20', label=label, data=data)
>>> print(element)
1, 16, 4, 24, 57, 13, 1, 32, 66, 92, 91, 90, 89, 93, 94, 95,
96, 98, 97, 99, 100

If you don’t specify the number of nodes to include per each line via _npll, there will be 16 items per line.

We can also specify the strings used to join data items (_joinS), and a string to include at the end of each line (_lineEnd). This should normally be whitespace characters, but different characters are used here for illustrative purposes:

>>> element = Element(eltype='C3D20', label=label, data=data, _lineEnd=['++', None], _joinS = ',_')
>>> print(element)
1,_16,_4,_24,_57,_13,_1,_32,_66,_92,_91,_90,_89,_93,_94,_95,++
96,_98,_97,_99,_100
Parameters:
  • eltype (str) – The element type name. Should be a valid Abaqus element type name, or the name of a user-element.

  • numNodes (int) – The number of nodes the element needs. If not specified, this will be retrieved from _elementTypeDictionary[eltype]. This should only be specified if an element type is not in that dictionary, which will mainly be for user or substructure elements.

  • datalines (list, str) – A list of strings representing the datalines for the Element. This can also be a string representing the entirety of the data for the element, with new line characters if the definition is spread across multiple lines. Defaults to None.

  • label (int) – The label for the element. Defaults to None.

  • data (list) – The data for the element. This will be a parsed dataline. The format should be [int, int, …].

  • _lineEnd (str, list) – Holds any additional whitespace characters to include at the end of the dataline. Mainly used to exactly reproduce the string representation of the keyword block. Defaults to None. If the data must be printed across multiple lines, _lineEnd will be expanded to a list if necessary, with each item in the list corresponding to the old value of _lineEnd. If a _lineEnd item is None, nothing will be added to the end of that line. If a _lineEnd item is a string, the _lineEnd item will follow a comma on the effected line.

  • _npll (list) – Nodes Per Line List, controls how many nodes should be printed on each line when converting the Element to a string. The default value of None will cause the maximum number of nodes to be printed on each line (up to 15 for line 0, and up to 16 for all subsequent lines).

  • _joinS (str) – The string used to join the data items together when creating strings of the Element instance. Defaults to None, which will use ‘, ‘. If preserveSpacing is True and datalines is not None, ‘,’ will be used.

  • _ParamInInp (bool) – Indicates if *PARAMETER is in the input file, which would mean that the dataline items could be strings instead of exclusively integers. Defaults to False.

  • preserveSpacing (bool) – If True, the exact spacing of all items will be preserved by using inpInt. In most cases when creating new Element instances, you will want to use the same value that the rest of the input file was parsed with. Defaults to True.

  • useDecimal (bool) – If True, any floating point numbers will be parsed as Decimal or inpDecimal. In most cases when creating new Element instances, you will want to use the same value that the rest of the input file was parsed with. Defaults to True.

  • _checkNumNodes (bool) – If True, the number of nodes parsed from datalines will be checked against numNodes. If the Element has the incorrect number of nodes, an ElementIncorrectNodeNumError will be raised. Defaults to True.

  • _nl (str) – Used to split datalines if it is a string. Defaults to ‘n’.

eltype

Indicates the element type name. Should be a valid Abaqus element type.

Type:

str

_checknumNodes

If True, the number of nodes parsed from datalines will be checked against the number in numNodes. Defaults to True.

Type:

bool

numNodes

The number of nodes needed for the Element. Can be specified by the user, or will be retrieved from _elementTypeDictionary[eltype].

Type:

int

_ParamInInp

Indicates if *PARAMETER is in the input file. If True, data items could be references to *PARAMETER functions, and the datalines might be strings, so the :func:’~eval2.eval2’ function must be used when parsing data items instead of assuming they must be integers. Defaults to False.

Type:

bool

preserveSpacing

If True, the exact spacing of all items will be preserved by using inpInt instead of int. Defaults to True.

Type:

bool

_nl

Used to split datalines if it is a string. Defaults to ‘n’, which should be correct for most cases.

Type:

str

useDecimal

If True, any floating point numbers will be parsed as Decimal or inpDecimal. Defaults to True.

Type:

bool

_joinS

The string used to join the data items together when creating strings of the Element instance.

Type:

str

label

The element label.

Type:

int

data

The data for the element. This will be a parsed dataline. The format should be [int, …].

Type:

list

_npll

Nodes Per Line List, controls how many nodes will be printed on each line when converting Element to a string.

Type:

list

_lineEnd

Holds any additional whitespace characters to include at the end of the dataline.

Type:

str

checkNumberNodes()

checkNumberNodes()

This function will check if the number of nodes in data matches that specified in numNodes.

It raises an ElementIncorrectNodeNumError if the number of nodes does not match the element type requirements. Otherwise, it does nothing. This function will be called by _parseDataLines() if _checknumNodes is True (thus, it will be called if Element is initialized with datalines and the default settings). It should be called manually if the Element is populated in another manner.

Example

>>> from mesh import Element
>>> element = Element(eltype='CPS4R', label=1, data=[1, 1, 2, 102, 101, 103])
>>> element.checkNumberNodes()
Traceback (most recent call last):
    ...
inpRWErrors.ElementIncorrectNodeNumError: ERROR! An element of type CPS4R must have 4 nodes.
Raises:

ElementIncorrectNodeNumError

_parseDataLines(datalines)

Populates the Element instance by parsing the strings in datalines.

This function will also call checkNumberNodes() if _checknumNodes = True. It is called automatically if Element is instantiated with the datalines argument.

Example usage:

>>> from mesh import Element
>>> element = Element(eltype='CPS4R')
>>> element._parseDataLines('1, 1, 2, 102, 101')
>>> print(element)
1,  1,  2,  102,  101
Parameters:

datalines (list) – A list of strings containing the information for the entire dataline.

_parseDataLine(dataline, con=False)

Parses an individual *ELEMENT dataline. Meant to be used by _parseDataLines().

Example usage:

>>> from mesh import Element
>>> dataline1 = ' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,'
>>> dataline2 = '     96,  98,  97,  99, 100'
>>> element = Element(eltype='C3D20')
>>> element._parseDataLine(dataline1)
>>> element
Element(label=inpInt(' 1'), data=[inpInt(' 1'), inpInt('  16'), inpInt('   4'), inpInt('  24'), inpInt('  57'), inpInt('  13'), inpInt('   1'), inpInt('  32'), inpInt('  66'), inpInt('  92'), inpInt('  91'), inpInt('  90'), inpInt('  89'), inpInt('  93'), inpInt('  94'), inpInt('  95')], eltype='C3D20', numNodes=20)
>>> element._parseDataLine(dataline2, con=True)
>>> element
Element(label=inpInt(' 1'), data=[inpInt(' 1'), inpInt('  16'), inpInt('   4'), inpInt('  24'), inpInt('  57'), inpInt('  13'), inpInt('   1'), inpInt('  32'), inpInt('  66'), inpInt('  92'), inpInt('  91'), inpInt('  90'), inpInt('  89'), inpInt('  93'), inpInt('  94'), inpInt('  95'), inpInt('     96'), inpInt('  98'), inpInt('  97'), inpInt('  99'), inpInt(' 100')], eltype='C3D20', numNodes=20)
Parameters:
  • dataline (str) – The string containing the information for one line of data.

  • con (bool) – If True, this function will treat dataline as a continuation of the previous dataline (i.e. all items represent node labels, instead of an element label and then node labels). Defaults to False.

_processDataLinesInput(datalines)

If datalines is a string, split datalines on _nl, which will convert datalines to a string.

This is called automatically by _parseDataLines(), so the user will likely never need to call it directly.

Example usage:

>>> from mesh import Element
>>> element = Element(eltype='CPS4R')
>>> element._processDataLinesInput('  1, 1, 2, 102, 101')
['  1, 1, 2, 102, 101']
>>> element._processDataLinesInput(' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,\n     96,  98,  97,  99, 100')
[' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,', '     96,  98,  97,  99, 100']
Parameters:

datalines (str, list) – A string or list of strings. If a string, will be converted to a list by splitting on _nl.

Returns:

list

setConnectedNodes(nd)

This function will find each node in nd corresponding to the node labels in data and append label to the elements.

Parameters:

nd (TotalMesh) – The TotalMesh instance containing the nodes for the input file.

__repr__()

Produces a repr of the dataline for the Element.

Example usage:

>>> from mesh import Element
>>> Element(eltype='CPS4R', datalines=' 1, 1, 2, 102, 101')
Element(label=inpInt(' 1'), data=[inpInt(' 1'), inpInt(' 1'), inpInt(' 2'), inpInt(' 102'), inpInt(' 101')], eltype='CPS4R', numNodes=4)
Returns:

string

__str__()

Produces a str of the dataline for the Element.

Example usage:

>>> from mesh import Element
>>> print(Element(eltype='CPS4R', datalines='1, 1, 2, 102, 101'))
1, 1, 2, 102, 101
Returns:

string

__weakref__

list of weak references to the object (if defined)

class mesh.Mesh(data=None)

Bases: csid

This class is a csid used to store the data from a node keyword block.

__init__(data=None)

Initializes the class. In most cases, users should not directly instantiate this class. Rather, they should create a *NODE inpKeyword instance and allow that keyword block to handle the logistics.

Example usage:

>>> from mesh import Node, Mesh
>>> node1 = Node('   1 ,  0.00,   0.00')
>>> node2 = Node('   21, 70.00,   0.00')
>>> Mesh([[i.label, i] for i in [node1, node2]])
csid(inpInt('   1 '): Node(label=inpInt('   1 '), data=[inpInt('   1 '), inpDecimal('  0.00'), inpDecimal('   0.00')], elements=[]), inpInt('   21'): Node(label=inpInt('   21'), data=[inpInt('   21'), inpDecimal(' 70.00'), inpDecimal('   0.00')], elements=[]))
Parameters:

datadata should be a format that can generate a dictionary. Defaults to None, which will produce a blank object.

__repr__()

Uses the default __repr__ method from dict.

Example usage:

>>> from mesh import Node, Mesh
>>> node1 = Node('   1 ,  0.00,   0.00')
>>> node2 = Node('   21, 70.00,   0.00')
>>> Mesh([[i.label, i] for i in [node1, node2]])
csid(inpInt('   1 '): Node(label=inpInt('   1 '), data=[inpInt('   1 '), inpDecimal('  0.00'), inpDecimal('   0.00')], elements=[]), inpInt('   21'): Node(label=inpInt('   21'), data=[inpInt('   21'), inpDecimal(' 70.00'), inpDecimal('   0.00')], elements=[]))
__str__()

Uses the default __str__ method from dict.

Example usage:

>>> from mesh import Node, Mesh
>>> node1 = Node('   1 ,  0.00,   0.00')
>>> node2 = Node('   21, 70.00,   0.00')
>>> print(Mesh([[i.label, i] for i in [node1, node2]]))
{
   1 :    1 ,  0.00,   0.00
   21:    21, 70.00,   0.00
}
class mesh.MeshElement(eltype, data=None)

Bases: Mesh

MeshElement is identical to Mesh, except that it checks to make sure that every item added to it has the same element type.

__init__(eltype, data=None)

__init__(eltype, data=None)

Initializes the class. In most cases, users should not directly instantiate this class. Rather, they should create a *ELEMENT inpKeyword instance and allow that keyword block to handle the logistics.

Example usage:

>>> from mesh import Element, MeshElement
>>> element1 = Element(eltype='C3D20', datalines=' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,\n     96,  98,  97,  99, 100')
>>> element2 = Element(eltype='C3D20', datalines=' 2,  15,  16,  57,  58,  14,  13,  66,  65, 103,  89, 102, 101, 104,  96, 105,\n    106, 107,  98, 100, 108')
>>> mesh = MeshElement(eltype='C3D20', data=[[i.label, i] for i in [element1, element2]])
>>> mesh
csid(inpInt(' 1'): Element(label=inpInt(' 1'), data=[inpInt(' 1'), inpInt('  16'), inpInt('   4'), inpInt('  24'), inpInt('  57'), inpInt('  13'), inpInt('   1'), inpInt('  32'), inpInt('  66'), inpInt('  92'), inpInt('  91'), inpInt('  90'), inpInt('  89'), inpInt('  93'), inpInt('  94'), inpInt('  95'), inpInt('     96'), inpInt('  98'), inpInt('  97'), inpInt('  99'), inpInt(' 100')], eltype='C3D20', numNodes=20), inpInt(' 2'): Element(label=inpInt(' 2'), data=[inpInt(' 2'), inpInt('  15'), inpInt('  16'), inpInt('  57'), inpInt('  58'), inpInt('  14'), inpInt('  13'), inpInt('  66'), inpInt('  65'), inpInt(' 103'), inpInt('  89'), inpInt(' 102'), inpInt(' 101'), inpInt(' 104'), inpInt('  96'), inpInt(' 105'), inpInt('    106'), inpInt(' 107'), inpInt('  98'), inpInt(' 100'), inpInt(' 108')], eltype='C3D20', numNodes=20))
Parameters:
  • eltype (str) – The string representing the Abaqus element type name.

  • datadata should be a format that can generate a dictionary. Defaults to None, which will produce a blank object.

eltype

A string representing the element type name

Type:

str

__setitem__(label, element)

Checks if element.eltype matches eltype. If it does, set MeshElement[label] = element, else raise ElementTypeMismatchError.

Correct usage, the eltype of the Element matches that of the MeshElement:

>>> from mesh import Element, MeshElement
>>> element1 = Element(eltype='C3D20', datalines=' 1,  16,   4,  24,  57,  13,   1,  32,  66,  92,  91,  90,  89,  93,  94,  95,\n     96,  98,  97,  99, 100')
>>> mesh = MeshElement(eltype='C3D20', data=[[element1.label, element1]])

The class raises a ElementTypeMismatchError if we try to add an element with a different eltype:

>>> element2 = Element(eltype='CPS4R', datalines='1, 1, 2, 102, 101')
>>> mesh[element2.label] = element2
Traceback (most recent call last):
    ...
inpRWErrors.ElementTypeMismatchError: ERROR! An element of type CPS4R cannot be added to a MeshElement with eltype C3D20
Parameters:
Raises:

ElementTypeMismatchError

class mesh.TotalMesh(_data=None)

Bases: csid

TotalMesh is a parent class, and not meant to be instantiated directly. Users should instead work with one of the sub-classes, which are TotalNodeMesh and TotalElementMesh.

Users should not need to created instances of this class or the child classes directly. In most cases, they can rely on inpKeywordSequence to create and manage these instances.

Every inpKeywordSequence contains attributes _nd and _ed, which are TotalNodeMesh and TotalElementMesh instances, respectively. They provide a convenient method to access all the mesh and element data in an input file, without needing to navigate through multiple keyword blocks. These instances of the top-level inpKeywordSequence (keywords) will be mapped to nd and ed.

Any operations on items in this class will be propagated back to the data of the appropriate node and element inpKeyword blocks.

Items should not be directly deleted from a TotalMesh, in most cases. The user should instead use a combination of findItemReferences() along with deleteItemReferences() to delete these entities, as it will also find and delete all references to those entities throughout the input file.

A function for replacing item references still needs to be written.

Items should not be added to this class directly. Rather, they should be added to data of a *NODE or *ELEMENT keyword block and added to this class via updateInp().

__init__(_data=None)

A TotalMesh instance holds all the nodes or elements for the children of an inpKeywordSequence. This class is meant to be initialized with _data = None. Data should be added to it via update() using a Mesh instance.

Parameters:

_data – Can be any construct used to populate a dict. Should not be used in most cases, as the data should instead be populated through a Mesh, and then calling update() on that Mesh instance.

subMeshes

Will hold a shared memory reference to every Mesh or TotalMesh instance which is a child of this object. This is thus a link to the data attributes of the appropriate keyword blocks.

Type:

list

removeEmptySubMeshes()

Deletes any subMeshes which are now empty. This will also delete the Mesh instance.

renameKeys(mapping)

Renames all keys in the TotalMesh instance (d) as specified by mapping.

d and each subMesh will be cleared and repopulated with the renamed keys to preserve the original order. Thus, this can be an expensive operation, so try to provide the entirety of the information to rename and call this function only once.

update(other)

Adds the data from other to the TotalMesh instance (d), and tracks other in subMeshes.

Parameters:

other (Mesh, TotalMesh) – A Mesh or TotalMesh instance whose items will be included in

__delitem__(key)

Deletes key and value in self and in the subMesh.

Parameters:

key – A valid hashable key. Should be an integer in most cases, as the node and element labels will be integers.

__repr__()

Uses the default __repr__ method from dict.

__setitem__()

Items should not be added to the TotalMesh instance. Add them instead to the appropriate Mesh instance and then update() TotalMesh with Mesh.

__str__()

Uses the default __str__ method from dict.

class mesh.TotalNodeMesh(_data=None)

Bases: TotalMesh

A TotalNodeMesh enhances TotalMesh with some additional functions specific to working with Abaqus nodes.

setNodesConnectedElements(nd)

This function will set the elements attribute of each node in the TotalMesh instance for each node found in nd.

It should be passed a Mesh instance which maps the node labels to the elements connected to those nodes. In most cases, this special Mesh instance should be created by _parseDataElement() and it will be available as the _nd attribute of a *ELEMENT keyword block and as the ‘nd_ed’ entry of _inpItemsToUpdate.

Parameters:

nd (Mesh) – The Mesh instance which contains the node and element label mapping.

updateNodesConnectedElements(ed)

Calls updateElements() on all Node instances.

Parameters:

ed (TotalMesh) – This should be the TotalMesh instance holding the elements.

Returns:

A dictionary with the node labels as the key, and the return value of updateElements() as the value.

Return type:

dict

__repr__()

Uses the default __repr__ method from dict.

__str__()

Uses the default __str__ method from dict.

class mesh.TotalElementMesh(_data=None)

Bases: TotalMesh

A TotalElementMesh is merely a subclass of TotalMesh with no additional behavior.

__repr__()

Uses the default __repr__ method from dict.

__str__()

Uses the default __str__ method from dict.