Professional Documents
Culture Documents
Advanced Post-Processing With The FEMAP API: Patrick Kriengsiri, Femap Development
Advanced Post-Processing With The FEMAP API: Patrick Kriengsiri, Femap Development
Introduction
How Output is Accessed in the
FEMAP Database
Attached vs. Internalized Results
Accessing Results via the API
Output Processing
Creating Custom Output
Importing Custom Output Data
Controlling Output Display
This presentation will cover post-processing using the FEMAP API; a working
knowledge of the FEMAP API workings is recommended. Topics covered in this
presentation do not represent the entire scope of what is capable – for that, see
the FEMAP API Reference Manual.
If at any time you would like further expansion on a topic, please feel free to ask.
Info
About your presenter – Patrick Kriengsiri is a FEMAP developer based out
of Atlanta. Prior to joining the FEMAP team, he was a consulting engineer
for a Siemens PLM VAR. His background is in aircraft stress analysis.
* Email: patrick.kriengsiri@siemens.com
Phone: 404-353-6596
OutputSet
ID = Output Set ID
Set ID = 1
Attributes…
FEMAP
Output
Database
ID = Output Vector ID
Attributes…
.Value(Entity) = result
Unrestricted © Siemens AG 2013 All rights reserved.
Page 4 Siemens PLM Software
Attached vs. Internalized Results
FEMAP v11.0 introduced the option to store results data internally within the
database or access the results externally.
When results are stored internally, the database size grows accordingly:
Translator Translator
FEMAP
Result Data
Result Data
Result Data
Result Data
Result Data
Result Data
Output Set
Output Set
Output Set
Output Set
Output Set
Output Set
Model
Data
With attached results, an index is created and stored within the FEMAP database
that references locations within the external results file.
Translator
Translator
FEMAP Index
Model Index
Data
Info
Any number of results files may be referenced. Additionally, internalized
* and attached results may be mixed, even within a single output set.
Info
Programmatically, there is no difference between accessing internalized results or
* attached results. All the management is transparently handled by FEMAP
Caution
When exporting a model to a pre-v11 neutral file, attached results will not
! be translated; they must be internalized first.
Output selection through the API can be done through the use of the Set
selection methods, however it’s much more efficient to use the
feSelectOutput and feSelectOutputSets (v11+) application object
methods.
feSelectOutputSets
( dlgTITLE, pOutputSets )
STRING dlgTitle Dialog title
OUT – OBJECT pOutputSets Set objects containing selected sets
Info
feSelectOutputSets will return failure codes if the user cancels out of the dialog
* (FE_CANCEL) or no output sets are available for selection (FE_NOT_EXIST)
Info
These output selection methods return FEMAP Sets – this is the preferred method for
* dealing with multiple output sets / vectors (rather than with Arrays)
feSelectOutput
( dlgTITLE, nBaseOutputSetID, limitOutputType, limitComplex,
limitToEntity, includeCorner, pOutputSets, pOutputVecs )
STRING dlgTitle Dialog title
INT4 nBaseOutputSetID Output set used to populate vectors
INT4 limitOutputType All / displacement / stress / strain / etc.
INT4 limitComplex Magnitude / Phase / Real / Imaginary / Any
INT4 limitToEntity Nodes / Elements / Any
BOOL includeCorner Include corner values
OUT – OBJECT pOutputSets Set objects containing selected sets
OUT – OBJECT pOutputVecs Set objects containing selected vectors
Info
feSelectOutput will return failure codes if the user cancels out of the dialog
* (FE_CANCEL) or no output sets are available for selection (FE_NOT_EXIST)
feSelectOutput feSelectOutputSets
Info
The feSelectOutput method is available in all recent versions of the FEMAP
* API, however it was re-written in v11 to be easier to use and more robust.
Example: feSelectOutput()
Sub Main
Dim App As femap.model
Set App = feFemap()
End Sub
Info
When programming with VB6 / VBA, the “Set” instruction doesn’t have to be used prior
* to passing the set object to this method, however it doesn’t hurt.
Info
Enums for the entity type argument can be either nodes (FT_NODE) or
* elements (FT_ELEM). To avoid filtering the vectors, specify 0.
Unrestricted © Siemens AG 2013 All rights reserved.
Page 11 Siemens PLM Software
Accessing Results via the API
Like all other FEMAP objects, Output data can be “get” from the database and
“put” with a new ID/SetID. A new relationship between the output vector and
output set is automatically created.
OutputSet1 Output
ID = Output Vector ID
Output
ID = Output Set ID
SetID
ID==Output
Output Set ID ID
Vector
Output
Set ID = 1 SetAttributes…
ID==Output
ID OutputVector
Set IDID
SetAttributes…
ID = Output
.Value(Entity) = resultSet ID
Attributes… Attributes…
.Value(Entity) = result
.Value(Entity) = result
The OutputSet object contains data relevant to a given output set / time step /
etc. and can also be used to create output vector objects
Creation:
Dim fOS As femap.OutputSet
Set fOS = app.feOutputSet
Properties:
Property Description
Sub Main
Dim App As femap.model
Set App = feFemap()
Continued…
fsOut.Reset()
While fsOut.Next()
fOS.Get( fsOut.CurrentID )
App.feAppMessage( FCM_COMMAND, "Output Set Value: " + _
Format$(fOS.Value, "0.00") )
Wend
End Sub
Results data is “stored” in the database in Output objects and can be accessed
through these objects. There is no difference in the usage of the objects between
attached results or internalized results.
The ID property of the Output object is the vector ID; the SetID property is
equal to the output set. Output objects can be “get” from the database in one of
two ways:
Manual:
Dim fOV As femap.Output
Set fOV = App.feOutput
With this method the user must ensure that the output vector is in sync with the
output set.
Unrestricted © Siemens AG 2013 All rights reserved.
Page 17 Siemens PLM Software
Output Vector (Output) Object
Accessing the output vector via the output set Vector method ensures that
vector data is always associated with the output set of interest. Note that when
using VBA, the Set instruction is used when using the vector method rather than
with the feOutput method.
Properties:
Property Description
BOOL nonlinear Flag indicating vector is nonlinear
REAL8 maxval Maximum value in vector
REAL8 minval Minimum value in vector
REAL8 absmaxval Max absolute
INT4 maxvalID ID of maximum value
INT4 minvalID ID of minimum value
REAL8 Value[1..n] Result quantity; array index is the ID of
the node or element
Output data can be accessed directly through the Value property of the output
vector method, but generally speaking it’s much easier and faster to use the
“helper” methods to access the data in bulk. Output objects still need to be “get”
from the database prior to using these methods.
GetOutputListAtSet:
Info
The methods GetScalarAtNode and GetScalarAtElem exist and are functionally
* identical to GetOutputListAtSet, however there is no default value argument.
Tip
Similar methods exist for specifying entity IDs via arrays, however the use
of the set method will work best with other API calls.
GetVectorAtNodeSet:
GetOutputListAtSet ( idSET, x, y, z )
INT4 idSET ID of FEMAP Set that contains entity IDs
OUT - REAL8 x[n], y[n], z[n] Vector values at node
GetElemWithCornerSet:
GetOutputListAtSet ( idSET, maxcorner, centroid, c1, c2, c3,
c4, c5, c6, c7, c8 )
INT4 idSET ID of FEMAP Set that contains entity IDs
OUT – INT4 maxcorner ID of the max corner for this vector type
OUT – REAL8 centroid[n] Centroidal values
OUT – REAL8 c1[n] … c8[n] Corner values 1-8. See maxcorner for
highest corner used
Info
In nearly all cases, nodal result data returned, regardless of the method
* used, will be in the global rectangular coordinate system.
Sub Main
Dim App As femap.model
Set App = feFemap()
fOS.Get(1)
Set fOV = fOS.Vector( 7033 )
fsElem.AddRange( 1, 50, 1 )
fsElem.GetArray( nArr, ents)
End Sub
Notionally, the Results Browsing Object is very similar to the FEMAP Data Table:
The FEMAP Results Browsing Object is a read-only object. Its primary function is
to access a “table” of data, however it can also replicate many of the output set /
vector querying methods of the OutputSet and Output objects. Unlike the Output
object, the Results Browsing Object allows for access to results from many
different output sets and vectors via a single API call.
Info
In most cases, the Results Browsing Object can be used as a direct
* replacement for the OutputSet and Output objects
Caution
Except in rare circumstances, the Results Browsing Object SHOULD NOT
! be used to access results one-at-a-time; performance may be poor.
Object Creation:
Populate
Specify
Required
Data /
Add Entities
Columns
Create
Results
Browsing
Object
The info query methods of the Results Browsing Object are similar to the
properties of the OutputSet and Output objects.
Info
If using the Results Browsing Object to query information regarding an
* output set out output vector, it none of the setup methods need to be called.
Unrestricted © Siemens AG 2013 All rights reserved.
Page 28 Siemens PLM Software
FEMAP Results Browsing Object
Results Set and Result Vector Information Query
Miscellaneous Methods:
Info
Any number of Results Browsing Objects may be used, or a single object
* can be reused.
While fsOut.Next()
fr.SetInfo( fsOut.CurrentID, enAP, enAT, dVal )
App.feAppMessage( FCM_COMMAND, "Output Set Value: " + _
Format$(dVal, "0.00") )
Wend
End Sub
If using the Results Browsing Object to query actual output data, the object must
be fist set up to receive the data – this involves specifying the output sets and
vectors as well as specifying where data should be recovered.
Adding Columns:
.AddColumn( nSetID, nVectorID, bAddComponentsCorners,
nColumnsAdded, nColumnIndices )
INT4 nSetID Output set ID
INT4 nVectorID Vector ID
BOOL bAddComponentsCorners Add related vectors to specified vector
OUT – INT4 nColumnsAdded Number of columns added to RBO
OUT – INT4 nColumnIndices[n] Column indexes of added columns
RETURN – FE_INVALID Populate has already been called
RETURN – FE_NOT_EXIST Specified output set / vector does not exist
RETURN – FE_BAD_TYPE Specified vector is of an incompatible type
RETURN – FE_FAIL Column can not be added
Unrestricted © Siemens AG 2013 All rights reserved.
Page 32 Siemens PLM Software
FEMAP Results Browsing Object
Setup Methods
Specifying Entities:
Info
Info
Caution When a Results Browsing Object is Populated, unless the DataNeeded() method is called,
! results for all entities are added. With large amounts of data, this can result in reduced
performance, so limit the data when possible.
Once the Results Browsing Object has been set up with columns containing
output sets and output vectors and rows containing entity IDs, the Populate
method needs to be called to load the object with results data.
Populate Methods:
.Populate()
RETURN – FE_INVALID Object has already been populated
RETURN – FE_NOT_AVAILABLE No columns have been added to the RBO
RETURN – FE_BAD_DATA Unable to populate with given entities / vecs
Info
After a table has been populated, additional columns cannot be added.
* Additionally, it may not be “repopulated”; to reuse the object, call .Clear()
Tip
By default, the value returned for “non-existing” values is 0.0. This value
can be customized using the .ValueForNonExisting RBO property.
Accessing data from the RBO via individual row/column methods can be slow
due to the number of calls possible and the related COM overhead. For best
performance, it’s advised to use one of the bulk data extraction methods: entire
row, subset of a row, or multiple rows
Entire Row:
Row Subset:
Multiple Rows:
Info
GetRowsByID() is the more common method for retrieving data from multiple rows. To
* retrieve all requested data, use the same set used for the DataNeeded() method.
Info
Row IDs in the RBO will be in the same order as they are in the set specified in the
* DataNeeded() method
Example: Get plate top VM stress for output set 1 and 2 for selected elements
Sub Main
Dim App As femap.model
Set App = feFemap()
Dim fr As femap.Results
Dim fsElem As femap.Set
Set fr = App.feResults
Set fsElem = App.feSet
Example: Get plate top VM stress for output set 1 and 2 for selected elements (con’t)
fsElem.Select( FT_ELEM, True, "Select Elements" )
fr.Populate()
End Sub
Column min/max:
Dim fr As femap.Results
Dim fsElem As femap.Set
Set fr = App.feResults
Set fsElem = App.feSet
fsElem.AddAll( FT_ELEM )
fr.Populate()
End Sub
Ideally, a single Results Browsing Object could be used to access all required
results, however in large models or models with lots of results, it is possible to
load so much data that performance is degraded.
FEMAP will attempt to keep the entire Results Browsing Object in memory,
however once a threshold of available system memory is passed, the object will
spill to disk.
RBO
= =
RBO
+
OK AVOID
Unrestricted © Siemens AG 2013 All rights reserved.
Page 44 Siemens PLM Software
FEMAP Results Browsing Object
Memory and Performance Considerations
What defines “too much data”? It’s very machine dependent. Things to keep in
mind:
- Each Results Browsing Object has overhead (although not much)
- Each result value (essentially each “cell” in the table) requires 8 bytes
Example:
100k elements * 2000 output sets * 6 vectors = 1.2 billion cells =~ 9.1GB
Info
There may be enough memory available to populate the RBO, however keep in mind
* there’s also a memory footprint associated with retrieving the data.
Splitting a Results Browsing Object into several objects has no real advantages /
disadvantages over recycling a single RBO, however using them concurrently
will not alleviate the memory issues. If using a single RBO, remember to call the
Clear() method prior to repopulating the RBO.
Tip
If reusing a single RBO, consider reusing code that add columns to the
RBO by separating it into a different function.
When processing results with application methods, the new output sets and/or
vectors are created. When processing results with a Results Browsing Object,
calculations are performed on-the-fly. This can greatly impact performance.
Caution
!
In FEMAP v11, the different types of results processors have been split into separate methods.
The old feOutputProcess() method is deprecated and should not be used.
Copy:
.feOutputProcessCopy( bFullSet, from_setID, from_vectorID,
to_setID )
BOOL bFullSet Copy the entire set
INT4 from_setID Source Set ID
INT4 from_vectorID Source vector; ignored if bFullSet = TRUE
INT4 to_setID Target set; ignored if bFullSet = TRUE
Merge:
Combine:
Convert:
Envelope:
.feOutputProcessEnvelope( bFullSet, nType, nApproach,
bEnvelopeInSets, bEnvelopeAcrossSets, bSetInfo, nCount,
from_setID, from_vectorID, to_setID )
BOOL bFullSet Envelope all vectors in all sets
INT4 nType Max / Min / Max Absolute
INT4 nApproach All vectors / All locations / Individual vectors
BOOL bEnvelopeInSets Store envelope in original set. Ignored if
envelope approach is individual vectors
BOOL bEnvelopeAcrossSets Envelope similar vectors across sets.
Ignored if approach is individual vectors
BOOL bSetInfo Create additional vectors to store
information about source set / location
INT4 nCount Number of output sets
INT4 from_setID[nCount] Array of output set IDs
INT4 from_vectorID[nCount] Array of vector IDs; used with from_setID
INT4 to_setID Output set ID
Transform:
Sub Main
Dim App As femap.model
Set App = feFemap()
Dim fs As femap.Set
Set fs = App.feSet
fs.AddAll( FT_ELEM )
End Sub
Convert:
Info
Process columns of the RBO need to be added prior to calling
* Populate().
Caution DataNeeded() must be called when using the AddConversionColumn method unless converting
! results for the entire mode. Regardless of if the conversion is node->element or element->node
elements are specified.
Transformation:
.SetNodalTransform( nTransformTo, nCsysID )
INT4 nTransformTo None (default), CSYS, Nodal Output Csys
INT4 nCSysID Coordinate system for CSYS
Envelope:
Dim fr As femap.Results
Dim fs As femap.Set
Set fr = App.feResults
Set fs = App.feSet
fr.Populate()
End Sub
Example: Transform plate data into material CSYS using Results Browsing
Object
Sub Main
Dim App As femap.model
Set App = feFemap()
Dim fr As femap.Results
Dim fs As femap.Set
Set fr = App.feResults
Set fs = App.feSet
fs.AddAll(FT_ELEM)
Example: Transform plate data into material CSYS using Results Browsing
Object (con’t )
fr.AddColumn( 1, 7206, False, nCol, nColIDs )
fr.SetPlateTransform( FOD_PLATE_TO_MATL, 0, 0, 0., 0., 0., 0. )
fr.Populate()
App.feAppMessage( FCM_NORMAL, _
"Nxx in Material Coordinate System, Element 464: " + Str$( dVal ) )
End Sub
1600
1400
Results:
1200
Application Method: < 1 sec.
1000
RBO Method: ~1500 sec.
800
600
400
200
0
RBO Method Application Method
The Output Set and Output Vector Objects can be used to create custom output
data. This output data can then be for post like output data created by FEMAP.
Data can be stored in either existing output sets or in new output sets. When
using an existing output set, take care in not overwriting existing result data
unless that is the actual intent.
Arbitrary Results
Location
API Translator
FEMAP
Output
Output
Output
Result
Result
Result
Data
Data
Data
Set
Set
Set
Model Data
Info
Remember that the FEMAP Results browsing object is a read-only object;
* output data must be created directly with the output set and vector objects.
There is no limitation to the vector ID used for user data, however keep the
following considerations in mind:
Vector Range Type
1 – 2,999 Nodal Output
3,000 – 5,999 Line Element Output
6,000 – 59,999 Plate Element Output
60,000 – 79,999 Solid Element Output
80,000 – 89,999 Output on any Element
90,000 – 99,999 Patran Element Output
100,000 – 299,999 Plate Corner Output
1,000,000 to 6,000,000 Laminate Ply Output
9,000,000 to 9,999,999 User Defined Output
Caution
Use care when creating output vectors < 9,000,000. There’s nothing in the
! API to prevent you from doing this, but its generally not recommended.
Unrestricted © Siemens AG 2013 All rights reserved.
Page 64 Siemens PLM Software
Creating Custom Output
Creating Results Data
Like with reading results data directly with the Output object, writing results data
may also be done with the .Value property.
Example:
Dim fOV As femap.Output
Set fOV = App.feOutput
While technically this works, like with reading it can incur a large number of calls, so the
use of the “helper” methods is recommended. Additionally, the use of the helper methods
will properly set up a results object for certain data types (ie nodal vector data) and can aid
in avoiding errors in manually setting the properties.
The output creation helper methods come in pairs – an Init* method and a
Put* method. The initialization method will set up all required vector objects and
the put method will load data into the object, however the .Put() entity
method still needs to be called on the parent Output object.
Initialization Methods:
Put Methods:
Info
When using the PutVectorAtNode() method, the resultant value is not
* specified; it is calculated automatically and stored in the specified vector ID.
Info
Elemental data orientation is specified via preferences for output objects; for RBOs
* methods exist to specify orientations that differ from the preferences.
Dim fr As femap.Results
Dim fs As femap.Set
Dim fOV As femap.Output
Set fr = App.feResults
Set fs = App.feSet()
Set fOV = App.feOutput
fs.AddAll( FT_ELEM )
fr.Populate()
End Sub
Custom output data may be created on the fly but there are also various methods
for importing data from an external source:
Info
The format of the FEMAP Neutral file can be found in
* <FEMAP root directory>\pdf\neutral.pdf
Info
The ReadFile object is designed for reading data formatted in rows /
* columns and is capable of reading both ASCII and binary data
Output visualization is controlled, for the most part, through the FEMAP View
(feView) Object.
Property Description
INT4 Deformed Deformed view style
INT4 Contour Contour view style
INT4 ContourGroup Contour group
INT4 OutputSet Output set for display
INT4 FinalOutputSet Final output set, used in animated plots
INT4 DeformData Vector ID for deformation plot
INT4 ContourData Vector ID for contour plot
BOOL Draw[] Draw array
INT4 Label[] Label array
INT4 ColorMode[] ColorMode array
INT4 Color[] Color array
Draw Boolean
Label integer
ColorMode
Array index (FVI_* enum)
Ref. API Manual, Section 5.59.1.2
Color
Additional View Properties