PCL and Customization > Accessing the Patran Database > Elements
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Elements
Element data consists of element IDs, element topology information and element connectivity information. The functions needed to import and export element data to and from a Patran database are listed in the next two sections.
Exporting Element Data
Element data can be extracted from the database for all elements in the database, for elements belonging to a specific group or for an individual element. To retrieve the data for all the elements in the database or for all elements belonging to a specified group, first determine the number of elements in the database or in the group for memory allocation purposes. To get the count of all the elements in the database, use the following function.
.
db_count_elems
( <num_elems> )
 
Output:
 
 
INTEGER
<num_elems>
The number of elements in the database.
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate a change in status or an error.
Notes:
The C name differs. It is DbFCountElems.
int DbFCountElems ( num_elems )
int 	*num_elems
To determine the number of elements belonging to a specified group, use the function below.
 
db_count_elems_in_group
( <group_id>, <num_elems> )
 
Input:
 
 
INTEGER
<group_id>
The internal ID of the group of interest. This ID can be determined by either “db_get_group_id” or “db_get_current_group_id” as described in Groups, 600.
Output:
 
 
INTEGER
<num_elems>
The number of elements belonging to the group specified by <group_id>.
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate a change in status or an error.
Notes:
The C name differs. It is DbFCountElemsInGroup.
int DbFCountElemsInGroup ( group_id, num_elems )
int 	group_id
int 	*num_elems
The following functions extract the IDs for all the elements in the database.
 
db_get_elem_ids
( <num_elems>, <elem_ids> )
 
Input:
 
 
INTEGER
<num_elems>
The total number of elements in the database.
Output:
 
 
INTEGER ARRAY
<elem_ids>
The IDs of all the <num_elems> elements in the database.
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate a change in status or an error.
Notes:
The C name differs. It is DbFGetElemIds.
int DbFGetElemIds ( num_elems, elem_ids )
int 	num_elems
int 	*elem_ids
To get the element IDs of all the elements belonging to a specific group, use the following function.
 
db_get_elem_ids_in_group
( <num_elems>, <group_id>, <elem_ids> )
 
Input:
 
 
INTEGER
<num_elems>
The number of elements belonging to the group of
interest.
INTEGER
<group_id>
The internal ID of the group of interest. This ID can be determined by either “db_get_group_id” or “db_get_current_group_id” as described in Groups, 600.
Output:
 
 
INTEGER ARRAY
<elem_ids>
The <num_elems> IDs of all the elements belonging to the group specified by <group_id>.
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate a change in status or an error.
Notes:
The C name differs. It is DbFGetElemIdsInGroup.
int DbFGetElemIdsInGroup ( num_elems, group_id, elem_ids )
int 	num_elems
int 	group_id
int 	*elem_ids
 
db_get_elem_etop
( num_elems, elem_ids, topo_codes )
 
Description:
 
 
This function will determine the topology codes of a list of elements.
Input:
 
 
INTEGER
num_elems
This value specifies the number of offsets in the input value elem_ids.
INTEGER
elem_ids(num_elems)
This value specifies the element identifier’s title to put in the packet 25 title field.
Output:
 
 
INTEGER
topo_codes
This value returns the topological codes for the list of elements. See the remarks below for more information.
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate a change in status or an error.
Error Conditions:
 
This function may return a nonzero value if an error occurs.
Remarks:
The PCL function db_get_elem_top_def() can be used to interpret the values returned by the output value topo_codes.
The FORTRAN call name for this function is DB_GET_ELEM_ETOP.
The C call name for this function is DbFGetElemEtop() and has the following prototype:
int DbFGetElemEtop(int num_elems, int * elem_ids, int *topo_codes);
Example:
None.
 
db_get_elem_top_def
(etop, etype, dimens, mxorder, nnodes, ncorner, nmidedge, nmidface, nmidbody, nedges, nfaces, nfedges, nfnodes, nacoords, nrcoords, shape, degen, edges, sense, faces, epacoords, eprcoords)
 
Description:
 
 
Gets the definition of an element topology in the database.
Input:
 
 
INTEGER
etop
The topology code of the definition created by this routine.
Output:
 
 
STRING
etype[31]
The name of the element topology.
INTEGER
dimens
Element Dimensionality.
INTEGER
mxorder
A code indicating the maximum order of any of the element edges, defined as follows:
Table 8‑1
Value
Edge Order
Number of Nodes/Edge
0
N/A
1
1
Linear
2
2
Parabolic
3
3
Cubic
4
INTEGER
nnodes
The number nodes in each new type.
INTEGER
ncorner
Number of corner nodes.
INTEGER
nmidedge
Number of midedge nodes.
INTEGER
nmidface
Number of midface nodes.
INTEGER
nmidbody
Number of midbody nodes.
INTEGER
nedges
The number of edges in the new element.
INTEGER
nfaces
The number of faces in the new element.
INTEGER
nfedges
The maximum number of edges on each face.
INTEGER
nfnodes
The maximum number of midface nodes on each face.
INTEGER
nacoords
The number of area parametric coordinates which define each node.
INTEGER
nrcoords
The number of rectangular parametric coordinates which define each node.
INTEGER
shape
Element shape code.
INTEGER
degen
The topology code of degenerate form of element. Must be a previously defined topology.
INTEGER
edges(mxorder+1, nedges)
Edge definitions - a list of IDs of all nodes on each edge, in order of increasing parametric value. A value of 0 indicates a missing node.
INTEGER
sense(faces)
Code indicating whether face normal is pointing in or out:
Table 8‑2
Value
Direction of Face Normal
-1
In
0
Face in undefined
+1
Out
INTEGER
faces(nfedges+
nfnodes, nfaces)
Face definitions - a list of NFEDGES edge IDs, followed by a list of NFNODES node IDs. A value of 0 indicates a missing edge or node.
REAL
epacoords(3)
Element area parametric coordinates of each node in the element.
REAL
eprcoords(3)
Element rectangular parametric coordinates of each node in the element.
INTEGER
<Return Value>
Integer indicating success or failure of the routine. If the routine failed, this value contains an indication of the reason.
Error Conditions:
 
13000002
Unrecoverable database error
Self explanatory.
DB_ETOP_UNDEFINED
The topology of element requested was not found.
DB_ETYPE_UNDEFINED
The type of element requested was not found.
External Dependencies and Side Effects:
None.
 
Example:
STRING  TOP_NAME
      INTEGER status
      INTEGER ELDIM, MXORDER, NCORNER, NMIDEDGE, NMIDFACE, NMIDBODY
      INTEGER NEDGES, NFACES, NFEDGES, NFNODES, NACOORDS, NRCOORDS
      INTEGER DEGEN, EDGES(_MAX_ELEM_EDGE_NODES*_MAX_ELEM_EDGES)
      INTEGER SENSE(_MAX_ELEM_FACES)
      INTEGER FACES(_MAX_ELEM_FACE_EDGES+4*_MAX_ELEM_FACES)
      REAL    EPACOORDS(3)
      REAL    EPRCOORDS(3)
      
/*
 *  Get the element shape and number of nodes
 */
 
status = DB_GET_ELEM_TOP_DEF( EL_TOP_ID, TOP_NAME, ELDIM,        @
               MXORDER, NUM_NODES, NCORNER, NMIDEDGE, NMIDFACE,        @
               NMIDBODY, NEDGES, NFACES, NFEDGES, NFNODES, NACOORDS,   @
               NRCOORDS, LSHAPE, DEGEN, EDGES, SENSE, FACES,           @
               EPACOORDS, EPRCOORDS)
      IF ( status != 0 ) THEN RETURN status
 
 
db_get_elem_use_all_node
(node_count, node_id, element_count, element_id)
Description:
 
 
This function finds the elements which nodes are all within the supplied list of node ids.
Input:
 
 
INTEGER
node_count
This value specifies the number of nodes.
INTEGER
node_id (node_account)
This array specifies the node ids.
Output:
 
 
INTEGER
element_count
This value returns the number of elements and the number of offsets in the element_id output value.
INTEGER
element_id(VIRTUAL)
This array returns the element ids.
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate an error.
Error Conditions:
 
-1
This is an internal error status condition. There is no corresponding status message in the message database.
Remarks:
Memory is allocated for the output variable within this function. If memory was allocated prior to the call, it is released prior to re-allocation. Therefore, if this function is used within a loop, there is no need to release the memory of the output variable.
Example:
INTEGER status, i_node, node_count, node_id(100), @
        i_elem, element_count, element_id(VIRTUAL)
 
node_count = 100
FOR (i_node = 1 TO node_count) 
   node_id(i_node) = i_node
END FOR
status = db_get_elem_use_all_node(node_count, node_id,  @
            element_count, element_id)
IF (0 < status) THEN
   msg_to_form(status, 4, 0, 0, 0.0, ““)
ELSE
   IF (0 > status) THEN
      /* Error information already displayed */
   ELSE
      write_line(“element_count =”, element_count)
      FOR (i_elem = 1 TO element_count)
         write_line(“element_id(“, i_elem, ”) =”, @
                    element_id(i_elem))
      END FOR
   END IF
END IF
 
To extract the IDs of the nodes associated to a list of elements or just a single element, use the function below.
.
db_get_nodes_for_elems
( <num_elems>, <max_connect>, <elem_ids>, <connectivity> )
 
Input:
 
 
INTEGER
<num_elems>
The number of elements input to this function.
INTEGER
<max_connect>
The maximum number of nodes associated with any one of the input elements.
INTEGER ARRAY
<elem_ids>
The IDs of the <num_elems> elements input to this function.
Output:
 
 
INTEGER ARRAY
<connectivity>
A <max_connect>x<num_elems> array containing the IDs of all the nodes associated with each of the input element. The nodes are listed in standard Patran element connectivity ordering and each row is blank filled. For example, if there were two elements (a two noded bar and a four noded plate) then the connectivity array would be: [BarNodeI, BarNodeJ, 0, 0, PlateNodeI, PlateNodeJ, PlateNodeK, PlateNodeL].
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate a change in status or an error.
Notes:
The C name differs. It is DbFGetNodesForElems.
int DbFGetNodesForElems ( num_elems, max_connect, elem_ids, connectivity )
int 	num_elems
int 	max_connect
int 	*elem_ids
int 	*connectivity
Importing Element Data
The function used to import element data into a database is described below.
.
db_create_elems
( <num_elems>, <max_connect>, <topo_codes>, <geom_type>, <geom_id>, <connectivity>, <group_id>, <elem_ids>, <exist_elem> )
 
Input:
 
 
INTEGER
<num_elems>
The number of elements to be added to the database.
INTEGER
<max_connect>
The maximum number of nodes associated with any one of the input elements.
INTEGER ARRAY
<topo_codes>
A <num_elems> array containing the topology codes associated with all of the input elements. These codes can be determined using the functions described in Patran Element Topology Codes (p. 613).
INTEGER ARRAY
<geom_type>
A <num_elems> array containing the geometry type each input element is to be associated with:
0 = no geometry association
2 = associated with a curve
3 = associated with a surface
4 = associated with a solid
INTEGER ARRAY
<geom_id>
A <num_elems> array containing the IDs of the geometry to which each element is associated. Zero if no geometry association exists.
INTEGER ARRAY
<connectivity>
The <max_connect>x<num_elems> array containing the IDs of all the nodes associated with each of the input element. The nodes are listed in standard Patran element connectivity ordering and each row is blank filled. For example, if there were two elements (a two noded bar and a four noded plate) then the connectivity array would be: [BarNodeI, BarNodeJ, 0, 0, PlateNodeI, PlateNodeJ, PlateNodeK, PlateNodeL].
INTEGER
<group_id>
The internal ID of the group to which these elements are to be added. The ID of a group can be determined by either “db_get_group_id” or “db_get_current_group_id” as described in Groups, 600.
INTEGER ARRAY
<elem_ids>
A <num_elems> array containing the IDs of all the elements to be added to the database.
Output:
 
 
INTEGER
<exist_elem>
The ID of the first duplicate element found. Zero if no duplicates were found.
INTEGER
<Return Value>
This function returns a value of 0 when executed successfully and a non zero value to indicate a change in status or an error.
 
Notes:
The C name differs. It is DbFCreateElems.
int DbFCreateElems ( num_elems, max_connect, topo_codes, geom_type, geom_id,
	connectivity, group_id, elem_ids, exist_elem )
int 	num_elems
int 	max_connect
int 	*topo_codes
int 	*geom_type
int 	*geom_id
int 	*connectivity
int 	group_id
int 	*elem_ids
int 	*exist_elem