pyfem.util package

Submodules

pyfem.util.BaseModule module

class BaseModule(props)[source]

Bases: object

type
def get_nested_attr(obj, attr_path, default=None):

“”” Access a nested attribute in an object hierarchy.

Parameters: - obj: The base object - attr_path: A string of dot-separated attribute names (e.g., “bar.foo.y”) - default: The value to return if any attribute in the chain doesn’t exist

Returns: - The value of the nested attribute, or the default if any attribute is missing “”” try:

for attr in attr_path.split(‘.’):

obj = getattr(obj, attr)

return obj

except AttributeError:

return default

# Example usage: # Assuming x.bar.foo.y exists value = get_nested_attr(x, “bar.foo.y”, default=”Attribute not found”) print(value)

writeHeader(cycle=None)[source]
writeFooter(globdat)[source]

pyfem.util.BezierShapeFunctions module

pyfem.util.dataStructures module

cleanVariable(a)[source]
class solverStatus[source]

Bases: object

increaseStep()[source]
class Properties(dictionary={})[source]

Bases: object

store(key, val)[source]
class GlobalData(nodes, elements, dofs)[source]

Bases: Properties

readFromFile(fname)[source]
printNodes(fileName=None, inodes=None)[source]
getData(outputName, inodes)[source]
resetNodalOutput()[source]
close()[source]
class elementData(elstate, elDstate)[source]

Bases: object

pyfem.util.fileParser module

containsValue(db, val)[source]

Addition of two numbers

Parameters:
  • db (integer) – a

  • val (integer) – btted

Returns:

new value

Return type:

integer

cleanVariable(a)[source]
isNodeDof(nodeDof)[source]
decodeNodeDof(nodeDof, nodes)[source]
getType(a)[source]
storeValue(db, key, a)[source]
readItem(l1, db)[source]
readBlock(ln, db)[source]
fileParser(fileName)[source]
deepFileParser(fileName, db)[source]
class nodeTable(label, subLabel='None')[source]

Bases: object

readNodeTable(fileName, label, nodes=None)[source]

pyfem.util.itemList module

class itemList[source]

Bases: dict

Class to construct a list of items that have a coninuous local number, and a global ID.

add(ID: int, item)[source]

Adds an item with an ID to the list. This item will be stored in the list.

Parameters:
  • ID (int) – the ID of the item to be stored.

  • item – the value(s) of the item to be stored.

get(IDs)[source]

Returns the index / indices of an ID or list of IDs of items in the list.

Parameters:
  • IDs (list[int]|int,optional) – the ID/IDs. If ommited, a list with all indces

  • returned. (will be)

Returns:

a list with the indices. In the case of a single ID, this list has length 1.

Return type:

list[int]

getIndices(IDs: list[int] | int = -1) list[int][source]

Returns the index / indices of an ID or list of IDs of items in the list.

Parameters:
  • IDs (list[int]|int,optional) – the ID/IDs. If ommited, a list with all indces

  • returned. (will be)

Returns:

a list with the indices. In the case of a single ID, this list has length 1.

Return type:

list[int]

findID(index: int) int[source]

Returns the ID of an index in the list.

Parameters:

index (int) – the index of the item

Returns:

the ID of the item

Return type:

int

pyfem.util.kinematics module

class Kinematics(nDim: int, nStr: int)[source]

Bases: object

Class that contains the kinematic state of a material point, i.e. strain and deformation gradient.

Parameters:
  • nDim (int) – the number of spatial dimensions of the problem (2 or 3)

  • nStr (int) – the number of strain components (2, 3 or 6)

pyfem.util.logger module

setLogger(props: dict)[source]

Creates a logger for the current analysis with a given format and level.

Parameters:

props (dict) – A dictionary containing the input file of the problem.

Returns:

an instance of the logger.

Return type:

logger

getLogger()[source]

Function that returns an instance of the active logger.

Parameters:

None

Returnslogger: an instance of the active logger.

pyfem.util.plotUtils module

plotCurve(output: ndarray) None[source]

Plots a curve based on the given output data points.

Parameters:

output (List[Tuple[float, float]]) – A list of (x, y) data points to plot.

Returns:

None

plotTime(t: float) str[source]

Formats a given time duration into a human-readable string.

Parameters:

t (float) – Time duration in seconds.

Returns:

A formatted string representing the time in seconds, minutes, or hours.

Return type:

str

pyfem.util.shapeFunctions module

pyfem.util.transformations module

pyfem.util.utilFunctions module

macauley(x: float) float[source]

Function that performs the macaulay operation to a variable. The macaulay operation returns the exact same value when that value is positive and returns zero when the values is negative.

Parameters:

x (float) – The input to the function

Returns:

The macauley value.

Return type:

float

sign(x: float) float[source]

Function that returns the sign of a value

Parameters:

x (float) – The input to the function

Returns:

the sign (-1.0 or 1.0).

Return type:

float

pyfem.util.vtkUtils module

storeNodes(grid, globdat)[source]
storeElements(grid, globdat, elementGroup='All')[source]
storeDofField(grid, data, globdat, dofTypes, label)[source]
storeDofFields(grid, data, globdat)[source]
storeNodeField(grid, data, globdat, name)[source]
storeElementField(grid, data, globdat, name)[source]
setCellNodes(cell, elemNodes)[source]
insertElement(grid, elemNodes, rank, family)[source]

Inserts an element

insert2Dcontinuum(grid, elemNodes)[source]
insert3Dcontinuum(grid, elemNodes)[source]
insert2Dinterface(grid, elemNodes)[source]
insert3Dinterface(grid, elemNodes)[source]
insert2Dsurface(grid, elemNodes)[source]
insert3Dsurface(grid, elemNodes)[source]
insertBeam(grid, elemNodes)[source]
insertShell(grid, elemNodes)[source]

Module contents