exomerge module

Exomerge is a lightweight Python interface for manipulating ExodusII files.

Copyright(C) 1999-2020, 2022, 2023, 2024 National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software.

See packages/seacas/LICENSE for details

Author: Tim Kostka (tdkostk@sandia.gov) Created: May 3, 2012

Simple example: >>> import exomerge >>> model = exomerge.import_model(‘results.e’) >>> model.delete_element_block(1) >>> model.export_model(‘most_results.e’)

Documentation can be accessed online through Python’s pydoc utility: $ pydoc exomerge $ pydoc exomerge.ExodusModel.delete_element_block

Documentation and sample scripts can be found in the following report. “Exomerge User’s Manual: A lightweight Python interface for manipulating Exodus files” (SAND2013-0725)

For additional information or to provide feedback or feature requests, please contact the author.

This is the python-3 version

class exomerge.DummyFile[source]

Bases: object

Dummy class used to suppress output to stdout.

write(x)[source]

Ignore the write command.

class exomerge.ExodusModel[source]

Bases: object

This class holds all information stored within an ExodusII file.

ALL_MULTI_COMPONENT_FIELD_SUBSCRIPTS = {'x', 'xx', 'xy', 'xz', 'y', 'yx', 'yy', 'yz', 'z', 'zx', 'zy', 'zz'}
COHESIVE_FORMULA = {'quad4': ['hex8', (0, 1, 2, 3, 4, 5, 6, 7)], 'tri3': ['wedge6', (0, 1, 2, 3, 4, 5)], 'tri6': ['wedge12', (0, 1, 2, 6, 7, 8, 3, 4, 5, 9, 10, 11)]}
DIMENSION = {'hex20': 3, 'hex8': 3, 'line2': 1, 'line3': 1, 'point': 0, 'quad4': 2, 'quad6': 2, 'quad8': 2, 'tet10': 3, 'tet4': 3, 'tri3': 2, 'tri6': 2, 'wedge12': 3, 'wedge15': 3, 'wedge16': 3, 'wedge6': 3}
ELEMENT_CONVERSIONS = {'hex20': {'hex8': [[0, 1, 2, 3, 4, 5, 6, 7]]}, 'hex8': {'hex20': [[0, 1, 2, 3, 4, 5, 6, 7, (0, 1), (1, 2), (2, 3), (0, 3), (0, 4), (1, 5), (2, 6), (3, 7), (4, 5), (5, 6), (6, 7), (4, 7)]]}, 'tet10': {'tet4': [[0, 1, 2, 3]]}, 'tet4': {'tet10': [[0, 1, 2, 3, (0, 1), (1, 2), (0, 2), (0, 3), (1, 3), (2, 3)]]}, 'wedge12': {'wedge15': [[0, 1, 2, 3, 4, 5, 6, 7, 8, (0, 3), (1, 4), (2, 5), 9, 10, 11]], 'wedge6': [[0, 1, 2, 3, 4, 5]]}, 'wedge15': {'wedge16': [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, (0, 1, 2, 3, 4, 5)]], 'wedge6': [[0, 1, 2, 3, 4, 5]]}, 'wedge16': {'wedge15': [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]], 'wedge6': [[0, 1, 2, 3, 4, 5]]}, 'wedge6': {'wedge15': [[0, 1, 2, 3, 4, 5, (0, 1), (1, 2), (0, 2), (0, 3), (1, 4), (2, 5), (3, 4), (4, 5), (3, 5)]], 'wedge16': [[0, 1, 2, 3, 4, 5, (0, 1), (1, 2), (0, 2), (0, 3), (1, 4), (2, 5), (3, 4), (4, 5), (3, 5), (0, 1, 2, 3, 4, 5)]]}}
ELEMENT_ORDER = {'hex20': 2, 'hex8': 1, 'line2': 1, 'line3': 2, 'point': 1, 'quad4': 1, 'quad6': 1, 'quad8': 2, 'tet10': 2, 'tet4': 1, 'tri3': 1, 'tri6': 2, 'wedge12': 1, 'wedge15': 2, 'wedge16': 2, 'wedge6': 1}
FACE_MAPPING = {'hex20': [('quad8', (0, 1, 5, 4, 8, 13, 16, 12)), ('quad8', (1, 2, 6, 5, 9, 14, 17, 13)), ('quad8', (2, 3, 7, 6, 10, 15, 18, 14)), ('quad8', (3, 0, 4, 7, 11, 12, 19, 15)), ('quad8', (0, 3, 2, 1, 11, 10, 9, 8)), ('quad8', (4, 5, 6, 7, 16, 17, 18, 19))], 'hex8': [('quad4', (0, 1, 5, 4)), ('quad4', (1, 2, 6, 5)), ('quad4', (2, 3, 7, 6)), ('quad4', (3, 0, 4, 7)), ('quad4', (0, 3, 2, 1)), ('quad4', (4, 5, 6, 7))], 'line2': [('point', (0,)), ('point', (1,))], 'line3': [('point', (0,)), ('point', (1,))], 'point': [], 'quad4': [('line2', (0, 1)), ('line2', (1, 2)), ('line2', (2, 3)), ('line2', (3, 0))], 'quad6': [('line3', (0, 1, 4)), ('line2', (1, 2)), ('line3', (2, 5, 3)), ('line2', (3, 0))], 'quad8': [('line3', (0, 1, 4)), ('line3', (1, 2, 5)), ('line3', (2, 3, 6)), ('line3', (3, 0, 7))], 'tet10': [('tri6', (0, 1, 3, 4, 8, 7)), ('tri6', (1, 2, 3, 5, 9, 8)), ('tri6', (2, 0, 3, 6, 7, 9)), ('tri6', (0, 2, 1, 6, 5, 4))], 'tet4': [('tri3', (0, 1, 3)), ('tri3', (1, 2, 3)), ('tri3', (2, 0, 3)), ('tri3', (0, 2, 1))], 'tri3': [('line2', (0, 1)), ('line2', (1, 2)), ('line2', (2, 0))], 'tri6': [('line3', (0, 1, 3)), ('line3', (1, 2, 4)), ('line3', (2, 0, 5))], 'wedge12': [('quad6', (0, 1, 4, 3, 6, 9)), ('quad6', (1, 2, 5, 4, 7, 10)), ('quad6', (2, 0, 3, 5, 8, 11)), ('tri6', (0, 2, 1, 8, 7, 6)), ('tri6', (3, 4, 5, 11, 10, 9))], 'wedge15': [('quad8', (0, 1, 4, 3, 6, 10, 12, 9)), ('quad8', (1, 2, 5, 4, 7, 11, 13, 10)), ('quad8', (2, 0, 3, 5, 8, 9, 14, 11)), ('tri6', (0, 2, 1, 8, 7, 6)), ('tri6', (3, 4, 5, 12, 13, 14))], 'wedge16': [('quad8', (0, 1, 4, 3, 6, 10, 12, 9)), ('quad8', (1, 2, 5, 4, 7, 11, 13, 10)), ('quad8', (2, 0, 3, 5, 8, 9, 14, 11)), ('tri6', (0, 2, 1, 8, 7, 6)), ('tri6', (3, 4, 5, 12, 13, 14))], 'wedge6': [('quad4', (0, 1, 4, 3)), ('quad4', (1, 2, 5, 4)), ('quad4', (2, 0, 3, 5)), ('tri3', (0, 2, 1)), ('tri3', (3, 4, 5))]}
INVERTED_CONNECTIVITY = {'hex20': (4, 5, 6, 7, 0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 12, 13, 14, 15), 'hex8': (4, 5, 6, 7, 0, 1, 2, 3), 'line2': (1, 0), 'line3': (1, 0, 2), 'point': (0,), 'quad4': (0, 3, 2, 1), 'quad6': (3, 2, 1, 0, 5, 4), 'quad8': (0, 3, 2, 1, 7, 6, 5, 4), 'tet10': (0, 2, 1, 3, 6, 5, 4, 7, 9, 8), 'tet4': (0, 2, 1, 3), 'tri3': (0, 2, 1), 'tri6': (0, 2, 1, 5, 4, 3), 'wedge12': (3, 4, 5, 0, 1, 2, 9, 10, 11, 6, 7, 8), 'wedge15': (3, 4, 5, 0, 1, 2, 12, 13, 14, 6, 7, 8, 9, 10, 11), 'wedge16': (3, 4, 5, 0, 1, 2, 12, 13, 14, 6, 7, 8, 9, 10, 11, 15), 'wedge6': (3, 4, 5, 0, 1, 2)}
MULTI_COMPONENT_FIELD_SUBSCRIPTS = {'full_3x3_tensor': ('xx', 'yy', 'zz', 'xy', 'yz', 'zx', 'yx', 'zy', 'xz'), 'symmetric_3x3_tensor': ('xx', 'yy', 'zz', 'xy', 'yz', 'zx'), 'vector': ('x', 'y', 'z')}
NODES_PER_ELEMENT = {'hex20': 20, 'hex8': 8, 'line2': 2, 'line3': 3, 'point': 1, 'quad4': 4, 'quad6': 6, 'quad8': 8, 'tet10': 10, 'tet4': 4, 'tri3': 3, 'tri6': 6, 'wedge12': 12, 'wedge15': 15, 'wedge16': 16, 'wedge6': 6}
ROTATED_CONNECTIVITY = {'quad4': (3, 0, 1, 2), 'quad8': (3, 0, 1, 2, 7, 4, 5, 6), 'tri3': (2, 0, 1), 'tri6': (2, 0, 1, 5, 3, 4)}
STANDARD_ELEMENT_TYPES = {'hex20', 'hex8', 'line2', 'line3', 'point', 'quad4', 'quad6', 'quad8', 'tet10', 'tet4', 'tri3', 'tri6', 'wedge12', 'wedge15', 'wedge16', 'wedge6'}
TRIANGULATED_FACES = {'quad4': [(0, 1, (0, 1, 2, 3)), (1, 2, (0, 1, 2, 3)), (2, 3, (0, 1, 2, 3)), (3, 0, (0, 1, 2, 3))], 'quad6': [(0, 4, (4, 5)), (4, 1, (4, 5)), (1, 2, (4, 5)), (2, 5, (4, 5)), (5, 3, (4, 5)), (3, 0, (4, 5))], 'quad8': [(4, 7, 0), (5, 4, 1), (6, 5, 2), (7, 6, 3), (7, 4, (4, 5, 6, 7)), (4, 5, (4, 5, 6, 7)), (5, 6, (4, 5, 6, 7)), (6, 7, (4, 5, 6, 7))], 'tri3': [(0, 1, 2)], 'tri6': [(0, 3, 5), (1, 4, 3), (2, 5, 4), (3, 4, 5)]}
VOLUME_FORMULA = {'hex20': [1.0, ((0, 3, 4, 7), (1, 2, 5, 6)), ((0, 1, 4, 5), (2, 3, 6, 7)), ((0, 1, 2, 3), (4, 5, 6, 7))], 'hex8': [1.0, ((0, 3, 4, 7), (1, 2, 5, 6)), ((0, 1, 4, 5), (2, 3, 6, 7)), ((0, 1, 2, 3), (4, 5, 6, 7))], 'line2': [1.0, (0, 1)], 'line3': [1.0, (0, 1)], 'quad4': [0.5, (0, 2), (1, 3)], 'quad6': [0.5, (0, 2), (1, 3)], 'quad8': [0.5, (0, 2), (1, 3)], 'tet10': [0.16666666666666666, (0, 1), (0, 2), (0, 3)], 'tet4': [0.16666666666666666, (0, 1), (0, 2), (0, 3)], 'tri3': [0.5, (0, 1), (0, 2)], 'tri6': [0.5, (0, 1), (0, 2)], 'wedge12': [0.5, ((0, 3), (1, 4)), ((0, 3), (2, 5)), ((0, 1, 2), (3, 4, 5))], 'wedge15': [0.5, ((0, 3), (1, 4)), ((0, 3), (2, 5)), ((0, 1, 2), (3, 4, 5))], 'wedge16': [0.5, ((0, 3), (1, 4)), ((0, 3), (2, 5)), ((0, 1, 2), (3, 4, 5))], 'wedge6': [0.5, ((0, 3), (1, 4)), ((0, 3), (2, 5)), ((0, 1, 2), (3, 4, 5))]}
__getattr__(name)[source]

Try to find the given attribute.

This is a special Python method which gets called if the attribute cannot be found. We use to to suggest similar names in the case the user made a typo.

We also use this to alias the plural forms of the delete functions.

add_faces_to_side_set(side_set_id, new_side_set_members)[source]

Add the given faces to the side set.

The parameter ‘new_side_set_members’ should be a list of tuples of the form: * ‘(element_block_id, local_element_index, element_side_index)’

Example: >>> model.add_faces_to_side_set(1, [(2, 0, 3), (3, 0, 4)])

add_nodes_to_node_set(node_set_id, new_node_set_members)[source]

Add nodes to an existing node set.

Example: >>> model.add_nodes_to_node_set(1, [4, 5, 6, 7])

build_hex8_cube(element_block_id='auto', extents=1.0, divisions=3)[source]

Create an element block in the shape of a cuboid.

Extent defines the extent of the block in the form ‘[[minx, maxx], [miny, maxy], [minz, maxz]]’. If only one value per dimension is given, the minimum is assumed to be zero. If a single value is given, it is assumed a cube with that edge length, with min=0 for all dimensions.

Divisions is the number of divisions per dimension. This can be defined as a single number for all dimensions or as a list of 3 numbers.

calculate_element_centroids(element_field_name_prefix='centroid_', element_block_ids='all')[source]

Calculate and store the centroid of each element.

This will approximate the element centroid as the nodal average of each element and will store that value in an element field. Since a timestep must be defined in order for element fields to exist, one will be created if none exist.

By default, the centroid will be stored in the fields ‘centroid_x’, ‘centroid_y’, and ‘centroid_z’. Alternatively, a prefix can be given or a list of three strings can be given.

Example: >>> model.calculate_element_centroids()

calculate_element_field(expression, element_block_ids='all')[source]

Store an element field calculated from the given expression.

The expression may include the following variables: * ‘time’ to refer to the current time * global variables (by name) * element fields (by name)

Example: >>> model.calculate_element_field(‘pressure = (stress_xx + ‘ … ‘stress_yy + stress_zz) / -3’)

calculate_element_field_maximum(element_field_names, element_block_ids='all', calculate_location=False, calculate_block_id=False)[source]

Store an element field maximum as a global variable.

If ‘calculate_block_id=True’, also store the element block id containing the element with this value.

If ‘calculate_location=True’, also store the location of the centroid of the element with this value.

Examples: >>> model.calculate_element_field_maximum(‘eqps’) >>> model.global_variables[‘eqps_max’]

calculate_element_field_minimum(element_field_names, element_block_ids='all', calculate_location=False, calculate_block_id=False)[source]

Store an element field minimum as a global variable.

If ‘calculate_block_id=True’, also store the element block id containing the element with this value.

If ‘calculate_location=True’, also store the location of the centroid of the element with this value.

Examples: >>> model.calculate_element_field_minimum(‘eqps’) >>> model.global_variables[‘eqps_min’]

calculate_element_volumes(element_field_name='volume', element_block_ids='all')[source]

Calculate and store the volume of each element.

This will approximate the element volume. Since a timestep must be defined in order for element fields to exist, one will be created if none exist.

For two dimensional elements, this calculates the area. For one dimensional elements, this calculates the length.

Example: >>> model.calculate_element_volumes()

calculate_global_variable(expression)[source]

Store a global variable calculated from the given expression.

The expression may include the following variables: * ‘time’ to refer to the current time * global variables (by name)

Examples: >>> model.calculate_global_variable(‘time_squared = time ^ 2’) >>> model.calculate_global_variable(‘total = potential + kinetic’)

calculate_node_field(expression)[source]

Store a node field calculated from the given expression.

The expression may include the following variables: * ‘time’ to refer to the current time * global variables (by name) * node fields (by name) * model coordinates (‘X’, ‘Y’, and ‘Z’)

Example: >>> model.calculate_node_field(‘temp_C = temp_K - 273.15’)

calculate_node_field_maximum(node_field_names, element_block_ids='auto', calculate_location=False)[source]

Store a node field maximum as a global variable.

If ‘calculate_location=True’, also store the location of the node with this value.

Examples: >>> model.calculate_node_field_maximum(‘temp’) >>> model.global_variables[‘temp_max’]

calculate_node_field_minimum(node_field_names, element_block_ids='auto', calculate_location=False)[source]

Store a node field minimum as a global variable.

If ‘calculate_location=True’, also store the location of the node with this value.

Examples: >>> model.calculate_node_field_maximum(‘temp’) >>> model.global_variables[‘temp_min’]

calculate_node_set_field(expression, node_set_ids='all')[source]

Store a node set field calculated from the given expression.

The expression may include the following variables: * ‘time’ to refer to the current time * global variables (by name) * node fields (by name) * node set fields (by name) * model coordinates (‘X’, ‘Y’, and ‘Z’)

Example: >>> model.calculate_node_set_field(‘temp_C = temp_K - 273.15’)

calculate_side_set_field(expression, side_set_ids='all')[source]

Store a side set field calculated from the given expression.

The expression may include the following variables: * ‘time’ to refer to the current time * global variables (by name)

Example: >>> model.calculate_side_set_field(‘temp_C = temp_K - 273.15’)

combine_element_blocks(element_block_ids, target_element_block_id='auto')[source]

Combine multiple element blocks into a single block.

By default, the target element block id will be the smallest of the merged element block ids.

The element blocks to combine must have the same element type.

Example: >>> model.combine_element_blocks(‘all’, 1)

convert_element_blocks(element_block_ids, new_element_type)[source]

Convert elements within a block to a new element type.

convert_element_field_to_node_field(element_field_name, node_field_name='auto')[source]

Convert an element field to a node field by performing.

For each node, the value of the field at that node will be the average of the values in every element which shares that node for elements on which the field is defined.

By default, the name of the node field will be the same as the element field.

Example: >>> model.convert_element_field_to_node_field(‘temperature’)

convert_hex8_block_to_tet4_block(element_block_id, scheme='hex24tet')[source]

Convert a block of ‘hex8’ elements to a block of ‘tet4’ elements.

Side sets are updated accordingly.

Node sets are not modified.

Currently, only the ‘hex24tet’ scheme is implemented, which creates 24 ‘tet4’ element for eeach ‘hex8’ element in the original mesh.

Example: >>> model.convert_hex8_block_to_tet4_block(1)

convert_node_field_to_element_field(node_field_name, element_field_name='auto', element_block_ids='all')[source]

Convert a node field to an element field.

For each element, the value of the field at that element will be the average of the values in each node of that element.

Example: >>> model.convert_node_field_to_element_field(‘temperature’)

convert_side_set_to_cohesive_zone(side_set_ids, new_element_block_id)[source]

Convert the given side sets into a block of cohesive zone elements.

The given side set must contain faces which are internal (i.e. shared by exactly two elements). Support for the following face types is implemented: * ‘quad4’ creates ‘hex8’ cohesive elements * ‘tri3’ creates ‘wedge6’ cohesive elements * ‘tri6’ creates ‘wedge12’ cohesive elements

Example: >>> model.convert_side_set_to_cohesive_zone(1, 2)

copy_timestep(timestep, new_timestep)[source]

Create a copy of an existing timestep.

This copies all information from the old timestep including values of global variables, node fields, element fields, node set fields and side set fields.

Example: object.copy_timestep(0.0, 1.0)

count_degenerate_elements(element_block_ids='all')[source]

Return the number of degenerate elements in the given element blocks.

A degenerate element is an element which contains one or more nodes which are a duplicate of another node within the same element.

count_disconnected_blocks(element_block_ids='all')[source]

Return the number of disconnected blocks.

A disconnected block is a group of elements which are connected to each other through one or more nodes.

create_averaged_element_field(from_element_field_names, new_element_field_name, element_block_ids='all')[source]

Create an element field by averaging the given field values.

Examples: >>> model.create_averaged_element_field([‘temp_1’, ‘temp_2’], … ‘temp_avg’) >>> model.create_averaged_element_field(‘temp_*’, ‘temp_avg’)

create_displacement_field()[source]

Create the displacement field if it doesn’t already exist.

Example: >>> model.create_displacement_field()

create_element_block(element_block_id, info, connectivity=None)[source]

Create a new element block.

The nodes for the elements in the block must have already been defined.

The info list should be comprised of the following information. * ‘[element_type, element_count, nodes_per_element, 0]’

For example, the following would be valid. * ‘[“hex8”, elements, 8, 0]’

The connectivity list should be a shallow list of element connectivity and must be of length ‘element_count * nodes_per_element’.

Element blocks are unnamed when created. To name them, use the ‘rename_element_block’ function.

Example: >>> model.create_element_block(1, [‘hex8’, 0, 8, 0])

create_element_field(element_field_name, element_block_ids='all', value='auto')[source]

Create an element field on one or more element blocks.

A default value can be passed. If no default value is given, 0.0 will be used if the element field appears to be a displacement field. Otherwise, NaN will be used.

Example: >>> model.create_element_field(‘eqps’, value=0.0)

create_global_variable(global_variable_name, value='auto')[source]

Create a new global variable.

Example: >>> model.create_global_variable(‘gravitational_acceleration’, 9.8)

create_interpolated_timestep(timestep, interpolation='cubic')[source]

Create a new timestep by interpolating neighboring steps.

This does not extrapolate, so the given timestep to be interpolated must lie within the range of timesteps already defined.

By default, ‘cubic’ interpolation is used. This can be changed to ‘linear’ interpolation if desired.

Examples: >>> model.create_interpolated_timestep(0.5) >>> model.create_interpolated_timestep(0.5, interpolation=’linear’)

create_node_field(node_field_name, value='auto')[source]

Create a node field and assign it a default value.

A default value can be passed. If no default value is given, 0.0 will be used if the element field appears to be a displacement field. Otherwise, NaN will be used.

Example: >>> model.create_node_field(‘temperature’, 298.15)

create_node_set(node_set_id, node_set_members=None)[source]

Create a node side from the list of node indices.

Node sets are unnamed when created. To name them, use the ‘rename_node_set’ function.

Example: >>> model.create_node_set(1, [0, 1, 2, 3])

create_node_set_field(node_set_field_name, node_set_ids='all', value='auto')[source]

Create a node set field on the given node sets.

A default value can be passed. If no default value is given, 0.0 will be used if the element field appears to be a displacement field. Otherwise, NaN will be used.

Example: >>> model.create_node_set_field(‘temperature’, 13, 298.15)

create_node_set_from_side_set(node_set_id, side_set_id)[source]

Create a node set from a side set.

The created node set will contain all nodes used by faces in the given side set.

Example: >>> model.create_node_set_from_side_set(1, 1)

create_nodes(new_nodes)[source]

Create nodes corresponding to the given coordinate list.

The list must contain coordinate triples ‘[x, y, z]’ defined for each new node. The new nodes are assigned a local index starting with the current length of the nodes list.

Example: >>> model.create_nodes([[0.0, 0.0, 0.0], [1.0, 2.0, 3.0]])

create_side_set(side_set_id, side_set_members=None)[source]

Create a side set from the given element faces.

If the side set already exists, the faces will be added.

side_set_members should be a list of tuples of the form: * ‘(element_block_id, local_element_index, element_side_index)’

Side sets are unnamed when created. To name them, use the ‘rename_side_set’ function.

Example: >>> model.create_side_set(1, [(1, 0, 1), (1, 0, 2)])

create_side_set_field(side_set_field_name, side_set_ids='all', value='auto')[source]

Create a side set field.

By default the field will be created on all side sets. To create a side set field on a particular field, pass in ‘side_set_ids’.

To set the value of the field, pass in ‘value’. By default this is 0 for displacement fields and NaN for all other fields.

Example: >>> model.create_side_set_field(‘temperature’, 13, 298.15)

create_side_set_from_expression(side_set_id, expression, element_block_ids='all', tolerance='auto', timesteps='last_if_any', zero_member_warning=True)[source]

Create a side set from faces which satisfy an expression.

Only external element faces of the given element blocks are checked.

For example, if the model had a symmetry plane at ‘Y = 0’, the expression ‘Y == 0’ would select all element faces on this plane.

Example: >>> model.create_side_set_from_expression(1, ‘Y == 0’)

create_timestep(timestep)[source]

Create a new timestep.

Field information at the created timestep is set to the default value.

Example: >>> model.create_timestep(0)

delete_duplicate_elements(element_block_ids='all')[source]

Delete duplicate elements.

For this calculation, a duplicate element is an element which shares all of its nodes with another element.

delete_element_block(element_block_ids, delete_orphaned_nodes=True)[source]

Delete one or more element blocks.

This will also delete any references to elements in that block in side sets.

By default, this will delete any nodes that become unused as a result of deleting the element blocks. To prevent this, set ‘delete_orphaned_nodes=False’.

Examples: >>> model.delete_element_block(1) >>> model.delete_element_block([1, 3, 4])

delete_element_field(element_field_names, element_block_ids='all')[source]

Delete one or more element fields.

Examples: >>> model.delete_element_field(‘eqps’) >>> model.delete_element_field(‘all’)

delete_empty_node_sets()[source]

Delete all side sets with zero members.

Example: >>> model.delete_empty_node_sets()

delete_empty_side_sets()[source]

Delete all side sets with zero members.

Example: >>> model.delete_empty_side_sets()

delete_global_variable(global_variable_names)[source]

Delete one or more global variables.

This function may also be called by its plural form ‘delete_global_variables()’.

Examples: >>> model.delete_global_variable(‘internal_energy’) >>> model.delete_global_variable(‘all’)

delete_node_field(node_field_names)[source]

Delete one or more node fields.

Examples: >>> model.delete_node_field(‘temperature’) >>> model.delete_node_field(‘all’) >>> model.delete_node_field(‘disp_*’)

delete_node_set(node_set_ids)[source]

Delete the given node set.

This function may also be called by its plural form ‘delete_node_sets()’.

Example: >>> model.delete_node_set(1)

delete_node_set_field(node_set_field_names, node_set_ids='all')[source]

Delete one or more node set fields.

Examples: >>> model.delete_node_set_field(‘contact_pressure’, 1)

delete_side_set(side_set_ids)[source]

Delete one or more side sets.

This function may also be called by its plural form ‘delete_side_sets()’.

Examples: >>> model.delete_side_set(1) >>> model.delete_side_set(‘all’)

delete_side_set_field(side_set_field_names, side_set_ids='all')[source]

Delete one or more side set fields.

Examples: >>> model.delete_side_set_field(‘contact_pressure’, 1)

delete_timestep(timesteps)[source]

Delete one or more timesteps.

Because fields are defined on each timestep, this also deletes field values for the corresponding timestep.

Examples: >>> model.delete_timestep(0.0) >>> model.delete_timestep(‘all’)

delete_unused_nodes()[source]

Delete nodes which are not used by any elements.

Example: >>> model.delete_unused_nodes()

displace_element_blocks(element_block_ids, offset, timesteps='all', check_for_merged_nodes=True)[source]

Displace all nodes in the given element blocks.

This function operates on the displacement field rather than the model coordinate field. To operate on the model coordinates, use ‘translate_element_blocks()’.

Examples: >>> model.displace_element_blocks(1, [1.0, 2.0, 3.0]) >>> model.displace_element_blocks(‘all’, [1.0, 2.0, 3.0])

displacement_field_exists()[source]

Return ‘True’ if the displacement field exists.

Example: >>> model.displacement_field_exists()

duplicate_element_block(element_block_id, new_element_block_id, duplicate_nodes=True)[source]

Create an duplicate of the given element block.

Nodes are duplicated by default. The new element block references these duplicated nodes, not the original ones.

Example: >>> model.duplicate_element_block(1, 2)

element_block_exists(element_block_id)[source]

Return ‘True’ if the given element block exists.

Examples: >>> model.element_block_exists(1) >>> model.element_block_exists(‘block_name’)

element_field_exists(element_field_name, element_block_ids='all')[source]

Return ‘True’ if the element field exists on the element blocks.

Examples: >>> model.element_field_exists(‘eqps’)

export(filename, *args, **kwargs)[source]

Export a model based on the filename extension.

The following extensions will call the appropriate functions: * ‘WRL –> export_wrl_model’ * ‘STL –> export_stl_file’ * ‘E, G, EXO –> export_model’

Arguments are passed through to the export function.

Examples: >>> model.export(‘result.e’) >>> model.export(‘result.stl’) >>> model.export(‘result.wrl’, ‘eqps’)

export_model(filename='output_exomerge.e', element_block_ids='all', timesteps='all', side_set_ids='all', node_set_ids='all', global_variable_names='auto', node_field_names='auto', element_field_names='auto', side_set_field_names='auto', node_set_field_names='auto')[source]

Export the current model to an ExodusII file.

Examples: >>> model.export_model(‘output.g’)

export_stl_file(filename, element_block_ids='all', displacement_timestep='auto')[source]

Export the exterior of the model to an STL file.

By default, if timesteps exist and a displacement field exists, the displacements at the last timestep will be applied.

Example: >>> model.export_stl_file(‘mesh_surface.stl’)

export_wrl_model(filename, node_field_name, element_block_ids='all', timestep='last', field_range='auto', intervals=9, colorspace='rgb', displacement_timestep='auto', export_exodus_copy=True)[source]

Export the exterior of the model to a colored WRL file.

The WRL file format is used by 3D printing software.

Example: >>> model.export_wrl_model(‘colored_eqps_model.wrl’, ‘eqps’)

get_all_element_block_names()[source]

Return a list of all element block names.

Example: >>> model.get_all_element_block_names()

get_all_node_set_names()[source]

Return a list of all node set names.

get_all_side_set_names()[source]

Return a list of all side set names.

get_closest_node_distance()[source]

Return the distance between the two closest nodes.

get_connectivity(element_block_id='auto')[source]

Return the connectivity list of an element block.

Example: >>> model.get_connectivity(1)

get_element_block_centroid(element_block_ids, element_volume_field_name=None, element_centroid_field_names=None)[source]

Return the centroid of the given element blocks.

Example: >>> model.get_element_block_centroid(‘all’) [1.0, 2.0, 3.0]

get_element_block_connectivity(element_block_id='auto')[source]

Alias for ‘get_connectivity()’.

get_element_block_dimension(element_block_id)[source]

Return the dimension of elements within this element block.

If this cannot be determined, return -1.

get_element_block_extents(element_block_ids='all')[source]

Return the extents of the element blocks as a list.

The results are returned in the following format: [[min_x, max_x], [min_y, max_y], [min_z, max_z]]

get_element_block_ids()[source]

Return a list of all element block ids.

Example: >>> model.get_element_block_ids()

get_element_block_name(element_block_id)[source]

Return the given element block name.

Example: >>> model.get_element_block_names()

get_element_block_volume(element_block_ids, element_volume_field_name=None)[source]

Return the total volume of the given element blocks.

Example: >>> model.get_element_block_volume(‘all’)

get_element_count(element_block_ids='all')[source]

Return the total number of elements in the given element blocks.

Example: >>> print((’ %d elements’ % (object.get_element_count())))

get_element_edge_length_info(element_block_ids='all')[source]

Return the minimum and average element edge lengths.

Only edges within element in the specified element blocks are counted. All element blocks specified must be 3-dimensional.

The result is returned as [minimum, average].

get_element_field_names(element_block_ids='all')[source]

Return a list of all element field names.

By default, this returns element fields which are defined on any element block. To return fields which are defined on a particular element block, pass an element block id.

Examples: >>> model.get_element_field_names() >>> model.get_element_field_names(1)

get_element_field_values(element_field_name, element_block_id='auto', timestep='last')[source]

Return the list of element field values.

The actual list of values is returned, so any modifications to it will be stored in the model.

Examples: >>> model.get_element_field_values(‘strain’, element_block_id=1) >>> model.get_element_field_values(‘strain’, timestep=2.0) >>> model.get_element_field_values(‘strain’, … element_block_id=5, … timestep=’last’)

get_global_variable_names()[source]

Return a list of all global variable names.

Example: >>> model.get_global_variable_names()

get_input_deck()[source]

Return each line of the input deck stored in the file.

Many SIERRA applications, when running a problem, will store the input deck within the results file. This function retrieves that information, if it exists. Note that due to format restriction, the retrieved input deck may not exactly match the original file.

Example: >>> object = exomerge.import_model(‘results.e’) >>> model.get_input_deck()

get_length_scale()[source]

Return the length scale of the model.

The length scale is defined as the largest of the following: * absolute nodal coordinate component * total range in nodal coordinate component

Example: >>> model.get_length_scale()

get_node_field_names()[source]

Return a list of all node field names.

Example: >>> model.get_node_field_names()

get_node_field_values(node_field_name, timestep='last')[source]

Return the list of node field values for the given field and timestep.

This returns the actual list of values, so any modifications to the list will be retained in the model.

Examples: >>> model.get_node_field_values(‘disp_x’) >>> model.get_node_field_values(‘disp_x’, 0.0)

get_node_set_field_names(node_set_ids='all')[source]

Return a list of all node set field names.

By default, this returns node set fields which are defined on any node set. To return fields which are defined on a particular node set, pass a node set id.

Examples: >>> model.get_node_set_field_names() >>> model.get_node_set_field_names(1)

get_node_set_field_values(node_set_field_name, node_set_id='auto', timestep='last')[source]

Return the list of node set field values.

The actual list of values is returned, so any modifications to it will be stored in the model.

Examples: >>> model.get_node_set_field_values(‘contact_pressure’, node_set_id=1) >>> model.get_node_set_field_values(‘contact_pressure’, timestep=2.0) >>> model.get_node_set_field_values(‘contact_pressure’, … node_set_id=5, … timestep=’last’)

get_node_set_ids()[source]

Return a list of all node set ids.

Example: >>> model.get_node_set_ids()

get_node_set_members(node_set_id)[source]

Return the list of node indices that belong to the given node set.

Example: >>> model.get_node_set_members(1)

get_node_set_name(node_set_id)[source]

Return the name of the given node set.

get_nodes_in_element_block(element_block_ids)[source]

Return a list of all node indices used in the given element blocks.

Examples: >>> model.get_nodes_in_element_block(1) >>> model.get_nodes_in_element_block([1, 3])

get_nodes_in_side_set(side_set_id)[source]

Return a list of node indices which belong to the given side set.

Example: >>> model.get_nodes_in_side_set(1)

get_nodes_per_element(element_block_id)[source]

Return the nodes per element in the given element block.

get_side_set_area(side_set_ids)[source]

Return the total area of the given side sets.

Example: >>> model.get_side_set_area(‘all’)

get_side_set_field_names(side_set_ids='all')[source]

Return a list of all side set field names.

By default, this returns side set fields which are defined on any side set. To return fields which are defined on a particular side set, pass a side set id.

Examples: >>> model.get_side_set_field_names() >>> model.get_side_set_field_names(1)

get_side_set_field_values(side_set_field_name, side_set_id='auto', timestep='last')[source]

Return the list of side set field values.

The actual list of values is returned, so any modifications to it will be stored in the model.

Examples: >>> model.get_side_set_field_values(‘contact_pressure’, side_set_id=1) >>> model.get_side_set_field_values(‘contact_pressure’, timestep=2.0) >>> model.get_side_set_field_values(‘contact_pressure’, … side_set_id=5, … timestep=’last’)

get_side_set_ids()[source]

Return a list of all side set ids.

Example: >>> model.get_side_set_ids()

get_side_set_members(side_set_id)[source]

Return the members of a side set.

get_side_set_name(side_set_id)[source]

Return the name of a side set.

get_timesteps()[source]

Return a list of all timesteps.

Example: >>> model.get_timesteps()

global_variable_exists(global_variable_name)[source]

Return ‘True’ if the given global variable exists.

Examples: >>> model.global_variable_exists(‘timestep’)

import_model(filename, element_block_ids='all', timesteps='all', node_field_names='all', element_field_names='all', side_set_ids='all', node_set_ids='all', global_variable_names='all', node_set_field_names='all', side_set_field_names='all')[source]

Import information from an ExodusII file.

This will add to the current model in memory, so multiple calls will act to merge files. As a shortcut, one may use the ‘exomerge.import_model’ to create a new model from a file. >>> model = exomerge.import_model(‘output.e’)

By default, this will import all information from the given ExodusII results file. To import only part of a mesh file, or to load only a particular timestep, one can use the following options. >>> model.import_model(‘output.e’, element_block_ids=[1, 2]) >>> model.import_model(‘output.e’, timesteps=’last’) >>> model.import_model(‘output.e’, node_field_names=’disp_*’)

To import only the mesh without any field information, one can use the following syntax. >>> model.import_model(‘output.e’, timesteps=’none’)

Example: >>> model.import_model(‘mesh_file.g’) >>> model.import_model(‘results_file.e’)

make_elements_linear(element_block_ids='all')[source]

Convert elements in one or more element blocks to a linear type.

This will attempt to find the best element to convert to given the conversion schemes involved. If more than one element option exists for a given element type, this will choose the option that produces the fewest nodes.

make_elements_quadratic(element_block_ids='all')[source]

Convert elements in one or more element blocks to a quadratic type.

This will attempt to find the best element to convert to given the conversion schemes involved. If more than one element option exists for a given element type, this will choose the option that produces the fewest nodes.

merge_nodes(tolerance=1e-06, relative_tolerance=True, suppress_warnings=False)[source]

Merge nodes that are closer than the given tolerance.

Node fields, node sets and node set fields are updated accordingly. Using a tolerance of 0 will merge nodes at the exact same location.

If ‘relative_tolerace=True’, this will multiply the tolerance by the length scale of the model as obtained from ‘get_length_scale()’.

Examples: >>> model.merge_nodes(0) >>> model.merge_nodes()

node_field_exists(node_field_name)[source]

Return ‘True’ if the given node field exists.

Examples: >>> model.node_field_exists(‘temperature’)

node_set_exists(node_set_id)[source]

Return ‘True’ if the given node set exists.

Examples: >>> model.node_set_exists(1) >>> model.node_set_exists(‘nodeset_name’)

node_set_field_exists(node_set_field_name, node_set_ids='all')[source]

Return ‘True’ if the node set field is defined on the node sets.

Examples: >>> model.node_set_field_exists(‘contact_pressure’)

output_global_variables(filename=None, global_variable_names='all', timesteps='all')[source]

Output global variables in CSV format.

If ‘filename=None’, output will be sent to stdout. Else, it will be output to the given filename.

By default, information is output for all timesteps and all global variables. This may be changed by specifying which timesteps and variables are output.

Examples: >>> model.output_global_variables(‘variables.csv’) >>> model.output_global_variables(‘variables.csv’, timesteps=’last’)

process_element_fields(element_block_ids='all')[source]

Process element field information to create node based fields.

For element fields with 8 integration points, this takes the average. This is useful for fully integrated or selective deviatoric elements within the SIERRA/SM code.

For element fields with 9 integration points, this takes the first one. This is useful for q1p0 elements within the SIERRA/SM code.

This function is provided as a convenience for post processing hex8 elements with multiple integration points.

Example: >>> model.process_element_fields()

reflect_element_blocks(element_block_ids, point, normal, check_for_merged_nodes=True, adjust_displacement_field='auto')[source]

Reflect the specified element blocks about the given plane.

Since an element becomes inverted when it is reflected across a plane, this function will also uninvert the elements.

Example: >>> model.reflect_element_blocks(1, [0, 0, 0], [1, 0, 0])

rename_element_block(element_block_id, new_element_block_id)[source]

Change an element block id or name.

This function can be used to change either the element block id or name. If ‘new_element_block_id’ is an integer, it will change the id. If it is a string, it will change the name.

Example: >>> model.rename_element_block(1, 100) >>> model.rename_element_block(1, ‘block_1’)

rename_element_field(element_field_name, new_element_field_name, element_block_ids='all')[source]

Rename an element field.

Example: >>> model.rename_element_field(‘p’, ‘pressure’)

rename_global_variable(global_variable_name, new_global_variable_name)[source]

Rename a global variable.

Example: >>> model.rename_global_variable(‘ke’, ‘kinetic_energy’)

rename_node_field(node_field_name, new_node_field_name)[source]

Rename a node field.

Example: >>> model.rename_node_field(‘temp’, ‘temperature’)

rename_node_set(node_set_id, new_node_set_id)[source]

Change a node set id or name.

This function can be used to change either the node set id or name. If ‘new_node_set_id’ is an integer, it will change the id. If it is a string, it will change the name.

Example: >>> model.rename_node_set(1, 100) >>> model.rename_node_set(1, ‘node_group_1’)

rename_node_set_field(node_set_field_name, new_node_set_field_name, node_set_ids='all')[source]

Rename a node set field.

Example: >>> model.rename_node_set_field(‘cp’, ‘contact_pressure’)

rename_side_set(side_set_id, new_side_set_id)[source]

Change a side set id or name.

This function can be used to change either the side set id or name. If ‘new_side_set_id’ is an integer, it will change the id. If it is a string, it will change the name.

Example: >>> model.rename_side_set(1, 100) >>> model.rename_side_set(1, ‘surface_1’)

rename_side_set_field(side_set_field_name, new_side_set_field_name, side_set_ids='all')[source]

Rename a side set field.

Example: >>> model.rename_side_set_field(‘cp’, ‘contact_pressure’)

rotate_element_blocks(element_block_ids, axis, angle_in_degrees, check_for_merged_nodes=True, adjust_displacement_field='auto')[source]

Rotate all nodes in the given element blocks by the given amount.

By default, if a displacement field exists, this will also rotate the displacement field.

The rotation axis includes the origin and points in the direction of the ‘axis’ parameter.

Example: >>> model.rotate_element_blocks(1, [1, 0, 0], 90)

rotate_geometry(axis, angle_in_degrees, adjust_displacement_field='auto')[source]

Rotate the model about an axis by the given angle.

The rotation axis includes the origin and points in the direction of the ‘axis’ parameter.

Example: >>> model.rotate_geometry([1, 0, 0], 90)

scale_element_blocks(element_block_ids, scale_factor, check_for_merged_nodes=True, adjust_displacement_field='auto')[source]

Scale all nodes in the given element blocks by the given amount.

By default, if a displacement field exists, this will also scale the displacement field.

Example: >>> model.scale_element_blocks(1, 0.0254)

scale_geometry(scale_factor, adjust_displacement_field='auto')[source]

Scale the model by the given factor.

By default, if it exists, the displacement field will also be scaled accordingly.

Example: >>> model.scale_geometry(0.0254)

side_set_exists(side_set_id)[source]

Return ‘True’ if the given side set exists.

Examples: >>> model.side_set_exists(1) >>> model.node_set_exists(‘sideset_name’)

side_set_field_exists(side_set_field_name, side_set_ids='all')[source]

Return ‘True’ if the side set field exists on the side sets.

Examples: >>> model.side_set_field_exists(‘contact_pressure’)

summarize()[source]

Print a summary of the information in the current model.

Example: >>> model.summarize()

threshold_element_blocks(expression, element_block_ids='all', timestep='last', new_element_block_id=None)[source]

Delete elements which do not satisfy a condition.

The expression can contain element field values.

If ‘new_element_block_id’ is given, all elements which don’t pass the threshold will be moved into that element block. Else, they are deleted.

Example: >>> model.threshold_element_block(‘all’, ‘eqps >= 0.01’)

timestep_exists(timestep)[source]

Return ‘True’ if the given timestep exists.

Examples: >>> model.timestep_exists(0.0)

to_lowercase()[source]

Convert the names of all entities within the model to lowercase.

This affects global variables, node fields, element fields, side set fields, and node set fields.

Example: >>> model.to_lowercase()

translate_element_blocks(element_block_ids, offset, check_for_merged_nodes=True)[source]

Translate the specified element blocks by the given offset.

Example: >>> model.translate_element_blocks(1, [1.0, 2.0, 3.0])

translate_geometry(offset)[source]

Translate the model by the given offset.

Example: >>> model.translate_geometry([1, 2, 3])

unmerge_element_blocks(element_block_ids='all')[source]

Duplicate nodes to unmerge element blocks.

For elements blocks that share one or more nodes, duplicate these nodes and unmerge the element blocks. For example, if element block A and B share node 1, that node will be duplicated, block A will use the original node and block B will use the duplicate.

Node fields, node sets, and node set fields are updated accordingly.

Example: >>> model.unmerge_element_blocks()

exomerge.import_model(filename, *args, **kwargs)[source]

Load information from an ExodusII file.

This function is a wrapper around ‘ExodusModel.import_model(…)’ and is provided for convenience. Internally, this is equivalent to executing the following two statements.

>>> model = ExodusModel()
>>> model.import_model(...)

See ‘ExodusModel.import_model’ for additional information.