Python Manual Pages 5
Python Manual Pages 5
PyPost References
Synopsis
Float, Float, Float node_displacement(Integer index)
Arguments
index Node index number
Description
Return the values of the nodal displacement at node index if available. The node_displacements method should
be called prior to calling the node_displacement method to make sure that nodal displacements are available.
This method returns three floats.
Also See
node_displacements
Example
p = post_open(‘c07_job1.t19’)
p.moveto(1)
n = p.nodes()
have_disp = p.node_displacements()
if have_disp:
for i in range(0,n):
x,y,z = p.node_displacement(i)
61 Marc Python Reference
Synopsis
Integer node_displacements()
Arguments
None
Description
This method should be used prior to calling the node_displacement method to determine if nodal displacements
are available. Returns 1 if nodal displacements are available; 0 otherwise.
Example
# print the name of each scalar label
p = post_open(’c07_job1.t19’)
p.moveto(1)
if p.node_displacements() :
print "Nodal displacements available"
CHAPTER 2 62
PyPost References
Synopsis
Integer node_id(Integer node)
Arguments
node The node index number
Description
Returns ID of node at index node.
Example
p = post_open(‘c08_job1.t19’)
# print the id’s of each node
p.moveto(0)
n = p.nodes()
for i in range(0,n):
print ‘Node ‘,i,’ has id ‘, p.node_id(i)
63 Marc Python Reference
Synopsis
Float node_scalar(Integer index, Integer scalar)
Arguments
index Node index number
scalar Scalar index number
Description
Return the value of a particular node scalar scalar at a particular node index.
This method returns a float.
Example
# get each scalar for node at index 4
f = [ ]
p = post_open(‘c07_job1.t19’)
p.moveto(1)
n = p.node_scalars()
id = node_id(4)
print ‘node scalars for node id ‘,id
for i in range(0,n):
f.append(p.node_scalar(4, i))
print ‘scalar ‘,f[i]
CHAPTER 2 64
PyPost References
Synopsis
Integer node_scalars()
Arguments
None
Description
Returns the number of node scalars available.
Example
# print the name of each scalar label
p = post_open(‘c07_job1.t19’)
p.moveto(1)
n = p.node_scalars()
for i in range(0, n):
print p.node_scalar_label(i)
65 Marc Python Reference
Synopsis
String node_scalar_label(Integer index)
Arguments
index Scalar index number
Description
Return the name of node scalar index.
This method returns a string.
Example
# print the name of each scalar label
p = post_open(‘c07_job1.t19’)
p.moveto(1)
n = p.node_scalars()
for i in range(0, n):
print p.node_scalar_label(i)
CHAPTER 2 66
PyPost References
Synopsis
Integer node_sequence(Integer node)
Arguments
node The node ID
Description
Returns the index number of node with ID node. This is the inverse of the node_id method.
Example
p = post_open(‘c08_job1.t19’)
p.moveto(0)
# print the index of each node
n = p.nodes()
for i in range(0,n):
print ‘Node Id ‘,i,’ has index ‘, p.node_sequence(i)
67 Marc Python Reference
Synopsis
PyVector node_vector(Integer index, Integer nv)
Arguments
index Node index number
nv Vector index number
Description
Return the vector of a particular node vector nv at a particular node index.
This method returns a PyVector.
Example
# get each vector for node 4
p = post_open(‘c07_job1.t19’)
p.moveto(1)
n = p.node_vectors()
for i in range(0,n):
v = p.node_vector(4, i)
print ‘Vector ‘,i,’ is ‘, v.x, v.y, v.z
CHAPTER 2 68
PyPost References
Synopsis
Integer node_vectors()
Arguments
None
Description
Returns the number of node vectors available.
Example
# print the name of each vector label
p = post_open(‘c07_job1.t19’)
p.moveto(1)
n = p.node_vectors()
for i in range(0, n):
print p.node_vector_label(i)
69 Marc Python Reference
Synopsis
String node_vector_label(Integer index)
Arguments
index Vector index number
Description
Return the name of node vector index.
This method returns a string.
Example
# print the name of each vector label
p = post_open(‘c07_job1.t19’)
p.moveto(1)
n = p.node_vectors()
for i in range(0, n):
print p.node_vector_label(i)
CHAPTER 2 70
PyPost References
Synopsis
PyPost post_open(String filename)
Arguments
filename Post file name.
Description
This method opens the specified post file and returns a PyPost object. This is the first PyPost routine that a Python
script should call. A call to moveto( ) should follow to force a reading of the increment data at the first increment
on the post file.
Members
position - current increment position
filename - the post file name
revision - the revision of the post file
The following members are updated when the moveto method is called:
Example
p1 = post_open(‘e7x14_solver0.t19’)
p1.moveto(0)
p2 = post_open(‘e7x14_solver1.t19’)
p2.moveto(0)
print ‘Comparing ‘,p1.filename, ‘ to ‘,p2.filename
71 Marc Python Reference
Synopsis
PyPostSet set(int nset)
Arguments
nset The set index number
Description
Returns a PyPostSet object containing the set data for set nset in the models.
Members
name - set name
type - set type
len - number of items in the set
items - list of data that comprise the set
Example
p = post_open(‘c08_job1.t19’)
p.moveto(0)
n = p.sets()
for i in range(0,n):
s = p.set(i)
print ‘Name:’,s.name, ‘Type: ‘,s.type
for j in range(0,s.len):
print ‘Item:’,j, ‘Value: ‘,s.items[j]
CHAPTER 2 72
PyPost References
Synopsis
Integer sets()
Arguments
None
Description
Returns the number of sets in the post file.
Example
p = post_open(‘c07_job1.t19’)
p.moveto(0)
n = p.sets()
73 Marc Python Reference
Synopsis
String title( )
Arguments
None
Description
Returns the title of the model stored in the post file.
This method returns a string.
Example
# print the title
p = post_open(‘c08_job1.t19’)
print ‘Title: ‘,p.title()
CHAPTER 2 74
PyPost References
Synopsis
String version( )
Arguments
None
Description
Return the version string of the PyPost module.
This method returns a string.
Example
print ‘PyPost version is ‘,version()
p = post_open(‘c08_job1.t19’)
Appendix A
Introduction
This chapter describes the Arithmetic and Database function supported by Mentat. If the argument to any function is
shown in capital letters (such as ARGn), then the argument is an index and may be negative; in which case, the entities
are counted in reverse order (i.e., ARGn = -1 would refer to the last item). A good example of the usage of these
functions can be found in the Marc User’s Guide, Chapter 31 procedure file. If the argument to a database function is
in lower case (such as argn), then the value is an ID, such as a node ID or an element ID unless otherwise described.
Arithmetic Functions
The following are the Marc Mentat Arithmetic Functions which can be used in the py_get_float or py_get_int
functions or in a formula.
Database Functions
The following are the Mentat Database Functions which can be used in the py_get_float, py_get_int, or
py_get_string functions.
Note that the database functions may also be used as the argument to many commands. For example:
*remove_elements element_id(-1)
would remove the last element of the model. To use numeric values in a string based command (such as
*job_title), a PARAMETER needs to be created from the database function and then used in the string command.
For example:
*eval_define num nnodes()
*job_title Model with $num nodes
will create an evaluated parameter named num using the nnodes( ) database function, and then use that in the
*job_title command (note the use of the $ to signify it is the name of a parameter). The job title for the CONTACT
demo would appear as:
Model with 72 nodes
mater_type(arg1) Material type for material named arg1. If arg1 is empty, then it uses the
current material.
mater_nsubmats(arg1) Number of submaterials of material named arg1, or of the current
material is arg1 is empty. The material must be a composite, mixture or
rebar material.
mater_vsubmat_name(arg1,arg2) Name of submaterial number arg2 of materal named arg1, or of the
current material if arg1 is empty. Material arg1 (or the current material
if arg1 is empty) must be a composite, mixture or rebar material.
mater_vsubmat_opt(arg1,arg2,arg3) Option string for the option named arg3 for submaterial number arg2 of
material named arg1, or of the current material if arg1 is empty. Material
arg1 (or the current material if arg1 is empty) must be a composite,
mixture or rebar material. Option argument uses same syntax as in the
*mater_submat_option command.
Example:
mater_vsubmat_opt(material3,5,general:thickdir)
CHAPTER A 98
Arithmetic and Database Functions
mater_vsubmat_par_table(arg1,arg2,arg3) Returns the parameter table name for the parameter named arg3 for
submaterial number arg2 or the material named arg1, or of the current
marterial if arg1 is empty. Material arg1 (or the current material if arg1
is empty) must be a composite, mixture or rebar material. Parameter
argument uses same syntax as in the
*mater_submat_param_table command.
mater_fsubmat_name(arg1,arg2) Name of submaterial arg2 of material named arg1, or of the current
marterial if arg1 is empty. Material arg1 (or the current material if arg1
is empty) must be an interface, gasket, pshell or pyrolysis material. The
submaterial argument arg2 takes the same values as the first argument
to the *mater_submat_set_mater command.
Example:
mater_fsubmat_name(material3,bend)
mesh_par(arg1) Meshing parameter value named arg1.
Example:
mesh_par(qt_max_elements)
Valid parameters:
angle_cylindrical_part, attempts, axis_orientation,
base_element_size_<x|y|z>, boundary_refine_level,
boundary_refine_tolerance, box_<1...10>_max_<x|y|z>,
box_<1...10>_min_<x|y|z>, box_<1...10>_active,
box_<1...10>_type, box_<1...10>_level, critical_ring_angle,
coarsening_level, coon_representation, curvature_tolerance,
edge_detection, edge_angle, edge_length, el_gap, edge_tolerance,
enhance_mode, hex_elements, gap, grid_type, in_rat, mesher_type,
self_contact, shrink_factor, ties, write_extended
99 Marc Python Reference
Utility Functions
The following are the Mentat Utility Functions which can be used in the py_get_float, py_get_int, or
py_get_string functions.
Set Functions
The following are the Mentat Set functions which can be used in a call to the py_get_float or py_get_int
functions. The set_name and set_type functions return a string and must be used in a call to the
py_get_string function.