Ansys Prog Features PDF
Ansys Prog Features PDF
Ansys Prog Features PDF
Programmable Features
ANSYS Release 10.0
002187
August 2005
ANSYS, Inc.
Southpointe
275 Technology Drive
Canonsburg, PA 15317
[email protected]
http://www.ansys.com
(T) 724-746-3304
(F) 724-514-9494
Revision History
Number Release Date
001385 ANSYS 5.7.1 May 2001
001514 ANSYS 6.1 March 2002
001975 ANSYS 8.1 April 2004
002099 ANSYS 9.0 November 2004
002187 ANSYS 10.0 August 2005
ANSYS, ANSYS Workbench, CFX, AUTODYN, and any and all ANSYS, Inc. product and service names are registered trademarks or trademarks of ANSYS, Inc.
or its subsidiaries located in the United States or other countries. ICEM CFD is a trademark licensed by ANSYS, Inc. All other trademarks or registered
trademarks are the property of their respective owners.
Disclaimer Notice
THIS ANSYS SOFTWARE PRODUCT AND PROGRAM DOCUMENTATION INCLUDE TRADE SECRETS AND ARE CONFIDENTIAL AND PROPRIETARY PRODUCTS
OF ANSYS, INC., ITS SUBSIDIARIES, OR LICENSORS. The software products and documentation are furnished by ANSYS, Inc., its subsidiaries, or affiliates
under a software license agreement that contains provisions concerning non-disclosure, copying, length and nature of use, compliance with exporting
laws, warranties, disclaimers, limitations of liability, and remedies, and other provisions. The software products and documentation may be used, disclosed,
transferred, or copied only in accordance with the terms and conditions of that software license agreement.
ANSYS, Inc. and ANSYS Europe, Ltd. are UL registered ISO 9001:2000 Companies.
Third-Party Software
See the online documentation in the product help files for the complete Legal Notice for ANSYS proprietary software and third-party software. The ANSYS
third-party software information is also available via download from the Customer Portal on the ANSYS web page. If you are unable to access the third-
party legal notices, please contact ANSYS, Inc.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Guide to ANSYS User Programmable Features
vi Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Guide to ANSYS User Programmable Features
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. vii
Guide to ANSYS User Programmable Features
2.5.4. ndgall Function (Getting the XYZ/Rotation Coordinates Vector for a Node) ........................... 2–6
2.5.5. ndspgt Subroutine (Getting the Nodal Solution for a Node of an Element) ............................. 2–6
2.6. Element Attribute Routines ........................................................................................................... 2–7
2.6.1. elmiqr Function (Getting Information About an Element) ...................................................... 2–7
2.6.2. elmget Function (Getting an Element's Attributes and Nodes) ............................................... 2–7
2.6.3. elmput Subroutine (Storing an Element) ............................................................................... 2–8
2.6.4. etyiqr Function (Getting a Data Item About an Element Type) ............................................... 2–8
2.6.5. etyget Function (Getting Information About an Element Type) ............................................. 2–9
2.6.6. etyput Subroutine (Storing Element Type Data) .................................................................... 2–9
2.6.7. echrtr Subroutine (Getting Information About Element Characteristics) ................................ 2–9
2.6.8. etysel Subroutine (Selecting, Unselecting, Deleting, or Inverting an Element Type) .............. 2–10
2.6.9. mpinqr Function (Getting Information About a Material Property) ....................................... 2–10
2.6.10. mpget Function (Getting a Material Property Table) .......................................................... 2–11
2.6.11. mpput Subroutine (Storing a Material Property Table) ....................................................... 2–12
2.6.12. mpdel Subroutine (Deleting a Material Property Table) ..................................................... 2–12
2.6.13. rlinqr Function (Getting Information About a Real Constant Set) ........................................ 2–12
2.6.14. rlget Function (Getting Real Constant Data) ...................................................................... 2–13
2.6.15. rlsel Subroutine (Selecting or Deleting a Real Constant Set) ............................................... 2–13
2.6.16. csyiqr Function (Getting Information About a Coordinate System) ..................................... 2–14
2.6.17. csyget Function (Getting a Coordinate System) ................................................................. 2–14
2.6.18. csyput Subroutine (Storing a Coordinate System) .............................................................. 2–15
2.6.19. csydel Subroutine (Deleting a Coordinate System) ............................................................ 2–15
2.6.20. userac Subroutine (Demonstrates Use of Element Attribute Routines) ............................... 2–15
2.7. Coupling and Constraint Routines ............................................................................................... 2–15
2.7.1. cpinqr Function (Getting Information About a Coupled Set) ................................................ 2–15
2.7.2. cpget Function (Getting a Coupled Set) .............................................................................. 2–16
2.7.3. cpput Subroutine (Storing a Coupled Set) ........................................................................... 2–16
2.7.4. cpsel Subroutine (Selecting or Deleting a Coupled Set) ....................................................... 2–17
2.7.5. ceinqr Function (Getting Information About a Constraint Equation Set) ............................... 2–17
2.7.6. ceget Function (Getting an Constraint Equation) ................................................................. 2–17
2.7.7. ceput Subroutine (Storing a Constraint Equation) ............................................................... 2–18
2.7.8. cesel Subroutine (Deleting or Selecting a Constraint Equation) ............................................ 2–18
2.8. Nodal Loading Routines .............................................................................................................. 2–18
2.8.1. disiqr Function (Getting a Information About Constraints) .................................................. 2–18
2.8.2. disget Function (Getting a Constraint from the Database) ................................................... 2–19
2.8.3. disput Subroutine (Storing a Constraint at a Node) .............................................................. 2–19
2.8.4. disdel Subroutine (Deleting a Constraint at a Node) ............................................................ 2–19
2.8.5. foriqr Function (Getting Information About Nodal Loads) .................................................... 2–20
2.8.6. forget Function (Getting a Constraint from the Database) ................................................... 2–20
2.8.7. forput Subroutine (Storing a Nodal Load at a Node) ............................................................ 2–20
2.8.8. fordel Subroutine (Deleting a Nodal Load at a Node) ........................................................... 2–21
2.8.9. ntpiqr Function (Getting Information About a Nodal Temperature) ..................................... 2–21
2.8.10. ntpget Function (Getting a Specified Nodal Temperature) ................................................. 2–21
2.8.11. ntpput Subroutine (Storing a Nodal Temperature) ............................................................ 2–22
2.8.12. ntpdel Subroutine (Deleting a Nodal Temperature) ........................................................... 2–22
2.8.13. nhgiqr Function (Getting Information About Nodal Heat Generations) .............................. 2–22
2.8.14. nhgget Function (Getting a Nodal Heat Generation) ......................................................... 2–23
2.8.15. nhgput Subroutine (Storing Nodal Heat Generation) ......................................................... 2–23
2.8.16. nhgdel Subroutine (Deleting a Nodal Heat Generation) ..................................................... 2–23
2.8.17. nfuiqr Function (Getting Information About Nodal Fluences) ............................................ 2–23
2.8.18. nfuget Function (Getting a Nodal Fluence) ........................................................................ 2–24
2.8.19. nfuput Subroutine (Storing a Nodal Fluence) .................................................................... 2–24
viii Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Guide to ANSYS User Programmable Features
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. ix
Guide to ANSYS User Programmable Features
x Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Guide to ANSYS User Programmable Features
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. xi
Guide to ANSYS User Programmable Features
List of Tables
1.1. ANSYS Exit Codes .............................................................................................................................. 1–56
xii Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Preface
Conventions Used in This Guide
This guide uses the following typographic conventions to indicate various types of information:
Convention Indicates
COMMAND ANSYS commands. These are shown as uppercase, bold text (for example,
K, DDELE, and so on). In the online documentation, these provide hyper-
links to the appropriate command reference information.
Menu > Item Menu paths (sometimes referred to as GUI paths). These are shown as bold
text with mixed-case, separated by angle brackets ">". An angle bracket
indicates a branch to a new menu item.
path/filename.ext File names, which may or may not include directory paths. These are shown
as lower-case, bold text, unless case is significant. Examples are shown
with the UNIX directory separator character "/" (slash); if you are using a
Microsoft Windows system, use "\" (backslash) as your directory separator
character.
ARGUMENT Arguments for numeric values (such as VALUE, INC, TIME) in command
syntax. These are shown as upper-case italic text. On some commands,
non-numeric convenience labels (for example, ALL and P) can also be
entered for these arguments.
Argument Arguments for alphanumeric values (for example, Lab or Fname) in com-
mand syntax. These are shown in mixed-case, italic letters. The guide also
uses italic text for emphasis.
ANSYS Guide Title The name of an ANSYS manual.
command,arg1,arg2 Command input listings, ANSYS output listings, and text that a user enters
are shown in fixed-width font.
Note-- Information that supplements the main topic being discussed, such as
important tips or guidelines.
Caution: Actions or situations that could cause problems, unexpected ANSYS beha-
vior, or unexpected results.
Warning Actions or situations that can shut down ANSYS, damage files, cause loss
of data, and so on.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Preface
xiv Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Chapter 1: Using User Programmable Features
(UPFs)
1.1. Introduction to UPFs
Because the ANSYS program has an open architecture, you can write your own routines or subroutines in C or
FORTRAN and either link them to ANSYS or use them as external commands. In fact, some of the ANSYS features
you see today as "standard" offerings originated as user programmable features (UPFs). You can take advantage
of UPFs if you are licensed for any of the following products:
• ANSYS Multiphysics
• ANSYS Mechanical
• ANSYS Structural
• ANSYS PrepPost
• ANSYS University Advanced
• ANSYS University Research
• To read information into or fetch information from the ANSYS database, you can create subroutines and
either link them into the ANSYS program or use them in the external command feature (see Appendix A:,
Creating External Commands in UNIX for more information about external commands). If you link these
subroutines into ANSYS, you are limited to 10 database access commands. Such commands, created
through either method, operate at all levels of ANSYS operation, including the begin, preprocessor, gen-
eral postprocessor, time-history postprocessor, and solution levels. For more information about accessing
the ANSYS database, see Chapter 2, “Accessing the ANSYS Database”.
• ANSYS provides a set of routines you can use to specify various types of loads, including BF or BFE loads,
pressures, convections, heat fluxes, and charge densities. These routines are described under Section 1.7:
Routines for Customizing Loads.
• Another set of UPF routines enables you to define the following material properties: plasticity, creep,
swelling law, viscoplasticity, hyperelasticity, and layered element failure criteria. To see inputs and outputs
for these routines, see Section 1.6: Routines for Customizing Material Behavior.
• Several sets of UPFs enable you to define new elements and to adjust the nodal orientation matrix. See
Section 1.3: Routines for Creating New Elements for more information.
• Another group of UPFs enables you to modify and monitor existing elements. For details, see Section 1.5:
Routines for Modifying and Monitoring Existing Elements.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Chapter 1: Using User Programmable Features (UPFs)
• You can customize UPF userop to create a custom design optimization routine. For more information,
see Section 1.12: Creating Your Own Optimization Routine.
• You can call the ANSYS program as a subroutine in a program you have written. To learn how, see Sec-
tion 1.8: Running ANSYS as a Subroutine.
The UPF subroutines are written in FORTRAN 90; some extensions are used. They contain comments intended
to give you enough detail to develop your own versions of the subroutines.
To use UPFs successfully, you need strong working knowledge of the following:
Important
• UPFs are not available or will behave unpredictably in certain data center environments or on some
hardware configurations. You should take special care when using UPFs on parallel systems. You should
never use the /CONFIG command or a config.ans file to activate parallelization on a system with UPFs.
For additional information, consult your ANSYS installation manual or your on-site ANSYS system support
person
• Carefully consider whether you wish to use UPFs, especially if you are linking them into ANSYS (rather
than into a shared library for use as external commands). When you add your own routines to ANSYS by
either method, you are creating a customized, site-dependent version of the program. ANSYS, Inc. considers
the use of UPFs a nonstandard use of the program, one that the ANSYS Quality Assurance verification
testing program does not cover. Therefore, you are responsible for verifying that the results produced
are accurate and that your customizations do not adversely affect unchanged areas of the ANSYS program.
• Although the flexibility that UPFs offer can be highly attractive, UPF usage is a complicated process that
can introduce errors. Consider what you want your customizations to accomplish. You may be able to
customize ANSYS more easily and safely with macros than with UPFs.
For other guidelines for nonstandard uses of the ANSYS program, see the ANSYS Advanced Analysis Techniques
Guide.
1–2 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.1: Introduction to UPFs
• Does the capability you want already exist in the ANSYS program? Remember, a capability may not be
obvious at first, especially to a novice ANSYS user.
• Does your proposed subroutine fit into the ANSYS program architecture and specifications? For example,
you can not program a user element that has more than 32 degrees of freedom per node or more than
44 nodes per element.
Use your experience and judgment to answer these questions. If you need help to do so, consult your ANSYS
Support Distributor. If you can respond "no" to both questions, then the user routine you are planning will be
both useful and feasible.
• If you have a UNIX version of ANSYS, the source code for the UPF routines resides in directory /an-
sys_inc/v100/ansys/customize/user/<platform>.
• If you are running the ANSYS program under Windows, the UPF source code resides in directory Program
Files\Ansys Inc\V100\ansys\custom\user\<platform>.
Most of the user routines have at least simple functionality, so print out the routines of interest before you start
programming. All source routines are concatenated onto file user.f or user.for. Delete the routines you do not
want and make appropriate changes to the others.
You need to take care when calling FORTRAN subroutines from C subroutines. You must use the symbol associated
with the FORTRAN subroutine when invoking the subroutine from a C function. This symbol typically differs
slightly from the FORTRAN subroutine name, and is extremely system dependent.
On many UNIX systems, you build this symbol name by taking the FORTRAN subroutine name, converting it to
lower case, and appending an underscore. For example, the symbol name for the FORTRAN subroutine
HeapInquire would be heapinquire_. You would have to use the symbol heapinquire_ in the invoking C
function to avoid an unsatisfied external reference when the program is linked.
Keep in mind that the instance described above is just an example. Compilers from different vendors may construct
the symbols differently. Please consult the manuals for your specific compiler for information on how to call
FORTRAN subroutines from C functions.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–3
Chapter 1: Using User Programmable Features (UPFs)
time so that if something goes wrong, the error that caused the problem should be isolated and relatively easy
to locate.
The example procedure below illustrates this type of gradual process. The example assumes that you are creating
a new element for the ANSYS program. You develop and test it by performing these steps:
1. Get the applicable element subroutines for uel101 from the ANSYS distribution medium. Add a small
change (such as a misspelling in an output heading), then compile and link the subroutines.
2. Using a production version of the ANSYS program, run several analysis problems using LINK8 (and maybe
other elements) to form a base for comparison.
3. Replacing LINK8 with USER101, run the same problem on your custom version of ANSYS.
4. Compare the results from Steps 2 and 3. If they show discrepancies other than the misspelled output
heading, resolve them before you go on to Step 5.
5. Choose the standard ANSYS element that most closely resembles your new custom element, and run
some problems on a production version of ANSYS using that element.
6. Modify the element subroutines to match the element you chose in Step 5. Then, compile and link those
subroutines into a custom version of ANSYS.
7. Again, compare the results from Steps 5 and 6. If they don't match, resolve the discrepancies before
moving on to Step 8.
8. Modify your element subroutines to include the features you want. Then, compile and link the subroutines
into a custom version of ANSYS.
9. Test the changes with a series of increasingly complex problems for which you already know the answers.
To insert include decks in a subroutine or function, use the INCLUDE (or an analogous) statement. Do not modify
an include deck under any circumstances. The following table lists some of the more commonly used ANSYS include
files and the definitions they contain:
1–4 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.1: Introduction to UPFs
• Link your routines into shared libraries (as discussed starting in Appendix A:, Creating External Commands
in UNIX).
• Compile and link your custom routines into the ANSYS program itself. This is discussed for UNIX systems
in Section 1.1.9: Compiling and Linking UPFs on UNIX Systems and for Windows systems in Section 1.1.10:
Compiling and Linking UPFs on Windows Systems. You may need superuser or root privileges to run the
procedure that does the linking.
When you run a user-linked version of the ANSYS program, the ANSYS output will include the following:
NOTE: This ANSYS version was linked by Licensee
The Relink ANSYS option compiles all FORTRAN files (files ending with .F) and all C files (files ending with .c) in
the current working directory. The procedure then loads all object files (files ending with .o) along with the default
ANSYS objects and libraries in /ansys_inc/v100/ansys/customize/user/<platform> (where platform is a dir-
ectory that uniquely identifies the hardware platform version). The new executable file created will be named
ansys.e100t and will reside in the current directory.
FORTRAN files are assumed to be FORTRAN 90 (some extensions are allowed), and C files are assumed to be
ANSI C.
When relinking on UNIX systems, you can choose to link a distributed version of ANSYS as well. If you choose to
link a distributed version, the executable must reside in the same directory path on all systems. However, you
need to link it on only one system; you can then copy the executable to the other systems. You cannot link a
distributed version on Windows systems.
Chapter 1 of the ANSYS Installation and Configuration Guide for UNIX lists the compilers you will need to use UPFs.
Creating a Shared Library You can also set up UPFs on some UNIX and Linux systems through a shared library
as an alternative to creating a custom ANSYS executable. Copy the ANSUSERSHARED script from /an-
sys_inc/v100/ansys/customize/user/<platform> into your working directory. All Fortran (*.F) and C (*.c) files
that you want to include in your shared library should also reside in your working directory. To compile all *.F
and *.c routines, issue the following command:
sh ./ANSUSERSHARED
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–5
Chapter 1: Using User Programmable Features (UPFs)
If the compile was successful, you will be asked if a shared file is to be created. Choose Yes to create a shared
library named libansuser.so (or .sl).
To use this library, set the ANS_USER_PATH environment variable to point to the working directory where the
libansuser shared library resides. Use one of the following commands, depending on the UNIX shell you are
using:
setenv ANS_USER_PATH workingdirectory
or
export ANS_USER_PATH=workingdirectory
When you run a user-linked version of the ANSYS program, the ANSYS output will echo the value of
ANS_USER_PATH and will include the following:
NOTE: This ANSYS version was linked by Licensee
To return to the original version of ANSYS, unset the ANS_USER_PATH environment variable.
ANSYS recommends using the ANSUSERSHARED script as a template to try compilers that are not supported
by ANSYS, Inc., such as the GNU compilers. To do so, edit the ANSUSERSHARED script, making changes to the
appropriate platform logic. Note that if you do use compilers other than those listed in the ANSYS Installation
and Configuration Guides, you will need to debug (i.e., find missing libraries, unsatisfied externals, etc.) them
yourself. ANSYS, Inc. does not provide assistance for customers using unsupported compilers or if the resulting
objects are not compatible with the ANSYS executable(s) as distributed.
Note — This shared library method is not available on Windows or IBM platforms, or with a Distributed
ANSYS executable.
Note — If you intend to modify any of the user routines, make a duplicate copy of the Program
Files\Ansys Inc\V100\ansys\custom\user\<platform> directory to preserve the original files for later
use, if necessary.
If you modify any of these subroutines, select the Relink ANSYS option from the ANS_ADMIN utility to link
these changes into the ANSYS program. This procedure compiles all FORTRAN files (files ending with .F) and all
C files (files ending with .c) in the Program Files\Ansys Inc\V100\ansys\custom\user\<platform> directory.
The procedure then loads all object files (files ending with .obj), along with the default ANSYS objects and libraries.
The executable file created will be named ansys.exe and will reside in Program Files\Ansys Inc\V100\ansys\cus-
tom\user\<platform>.
Note — ANS_ADMIN does not exist on Windows 64-bit systems. In order to relink on Itanium systems,
you must open a command prompt window, set your current directory to Program Files\Ansys
Inc\V100\ansys\custom\user\win64, and run ansys100 with the -custom option.
When relinking on a Windows system, you can choose to link with the small export list (“Do you want to link with
the small export list?”).
1–6 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.1: Introduction to UPFs
• Answer “No” to link ANSYS with all symbols exported (which may be required by third party interfaces).
The link time will be significantly longer. The ANSYS executable provided on the media is linked using
this option, and ANSYS recommends that you select this option.
• Answer “Yes” to link ANSYS with the minimum amount of symbols needed to be exported for ANSYS to
run. Select this option for the fastest link time.
Caution: When creating a custom ANSYS executable, the executable must be named ansys.exe. This
requirement is due to shared library usage.
After relinking the ANSYS executable, the program can be executed by either of the following two methods:
2. To execute the relinked ansys.exe from a Command Prompt window, use one of the following commands.
• Interactive:
ansys100 -custom <path> -p <product variable> -g
• Batch:
ansys100 -custom <path> -b -p <product variable>-j jobname -i <input file> -o <output file>
Note — Output from a user-linked version will contain the following statement:
This ANSYS version was linked by Licensee
Note — You will need all the compilers specified in Chapter 1 of the ANSYS Installation and Configuration
Guide for Windows to use these user programmable features. The user programmable features are loaded
onto the system only if you perform a custom installation and choose to install the customization tools.
UPFs that are not activated by the means described above must be activated by either of the following methods:
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–7
Chapter 1: Using User Programmable Features (UPFs)
To activate or deactivate the routines, issue the command USRCAL,Rnam1, ...Rnam9, where Rnam1 and Rnam9
are the names of specific routines. You can specify up to nine routines with one USRCAL command, or you can
issue multiple USRCAL commands.
Issue the command USRCAL,NONE to deactivate all valid user subroutines. To list the status of the routines, issue
the command USRCAL,STAT.
For a list of the user routines that the USRCAL command (or its equivalent menu paths) affects, see the USRCAL
command description in the ANSYS Commands Reference.
If you do not activate the UPFs in this manner, standard ANSYS logic will be used by default. For instance, when
you apply a convection load, standard ANSYS logic is the default even if you have a user convection routine
linked in. The user convection routine must be activated by the USRCAL command or its menu equivalent.
Enter the full pathname to the custom executable in the ANSYS Custom Exe field. Do not include the -custom
flag.
This script resides in the /ansys_inc/v100/ansys/bin/<platform> directory on UNIX or the Program Files\ANSYS
Inc\V100\ANSYS\bin\<platform> directory on Windows. When run, the script searches the current working
directory for the custom ANSYS executable (ansys.e100t by default on UNIX or ansys.exe on Windows). If the
custom ANSYS executable resides in a separate directory (or has a name other than ansys.e100t on UNIX), you
can specify a different path and filename.
Caution: If you are running on a Windows system and you create a custom ANSYS executable, the ex-
ecutable must be named ansys.exe. This requirement is due to shared library usage.
On UNIX, you can also run your custom executable via command line.
ansys100 -custom /pathname/ansys.e100t
Make certain that your custom version of the ANSYS program performs correctly for the combinations of elements,
analysis types, materials, boundary conditions, and so on. that you plan to use. Confirm that the logic you intro-
duced is correct and does not produce any unwanted side effects.
In testing your custom user routines, you also should verify that the changes you have made do not affect
standard, non-customized ANSYS features. To do so, you can compare the results of a set of problems from the
ANSYS Verification Manual run on the standard version and on the customized version. Input for these problems
is also available on your ANSYS distribution medium.
Always remember: your last step, a series of steps, or even your concept may be wrong. Proceed in clear steps,
and verify your work as often as possible. Keep intermediate versions of your modified source code on backup
media.
1–8 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.1: Introduction to UPFs
Note — If you contact your site's ANSYS system support person or any ANSYS, Inc. representative about
the performance of a custom version of ANSYS, always tell him or her explicitly that you are using a user
programmable feature. If you feel that an error exists in an unrelated feature of the ANSYS program,
demonstrate the suspected error in an non-customized, production version of the program before you
report the error to an ANSYS. Inc. representative.
MonLevel
The level for timing monitoring.
PrintLevel
The level for enter/exit printout.
SumLevel
The level at which the timing sum is output.
Each of these arguments can be any value between 0 and 9 (default is 0).
You can use the /TRACK command to identify which section of code is causing the program to abort. For example,
to flag up to eight levels of subroutines to determine when the program logic enters and leaves them, you would
issue the command /TRACK,,8.
F1
1 (provides basic solution control debugging)
F2
1 (provides transient debugging using Newmark constants)
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–9
Chapter 1: Using User Programmable Features (UPFs)
3 (provides element matrix debugging with matrix diagonals and load vectors)
F4
1 (provides auto time stepping debugging)
F5
1 (provides multifield debugging)
F6
1 (provides arc-length debugging)
F7
1 (provides basic Newton-Raphson debugging)
3 (provides Newton-Raphson debugging and prints applied loads and n-r restoring force for each DOF)
F8
1,2 (provides displacement vector debugging with displacement pointers)
G1
1 (provides basic element pass debugging)
G2
1 (provides element displacement and coordinate debugging)
G3
1 (provides element matrix debugging and prints matrix + load vectors)
3 (provides element matrix debugging with matrix diagonals and load vectors)
G4
1 (provides element load information debugging)
G5
1 (provides element real constant debugging)
1–10 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.1: Introduction to UPFs
G6
1 (provides element saved variable debugging)
G7
1 (provides element material property debugging with linear material properties)
H1
1 (provides file header record information)
-99 (resume only the command log information for subsequent LGWRITE command)
Issue the /UCMD command to make a user routine into a custom command. For more information, see Section 1.9:
Defining Your Own Commands later in this chapter.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–11
Chapter 1: Using User Programmable Features (UPFs)
You can shorten the time ANSYS takes to read such files by including two commands in your programs, UPFs,
or macros: EBLOCK and NBLOCK. The NBLOCK command converts nodal data into fixed format data blocks
(which ANSYS can read more quickly than commands). The EBLOCK command places element data into a fixed
format block, one line per element. These commands also compress displacement constraint data to one line
per constraint node. See Chapter 3, “Using CDREAD and CDWRITE” in the Guide to Interfacing with ANSYS for more
information on the use of these commands.
int - integer
dp - double precision
log - logical
chr - character
dcp - double precision complex
• Argument size is one of the following:
sc - scalar variable
ar(n) - array variable of length n
func - functional return value
• Argument intent is one of the following:
in - input argument
out - output argument
inout - both an input and an output argument
1–12 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.3: Routines for Creating New Elements
Routines uel100 through uel105 calculate the element matrices (stiffness, specific heat, and so on), the element
load vector (force, heat flow, and so on), and any element output quantities. The element printout also is generated,
and the variables to be saved are calculated and stored in the results file.
Other user routines available for manipulating element information include the following:
• Routines uep100 through uep105 provide printed output of line elements. The general ANSYS postpro-
cessor, POST1, calls the subroutines, or you can call them using uel100 through uel105.
• Routine usertr allows access to the nodal transformations.
• Routine userac describes some of the data handling.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–13
Chapter 1: Using User Programmable Features (UPFs)
c *** user programmable functions may not be used in parallel processing ***
1–14 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.3: Routines for Creating New Elements
c input arguments:
c elem (int,sc,in) - element label (number)
c ielc (int,ar(IELCSZ),in) - array of element type characteristics
c (IELCSZ = array size, defined in echprm)
c elmdat (int,ar(10),in) - array of element data
c eomask (int,sc,in) - bit pattern for element output
c (see outpcm)
c nodes (int,ar(nnod),in) - array of element node numbers
c (nnod = number of nodes; 1 in this case)
c locsvrL (int,sc,in) - location of the saved variables
c on file .esav for this element
c kelreq (int,ar(10),in) - matrix and load vector form requests
c (indices for kelreq are given with output
c arguments below)
c kelfil (int,ar(10),in) - keys indicating incoming matrices and
c load vectors (indices for kelfil are the
c same as given for kelreq with output
c arguments below)
c nr (int,sc,in) - matrix and load vector size
c xyz (dp,ar(6,nnod),in) - nodal coordinates (orig) and rotation angle
c u (dp,ar(nr,5),in) - element nodal solution values
c output arguments:
c kelout (int,ar(10),out) - keys indicating created matrices and
c load vectors (indices for kelout
c are the same as for kelreq below,
c as well as kelin and kelout later)
c zs (dp,ar(nr,nr),inout)- stiffness/conductivity matrix (kelreq(1))
c zass (dp,ar(nr,nr),inout)- mass matrix (kelreq(2))
c damp (dp,ar(nr,nr),inout)- damping/specific heat matrix (kelreq(3))
c gstif (dp,ar(nr,nr),inout)- stress stiffness matrix (kelreq(4))
c zsc (dp,ar(nr),out) - applied f vector (kelreq(5))
c zscnr (dp,ar(nr),out) - n-r restoring f vector (kelreq(6))
c or imaginary f vector (kelreq(7))
c elvol (dp,sc,out) - element volume
c elmass (dp,sc,out) - element mass
c center (dp,ar(3),out) - centroid location
c elener (dp,ar(5),out) - element energies
c edindxL(LONG,ar(25),out) - element result data file indexes
c lcerstL(LONG,sc,inout) - position on result file
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–15
Chapter 1: Using User Programmable Features (UPFs)
1–16 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
*deck,userac
subroutine userac (elem)
c *** primary function: To demonstrate user access of element information.
c --- Given the element number, all information about the element is avaiable.
c --- Starting with elmdat, one can get the element type, real constant number,
c --- the material number, the element coordinate system number, as well as
c --- the node numbers. Then, one can get more information about any or all
c --- of these things. The below demonstrates getting the element type and
c --- real constants.
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c input arguments:
c variable (typ,siz,intent) description
c elem (int,sc,in) - element number
c
c output arguments:
c none
c
c input arguments:
c locsvr (LONGINT,sc,in) - pointer to location of index
c output arguments:
c svindx (int,ar(20),out) - the 20 word index of svr variables
c 1,2-starting loc of this eles svr sets
c 3- length of eles svr sets
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–17
Chapter 1: Using User Programmable Features (UPFs)
c input arguments:
c svindx (int,ar(20),in) - index for svr for this element (see svgidx)
c nset (int,sc,in) - the set number in this index
c = 1 - structural svrs
c = 2 - thermal/electric/fluid svrs
c = 3 - magnetic svrs
c = 4 - nonlinear svrs
c = 5 - plasticity svrs
c = 6 - creep svrs
c = 7 - coupled svrs
c = 8 - user svrs
c = 9 - initial stress svrs
c (2,42,82,45,92,95 only)
c = 10 - section data after FiberSIM conversion
c (shell181 only)
c = 11-17 - spares (note that the first three
c items in svindx are not available)
c nsvr (int,sc,inout) - number of dp words expected in this set
c output arguments:
c nsvr (int,sc,inout) - number of dp words in this set
c svr (dp,ar(nsvr),in) - data in this set
c input arguments:
c svindx (int,ar(20),inout)- the index for svr for this element
c (see svgidx)
c nset (int,sc,in) - the set number in this index (same as svrget)
c = 1 - structural svrs
c = 2 - thermal/electric/fluid svrs
c = 3 - magnetic svrs
c = 4 - nonlinear svrs
c = 5 - plasticity svrs
c = 6 - creep svrs
c = 7 - coupled svrs
c = 8 - user svrs
c = 9 - initial stress svrs
c (2,42,82,45,92,95 only)
1–18 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
c output arguments:
c svindx (int,ar(10,2),inout)- updated index
1.4.5. Subroutine svpidx (Writing the Saved Variable Element Index to a File)
*deck,svpidx
subroutine svpidx (locsvr,svindx)
c *** primary function: write the svr element index onto file
c *** secondary functions: update the locsvr pointer to next element
c input arguments:
c locsvr (LONGINT,sc,inout) - pointer to start of svr for element
c svindx (int,ar(10,2),in) - index to svr for this element
c low and high parts of 64 bit address
c output arguments:
c locsvr (LONGINT,sc,inout) - pointer to start of svr for next element
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–19
Chapter 1: Using User Programmable Features (UPFs)
c sfrmpo
c 3 - general like old sfrmoo
c kprop (int,sc,in) - key indicating which material properties
c in the prop vector that need to be
c checked (see below)
c nprop (int,sc,in) - number of properties
c prop (dp,ar(nprop),in) - current mat props
c propo (dp,ar(nprop),inout)- previous material properties
c krvro (int,sc,in) -
c = 0 - real constants are used by this element, and the old
c values(rvro) have been saved; or the element does not
c use real constants. Any change of real constants
c causes all matrices to be reformed.
c = 1 - real constants are used by this element and the old
c values(rvro) have been saved. However, any change
c of real constants will cause the run to terminate,
c because the results would be too unpredictable.
c (e.g. gap elements)
c = 2 - element is nonlinear, so do not bother to check
c = 3 - real constants are used by this element, and the old
c values(rvro) have been saved. However, no checking is
c done in this routine because of needed customized logic.
c = 4 - real constants are used by this element, but the old
c values(rvro) have not been saved because it was
c decided not to use this much storage. therefore, no check
c can be made to determine if matrices should be reformed.
c (e.g. 100 layer elements)
c = 5 - real constants are used by this element, but the old
c values(rvro) have not been saved because the real
c constants have no effect on matrix formulation.
c (e.g. acoustic elements)
c rvr (dp,ar(*),in) - current real constants
c rvro (dp,ar(*),inout) - previous real constants
c amodo (dp,sc,inout) - previous value of mode
c asymo (dp,sc,inout) - previous value of isym
c
c output arguments:
c propo (dp,ar(nprop),inout)- current material properties
c rvro (dp,ar(*),inout) - current real constants
c amodo (dp,sc,inout) - current value of mode
c asymo (dp,sc,inout) - current value of isym
c kelin (int,ar(10),out) - keys indicating matrices to form
c
1.4.7. Subroutine subrd (Reading Element Load Data for a Substructure Gen-
eration Run)
*deck,subrd
subroutine subrd (iel,key,nd,vect,ka)
c *** primary function: read element load data from file for substructure
c generation run
c *** secondary functions: none
c input arguments:
c iel (int,sc,in) - element number
c key (int,sc,in) - type of load data
c = 1 temperature
c = 2 fluences
c = 3 heat generation rates
c = 4 current densities
c =10 pressures
c =11 film coefficients
c =12 bulk temperatures
c =13 extra displacement shapes
c =14 thermal strains(eptho in el42)
c =15 thermal flux (as in el55)
c =16 initial strains(epino in el01)
c =17 magnetic virtual displacements
1–20 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
c output arguments:
c vect (dp,ar(nd),out) - array of load data
c ka (int,sc,out) - load activation key
c = 0 no load for this data
c = 1 load is active
1.4.8. Subroutine subwrt (Writing an Element Load Vector to a File for a Sub-
structure Generation Run)
*deck,subwrt
subroutine subwrt (iel,nvect,key,nd,vect,ref)
c *** primary function: write element load vect to file for substructure
c generation run
c *** secondary functions: none
c input arguments:
c iel (int,sc,in) - element number
c nvect (int,sc,in) - number of load vectors
c (current load step number)
c key (int,sc,in) - type of load vect
c = 1 temperature
c = 2 fluences
c = 3 heat generation rates
c = 4 current densities
c =10 pressures
c =11 film coefficients
c =12 bulk temperatures
c =13 extra displacement shapes
c =14 thermal strains(eptho in el42)
c =15 thermal flux (as in el55)
c =16 initial strains(epino in el01)
c =17 magnetic virtual displacements
c =18 calculated source field(hsn in el96)
c =20 element load vector
c =30 copy - do not scale(tempev in el42)
c nd (int,sc,in) - number of vect items
c vect (dp,ar(nd),in) - array of load data
c ref (dp,sc,in) - reference value for zero load
c output arguments:
c nrvr (int,sc,out) - number of real variables
c rvr (dp,ar(*),out) - element real constants
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–21
Chapter 1: Using User Programmable Features (UPFs)
c integer lp(3)
c data lp /1,10,13/
c call propev (elem,mat,lp(1),tem,prop(1),3)
c input arguments:
c iel (int,sc,in) - element number
c mtr (int,sc,in) - material number(input quantity mat, mat comma
c lp (int,ar(n),in) - keys for which specific value is requested
c each group must be in ascending
c order (ex,ey,ez, etc)
c if negative, a required property
c if zero, leave prop term unchanged
c ---- MP command labels --------
c EX = 1, EY = 2, EZ = 3, NUXY= 4, NUYZ= 5, NUXZ= 6, GXY = 7, GYZ = 8,
c GXZ = 9, ALPX=10, ALPY=11, ALPZ=12, DENS=13, MU =14, DAMP=15, KXX =16,
c KYY =17, KZZ =18, RSVX=19, RSVY=20, RSVZ=21, C =22, HF =23, VISC=24,
c EMIS=25, ENTH=26, LSST=27, PRXY=28, PRYZ=29, PRXZ=30, MURX=31, MURY=32,
c MURZ=33, PERX=34, PERY=35, PERZ=36, MGXX=37, MGYY=38, MGZZ=39, EGXX=40,
c EGYY=41, EGZZ=42, SBKX=43, SBKY=44, SBKZ=45, SONC=46, SLIM=47, ELIM=48,
c USR1=49, USR2=50, USR3=51, USR4=51, FLUI=53, ORTH=54, CABL=55, RIGI=56,
c HGLS=57, BM =58, QRAT=59, REFT=60, CTEX=61, CTEY=62, CTEZ=63, THSX=64,
c THSY=65, THSZ=66, DMPR=67, =68, =69, =79, =71, =72,
c =73, =74, =75, =76, =77, =78, =79, =80
c (see mpinit for uncommented code)
c (see chapter 2 of the elements volume of the user's manual
c for a detailed description))
c output arguments:
c prop (dp,ar(n),out) - values of material property
c input arguments:
c iel (int,sc,in) - element number
c mtr (int,sc,in) - material number
c icon (int,sc,in) - key for which specific value is requested
1–22 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
c output arguments:
c prop1 (dp,sc,out) - value of material property
c input arguments:
c mat (int,sc,in) - material property number
c numitm (int,sc,in) - the number of data items requested
c output arguments:
c tbprop (dp,ar(numitm),out) - array of tb data
c input arguments:
c option (int,sc,in) - plasticity option
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–23
Chapter 1: Using User Programmable Features (UPFs)
c output arguments:
c epel (dp,sc,inout) - elastic strain
c eppl (dp,sc,inout) - updated plastic strain
c statev (dp,ar(6),inout) - updated state variables
c usvr (dp,ar(*),inout) - updated user-defined state variables
c epeq (dp,sc,inout) - updated effective plastic strain
c plwork (dp,sc,inout) - updated accumulated plastic work
c sigepl (dp,sc,out) - stress value on stress-strain curve
c sigrat (dp,sc,out) - ratio of trial stress to yield stress
c et (dp,sc,out) - tangent modulus
c internal variables:
c deppl (dp,sc) - equivalent plastic strain increment
c input arguments:
c option (int,sc,in) -
plasticity option
c elem (int,sc,in) -
element number (label)
c intpt (int,sc,in) -
element integration point number
c mat (int,sc,in) -
material reference number
c kstartL (intL,sc,in) -
virtual starting address of the data table
c ncomp (int,sc,in) -
number of stress/strain components (4 or 6)
c tem (dp,sc,in) -
temperature at the end of this substep
c dtem (dp,sc,in) -
temperature increment over this substep
c prop (dp,ar(9),in) -
material property array (ex,ey,ez,
c gxy,gyz,gxz, uxy,uyz,uxz)
c d (dp,ar(ncomp,ncomp),in) - elastic stress-strain matrix
c ktform (int,sc,in) - request key for tangent matrix formation
c dens (dp,sc,in) - material density
c flu (dp,sc,in) - fluence at the end of this substep
c dflu (dp,sc,in) - fluence increment over this substep
c epel (dp,ar(ncomp),inout)- modified total strain (trial strain)
c eppl (dp,ar(ncomp),inout)- plastic strain at previous substep
c statev (dp,ar(ncomp,6),inout)- state variables at previous substep
c usvr (dp,ar(*),inout) - user-defined state variables (for pluser)
c epeq (dp,sc,inout) - effective plastic strain at prev substep
c plwork (dp,sc,inout) - accumulated plastic work at prev substep
1–24 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
c output arguments:
c epel (dp,ar(ncomp),inout)- elastic strain
c eppl (dp,ar(ncomp),inout)- updated plastic strain
c statev (dp,ar(ncomp,6),inout)- updated state variables
c usvr (dp,ar(*),inout) - updated user-defined state variables
c epeq (dp,sc,inout) - updated effective plastic strain
c plwork (dp,sc,inout) - updated accumulated plastic work
c sigepl (dp,sc,out) - stress value on stress-strain curve
c sigrat (dp,sc,out) - ratio of trial stress to yield stress
c dt (dp,ar(ncomp,ncomp),out)- material modulus modified by dscpar
c dtt (dp,ar(ncomp,ncomp),out)- consistent tangent modulus
c (formed only if kplst=1)
c internal variables:
c deppl (dp,sc) - equivalent plastic strain increment
c input arguments:
c option (int,sc,in) - creep option
c elem (int,sc,in) - element number (label)
c intpt (int,sc,in) - element integration point number
c mat (int,sc,in) - material reference number
c kstartL (intL,sc,in) - virtual starting address of the data table
c epel (dp,sc,inout) - elastic strain
c e (dp,sc,in) - elastic modulus
c epcrp (dp,sc,inout) - creep strain at previous substep
c statev (dp,ar(7),inout) - state variables at previous substep
c usvr (dp,ar(*),inout) - user-defined state variables (for usercr)
c tem (dp,sc,in) - temperature at the end of this substep
c dtem (dp,sc,in) - temperature increment over this substep
c fluen (dp,sc,in) - fluence at the end of this substep
c dflu (dp,sc,in) - fluence increment over this substep
c epel (dp,sc,inout) - elastic strain adjusted for creep increment
c sig (dp,sc,inout) - stress (not really used)
c output arguments:
c epcrp (dp,sc,inout) - updated creep strain
c statev (dp,ar(7),inout) - updated state variables
c usvr (dp,ar(*),inout) - updated user-defined state variables
c sig (dp,sc,inout) - stress (recomputed if requested)
c input arguments:
c option (int,sc,in) - creep option
c elem (int,sc,in) - element number (label)
c intpt (int,sc,in) - element integration point number
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–25
Chapter 1: Using User Programmable Features (UPFs)
c output arguments:
c epel (dp,ar(ncomp),inout)- elastic strain adjusted for creep increment
c epcrp (dp,ar(ncomp),inout)- updated creep strain
c statev (dp,ar(ncomp*5+2),inout)- updated state variables
c usvr (dp,ar(*),inout) - updated user-defined state variables
c sig (dp,ar(ncomp),inout)- stresses (redefined if c13 > 0)
c hsig (dp,sc,inout) - hydrostatic stress (redefined if c13 > 0)
c input arguments:
c option (int,sc,in) - swelling option
c elem (int,sc,in) - element number (label)
c intpt (int,sc,in) - element integration point number
c mat (int,sc,in) - material reference number
c kstartL (intL,sc,in) - virtual starting address of the data table
c epswel (dp,sc,inout) - swell strain at previous substep
c epel (dp,sc,inout) - elastic strain
c e (dp,sc,in) - elastic young'S MODULUS
c fluen (dp,sc,in) - fluence at the end of this substep
c dfluen (dp,sc,in) - fluence increment over this substep
c tem (dp,sc,in) - temperature at the end of this substep
c dtem (dp,sc,in) - temperature increment over this substep
c usvr (dp,ar(*),inout) - user-defined state variables (for usersw)
c output arguments:
c epel (dp,sc,inout) - elastic strain adjusted for swelling inc
c epswel (dp,sc,inout) - updated swelling strain
c usvr (dp,ar(*),inout) - updated user-defined state variables
1–26 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
c input arguments:
c option (int,sc,in) - swelling option
c elem (int,sc,in) - element number (label)
c intpt (int,sc,in) - element integration point number
c mat (int,sc,in) - material reference number
c kstartL (intL,sc,in) - virtual starting address of the data table
c ncomp (int,sc,in) - number of stress/strain components (4 or 6)
c epswel (dp,sc,inout) - swell strain at previous substep
c epel (dp,ar(ncomp),inout)- elastic strain
c e (dp,sc,in) - elastic young'S MODULUS
c nuxy (dp,sc,in) - poisson'S RATIO
c fluen (dp,sc,in) - fluence at the end of this substep
c dfluen (dp,sc,in) - fluence increment over this substep
c tem (dp,sc,in) - temperature at the end of this substep
c dtem (dp,sc,in) - temperature increment over this substep
c usvr (dp,ar(*),inout) - user-defined state variables (for usersw)
c output arguments:
c epel (dp,ar(ncomp),inout)- elastic strain adjusted for swelling inc
c epswel (dp,sc,inout) - updated swelling strain
c usvr (dp,ar(*),inout) - updated user-defined state variables
c************************************************************************
c input arguments
c ===============
c mat (int,sc,in) - material ID
c plOpt (int,sc,in) - plasticity option
c ncomp (int,sc,in) - number of strain components (1,4, or 6)
c output arguments
c ================
c elLenPsvrBuf (int,sc,out) - number of extra data items saved
c local variables
c ===============
c************************************************************************
c input arguments:
c variable (typ,siz,intent) description
c mat (int,sc,in) - material number
c iprop (int,sc,in) - property number (tbpnum in tblecm)
c use 13 for tb,user
c use 14 for tb,nl
c output arguments:
c variable (typ,siz,intent) description
c nlget (int,sc,out) - number of property values
c prop (dp,ar(nlget),out) - vector of the property values
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–27
Chapter 1: Using User Programmable Features (UPFs)
1–28 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
c input arguments:
c ielem (int,sc,in) - element number
c edtype (int,sc,in) - element data type (see elparm)
c lcerstL (LONG,sc,inout) - pointer to results file position
c edindxL (LONG,ar(25),inout)- index to results file data
c nval (int,sc,in) - the total number of values
c if edtype = EDEMS,
c this should -always- be ielc(nmsmis),
c unless there is a variable number, as
c in the layered shell elements.
c value (dp,ar(nval),in) - output values (real)
c input arguments:
c elem (int,sc,in) - element number
c ielc (int,ar(IELCSZ),in) - element characteristic vector
c defined in elccmt
c lcerstL (LONG,sc,inout) - pointer to results file position
c edindxL (LONG,ar(25),inout)- index to results file data
c nudb (in,sc,inout) - size of what the user wants to add
c udbdat (dp,ar(*),in) - what the user wants to add
c nval (int,sc,in) - the total number of values to
c be output(does not include nudb)
c this should -always- be ielc(NMNMIS),
c unless there is a variable number, as
c in the layered shell elements.
c value (dp,ar(ndval),in) - output values
c ndval (int,sc,in) - dimension of value - must be no less than
c ielc(NMNMIS) + ielc(NMNMUP)
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–29
Chapter 1: Using User Programmable Features (UPFs)
1–30 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.4: Supporting Subroutines for Element Creation
c input arguments:
c iel (int,sc,in) - element number
c ielc (int,ar(IELCSZ),in) - array of element type characteristics
c nfac (int,sc,in) - number of pressure faces
c ndat (int,sc,in) - number of pressure values
c begdat (dp,ar(ndat),in) - pressure at the beginning of load step
c output arguments:
c dat (dp,ar(ndat),out) - pressures at this iteration
c enddat (dp,ar(ndat),out) - pressure at end of this load step
c iexist (int,sc,out) - flag if pressure exist
c = 0 - no pressure
c = 1 - yes pressure
c input arguments:
c iel (int,sc,in) - element number
c ielc (int,ar(IELCSZ),in) - array of element type characteristics
c nr (int,sc,in) - dimension of u (temperature) vector
c u (dp,ar(nr),in) - most current temperatures
c nfac (int,sc,in) - number of convection faces
c ndat (int,sc,in) - number of convection values
c beghc (dp,ar(ndat),in) - hcoef at the beginning of load step
c begtb (dp,ar(ndat),in) - tbulk at the beginning of load step
c output arguments:
c hc (dp,ar(ndat),out) - hcoef at this substep
c tb (dp,ar(ndat),out) - tbulk at this substep
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–31
Chapter 1: Using User Programmable Features (UPFs)
1–32 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.5: Routines for Modifying and Monitoring Existing Elements
1.5.1. Subroutine userfd (Computing the Complex Load Vector for Frequency
Domain Logic)
*deck,userfd
subroutine userfd (nr,kpeak,kcbrm,kpfor,ktrsur,isur,
x cd,cm,ct,cb,do,doext,aread,alenv,nuxy,faclen,conac,fluidt,visc,
x dprtem,watmot,xyzup,tr,accel,puvel,u,zass,
x forl,zsc,zsc2,pdyn,holdwv)
c *** primary function: compute complex load vector for frequency domain logic
c for pipe59
c *** secondary functions: none
c -- accessed with keyopt(12) = 2
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c input arguments:
c nr (int,sc,in) - matrix size
c kpeak (int,sc,in) - keyopt for wave combinations
c kcbrm (int,sc,in) - key for reduced matrices/cable option
c kpfor (int,sc,in) - keyopt for wave printout
c ktrsur (int,sc,in) - keyopt for surface treatment(unfinished)
c isur (int,sc,in) - surface flag
c cd (dp,sc,in) - normal drag coefficient (real constant)
c cm (dp,sc,in) - inertial coefficient (real constant)
c ct (dp,sc,in) - tangential drag coefficient (real constant)
c cb (dp,sc,in) - buoyancy coefficient (real constant)
c do (dp,sc,in) - outside diameter of pipe
c doext (dp,sc,in) - outside diameter of insulation
c aread (dp,sc,in) - area of displaced water
c alenv (dp,sc,in) - length of element
c nuxy (dp,sc,in) - poisson's ratio
c faclen (dp,sc,in) - wetted fraction of pipe
c conac (dp,sc,in) - added mass per unit length
c fluidt (dp,sc,in) - fluid temperature
c visc (dp,sc,in) - viscosity
c dprtem (int,sc,in) - size of water motion table
c watmot (dp,ar(1278),in) - water motion table
c xyzup (dp,ar(3,2),in) - updated coordinates
c tr (dp,ar(3,3),in) - local to global transformation matrix
c accel (dp,ar(3),in) - acceleration vector
c puvel (int,sc,in) - index for velocities in u matrix
c u (dp,ar(nr,5),in - displacements and velocities
c zass (dp,ar(nr,nr),in) - mass matrix
c forl (dp,ar(12),inout) - force vector in element coordinates
c zsc (dp,ar(nr),inout) - real load vector for frequency domain
c zsc2 (dp,ar(nr),inout) - complex load vector for frequency domain
c
c output arguments:
c forl (dp,ar(12),inout) - force vector in element coordinates
c zsc (dp,ar(nr),inout) - real load vector for frequency domain
c zsc2 (dp,ar(nr),inout) - complex load vector for frequency domain
c pdyn (dp,ar(2),out) - dynamic pressure
c holdwv (dp,ar(60),out) - wave information held for printout
c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–33
Chapter 1: Using User Programmable Features (UPFs)
1–34 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.5: Routines for Modifying and Monitoring Existing Elements
c
c input(do not change)---
c vn = vector normal to element
c vref = unit vector orienting element, essentially edge i-j
c elem = element number
c thick = total thickness of element at this point (see note below)
c xyzctr = location of element centroid or integration point
c
c output---
c bsangl = output from this subroutine. it represents the angle(s)
c between vref and the desired orientation. it may have
c the default orientation coming in to useran.
c This will be combined with the angles derived from
c the ESYS command.
c use 1 angle for 2-d elements and shells
c use 3 angles for 3-d solids
c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–35
Chapter 1: Using User Programmable Features (UPFs)
c primary function: User routine to access element matrices and load vectors.
c Needs to have USRCAL,UELMATX to be accessed.
c Called after the call to the element routine and
c before the solver.
c May be used to monitor and/or modify the element matrices
c and load vectors.
c input arguments:
c variable (typ,siz,intent) description
c elem (int,sc,in) - User element number
c nr (int,sc,in) - number of rows in element matrix
c ls (int,ar(nr),in) - Dof Index vector for this element matrix
c zs (dp,ar(nr,nr,4),inout)- K,M,C,SS matrices for this element
1–36 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.5: Routines for Modifying and Monitoring Existing Elements
c output arguments:
c zs (dp,ar(nr,nr,4),inout)- K,M,C,SS matrices for this element
c zsc (dp,ar(nr,2),inout) - Element load vector and N-R correction vec
c WARNING: any CHANGES to these (or any other) arguments will have a direc
c impact on the solution, possibly giving meaningless results. The normal
c usage of this routine is simply monitor what is happening.
*deck,uthick
SUBROUTINE uthick (elemId, elemType, matId, realId,
$ numDomIntPts, curCoords, thickness)
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c *** primary function: get the user defined thickness
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
c
c input arguments
c ===============
c Variable (type,sz,i/o) description
c elemId (int,sc,i) element number
c elemType (int,sc,i) element TYPE (181 etc.)
c matId (int,sc,i) material number
c realId (int,sc,i) real constant set number
c numDomIntPts (int,sc,i) number of integration points
c curCoords (dp,ar(3,numDomIntPts),i)
c current coordinates
c
c output arguments
c ================
c thickness (dp,ar(3,numDomIntPts),o)
c thickness at the integration points
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c --- parameters
c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–37
Chapter 1: Using User Programmable Features (UPFs)
c ===============
c Variable (type,sz,i/o) description
c elemId (int,sc,i) element number
c elemType (int,sc,i) element TYPE (42, 181 etc.)
c matId (int,sc,i) material number
c basis (dp,ar(3,3),i) basis directions (for the element)
c curIntPt (int,sc,i) current Integration point
c curLayer (int,sc,i) current Layer number (for shell
c and layered solids)
c curSecPt (int,sc,i) current point through the thickness in the
c current layer
c numDirect (int,sc,i) number of direct stress comp
c (s_xx,s_yy,s_zz)
c numShear (int,sc,i) number of shear stress comp
c (s_xy,s_yz,s_zx)
c curCoords (dp,ar(3),i) current coordinates
c tLocation (dp,sc,i) normalized thickness location
c (shell elements only)
c -1 = bottom or first sec pt
c +1 = top or last sec pt
c 0 = mid surface
c
c output arguments
c ================
c iniData (dp,ar(numDirect+numShear),o)
c user input stress values
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c --- parameters
c
1–38 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.6: Routines for Customizing Material Behavior
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–39
Chapter 1: Using User Programmable Features (UPFs)
Note — If you write a material behavior routine using any of the ANSYS commands MPDATA, MPDELE,
TB, or TBDELE, be aware that these commands interpret the string "_MATL" to mean the current active
material when it appears in their MAT field. The "_MATL" is used in conjunction with the library (LIB) option
of the MPREAD and MPWRITE commands. MPWRITE inserts "_MATL" in lieu of the specified material
number as these commands are written to the material library file. This occurs only when you use the
LIB option. When ANSYS reads a material library file written in this format, it interprets "_MATL" to mean
the currently active material (as defined by the MAT,MAT command). Do not use the "_MATL" string
outside the scope of the MPREAD command.
*deck,usermat
subroutine usermat(
& matId, elemId,kDomIntPt, kLayer, kSectPt,
& ldstep,isubst,keycut,
& nDirect,nShear,ncomp,nStatev,nProp,
& Time,dTime,Temp,dTemp,
& stress,ustatev,dsdePl,sedEl,sedPl,epseq,
& Strain,dStrain, epsPl, prop, coords,
& rotateM, defGrad_t, defGrad,
& tsstif, epsZZ,
& var1, var2, var3, var4, var5,
& var6, var7, var8)
c*************************************************************************
c *** primary function ***
c
c user defined material constitutive model
c
c Attention:
c User must define material constitutive law properly
c according to the stress state such as 3D, plain strain
c and axisymmetry, plane stress and 3D/1D beam.
c
c a 3D material constitutive model can use for
c plain strain and axisymmetry cases.
c
c When using shell elements, a plane stress algorithm
c must be use.
c
c gal July, 1999
c
c The following demonstrates a USERMAT subroutine for
c a plasticity model, which is the same as TB, BISO,
c for different stress states.
c See "ANSYS user material subroutine USERMAT" for detailed
c description of how to write a USERMAT routine.
c
c This routine calls four routines,
c usermat3d.F, usermatps.F usermatbm.F and usermat1d.F, w.r.t.
c the corresponding stress states.
c Each routine can be also a usermat routine for the specific
c element.
c
c*************************************************************************
c
c input arguments
c ===============
c matId (int,sc,i) material #
c elemId (int,sc,i) element #
c kDomIntPt (int,sc,i) "k"th domain integration point
c kLayer (int,sc,i) "k"th layer
c kSectPt (int,sc,i) "k"th Section point
c ldstep (int,sc,i) load step number
1–40 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.6: Routines for Customizing Material Behavior
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–41
Chapter 1: Using User Programmable Features (UPFs)
*deck,userpl
subroutine userpl (elem,intpt,mat,ncomp,kfirst,kfsteq,e,nu,dens,
x prop,d,ktform,timval,timinc,tem,dtem,toffst,flu,dflu,epel,eppl,
x statev,usvr,epeq,plwork,sigepl,sigrat,depeq,dt)
c
c *** primary function: allow users to write their own plasticity laws.
c this logic is accessed with tb,user.
c the below demonstration logic is the same as using
c tb,bkin, without adaptive descent (nropt,,,off).
c Other plasticity rules may require internal
c iterations and/or the more general definition of
c plasticity theory, discussed in the Theory
c Manual.
c *** secondary function: demonstrate the use of user-written plasticity laws
c in this routine:
c a. update the nonlinear strain history
c b. compute the material tangent matrix if requested
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
c
c input arguments:
c variable (type,sze,intent) description
c
c elem (int,sc,in) - element number (label)
c intpt (int,sc,in) - element integration point number
c mat (int,sc,in) - material reference number
c ncomp (int,sc,in) - no. of stress/strain components (1,4 or 6)
c 1 - x
c 4 - x,y,z,xy
c 6 - x,y,z,xy,yz,xz
c kfirst (int,sc,in) - 1 if first time through, 0 otherwise
c (useful for initializing state variables
c to a non-zero value)
c kfsteq (int,sc,in) - 1 if first equilibrium iteration of a
c substep, 0 otherwise
c
c e (dp,sc,in) - average elastic modulus
c nu (dp,sc,in) - average poisson ratio
c dens (dp,sc,in) - current material density (mass/volume)
c prop - linear material property array
c (dp,ar(9),in) (ex,ey,ez, gxy,gyz,gxz, nuxy,nuyz,nuxz)
c (dp,ar(1),in) if ncomp=1 (ex)
1–42 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.6: Routines for Customizing Material Behavior
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–43
Chapter 1: Using User Programmable Features (UPFs)
*deck,usercreep
SUBROUTINE usercreep (impflg, ldstep, isubst, matId , elemId,
& kDInPt, kLayer, kSecPt, nstatv, nprop,
& prop , time , dtime , temp , dtemp ,
& toffst, Ustatev, creqv , pres , seqv ,
& delcr , dcrda)
c*************************************************************************
c *** primary function ***
c Define creep laws when creep table options are
c TB,CREEP with TBOPT=100.
c Demonstrate how to implement usercreep subroutine
c
c Creep equation is
c dotcreq := k0 * seqv ^ n * creqv ^ m * exp (-b/T)
c
c seqv is equivalent effective stress (Von-Mises stress)
c creqv is equivalent effective creep strain
c T is the temperature
c k0, m, n, b are materials constants,
c
c This model corresponds to primary creep function TBOPT = 1
c
c gal 10.01.1998
c
c*************************************************************************
c
c input arguments
1–44 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.6: Routines for Customizing Material Behavior
c ===============
c impflg (in ,sc ,i) Explicit/implicit integration
c flag (currently not used)
c ldstep (in ,sc ,i) Current load step
c isubst (in ,sc ,i) Current sub step
c matId (in ,sc ,i) number of material index
c elemId (in ,sc ,i) Element number
c kDInPt (in ,sc ,i) Material integration point
c kLayer (in ,sc ,i) Layer number
c kSecPt (in ,sc ,i) Section point
c nstatv (in ,sc ,i) Number of state variables
c nprop (in ,sc ,i) size of mat properties array
c
c prop (dp ,ar(*),i) mat properties array
c This array is passed all the creep
c constants defined by command
c TBDATA associated with TB,CREEP
c (do not use prop(13), as it is used
c elsewhere)
c at temperature temp.
c time Current time
c dtime Current time increment
c temp Current temperature
c dtemp Current temperature increment
c toffst (dp, sc, i) temperature offset from absolute zero
c seqv (dp ,sc , i) equivalent effective stress
c creqv (dp ,sc , i) equivalent effective creep strain
c pres (dp ,sc , i) hydrostatic pressure stress, -(Sxx+Syy+Szz)/3
c
c input output arguments input desc / output desc
c ====================== ========== ===========
c Ustatev (dp,ar(*), i/o) user defined iinternal state variables at
c time 't' / 't+dt'.
c This array will be passed in containing the
c values of these variables at start of the
c time increment. They must be updated in this
c subroutine to their values at the end of
c time increment, if any of these internal
c state variables are associated with the
c creep behavior.
c
c output arguments
c ================
c delcr (dp ,sc , o) incremental creep strain
c dcrda (dp,ar(*), o) output array
c dcrda(1) - derivitive of incremental creep
c strain to effective stress
c dcrda(2) - derivitive of incremental creep
c strain to creep strain
c
c local variables
c ===============
c c1,c2,c3,c4 (dp, sc, l) temporary variables as creep constants
c con1 (dp ,sc, l) temporary variable
c t (dp ,sc, l) temporary variable
c
*deck,usercr
subroutine usercr (elem,intpt,mat,ncomp,kfirst,kfsteq,e,posn,d,
x proptb,timval,timinc,tem,dtem,toffst,fluen,dfluen,epel,epcrp,
x statev,usvr,delcr)
c
c *** primary function: allow users to write their own creep laws.
c this logic is accessed with c6 = 100
c *** secondary function: demonstrate the use of user-written creep laws
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–45
Chapter 1: Using User Programmable Features (UPFs)
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
c
c input arguments:
c variable (type,sze,intent) description
c
c elem (int,sc,in) - element number (label)
c intpt (int,sc,in) - element integration point number
c mat (int,sc,in) - material reference number
c ncomp (int,sc,in) - no. of stress/strain components (1,4 or 6)
c 1 - x
c 4 - x,y,z,xy
c 6 - x,y,z,xy,yz,xz
c kfirst (int,sc,in) - 1 if first time through, 0 otherwise
c (useful for initializing state variables
c to a non-zero value)
c kfsteq (int,sc,in) - 1 if first equilibrium iteration of a
c substep, 0 otherwise
c
c
c e (dp,sc,in) - elastic young'S MODULUS
c posn (dp,sc,in) - poisson'S RATIO
c d (dp,ar(ncomp,ncomp),in)- elastic stress-strain matrix
c proptb (dp,ar(72),in) - material properties input on tb commands
c (do not use proptb(13), as it is used elsewhere)
c timval (dp,sc,in) - current time value
c timinc (dp,sc,in) - time increment over this substep
c tem (dp,sc,in) - temperature at the end of this substep
c dtem (dp,sc,in) - temperature increment over this substep
c toffst (dp,sc,in) - temperature offset from absolute zero
c fluen (dp,sc,in) - fluence at the end of this substep
c dfluen (dp,sc,in) - fluence increment over this substep
c
c epel (dp,ar(ncomp),inout)- elastic strain
c epcrp (dp,ar(ncomp),inout)- creep strain from previous substep
c statev (dp,ar(ncomp*5+2),inout)- state variables from previous
c (converged) substep. This variable is for
c explicit creep only and refers to a
c different internal variable than that
c defined by TB,stat which is used by
c implicit creep (usercreep) and usermat.
c usvr (dp,ar(nuval,nintp),inout)- additional state variables from
c previous equilibrium iteration (saved
c if the nsvr command is used)
c
c
c output arguments:
c variable (type,sze,intent) description
c
c epel (dp,ar(ncomp),inout)- elastic strain adjusted for creep increment
c epcrp (dp,ar(ncomp),inout)- updated creep strain
c statev (dp,ar(ncomp*5+2),inout)- updated state variables
c usvr (dp,ar(nuval,nintp),inout)- updated additional state variables
c delcr (dp,sc,out) - equivalent creep strain increment (used
c for creep ratio calculation)
c
c fortran parameters (to be defined by the user):
c variable (type) description
c nuval (int) - number of additional state variables per
c integration point
c nintp (int) - maximum number of integration points of
c an element to be used with this routine
c (14 is the maximum)
c note: nuval x nintp = nstv(on nsvr command); cannot exceed 840!
c
c internal variables:
c variable (type,sze) description
c con (dp,sc) - temporary variable
1–46 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.6: Routines for Customizing Material Behavior
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–47
Chapter 1: Using User Programmable Features (UPFs)
c input arguments
c ===============
c prophy (dp,ar(*),i) material property array
c nprophy (int,sc,i) # of material constants
c invar dp,ar(3) invariants
c
c output arguments
c ================
c incomp (log,sc,i) fully incompressible or compressible
c potential dp,sc value of potential
c pInvDer dp,ar(9) der of potential wrt i1,i2,j
c 1 - der of potential wrt i1
c 2 - der of potential wrt i2
c 3 - der of potential wrt i1i1
c 4 - der of potential wrt i1i2
c 5 - der of potential wrt i2i2
c 6 - der of potential wrt i1j
c 7 - der of potential wrt i2j
c 8 - der of potential wrt j
c 9 - der of potential wrt jj
1–48 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.6: Routines for Customizing Material Behavior
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–49
Chapter 1: Using User Programmable Features (UPFs)
1–50 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.6: Routines for Customizing Material Behavior
x Vis,Temp,Tref,Pres,Pref,Cf,
x MFrac,DfNSpec,Time,VisNew,toffst)
*deck,egen
function egen (kcomp,ep,posn)
c primary function: combines strain components to give an "overall" strain
c used in creep and plasticity calculations
c secondary functions: none
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–51
Chapter 1: Using User Programmable Features (UPFs)
c ___________________________________________________________________
c /1 2 2 2 1 2 2 2
c \ / -*((ep - ep ) + (ep - ep ) + (ep - ep ) + -*(ep + ep + ep ))
c \/ 2 1 2 2 3 3 1 2 4 5 6
c ------------------------------------------------------------------------
c (1 + posn)
c input arguments:
c variable (typ,siz,intent) description
c kcomp (int,sc,in) - number of components of strain
c ep (dp,ar(6),in) - the strain components
c posn (dp,sc,in) - poisson's ratio
c output arguments:
c egen (dp,func,out) - the combined strain value
c
• Setting custom values for scalar fields (temperatures, heat fluxes, etc.)
• Changing element pressure information
• Changing information about element face convection surfaces
• Changing information about element face heat flux surfaces
• Changing information about element face charge density surfaces
• Changing information about element acceleration/angular velocity.
Activate these routines by issuing the USRCAL command or by choosing an equivalent menu path.
1–52 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.7: Routines for Customizing Loads
c = 1 temperatures
c = 2 fluences
c = 3 heat generation rates
c = 4 moisture contents
c = 5 magnetic virtual displacements
c iel (int,sc,in) - element number
c ielc (int,ar(IELCSZ),in) - array of element type characteristics
c nnod (int,sc,in) - number of nodes
c nodes (int,ar(nnod),in) - list of nodes
c time (dp,sc,in) - time of current substep
c defalt (dp,sc,in) - default value (e.g. tunif)
c nd (int,sc,in) - size of dat array
c dat (dp,ar(nd),inout) - array of data as normally computed by element
c as selected by key
c
c output arguments:
c variable (typ,siz,intent) description
c dat (dp,ar(nd),inout) - array of data passed back to element
c this data represents values at the end
c of the load step
c
c the input argument dat may be used in one of three ways:
c 1. it may be simply passed thru
c 2. it may be used as a flag(e.g. if dat(1) = -3.0, use
c a certain set of logic)
c 3. it may be completely ignored and instead defined with new logic
c
c this routine is called at each substep of each load step for which
c pressures are used. it is called for each equilibrium iteration.
c it is called once per element.
c the call to get the standard ansys input pressures is made just before
c entering this routine.
c input arguments:
c variable (typ,siz,intent) description
c ielc (int,ar(IELCSZ),in) - array of element type characteristics
c elem (int,sc,in) - element number for operation.
c time (dp,sc,in) - time of current substep
c ndat (int,sc,in) - number of pressure items for this element
c dat (dp,ar(ndat,2),inout) - the element pressure vector
c (has input values for each corner
c of each face)
c output arguments:
c variable (typ,siz,intent) description
c dat (dp,ar(ndat,2),inout) - the element pressure vector
c (defines input values for each corner
c of each face)
c dat(1:ndat,1) - real pressures
c dat(1:ndat,2) - complex pressures
c (surface elements only)
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–53
Chapter 1: Using User Programmable Features (UPFs)
c
c input arguments:
c variable (typ,siz,intent) description
c elem (int,sc,in) - element number for operation.
c ielc (int,ar(IELCSZ),in) - array of element type characteristics
c time (dp,sc,in) - time of current substep
c nr (int,sc,in) - number of nodal temperatures
c of the element
c u (dp,ar(nr),in) - vector of most recent values of the
c temperatures
c ndat (int,sc,in) - number of data points per element
c for example, for solid70, ndat = 24 = 6*4
c where 6 = faces per element
c 4 = corners per face
c hc (dp,ar(ndat),inout) - film coefficients
c (has input values for each corner
c of each face)
c tb (dp,ar(ndat),inout) - bulk temperature
c (has input values for each corner
c of each face)
c
c output arguments:
c variable (typ,siz,intent) description
c hc (dp,ar(ndat),inout) - film coefficients
c (defines input values for each corner
c of each face)
c tb (dp,ar(ndat),inout) - bulk temperature
c (defines input values for each corner
c of each face)
c
1–54 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.7: Routines for Customizing Loads
1.7.4. Subroutine userfx (Changing Element Face Heat Flux Surface Informa-
tion)
*deck,userfx
subroutine userfx (ielc,elem,time,nr,u, ndat,dat)
c *** primary function: change element face heat flux surface info
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
c
c in order to activate this user programmable feature,
c the user must enter the 'usrcal,userfx' command.
c
c this routine is called during each substep of each load step.
c it is called for each equilibrium iteration.
c it is called once per element. it is called only during the heat
c flow load vector formulation stage, and not during the heat flow
c evaluation stage.
c the call to get the standard ansys input heat flux surfaces
c is made just before entering this routine, so this information is
c available to be modified, if desired.
c
c input arguments:
c variable (typ,siz,intent) description
c ielc (int,ar(IELCSZ),in) - array of element type characteristics
c elem (int,sc,in) - element number for operation.
c time (dp,sc,in) - time of current substep
c nr (int,sc,in) - number of nodal temperatures
c of the element
c u (dp,ar(nr),in) - vector of most recent values of the
c temperatures
c ndat (int,sc,in) - number of data points per element
c for example, for solid70, ndat = 24 = 6*4
c where 6 = faces per element
c 4 = corners per face
c dat (dp,ar(ndat),inout) - fluxes
c (has input values for each corner
c of each face)
c
c output arguments:
c variable (typ,siz,intent) description
c dat (dp,ar(ndat),inout) - fluxes
c (defines input values for each corner
c of each face)
c
1.7.5. Subroutine userch (Changing Element Face Charge Density Surface In-
formation)
*deck,userch
subroutine userch (ielc,ielem,time,nr,u, ndat,dat)
c *** primary function: change element face charge density surface info
c
c in order to activate this user programmable feature,
c the user must enter the usrcal command.
c
c this routine is called during each substep of each load step.
c it is called once per element. it is called only during the heat
c flow load vector formulation stage, and not during the heat flow
c evaluation stage.
c the call to get the standard ansys input charge densities of surfaces
c is made just before entering this routine, so this information is
c available to be modified, if desired.
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–55
Chapter 1: Using User Programmable Features (UPFs)
c
c input arguments:
c variable (typ,siz,intent) description
c ielc (int,ar(IELCSZ),in) -
array of element type characteristics
c ielem (int,sc,in) -
element number for operation.
c time (dp,sc,in) -
time of current substep
c nr (int,sc,in) -
number of nodal temperatures
c of the element
c u (dp,ar(nr),in) - vector of most recent values of the
c temperatures
c ndat (int,sc,in) - number of data points per element
c dat (dp,ar(ndat),inout) - fluxes
c
c output arguments:
c variable (typ,siz,intent) description
c dat (dp,ar(ndat),inout) - fluxes
c
c the input argument dat may be used in one of three ways:
c 1. they may be simply passed thru.
c 2. they may be used as a flag(e.g. if dat(2) = -3.0, use
c a certain set of logic).
c 3. they may be completely ignored.
c and instead redefined with new logic
c
If you are running ANSYS on a UNIX system (but not under Windows), you also can call the ANSYS program as a
subroutine in a program you've written. To do so, use the following:
subroutine ansys
For multiple calls to subroutine ANSYS, you must open and close standard input in the calling routine. (Usually,
input and output are FORTRAN units 5 and 6, respectively.) The calling routine can't use the database access
routines. But, other user programmable features can use the database access routines freely.
There may be times when ANSYS exits abnormally. Check the file.err file to see if ANSYS wrote an exit code to
the file before ending. These error codes may help you to understand the problem ANSYS had:
1–56 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.9: Defining Your Own Commands
1. Insert the code for the functions you want to perform into routine user01 (or user02, etc.).
2. Link the routine into the ANSYS program.
3. Issue the ANSYS command /UCMD to define a name for a custom command that calls and executes your
routine. Use the command format shown below:
/UCMD,Cmd,SRNUM
Cmd
The name for your new command. It can contain any number of characters, but only the first four are signi-
ficant. The name you specify can not conflict with the name of any ANSYS command or the names of any
other commands or macros.
SRNUM
The number of the routine your command should call; that is, a value between 01 and 10. For example,
suppose that you create and link in a user routine for a parabolic distribution of pressure, and you name that
routine user01. Issuing the command shown below creates a new command, PARB, that when issued calls
your parabolic pressure distribution routine:
/UCMD,PARB,1
To make these "custom command" routines available in all your ANSYS sessions, include the /UCMD commands
in your start-up file (START.ANS).
You also can use /UCMD to remove a custom command. To do so, simply use a blank value for Cmd, as shown
below:
/UCMD,,1
This command removes the PARB command. To list all user-defined command names, issue the command
/UCMD,STAT.
c /*******************************************************************\
c | this is a user routine that may be used by users to include their |
c | special coding. accesss to this routine is by the command usr1. |
c | usr1 may be changed by the user using the command /ucmd. the |
c | user may then use this routine to call his/her special routines. |
c | ansys routines to access information in the ansys database may be |
c | found in the "ansys programmer's manual", available from ansys,inc|
c | see user02 for a simple example usage. |
C | routines user03 to user10 are also available. |
C \*******************************************************************/
c output arguments:
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–57
Chapter 1: Using User Programmable Features (UPFs)
c **************************************************************
c Functions for accessing data on the command line
c integer function intinfun(iField) - gets an integer from field iField
c double precision function dpinfun(iField) - gets double precision
c character*4 ch4infun(iField) - gets (upper case) 4 characters
c character*8 ch8infun(iField) - gets (mixed case) 8 characters
c character*32 ch32infun(iField) - gets (mixed case) 32 characters
c **************************************************************
external wrinqr
integer wrinqr
iott = wrinqr(2)
return
end
c /*******************************************************************\
c | see user01 for additional information on user routines |
c \*******************************************************************/
c output arguments:
c user02 (int,sc,out) - result code (should be zero)
c (which is ignored for now)
c **************************************************************
c Functions for accessing data on the command line
c integer function intinfun(iField) - gets an integer from field iField
c double precision function dpinfun(iField) - gets double precision
c character*4 ch4infun(iField) - gets (upper case) 4 characters
c character*8 ch8infun(iField) - gets (mixed case) 8 characters
c character*32 ch32infun(iField) - gets (mixed case) 32 characters
c **************************************************************
1–58 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.9: Defining Your Own Commands
#include "ansysdef.inc"
maxnp = ndinqr(0,DB_MAXDEFINED)
c ***** get the desired offsets from the command line *****
offset(1) = dpinfun(2)
offset(2) = dpinfun(3)
offset(3) = dpinfun(4)
do i = 1,maxnp
ksel = ndgxyz (i,xyz(1))
if (ksel .eq. 1) then
xyz(1) = xyz(1) + offset(1)
xyz(2) = xyz(2) + offset(2)
xyz(3) = xyz(3) + offset(3)
call ndpxyz (i,xyz(1))
endif
enddo
c /*******************************************************************\
c | see user01 for additional information on user routines |
c \*******************************************************************/
c output arguments:
c user03 (int,sc,out) - result code (should be zero)
c (which is ignored for now)
c **************************************************************
c Functions for accessing data on the command line
c integer function intinfun(iField) - gets an integer from field iField
c double precision function dpinfun(iField) - gets double precision
c character*4 ch4infun(iField) - gets (upper case) 4 characters
c character*8 ch8infun(iField) - gets (mixed case) 8 characters
c character*32 ch32infun(iField) - gets (mixed case) 32 characters
c **************************************************************
#include "impcom.inc"
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–59
Chapter 1: Using User Programmable Features (UPFs)
#include "ansysdef.inc"
c pointers:
pointer (pdXnodeL,Xnode)
pointer (pdYnodeL,Ynode)
pointer (pdZnodeL,Znode)
double precision Xnode(*), Ynode(*), Znode(*)
istat = 1
if (numnp .le. 0) go to 999
10 node = ndnext(node)
c increment index
i = i + 1
endif
1–60 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.9: Defining Your Own Commands
c /*******************************************************************\
c | see user01 for additional information on user routines |
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–61
Chapter 1: Using User Programmable Features (UPFs)
c \*******************************************************************/
c output arguments:
c user04 (int,sc,out) - result code (should be zero)
c (which is ignored for now)
c **************************************************************
c Functions for accessing data on the command line
c integer function intinfun(iField) - gets an integer from field iField
c double precision function dpinfun(iField) - gets double precision
c character*4 ch4infun(iField) - gets (upper case) 4 characters
c character*8 ch8infun(iField) - gets (mixed case) 8 characters
c character*32 ch32infun(iField) - gets (mixed case) 32 characters
c **************************************************************
#include "ansysdef.inc"
lab2 = ch4infun(2)
write (iott,2010) lab2
2010 format(/' group name (type of entity) = ',a4)
num = intinfun(3)
write (iott,2020) num
2020 format (' entity number =',i4)
1–62 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.10: Supporting Subroutines
else
write (iott,2150)
2150 format (' Only KP, LN, or AR are acceptable on user-written ',
x 'gnsme command')
endif
user04 = 0
return
end
c object/library: usr
c input arguments:
c variable (typ,siz,intent) description
c Node (int,sc,in) - Node Number (User)
c Label (ch*4,sc,in) - DOF Label (Upper Case)
c 'UX ','UY ','TEMP','VOLT','ROTY', etc
c output arguments:
c GetRForce (int,func,out) - status/pointer
c = 0 - data not valid
c > 0 - Rfsum pointer to data for fast access
c see comments below
c Value (dp,sc,out) - Solution value for Node,Label
c All results are in the nodal coordinate
c system
c example usage:
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–63
Chapter 1: Using User Programmable Features (UPFs)
c external GetRForce
c integer GetRForce, ptr, Node2
c double precision Value
c #include "handlecom.inc" (if Value = Rfsum(ptr) form is to be used)
c later...
c Value = Rfsum(ptr)
c primary function: Get the displacement at a node from the disp vector
c secondary functions: Return pointer for fast access
c object/library: usr
c *** Notice - This file contains ANSYS Confidential information ***
c Prolog is not CONFIDENTIAL INFORMATION
c input arguments:
c variable (typ,siz,intent) description
c Node (int,sc,in) - Node Number (User)
c Label (ch*4,sc,in) - DOF Label (Upper Case)
c 'UX ','UY ','TEMP','VOLT','ROTY', etc
c output arguments:
c variable (typ,siz,intent) description
c GetStackDisp (int,sc,out) - status/pointer
c = 0 - data not valid
c > 0 - UDisp pointer to data for fast access
c see comments below
c Value (dp,sc,out) - Solution value for Node,Label
c example usage:
c external GetStackDisp
c#include "handlecom.inc" (only if UDisp(ptr) form is used
c integer GetStackDisp, ptr, Node2
c double precision Value
c later...
c Value = UDisp(ptr)
c input arguments:
c Label (ch*4,sc,in) - Result Type
c Comp (ch*4,sc,in) - Result Component (8 char for ESTR)
c LabAvg (ch*4,sc,in) - 'AVG ' or 'NOAV' ('AVG ' default)
c output arguments:
c TypeData (int,sc,out) - Code for data type
c nVal (int,sc,out) - Number of values per point
1–64 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.11: Access at the Beginning and End of Various Operations
c If 0, no data
c iLoc (int,sc,out) - Location of Comp in values
c input arguments:
c nPoints (int,sc,in) - Number of evaluation points
c *** from ElInterp ***
c ebest (int,ar(nPoints),in) - Element(s) containing points
c elcord (dp,ar(3,nPoints),in) - Element coordinates
c *** from ElResultStrt ***
c TypeData (int,sc,in) - Data type code
c iLoc (int,sc,in) - Start of selected data
c nVal (int,sc,in) - Number of results per point
c output arguments:
c Result (dp,ar(nvar,nPoints),out) - Array of results
c object/library: upf
c input arguments:
c piFEML (ptr,sc,in) - If non 0, pointer of a FEM Object
c nPoints (int,sc,in) - Number of points to find (do in one group)
c xyzPoints(dp,ar(3,nPoints),in)- XYZ coordinates of each point
c tolInsidein(dp,sc,in) - Tolerance for point inside element
c (0.0d0 defaults to 1.0d-4)
c tolOutsidein(dp,sc,in) - Maximum distance outside to be associated
c with an element (0.0d0 defaults to 0.25)
c MoveTol (dp,sc,in) - Node move tolerance (0.0d0, no move)
c output arguments:
c ebest (int,ar(nPoints),out) - Best element number for each point
c elcord (dp,ar(3,nPoints),out) - Element coordinates of the point
Issue the USRCAL command (or use an equivalent menu path) to activate or deactivate these routines.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–65
Chapter 1: Using User Programmable Features (UPFs)
Subroutines USSBeg, UItBeg, UItFin and USSFin default to reading a command macro file from the current
working directory whose name is subroutine.mac (that is, ussfin.mac is read by USSFin.F). No user action to
relink the ANSYS program is required for the command macro to be read except that the calling subroutine must
be activated by the USRCAL command. The design of the command reading ability of these subroutines is limited
to APDL parameter setting commands (*GET, *SET, a = value, etc) and testing for general ANSYS commands is
limited. Commands which are known to work include *DIM, *STATUS. Commands which require another line
(*MSG, *VWRITE) are not allowed. Other commands which are known to not work are the solution loading
commands (D, F, SFE, and so on). If these capabilties are required, the user will need to create a Fortran subroutine
and link this subroutine into ANSYS, as described in Section 1.1: Introduction to UPFs.
While parameter substitution into commands is not permitted, USSBeg, and so on were designed to be used in
conjunction with dynamic tables and parameter substitution from the user subroutine. As an example, consider
an ANSYS table defined as d5 = f(par1), If d5 contains values of displacement as a function of PAR1, then d5 may
be used as a constraint, as
*dim,d5,table,10,1,1,PAR1
d5(1)=0,.1,.25,
/solu
d,5,ux,%d5%
Modify the value of PAR1 in USSBeg.MAC and the constraint on node 5, ux can then be modified in the middle
of a load step.
The following is an example of a valid input that may be read by USSBeg, UItBeg, UItFin and USSFin.
/COM, SAMPLE ussfin.mac
a=5
b=nx(1) ! *get function is ok
*get,c,active,solu,Time,cpu ! *get is ok
*dim,array,,6 ! array parameters are ok
array(1) = 1
array(2) = 2
array(3) = 3
array(4) = 4
array(5) = 5
array(6) = 6
*vleng,3 ! vector operations are ok
*vfun,array(4),copy,array(1)
*stat
*stat,array(1)
array(1)=
nnode = ndinqr(0,14)
*dim,array,,nnode
*vget,array(1),NODE,1,NSEL
*stat,array(1)
array(1)=
/eof
1–66 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.12: Creating Your Own Optimization Routine
This chapter describes both methods. You can find additional information on design optimization techniques
and procedures in the ANSYS Advanced Analysis Techniques Guide.
However, if you plan to use an optimization routine of your own design, you must do the following:
1. Define parameters for your external optimization routine, using either the OPUSER command or GUI
path Main Menu>Design Opt>Method/Tool. (For more information about OPUSER, see the ANSYS
Commands Reference.)
2. Either issue the OPTYPE,USER command or choose menu path Main Menu>Design Opt>Method/Tool
and specify User Optimizer.
3. Issue the OPEXE command or choose GUI path Main Menu>Design Opt>Run.
Issuing the OPTYPE,USER command (or its GUI equivalent) instructs the ANSYS program to bypass the standard
ANSYS design optimizer logic and instead execute your custom optimization routine.
Below is a simplified flow chart showing how a user-defined optimization routine interacts with the ANSYS pro-
gram:
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–67
Chapter 1: Using User Programmable Features (UPFs)
% '&)(+*-, /.0
IJ
C 2/0 3-D8EGF
. . 1 %
0 23 8 5
23 4 5
6
7 %
/7 % : 9 ;=<>(+* 0
$
HG @2
G2
7 F
!8E$
!#"$
? 23 8 5
4 0
@A2 @ + B ? %
For information about the kopusr variable and the userop routine, see the next section.
Below is a listing of the inputs and outputs for userop and the comments of common block cmopt:
*deck,userop
subroutine userop (iott,nterm,maxparm,optvar)
c primary purpose: user-supplied optimization routine
c accessed with optype,user
c other input comes from the opuser command
c
c *** ansys(r) copyright(c) 2004
c *** ansys, inc.
c *** Notice - This file contains ANSYS Confidential information ***
c
c****************************************************************************
c *
c incoming arguments: *
c *
c *
c iott is the ansys output unit *
c *
c nterm is passed back to routine opterm. this variable should be set *
c as follows: *
c nterm = 0 if optimization looping should stop *
c nterm = 1 if optimization looping should continue *
1–68 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.12: Creating Your Own Optimization Routine
c *
c****************************************************************************
When you finish customizing the userop routine, you relink it using either of the methods described in Sec-
tion 1.1.8: Linking User Routines and in the ANSYS Installation and Configuration Guide for UNIX or in the ANSYS
Installation and Configuration Guide for Windows. You must include the cmopt common block in your routine,
to allow it to pass common data (such as design variables, state variables, and objective function values) to and
from the ANSYS program.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–69
Chapter 1: Using User Programmable Features (UPFs)
You may certainly use the system malloc and free functions or, for FORTRAN, the allocate system function. However,
you may end up competing with ANSYS for memory, and for large problems there may be insufficient system
memory to perform the function.
Dynamic memory is done through Cray-style pointers, where a dynamically allocated array is defined via the
construct
pointer (piArray,Array)
integer Array(*)
and memory space for the array is allocated by assigning the pointer, in this case piArray, to the allocated memory
space:
piArray = fAnsMemAlloc (size,...)
1–70 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.13: Memory Management Routines
piArray = PTRFTNNULL
pdData = PTRFTNNULL
You must include the ansysdef.inc include file to get the parameter values of MEM_INTEGER,
MEM_DOUBLE, MEM_COMPLEX, and MEM_REAL.
The next two sections provide input and output listings for the memory management routines.
For an example, see Section 1.9.3: Function user03 (Demonstrates Using ANSYS Memory), which appears earlier
in this chapter.
c primary function: Get A Block of Space from mem manager and Return Pointer
c object/library: mem
c input arguments:
c iLen (int,sc,in) - length of the block (in data elements)
c c16Label (chr*16,sc,in) - 16 character name for the Block
c key (int,sc,in) - type of data for this block (see ansysdef)
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–71
Chapter 1: Using User Programmable Features (UPFs)
c output arguments:
c fAnsMemAlloc (PTRFTN,sc,out) - Pointer to this data block -- needs to be
c tied to a local variable in the calling
c routine
c object/library: mem
c input arguments:
c ptr (PTRFTN,sc,inout) - pointer for this block
c output arguments:
c ptr (PTRFTN,sc,inout) - pointer will be set to zero
c *dim,parm32,type,d1,d2,d3,cName1,cName2,cName3
c *dim,parm32,type,d1,cName1
c *dim,parm32,type,d1,d2,d3,d4,d5,cName1,cName2,cName3,cName4,cName5
c input arguments:
c cName (chr*32,sc,in) - the name of the parameter to create
c labl4 (chr*4,sc,in) - 'TABL' or 'ARRA' or 'CHAR' or 'STRI'
c nDim (int,sc,in) - Dimension of array
c nxyz (int,ar(nDim),in) - the dimensions of the array
c cLabels (chr*32,ar(nDim),in) - Names for the directions in table
1–72 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.14: Parameter Processing Routines
c
c output arguments:
c dpValue (dp,sc,out) - the value of the parameter (may be a
c packed character*8
c chValue (ch*128,sc,out) - character output
c kerr (int,sc,out) - error flag (0,ok -1,output is packed
c 0=ok, 1=error, 2=error but TINY is used
c -2, output is string in chValue
c
c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–73
Chapter 1: Using User Programmable Features (UPFs)
c will occur.
c
c valuein(dp,sc,in) - the value for this parameter
c (should be a packed character*8 if
c ctype=1. To pack a char into a dp
c variable use "call chtodp(ch8,dp)".
c To unpack a dp variable into a char
c use "call dptoch(dp,ch8)" )
c Value is the data value that is to be stored for
c "label" (arg 1). If "ctype=1" (arg 2) then this
c value would be a "packed character" data from the
c "chtodp" Ansys function.
c
c output arguments:
c kerr (int,sc,out) - error flag (0=ok, 1=error)
c kerr is an integer error flag that is
c returned to the calling subroutine. Any
c non zero number would indicate an error
c was detected in subroutine "pardef"
c
c
• The erhandler routine displays output messages (notes, warnings, and errors).
• The RunCommand function lets you issue an ANSYS command from within a user routine.
• The GetStackDisp routine retrieves current displacement values.
• The /UNDO command writes an "undo" file at critical points as a user routine executes.
• The/HOLD command allows you to synchronize multiple tasks in ANSYS.
• The /TRACK command enables you to do program tracing and timing.
For further descriptions of erhandler and /TRACK, see Chapter 3, “Subroutines for Users' Convenience”. For
details about the GetStackDisp function, see Section 1.10.2: Function GetStackDisp (Getting Current Displace-
ment Values).
*deck,RunCommand
function RunCommand (nChar,command)
c object/library: upf
c input arguments:
c nChar (int,sc,in) - Length of the command string (8 min)
c command (ch*(nChar),sc,in) - A character string containing a
c valid ANSYS command
c output arguments:
c RunCommand (int,sc,out) - An internally defined value, ignore
1–74 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 1.15: Miscellaneous Useful Functions
Action
Filename
The eight-character name of a message file. If the named file exists, the ANSYS program reads a command
from the file and then deletes the file.
TimeInterval
The length of time, in seconds, that ANSYS waits before trying to read the message file again.
Timeout
The maximum length of time, in seconds, that ANSYS can wait between attempts to read the file.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 1–75
1–76
Chapter 2: Accessing the ANSYS Database
2.1. What This Chapter Covers
This chapter describes how you can retrieve information in the ANSYS database (or store information in the
database) by linking subroutines you create into the ANSYS program.
You can use the database access routines with any of the user-programmable features. For example, you can
create your own ANSYS commands and use them to execute database access routines (or have a database access
routine call a user-defined command).
int - integer
dp - double precision
log - logical
chr - character
dcp - double precision complex
• Argument size is one of the following:
sc - scalar variable
ar(n) - array variable of length n
func - functional return value
• Argument intent is one of the following:
in - input argument
out - output argument
inout - both an input and an output argument
c input arguments:
c next (int,sc,in) - the last node number used
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Chapter 2: Accessing the ANSYS Database
c output arguments:
c ndnext (int,func,out) - the next selected node number
c = 0 - no more nodes
2.4.2. ndprev Function (Getting the Number of the Previous Selected Node)
*deck,ndprev
function ndprev (next)
c *** primary function: get the number of the previous selected node
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c typ=int,dp,log,chr,dcp siz=sc,ar(n),func intent=in,out,inout
c
c input arguments:
c variable (typ,siz,intent) description
c next (int,sc,in) - the next node number used
c = 0 - use for initial value
c
c output arguments:
c ndprev (int,func,out) - the previous selected node number
c = 0 - no more nodes
c
2.4.3. ndnxdf Function (Getting the Number of the Next Defined Node)
*deck,ndnxdf
function ndnxdf (next)
c *** primary function: get the number of the next defined node
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c typ=int,dp,log,chr,dcp siz=sc,ar(n),func intent=in,out,inout
c
c input arguments:
c variable (typ,siz,intent) description
c next (int,sc,in) - the last node number used
c = 0 - use for initial value
c
c output arguments:
c ndnxdf (int,func,out) - the next defined node number
c = 0 - no more nodes
c
c
2–2 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.4: Routines for Selecting and Retrieving Nodes and Elements
c input arguments:
c next (int,sc,in) - the last element number used
c = 0 - use for initial value
c output arguments:
c elnext (int,func,out) - the next selected element
c = 0 - no more elements
2.4.6. elprev Function (Getting the Number of the Previous Selected Element)
*deck,elprev
function elprev (prev)
c *** primary function: get the number of the previous selected element
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c typ=int,dp,log,chr,dcp siz=sc,ar(n),func intent=in,out,inout
c
c input arguments:
c variable (typ,siz,intent) description
c prev (int,sc,in) - the last element used
c = 0 - use for initial value
c
c output arguments:
c elprev (int,func,out) - the previous selected element
c = 0 - no more elements
c
2.4.7. elnxdf Function (Getting the Number of the Next Defined Element)
*deck,elnxdf
function elnxdf (next)
c *** primary function: get the number of the next defined element
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c typ=int,dp,log,chr,dcp siz=sc,ar(n),func intent=in,out,inout
c
c input arguments:
c variable (typ,siz,intent) description
c next (int,sc,in) - the last element used
c = 0 - use for initial value
c
c output arguments:
c elnxdf (int,func,out) - the next defined element
c = 0 - no more elements
c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–3
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielei (int,sc,in) - element number
c = 0 - all elements
c ksel (int,sc,in) - type of operation to be performed.
c = 0 - delete element.
c = 1 - select element.
c =-1 - unselect element.
c = 2 - invert select status for element
*deck,ndinqr
function ndinqr (node,key)
c *** primary function: get information about a node.
c *** secondary functions: set current node pointer to this node.
c input arguments:
c node (int,sc,in) - node number
c Should be 0 for key=11, DB_NUMDEFINED,
c DB_NUMSELECTED, DB_MAXDEFINED, and
c DB_MAXRECLENG
c key (dp,sc,in) - key as to information needed about
c the node.
c = DB_SELECTED - return select status:
c ndinqr = 0 - node is undefined.
c =-1 - node is unselected.
c = 1 - node is selected.
c = DB_NUMDEFINED - return number of defined nodes
c = DB_NUMSELECTED - return number of selected nodes
c = DB_MAXDEFINED - return highest node number defined
c = DB_MAXRECLENG - return maximum record length (dp words)
c = 2, return length (dp words)
c = 3,
c = 4, pointer to first data word
c = 11, return void percent (integer)
c = 17, pointer to start of index
c = -1,
c = -2, superelement flag
c = -3, master dof bit pattern
c = -4, active dof bit pattern
c = -5, solid model attachment
c = -6, pack nodal line parametric value
c = -7, constraint bit pattern
c = -8, force bit pattern
c = -9, body force bit pattern
c = -10, internal node flag
c = -11, orientation node flag =1 is =0 isnot
c = -11, contact node flag <0
2–4 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.5: Node Information Routines
c output arguments:
c ndinqr (int,func,out) - the returned value of ndinqr is based on
c setting of key.
c input arguments:
c node (int,sc,in) - node number
c kerr (int,sc,inout) - message flag
c = 0 - print no message if node is unselected
c or undefined
c = 1 - print message if node is undefined
c = 2 - print message if node is undefined
c or unselected
c kcrot (int,sc,in) - output coordinates in this coordinate system.
c if kcrot is negative, output theta and
c phi coordinates in radians
c output arguments:
c v (dp,ar(6),out) - Coordinates (first 3 values) and rotation
c angles (last 3 values)
c kerr (int,sc,inout) - select status
c = 0 - node is selected
c = 1 - node is not defined
c =-1 - node is unselected
c input arguments:
c node (int,sc,in) - node number
c vctn (dp,ar(6),in) - array of 3 nodal coordinates and
c 3 nodal rotation angles.
c kcrot (int,sc,in) - local coordinate system in which the nodal
c coordinates and angles are defined
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–5
Chapter 2: Accessing the ANSYS Database
c input arguments:
c node (int,sc,in) - node number for operation.
c output arguments:
c ndgall (int,sc,out) - status of node.
c 0=node is undefined.
c -1=node is unselected.
c 1=node is selected.
c xyz (dp,ar(6),out) - vector containing x,y,z,rotx,roty,rotz
2.5.5. ndspgt Subroutine (Getting the Nodal Solution for a Node of an Element)
*deck,ndspgt
subroutine ndspgt (node,dofs,ndof,nrot,xyzang,nuvect,unode)
c *** primary function: get the nodal solution for a node of an element
c input arguments:
c node (int,sc,in) - The node number
c dofs (int,ar(DOFBITLENG),in) - The dofs to retrieve for the node.
c dof = degree of freedom
c The dofs array should be zeroed out,
c except for the needed parts.
c dofs is a bit pattern with true bits
c representing the GLOBAL Dof set desired.
c That is, dofs(1) is used for UX to SP06,
c and dofs(2) is used for TBOT to TTOP.
c See ECHPRM for details. For example,
c dofs(1) = UX + TEMP
c dofs(2) = TE3
c TTOP is a special case. If you want
c TTOP alone, use:
c dofs(2) = ibset(0,TTOP)
c If TBOT and TTOP are desired, you must use:
c dofs(2) = TBOT
c dofs(2) = ibset(dofs(2),TTOP)
c ndof (int,sc,in) - The number of node dofs (1, 2 or 3).
c nrot (int,sc,in) - Key to rotate dofs from nodal to global
c coordinate systems.
c if 0, none. if 2, 2-d. if 3, 3-d
c if > 0, dof set must include and only
c include all terms of the vector (e.g.
c UX,UY,UZ, or AX,AY,AZ).
c xyzang (dp,ar(6),in) - The xyz virgin node coordinates
c (including angles). Not used if
c nrot = 0 or ndof < 2.
c nuvect (int,sc,in) - Number of vectors to retrieve. Can vary
c between 1 and 5. Normally 1 is what is
c wanted. Other vectors include previous
c values and/or velocities. See elucom for
c all possibilites. Contents are analysis
c type dependent.
c output arguments:
c unode (dp,ar(ndof,nuvect),out) - Element nodal solution vectors in
c the global coordinate system.
2–6 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.6: Element Attribute Routines
c input arguments:
c ielem (int,sc,in) - element number
c should be zero for key=11, DB_NUMDEFINED,
c DB_NUMSELECTED, or DB_MAXDEFINED
c key (int,sc,in) - information flag.
c = DB_SELECTED - return select status: (1)
c elmiqr = 0 - element is undefined.
c =-1 - element is unselected.
c = 1 - element is selected.
c = DB_NUMDEFINED - return number of defined elements (12)
c = DB_NUMSELECTED - return number of selected elements (13)
c = DB_MAXDEFINED - return maximum element number used (14)
c = DB_MAXRECLENG - return maximum record length (15)
c (int words)
c = 2 - return length (int words)
c = 3 - return layer number
c (for cross reference files return number of entities)
c = 4 - return address of first data word
c = 5 - return length (in record type units)
c = 6 - return compressed record number.
c = 11 - return void percent (integer)
c = 16 - return location of next record
c (this increments the next record count)
c = 17 - pointer to start of index
c = 18 - return type of file.
c elmiqr = 0 - integer
c = 1 - double precision
c = 2 - real
c = 3 - complex
c = 4 - character*8
c = 7 - index
c = 19 - return virtual type of file.
c elmiqr = 0 - fixed length (4.4 form)
c = 1 - indexed variable length (layer data)
c = 2 - xref data tables
c = 3 - bitmap data (for 32 data item packed records)
c = 4 - data tables (three dimensional arrays)
c = -1 - material number etc. (see elmcmx)
c =-101 - pointer to element integers etc.
c (see elmcmx with elmilg and 1 instead of -101)
c
c output arguments:
c elmiqr (int,sc,out) - the returned value of elmiqr is based on
c setting of key.
c input arguments:
c ielem (int,sc,in) - element number
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–7
Chapter 2: Accessing the ANSYS Database
c output arguments:
c elmget (int,func,out) - status of element.
c = 0 - element undefined
c < 0 - number of nodes on unselected
c element
c > 0 - number of nodes on selected element
c elmdat (int,ar(EL_DIM),in) - element attributes.
c elmdat(EL_MAT) - material number
c (EL_TYPE) - element type
c (EL_REAL) - real constant number
c (EL_SECT) - section number
c (EL_CSYS) - coordinate system number
c (EL_DEAD) - death flag (bit 0)
c if clear - alive
c if set - dead
c (EL_SOLID) - solid model reference
c (EL_SHAPE) - 100*shape + specific shape
c (EL_OBJOPTIONS) - reserved
c (EL_PEXCLUDE) - p element include flag
c (bit 0)
c if clear - include
c if set - exclude
c *** NOTICE - The user is also responsible for defining the centroid for the
c element using the elmpct subroutine. Calling the elmput
c subroutine will NULL the element centroid previously defined.
c input arguments:
c ielem (int,sc,in) - element number
c elmdat (int,ar(EL_DIM),in) - element attributes.
c elmdat(EL_MAT) - material number
c (EL_TYPE) - element type
c (EL_REAL) - real constant number
c (EL_SECT) - section number
c (EL_CSYS) - coordinate system number
c (EL_DEAD) - death flag (bit 0)
c if clear - alive
c if set - dead
c (EL_SOLID) - solid model reference
c (EL_SHAPE) - 100*shape + specific shape
c (EL_OBJOPTIONS) - reserved
c (EL_PEXCLUDE) - p element include flag
c (bit 0)
c if clear - include
c if set - exclude
c For LSDYNA, it means part ID
c in reqular ANSYS, it is never part ID
c nnod (int,sc,in) - number of nodes for this element.
c nodes (int,ar(*),in) - node numbers for this element.
2–8 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.6: Element Attribute Routines
c input arguments:
c itype (int,sc,in) - element type number
c Should be 0 for key=11, DB_NUMDEFINED,
c DB_NUMSELECTED, DB_MAXDEFINED, and
c DB_MAXRECLENG
c key (int,sc,in) - information flag.
c = DB_SELECTED - return select status:
c etyiqr = 0 - element type is undefined.
c =-1 - element type is unselected.
c = 1 - element type is selected.
c = DB_NUMDEFINED - return number of defined element types
c = DB_NUMSELECTED - return number of selected element types
c = DB_MAXDEFINED - return highest element type number defined
c = DB_MAXRECLENG - return maximum record length (int words)
c = -n, return element characteristic n from etycom for element
c type itype.
c n is correlated to the parameter names in echprm.
c see elccmt for definitions of element characteristics.
c note- this will not overwrite the current setting of
c etycom.
c output arguments:
c etyiqr (int,func,out) - the returned value of etyiqr is based on
c setting of key.
c input arguments:
c itype (int,sc,in) - element type number
c output arguments:
c etyget (int,func,out) - status of element type.
c = 0 - element type is undefined.
c < 0 - number of data items on unselected
c element type.
c > 0 - number of data items on selected
c element type.
c ielx (int,ar(*),out) - element type data. see elccmt for
c description of data.
c input arguments:
c itype (int,sc,in) - element type number for operation.
c n (int,sc,in) - length of data vector to store.
c ielx (int,ar(*),in) - element type data. see elccmt for
c description.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–9
Chapter 2: Accessing the ANSYS Database
c input arguments:
c mat (int,sc,in) - material number
c should be 0 for key=11,
c DB_NUMDEFINED(12),
c DB_MAXDEFINED(14), and
c DB_MAXRECLENG(15)
2–10 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.6: Element Attribute Routines
c output arguments:
c mpinqr (int,func,out) - returned value of mpinqr is based on
c setting of key.
c input arguments:
c variable (typ,siz,intent) description
c mat (int,sc,in) - material number
c iprop (int,sc,in) - property reference number:
c ---- MP command labels --------
c EX = 1, EY = 2, EZ = 3, NUXY= 4, NUYZ= 5, NUXZ= 6, GXY = 7, GYZ = 8
c GXZ = 9, ALPX=10, ALPY=11, ALPZ=12, DENS=13, MU =14, DAMP=15, KXX =16
c KYY =17, KZZ =18, RSVX=19, RSVY=20, RSVZ=21, C =22, HF =23, VISC=24
c EMIS=25, ENTH=26, LSST=27, PRXY=28, PRYZ=29, PRXZ=30, MURX=31, MURY=32
c MURZ=33, PERX=34, PERY=35, PERZ=36, MGXX=37, MGYY=38, MGZZ=39, EGXX=40
c EGYY=41, EGZZ=42, SBKX=43, SBKY=44, SBKZ=45, SONC=46, SLIM=47, ELIM=48
c USR1=49, USR2=50, USR3=51, USR4=51, FLUI=53, ORTH=54, CABL=55, RIGI=56
c HGLS=57, BM =58, QRAT=59, REFT=60, CTEX=61, CTEY=62, CTEZ=63, THSX=64,
c THSY=65, THSZ=66, DMPR=67, =68, =69, =79, =71, =72,
c =73, =74, =75, =76, =77, =78, =79, =80
c
c (see mpinit for uncommented code and TB command information)
c output arguments:
c mpget (int,func,out) - number of temperature values
c temp (dp,ar(mpget),out) - vector of the temperature values
c prop (dp,ar(mpget),out) - vector of the property values
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–11
Chapter 2: Accessing the ANSYS Database
c input arguments:
c mat (int,sc,in) - material number.
c iprop (int,sc,in) - property reference number:
c ---- MP command labels --------
c EX = 1, EY = 2, EZ = 3, NUXY= 4, NUYZ= 5, NUXZ= 6, GXY = 7, GYZ = 8
c GXZ = 9, ALPX=10, ALPY=11, ALPZ=12, DENS=13, MU =14, DAMP=15, KXX =16
c KYY =17, KZZ =18, RSVX=19, RSVY=20, RSVZ=21, C =22, HF =23, VISC=24
c EMIS=25, ENTH=26, LSST=27, PRXY=28, PRYZ=29, PRXZ=30, MURX=31, MURY=32
c MURZ=33, PERX=34, PERY=35, PERZ=36, MGXX=37, MGYY=38, MGZZ=39, EGXX=40
c EGYY=41, EGZZ=42, SBKX=43, SBKY=44, SBKZ=45, SONC=46, SLIM=47, ELIM=48
c USR1=49, USR2=50, USR3=51, USR4=51, FLUI=53, ORTH=54, CABL=55, RIGI=56
c HGLS=57, BM =58, QRAT=59, REFT=60, CTEX=61, CTEY=62, CTEZ=63, THSX=64,
c THSY=65, THSZ=66, DMPR=67, =68, =69, =79, =71, =72,
c =73, =74, =75, =76, =77, =78, =79, =80
c
c (see mpinit for uncommented code and TB command information)
c output arguments:
c none.
c input arguments:
c mat (int,sc,in) - material number.
c iprop (int,sc,in) - property reference number:
c (0 = all properties)
c ---- MP command labels --------
c EX = 1, EY = 2, EZ = 3, NUXY= 4, NUYZ= 5, NUXZ= 6, GXY = 7, GYZ = 8
c GXZ = 9, ALPX=10, ALPY=11, ALPZ=12, DENS=13, MU =14, DAMP=15, KXX =16
c KYY =17, KZZ =18, RSVX=19, RSVY=20, RSVZ=21, C =22, HF =23, VISC=24
c EMIS=25, ENTH=26, LSST=27, PRXY=28, PRYZ=29, PRXZ=30, MURX=31, MURY=32
c MURZ=33, PERX=34, PERY=35, PERZ=36, MGXX=37, MGYY=38, MGZZ=39, EGXX=40
c EGYY=41, EGZZ=42, SBKX=43, SBKY=44, SBKZ=45, SONC=46, SLIM=47, ELIM=48
c USR1=49, USR2=50, USR3=51, USR4=51, FLUI=53, ORTH=54, CABL=55, RIGI=56
c HGLS=57, BM =58, QRAT=59, REFT=60, CTEX=61, CTEY=62, CTEZ=63, THSX=64,
c THSY=65, THSZ=66, DMPR=67, =68, =69, =79, =71, =72,
c =73, =74, =75, =76, =77, =78, =79, =80
c
c (see mpinit for uncommented code and for TB command information)
2–12 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.6: Element Attribute Routines
c input arguments:
c variable (typ,siz,intent) description
c nreal (int,sc,in) - real constant table number
c should be 0 for key=11, DB_NUMDEFINED,
c DB_NUMSELECTED, DB_MAXDEFINED, and
c DB_MAXRECLENG
c key (int,sc,in) - information flag.
c = 5 - return number of values stored for nreal
c = DB_SELECTED - return select status
c rlinqr = 0 - real constant table is undefined.
c =-1 - real constant table is unselected.
c = 1 - real constant table is selected
c = DB_NUMDEFINED - return number of defined real constant tables
c = DB_NUMSELECTED - return number of selected real constant tables
c = DB_MAXDEFINED - return highest real constant table defined
c = DB_MAXRECLENG - return maximum record length (dp words)
c output arguments:
c rlinqr (int,func,out) - the returned value of rlinqr is based on
c setting of key.
c input arguments:
c nreal (int,sc,in) - real constant table number
c output arguments:
c rlget (int,func,out) - number of real constant data obtained
c rtable (dp,ar(*),out) - real constant data obtained
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–13
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ncsy (int,sc,in) - coordinate system reference number
c should be zero for key= DB_NUMDEFINED
c or DB_MAXDEFINED
c key (int,sc,in) - information flag.
c = DB_SELECTED - return status:
c csyiqr = 0 - coordinate system is not defined
c -1 - coordinate system is not selected
c 1 - coordinate system is selected
c = DB_NUMDEFINED - number of defined coordinate systems
c = DB_MAXDEFINED - maximum coordinate system reference
c number used.
c output arguments:
c csyiqr (int,func,out) - the returned value of csyiqr is based on
c setting of key.
c NOTE: As a time-saving device, this routine will not fetch the coordinate
c system data from the database (an expensive operation)
c if ncsy = csyinx(4), as this would indicate that the data is current.
c If you wish to force this routine to fetch coordinate system data (in
c the case of loading a local array, for example), you MUST set
c ncsy != csyinx(4) before function call.
c input arguments:
c variable (typ,siz,intent) description csycom name
c ncsy (int,sc,in) - coordinate system number
c csyinx(4) (int,sc,inout) - coordinate system number csyact
c output arguments:
c csydpx (dp,ar(18),out)
c csydpx(1-9) - transformation matrix
c (10-12) - origin (XC, YC, ZC)
c (13-14) - coordinate system parameters cparm
c cparm2
c (15) - spare
c (16-18) - defining angles
c csyinx (int,ar(6),out)
c csyinx(1-2) - theta, phi singularity keys
c (3) - coordinate system type icdsys
c (csyinx(4) is inout) (4) - coordinate system number csyact
c (5) - spare
c (6) - spare
c csyget (int,func,out) - status of coordinate system
c = 0 - coordinate system exists
c = 1 - coordinate system doesn't exist
2–14 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.7: Coupling and Constraint Routines
c input arguments:
c ncsy (int,sc,in) - coordinate system number
c csydpx (dp,ar(18),out)
c csydpx(1-9) - transformation matrix
c (10-12) - origin (XC, YC, ZC)
c (13-14) - coordinate system parameters cparm
c cparm2
c (15) - spare
c (16-18) - defining angles
c csyinx (int,ar(6),out)
c csyinx(1-2) - theta, phi singularity keys
c (3) - coordinate system type icdsys
c (4) - coordinate system number csyact
c (5) - spare
c (6) - spare
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–15
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ncp (int,sc,in) - coupled set number
c
c output arguments:
c cpget (int,func,out) - number of nodes in list
c ieqn (int,ar(cpget+2),out) - coupled set info:
c ieqn(1:cpget) - list of coupled nodes
c ieqn(cpget+1) - set degree of freedom
c ieqn(cpget+2) - number of nodes in list
c (copy of return value)
c input arguments:
c ncp (int,sc,in) - coupled set number
c n (int,sc,in) - number of nodes in coupled set
c ieqn (int,ar(n+2),in) - info for storage
c ieqn(1:n) - list of coupled nodes
c ieqn(n+1) - degree of freedom label for set
c (ieqn(n+2) is inout) ieqn(n+2) - number of nodes in coupled set
c (copy of n)
c output arguments:
2–16 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.7: Coupling and Constraint Routines
c input arguments:
c nce (int,sc,in) - constraint equation number
c key (int,sc,in) - inquiry key:
c should be zero for key=11, DB_NUMDEFINED,
c DB_NUMSELECTED, DB_MAXDEFINED, and
c DB_MAXRECLENG
c = DB_SELECTED - return select status
c ceinqr = 1 - equation is selected
c = 0 - equation is undefined
c =-1 - equation is unselected
c = DB_NUMDEFINED - return number of defined contraint equations
c = DB_NUMSELECTED - return number of selected contraint equations
c = DB_MAXDEFINED - return number of highest numbered constraint
c equation defined
c = DB_MAXRECLENG - return length of longest contraint equation set
c (max record length)
c = 2 - return length (data units)
c = 3 - return layer number
c = 4 - address of first data word
c = 11 - return void percent (integer)
c = 16 - return location of next record
c = -1 - return master dof for this eqn
c output arguments:
c ceinqr (int,func,out) - the returned value of ceinqr is based on
c setting of key
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–17
Chapter 2: Accessing the ANSYS Database
c input arguments:
c nce (int,sc,in) - constraint equation number
c output arguments:
c ceget (int,func,out) - number of dof in equation
c ieqn (int,ar(ceget+1),out) - integer info
c ieqn(1:ceget) - list of node*32+dof
c ieqn(ceget+1) - number of dof in equation
c (copy of return value)
c - negative means internal CE
c deqn (dp,ar(ceget+1),out) - dp info
c deqn(1:ceget) - list of coefficients
c deqn(ceget+1) - constant term
c input arguments:
c nce (int,sc,in) - constraint equation set number
c n (int,sc,in) - number of degrees of freedom in set
c ieqn (int,ar(n+1),in) - integer info
c ieqn(1:n) - node*32+dof for each dof in set
c ieqn(n+1) - number of dof in set (copy of n above)
c - negative means internal CE
c deqn (dp,ar(n+1),in) - dp info
c deqn(1:n) - coefficients of each dof in set
c deqn(n+1) - constant term
c
c output arguments: none
c input arguments:
c ncei (int,sc,in) - constraint equation number
c ksel (int,sc,in) - select/delete flag
c = 0 - delete equation
c = 1 - select equation
c input arguments:
c node (int,sc,in) - node number for inquire.
c key (int,sc,in) - key as to the information needed
c = 1 - return constraint mask
c = DB_MAXDEFINED,
2–18 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.8: Nodal Loading Routines
c output arguments:
c disiqr (int,func,out) - the returned value of disiqr is based on
c setting of key.
c output arguments:
c disget (int,func,out) - status of constraint.
c = 0 - no constraint on this node
c for this DOF
c = 4 - this node has a constraint
c defined for this DOF
c value (dp,ar(4),out) - constraint values
c value(1-2) - (real,imag) values of present settings
c value(3-4) - (real,imag) values of previous settings
c input arguments:
c node (int,sc,in) - node number
c idf (int,sc,in) - reference number of DOF: (1-32)
c UX = 1, UY = 2, UZ = 3, ROTX= 4, ROTY= 5, ROTZ= 6, AX = 7, AY = 8
c AZ = 9, VX =10, VY =11, VZ =12
c PRES=19, TEMP=20, VOLT=21, MAG =22, ENKE=23, ENDS=24
c EMF =25, CURR=26 (missing entries are spares)
c input arguments:
c node (int,sc,in) - node number.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–19
Chapter 2: Accessing the ANSYS Database
c input arguments:
c node (int,sc,in) - number of node being inquired about.
c should be 0 for key=DB_MAXDEFINED or
c DB_NUMDEFINED
c key (dp,sc,in) - key as to information needed
c = 1 - return force mask for node
c = DB_MAXDEFINED,
c DB_NUMDEFINED - return number of nodal loadings
c in model
c NOTE: both DB_MAXDEFINED and DB_NUMDEFINED
c produce the same functionality
c output arguments:
c foriqr (int,func,out) - the returned value of foriqr is based on
c setting of key.
c input arguments:
c inode (int,sc,in) - node number (negative value for no
c partabeval)
c idf (int,sc,in) - reference number for the DOF: (1-32)
c (see echprm.inc)
c output arguments:
c forget (int,func,out) - status of constraint.
c = 0 - no loading on this node for this DOF
c = 4 - this node has a loading for this DOF
c value (dp,ar(4),out)
c value(1-2) - (real,imag) values of present settings
c value(3-4) - (real,imag) values of previous settings
c input arguments:
c node (int,sc,in) - node number
c idf (int,sc,in) - reference number for the DOF: (1-32)
c FX = 1, FY = 2, FZ = 3, MX = 4, MY = 5, MZ = 6, CSGX= 7, CSGY= 8
c CSGZ= 9, VFX =10, VFY =11, VFZ =12
2–20 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.8: Nodal Loading Routines
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c idf (int,sc,in) - reference number for the DOF: (1-32)
c FX = 1, FY = 2, FZ = 3, MX = 4, MY = 5, MZ = 6, CSGX= 7, CSGY= 8
c CSGZ= 9, VFX =10, VFY =11, VFZ =12
c FLOW=19, HEAT=20, AMPS=21, FLUX=22, NPKE=23, NPDS=24
c CURT=25, VLTG=26 (missing entries are spares)
c output arguments:
c none.
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c should be zero for key=2
c key (int,sc,in) - key for operation
c = 1 - return temperature status
c ntpiqr = 0 - node has no temperature
c constraint defined
c = 1 - node has a temperature
c constraint defined
c = 2 - return total number of nodal
c temperatures defined in model
c output arguments:
c ndinqr (int,func,out) - the returned value of ndinqr is based on
c setting of key.
c input arguments:
c node (int,sc,in) - node number
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–21
Chapter 2: Accessing the ANSYS Database
c output arguments:
c ntpget (int,func,out) - heat generation status of node.
c = 0 - nodal heat generation undefined
c = 1 - nodal heat generation is defined
c tmp (dp,ar(2),out) - the nodal heat generation (new,old).
c input arguments:
c node (int,sc,in) - node number
c temp (dp ,sc,in) - nodal temperature
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c should be 0 for key=2
c key (int,sc,in) - key for operation
c = 1 - return whether node has a heat generation rate
c defined
c nhgiqr = 0 - no heat generation defined for node
c = 1 - heat generation is defined for node
c = 2 - return total number of nodal heat generation
c rates defined in model
c output arguments:
c nhgiqr (int,func,out) - the returned value of nhgiqr is based on
c setting of key.
2–22 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.8: Nodal Loading Routines
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c output arguments:
c nhgget (int,func,out) - heat generation status of node.
c = 0 - nodal heat generation undefined
c = 1 - nodal heat generation is defined
c hg (dp,ar(2),out) - the nodal heat generation (new,old).
c input arguments:
c node (int,sc,in) - node number
c hg (dp ,sc,in) - nodal heat generation
c output arguments:
c none.
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c should be zero for key=2
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–23
Chapter 2: Accessing the ANSYS Database
c output arguments:
c nfuiqr (int,func,out) - the returned value of nfuiqr is based on
c setting of key.
c input arguments:
c node (int,sc,in) - node number
c output arguments:
c nfuget (int,func,out) - fluence status of node.
c = 0 - node has no fluence constraint
c = 1 - node has a fluence constaint
c fluen (dp ,ar(2),out) - the nodal fluences (new,old).
c input arguments:
c node (int,sc,in) - node number
c fluen (dp ,sc,in) - nodal fluence
2–24 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.8: Nodal Loading Routines
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c should be zero for key=2
c key (int,sc,in) - key for operation
c = 1 - return nodal current status:
c ndciqr = 0 - no current density defined for this node
c = 1 - node has a current density defined
c = 2 - total number of nodal current densities defined
c on model
c output arguments:
c ndciqr (int,func,out) - the returned value of ndciqr is based on
c setting of key.
c input arguments:
c node (int,sc,in) - node number
c output arguments:
c ndcget (int,func,out) - current density status of node.
c = 0 - node has no current density defined
c = 1 - node has a current density defined
c currd (dp,ar(4,2),out) - the node current density (new,old).
c input arguments:
c node (int,sc,in) - node number
c currd (dp ,ar(4),in) - nodal current densities
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–25
Chapter 2: Accessing the ANSYS Database
c output arguments:
c none.
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c should be zero for key=2
c key (int,sc,in) - key for operation
c = 1 - return magnetic virtual displacement status
c nvdiqr = 0 - no mag. virt. disps defined for this node
c = 1 - node has mag. virt. disps defined
c = 2 - return total number of nodal magnetic virtual
c displacements defined on model
c output arguments
c nvdiqr (int,func,out) - the returned value of nvdiqr is based on
c setting of key.
c input arguments:
c node (int,sc,in) - node number
c output arguments:
c nvdget (int,func,out) - virtual disp status of node.
c = 0 - node has no magnetic virtual
c displacement
c = 1 - node has a magnetic virtual
c displacement
c virtd (dp ,sc,out) - the nodal virtual displacement value
c input arguments:
c node (int,sc,in) - node number
c virtd (dp ,sc,in) - nodal virtual displacement
2–26 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.9: Element Loading Routines
c input arguments:
c ielem (int,sc,in) - element number
c should be zero for key=DB_NUMDEFINED or
c DB_MAXRECLENG
c iface (int,sc,in) - face number for inquire (0-6)
c face number is needed for key=5. for
c other values of key, iface has different
c meaning (see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return pressure mask for element
c = 5 - return number of pressures for this
c element face
c = DB_NUMDEFINED,
c = DB_MAXDEFINED - return value is based on setting of iface
c NOTE: both DB_NUMDEFINED and
c DB_MAXDEFINED produce the same
c functionality
c iface = 0 - return number of surface loads defined
c = 1-6 - return number of pressure loads
c defined for this element.
c NOTE: only 1-6 is valid, but this
c routine simply checks that iface is in
c the range. The actual value of iface
c does not matter in this case.
c = DB_MAXRECLENG - return the maximum number of element
c pressures on any element (max record
c length)
c output arguments:
c epriqr (int,func,out) - the returned value of epriqr is based on
c setting of key.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–27
Chapter 2: Accessing the ANSYS Database
c input arguments:
c elem (int,sc,in) - element number (negative value for
c no partabeval)
c iface (int,sc,in) - face number (1-6)
c output arguments:
c eprget (int,func,out) - status of element.
c =-1 - element has no pressures
c = 0 - this element face has no pressures
c > 0 - number of values defined
c value (dp ,ar(*),out) - the element pressures (real,imag) at each
c face
c input arguments:
c ielem (int,sc,in) - element number for operation.
c iface (int,sc,in) - face number (1-6)
c nval (int,sc,in) - number of values to put
c value (dp ,ar(nval),in) - the element pressures (real,imag) at each
c face
c input arguments:
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number
c = 0 - delete all pressures on this
c element
c = 1-6 - delete pressure on this face
c input arguments:
c ielem (int,sc,in) - element number for inquire
c should be zero for key=DB_NUMDEFINED or
c DB_MAXRECLENG
c iface (int,sc,in) - face number for inquire (0-6)
c face number is needed for key=5. for
c other values of key, iface has different
c meaning (see below)
c key (int,sc,in) - key as to the information needed
2–28 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.9: Element Loading Routines
c output arguments:
c ecviqr (int,func,out) - the returned value of ecviqr is based on
c setting of key.
c input arguments:
c elem (int,sc,in) - element number
c iface (int,sc,in) - face number (1-6)
c output arguments:
c ecvget (int,func,out) - status of element.
c =-1 - element has no convections/heat
c fluxes
c = 0 - this element face has no
c convections/heat fluxes
c > 0 - number of values defined
c value (dp ,ar(*),out) - the element convections
c input arguments:
c variable (typ,siz,intent) description
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number (1-6)
c nval (int,sc,in) - number of values to put
c value (dp ,ar(nval),in) - the element convections.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–29
Chapter 2: Accessing the ANSYS Database
c input arguments:
c variable (typ,siz,intent) description
c ielem (int,sc,in) - element number.
c iface (int,sc,in) - face number
c = 0 - delete all convections on this
c element
c = 1-6 - delete convections on this face
c output arguments:
c none.
c input arguments:
c ielem (int,sc,in) - element number
c Should be 0 for key=11, DB_NUMDEFINED,
c DB_MAXDEFINED, and DB_MAXRECLENG
c key (int,sc,in) - information flag.
c = DB_SELECTED - return status:
c etpiqr = 0 - element has no temperatures
c = 1 - element has temperatures defined
c = DB_NUMDEFINED - return number of temperatures defined for
c this element (rec length)
c = DB_MAXDEFINED - return number of temperatures defined in
c model
c = DB_MAXRECLENG - return maximum number of temperatures
c defined for any element (max rec length)
c = 2 - return length (dp words)
c = 3 - return layer number (for cross reference files return
c number of entities)
c = 4 - return address of first data word
c = 5 - return length (dp words)
c = 6 - return compressed record number.
c = 11 - return void percent (integer)
c = 16 - return location of next record (this increments the
c next record count)
c = 18 - return type of file.
c etpiqr = 0 - integer
c = 1 - double precision
c = 2 - real
c = 3 - complex
c = 4 - character*8
2–30 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.9: Element Loading Routines
c = 7 - index
c = 19 - return virtual type of file.
c etpiqr = 0 - fixed length (4.4 form)
c = 1 - indexed variable length
c (layer data)
c = 2 - xref data tables
c = 3 - bitmap data (for 32 data item packed
c records)
c = 4 - data tables (three dimensional arrays)
c output arguments:
c etpiqr (int,func,out) - the returned value of etpiqr is based on
c setting of key.
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c etpget (int,func,out) - status of element.
c = 0 - this element has no element
c temperatures
c > 0 - number of element temperatures
c retrieved
c tem (dp,ar(n,2),out) - the element temperatures (new,old).
c input arguments:
c ielem (int,sc,in) - element number
c n (int,sc,in) - number of element temperature values
c temp (dp ,ar(n),in) - element temperatures.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–31
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c input arguments:
c ielem (int,sc,in) - element number
c should be 0 for key=11, DB_NUMDEFINED,
c DB_MAXDEFINED, and DB_MAXRECLENG
c key (int,sc,in) - information flag.
c = DB_SELECTED - return status:
c ehgiqr = 0 - heat generation is undefined
c = 1 - heat generation is defined
c = DB_NUMDEFINED - return number of defined heat generations
c in model
c = DB_MAXRECLENG - return maximum number of heat generations
c on any element (max rec length)
c = 2 - return length (dp words)
c = 3 - return layer number (for cross reference files return
c number of entities)
c = 4 - return address of first data word
c = 5 - return length (record type units)
c = 6 - return compressed record number.
c = 11 - return void percent (integer)
c = 16 - return location of next record (this increments the
c next record count)
c = 18 - return type of file.
c ehgiqr = 0 - integer
c = 1 - double precision
c = 2 - real
c = 3 - complex
c = 4 - character*8
c = 7 - index
c = 19 - return virtual type of file.
c ehgiqr = 0 - fixed length (4.4 form)
c = 1 - indexed variable length
c (layer data)
c = 2 - xref data tables
c = 3 - bitmap data (for 32 data
c item packed records)
c = 4 - data tables (three
c dimensional arrays)
c output arguments:
c ehgiqr (int,func,out) - the returned value of ehgiqr is based on
c setting of key.
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c ehgget (int,func,out) - status of element.
2–32 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.9: Element Loading Routines
c input arguments:
c ielem (int,sc,in) - element number
c n (int,sc,in) - number of element heat generation values
c qgen (dp ,ar(n),in) - element heat generations
c input arguments:
c variable (typ,siz,intent) description
c ielem (int,sc,in) - element number
c output arguments:
c none
c input arguments:
c ielem (int,sc,in) - element number or zero (see below)
c key (int,sc,in) - key as to the information needed
c = 1 or DB_MAXRECLENG - return element fluences info
c for ielem > 0 - return number of fluences for this
c element (record length)
c = 0 - return maximum number of fluences
c defined for any element
c (max rec length)
c = DB_NUMDEFINED,
c = DB_MAXDEFINED - return number of defined fluences
c in model
c NOTE: both DB_NUMDEFINED and DB_MAXDEFINED
c produce the same functionality
c output arguments:
c efuiqr (int,func,out) - the returned value of efuiqr is based on
c setting of key
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–33
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c efuget (int,func,out) - status of element.
c = 0 - element has no fluences defined
c > 0 - number of element fluences defined
c value (dp,ar(*),out) - element fluences.
c input arguments:
c ielem (int,sc,in) - element number
c n (int,sc,in) - the number of values to store
c value (dp,ar(n),in) - element fluences.
c input arguments:
c ielem (int,sc,in) - element number or zero (see below)
c key (int,sc,in) - key as to the information needed
c = 1 or DB_MAXRECLENG - return element densities info
c for ielem > 0 - number of current densities for this
c element (rec length)
2–34 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.9: Element Loading Routines
c output arguments:
c edciqr (int,func,out) - the returned value of edciqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c n (int,sc,in) - the number of current densities to store
c value (dp,ar(n),in) - element current densities
c output arguments:
c none
c NOTE: If a value is not defined, a very
c small number should be used (2**-100)
c input arguments:
c ielem (int,sc,in) - element number
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–35
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number or zero (see below)
c key (int,sc,in) - key as to the information needed
c = 1 or DB_MAXRECLENG - return element virt disps info
c for ielem > 0 - number of virt disps defined for this
c element (rec length)
c = 0 - maximum number of virt disps defined
c for any element (max rec length)
c = DB_NUMDEFINED,
c = DB_MAXDEFINED - return total number of virt disps defined
c in model
c NOTE: both DB_NUMDEFINED and DB_MAXDEFINED
c produce the same functionality
c output arguments:
c evdiqr (int,func,out) - the returned value of evdiqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c
c output arguments:
c evdget (int,func,out) - status of element.
c = 0 - no virt disps defined for this
c element
c > 0 - number of element virtual
c displacements
c value (dp,ar(*),out) - element virtual displacements
c
c NOTE: If a value is not defined, it will
c be a very small number (2**-100)
c input arguments:
c ielem (int,sc,in) - element number
c n (int,sc,in) - the total number of values
c value (dp,ar(n),in) - element virtual displacments
2–36 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.9: Element Loading Routines
c input arguments:
c ielem (int,sc,in) - element number for inquire.
c should be zero for key=DB_NUMDEFINED,
c DB_MAXDEFINED or DB_MAXRECLENG
c iface (int,sc,in) - face number for inquire (0-6)
c face number is needed for key=5. for
c other values of key, iface has different
c meaning (see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return impedence mask for element
c = 5 - return number of impedences for this
c element face
c = DB_NUMDEFINED,
c = DB_MAXDEFINED - return value is based on setting of iface
c NOTE: both DB_NUMDEFINED and
c DB_MAXDEFINED produce the same
c functionality
c iface = 0 - return number of surface loads defined
c in model
c = 1-6 - return number of pressure loads
c defined for this element. (rec length)
c NOTE: only 1-6 is valid, but this
c routine simply checks that iface is in
c the range. The actual value of iface
c does not matter in this case.
c = DB_MAXRECLENG - return the maximum number of element
c impedences defined for any element
c (max rec length)
c output arguments:
c eimiqr (int,func,out) - the returned value of eimiqr is based on
c setting of key.
c input arguments:
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number (1-6)
c output arguments:
c eimget (int,func,out) - status of element.
c =-1 - element has no impedences
c = 0 - this element face has no impedences
c > 0 - number of values defined
c value (dp ,ar(*),out) - the element impedences (real,imag)
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–37
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number (1-6)
c nval (int,sc,in) - number of values to put
c value (dp ,ar(nval),in) - the element impedences (real,imag)
c input arguments:
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number
c = 0 - delete all impedences on this
c element
c = 1-6 - delete impedence on this face
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about surface stress
c ielem > 0 - return number of surface stresses on this
c element (rec length)
c = 0 - return maximum number of surface stresses
c on any element (max rec length)
c = DB_NUMDEFINED - return the number of surface stresses
c defined in model
c output arguments:
c esfiqr (int,func,out) - the returned value of esfiqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c esfget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of values returned
c value (dp,ar(*),out) - element surface stress data.
2–38 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.9: Element Loading Routines
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (19 * number of stress faces)
c There is a max of 2 stress faces
c value (dp,ar(nval),in) - the values
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number
c = 0 - all flagged surfaces
c = 1-6 - this flagged surface
c input arguments:
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number (1-6)
c output arguments:
c efsget (int,func,out) - status of element.
c =-1 - no values for this element
c = 0 - zero flagged surfaces defined
c > 0 - number of values defined
c value (dp ,ar(*),out) - the element flagged surfaces
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–39
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number for inquire.
c should be zero for key=DB_NUMDEFINED,
c DB_MAXDEFINED or DB_MAXRECLENG
c iface (int,sc,in) - face number for inquire (0-6)
c face number is needed for key=5. for
c other values of key, iface has different
c meaning (see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return flagged surfaces mask for element
c = 5 - return number of flagged surfaces for this
c element face
c = DB_NUMDEFINED,
c = DB_MAXDEFINED - return value is based on setting of iface
c NOTE: both DB_NUMDEFINED and
c DB_MAXDEFINED produce the same
c functionality
c iface = 0 - return total number of pressures,
c convections, etc defined in model
c = 1-6 - return number of flagged surfaces
c defined for this element. (rec length)
c NOTE: only 1-6 is valid, but this
c routine simply checks that iface is in
c the range. The actual value of iface
c does not matter in this case.
c = DB_MAXRECLENG - return maximum number of flagged surfaces
c for any element (max rec length)
c output arguments:
c efsiqr (int,func,out) - the returned value of efsiqr is based on
c setting of key.
c input arguments:
c ielem (int,sc,in) - element number
c iface (int,sc,in) - face number (1-6)
c nval (int,sc,in) - number of values to put
c value (dp ,ar(nval),in) - the element flagged surface values
2–40 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c node (int,sc,in) - node number
c > 0 - return result mask at this node
c = 0 - return number of calculated
c displacements in model
c key (int,sc,in) - key as to the information needed
c At this time, key should always = 1
c output arguments:
c dspiqr (int,func,out) - the returned value of dspiqr is based on
c setting of key
c input arguments:
c variable (typ,siz,intent) description
c node (int,sc,in) - node number
c ndf (int,sc,in) - number of results requested
c idf (int,ary(ndf),in) - reference number for the DOF: (1-32)
c UX = 1, UY = 2, UZ = 3, ROTX= 4, ROTY= 5, ROTZ= 6, AX = 7, AY = 8
c AZ = 9, VX =10, VY =11, VZ =12
c PRES=19, TEMP=20, VOLT=21, MAG =22, ENKE=23, ENDS=24
c EMF =25, CURR=26 SP01=27, SP02=28, SP03=29, SP04=30, SP05=31, SP06=32
c (missing entries are spares)
c output arguments:
c dspget (int,func,out) - number of actual results
c value (dp,ar(ndf),out) - result values
c input arguments:
c node (int,sc,in) - node number
c ndf (int,sc,in) - number of results to be stored
c idf (int,ary(ndf),in) - reference number for the DOF: (1-32)
c value (dp,ar(ndf),in) - displacement values
c input arguments:
c node (int,sc,in) - node number. (0 to delete DOF at all
c nodes)
c ndf (int,sc,in) - number of DOFs to delete (0 to delete
c all DOFs)
c idf (int,ar(*),in) - reference number for the DOF: (1-32)
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–41
Chapter 2: Accessing the ANSYS Database
c UX = 1, UY
= 2, UZ = 3, ROTX= 4, ROTY= 5, ROTZ= 6, AX = 7, AY = 8
c AZ = 9, VX
=10, VY =11, VZ =12
c PRES=19, TEMP=20, VOLT=21, MAG =22, ENKE=23, ENDS=24
c EMF =25, CURR=26 (missing entries are spares)
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about misc summed data records
c ielem > 0 - return number of misc summed
c data items for this element
c (record length)
c = 0 - return maximum number of misc
c summed data items on any
c element (max record length)
c = DB_NUMDEFINED - return total number of misc summed data
c items defined in model
c output arguments:
c emsiqr (int,func,out) - the returned value of emsiqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c emsget (int,func,out) - status of element.
c = 0 - element is undefined
c > 0 - number of data items returned
c value (dp,ar(*),out) - element misc summed data.
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - number of values to be stored
2–42 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete data for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element nodal forces
c ielem > 0 - return number of element nodal
c forces for this element
c (record length)
c = 0 - return maximum number of element
c nodal forces on any element
c (max record length)
c = DB_NUMDEFINED - return total number of element nodal
c forces defined in model
c output arguments:
c enfiqr (int,func,out) - the returned value of enfiqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c enfget (int,func,out) - status of element.
c = 0 - element has no nodal forces
c > 0 - number of nodal forces returned
c value (dp,ar(*),out) - element nodal forces
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–43
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c NOTE: There may be a maximum of 3 sets of
c nodal forces in the record: static
c forces, inertia forces, and damping forces
c value (dp,ar(nval),in) - nodal force results
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element nodal stresses
c ielem > 0 - return number of element nodal
c stresses for this element
c (record length)
c = 0 - return maximum number of element
c nodal stresses on any element
c (max record length)
c = DB_NUMDEFINED - return total number of element
c nodal stresses defined in model
c output arguments:
c ensiqr (int,func,out) - the returned value of ensiqr is based on
c setting of key
2–44 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c ensget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of nodal stresses
c returned
c value (dp,ar(*),out) - element nodal stresses
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (6*nnod*nface)
c value (dp,ar(nval),in) - the stress values
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–45
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element energies
c ielem > 0 - return number of element energies on
c this element (rec length)
c = 0 - return maximum number of element
c energies on any element
c (max rec length)
c = DB_NUMDEFINED - return the number of element energies
c defined in model
c output arguments:
c engiqr (int,func,out) - the returned value of engiqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c engget (int,func,out) - status of element.
c = 0 - element undefined
c = 11 - energies returned
c value (dp,ar(6),out)
c value(1) = volume of element
2–46 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values to be stored
c Must be 11!
c value (dp,ar(6),in) - volume and energies
c value(1) = volume of element
c (2) = strain energy
c (3) = dissipation energy
c (4) = kinetic energy
c (5) = plastic energy
c (6) = creep energy
c (7-8) = spares
c (9) = thermal energy
c (10-11) = spares
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about nodal gradients
c for ielem > 0 - return number of nodal gradients on
c this element (record length)
c = 0 - return maximum number of nodal
c gradients on any element
c (maximum record length)
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–47
Chapter 2: Accessing the ANSYS Database
c output arguments:
c egriqr (int,func,out) - the returned value of egriqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c egrget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of nodal gradients
c returned
c value (dp,ar(*),out) - element nodal gradients
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (ndir*nnod*nscalr)
c value (dp,ar(nval),in) - the gradient values
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
2–48 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about elastic strains
c ielem > 0 - return number of nodal elasic strains
c on this element (rec length)
c = 0 - return maximum number of nodal elastic
c strains on any element
c (max rec length)
c = DB_NUMDEFINED - return the number of nodal elastic strains
c defined in model
c output arguments:
c eeliqr (int,func,out) - the returned value of eeliqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c eelget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of nodal elastic strains
c returned
c value (dp,ar(*),out) - element nodal elastic strains
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–49
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (6*nnod*nface)
c value (dp,ar(nval),in) - nval strain values
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
2–50 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about plastic strains
c ielem > 0 - return number of nodal plastic strains
c on this element
c (record length)
c = 0 - return maximum number of nodal plastic
c strains on any element
c (max record length)
c = DB_NUMDEFINED - return the number of nodal plastic strains
c defined in model
c output arguments:
c epliqr (int,func,out) - the returned value of epliqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c eplget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of nodal plastic strains
c returned
c value (dp,ar(*),out) - element nodal plastic strains
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–51
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (6*nnod*nface)
c value (dp,ar(nval),in) - the strain values
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about creep strains
c ielem > 0 - return number of nodal creep strains
c on this element
c (record length)
2–52 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c output arguments:
c ecriqr (int,func,out) - the returned value of ecriqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c ecrget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of nodal creep strains
c returned
c value (dp,ar(*),out) - element nodal creep strains
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (6*nnod*nface)
c value (dp,ar(nval),in) - the strain values
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–53
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about thermal strains
c ielem > 0 - return number of nodal thermal strains
c on this element
c (record length)
c = 0 - return maximum number of nodal thermal
c strains on any element
c (max record length)
c = DB_NUMDEFINED - return the number of nodal thermal strains
c defined in model
c output arguments:
c ethiqr (int,sc,out) - the returned value of ethiqr is based on
c setting of key
2–54 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c ethget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of nodal thermal strains
c returned
c value (dp,ar(*),out) - element nodal thermal strains
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (6*nnod*nface)
c value (dp,ar(nval),in) - the strain values
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–55
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element euler angles
c ielem > 0 - return number of euler angles on this
c element
c (record length)
c = 0 - return maximum number of euler angles
c on any element
c (max record length)
c = DB_NUMDEFINED - return the number of element euler angles
c defined in model
c output arguments:
c euliqr (int,func,out) - the returned value of euliqr is based on
c setting of key
2–56 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c eulget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of euler angle values
c returned
c value (dp,ar(*),out) - element euler angles
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (3 * number of display nodes)
c value (dp,ar(nval),in) - the euler angle values
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–57
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element fluxes
c ielem > 0 - return number of fluxes on this
c element
c (record length)
c = 0 - return maximum number of fluxes
c on any element
c (max record length)
c = DB_NUMDEFINED - return the number of element fluxes defined
c in model
c output arguments:
c efxiqr (int,func,out) - the returned value of efxiqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c efxget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of nodal fluxes returned
c value (dp,ar(*),out) - element nodal fluxes
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c (ndir*nnod*nscalr)
c value (dp,ar(nval),in) - the flux values
2–58 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element local forces
c ielem > 0 - return number of local forces on this
c element
c (record length)
c = 0 - return maximum number of local forces
c on any element
c (max record length)
c = DB_NUMDEFINED - return the number of element local forces
c defined in model
c output arguments:
c elfiqr (int,func,out) - the returned value of elfiqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c elfget (int,func,out) - status of element.
c = 0 - element has no local nodal forces
c > 0 - number of nodal forces returned
c value (dp,ar(*),out) - element local nodal forces.
c input arguments:
c variable (typ,siz,intent) description
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c NOTE: There may be a maximum of 3 sets of
c nodal forces in the record: static
c forces, inertia forces, and damping forces
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–59
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element misc non-summed data
c ielem > 0 - return number of data items on this
c element
c (record length)
c = 0 - return maximum number of data items
c on any element
c (max record length)
c = DB_NUMDEFINED - return the number of element misc non-summed
c data items defined in model
c output arguments:
c emniqr (int,func,out) - the returned value of emniqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c emnget (int,func,out) - status of element.
c = 0 - no non-summed misc data at this
c element
c > 0 - number of data items returned
c value (dp,ar(*),out) - element misc non-summed data.
2–60 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c value (dp,ar(nval),in) - the misc. non-summed data items
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element current densities
c ielem > 0 - return number of current densities on
c this element
c (record length)
c = 0 - return maximum number of current
c densities on any element
c (max record length)
c = DB_NUMDEFINED - return the number of element current
c densities defined in model
c output arguments:
c ecdiqr (int,func,out) - the returned value of ecdiqr is based on
c setting of key
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–61
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c ecdget (int,func,out) - status of element.
c = 0 - element has no current densities
c > 0 - number of calculated element
c current densities
c value (dp,ar(*),out) - calculated element current densities.
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c value (dp,ar(nval),in) - calculated element current densities.
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about element nonlinear tables
c ielem > 0 - return number of nonlinear tables for
2–62 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c this element
c (record length)
c = 0 - return maximum number of nonlinear
c tables for any element
c (max record length)
c = DB_NUMDEFINED - return the number of element nonlinear
c tables defined in model
c output arguments:
c enliqr (int,func,out) - the returned value of enliqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c enlget (int,func,out) - status of element.
c = 0 - nonlinear tables undefined
c > 0 - number of nonlinear tables defined
c value (dp ,ar(n),out) - the element nonlinear tables.
c input arguments:
c ielem (int,sc,in) - element number
c n (int,sc,in) - number of element nonlinear table values
c temp (dp ,ar(6),in) - element nonlinear table,etc.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–63
Chapter 2: Accessing the ANSYS Database
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
c input arguments:
c ielem (int,sc,in) - element number (or zero, see below)
c key (int,sc,in) - key as to the information needed
c = 1 - return info about calculated element heat gens
c for ielem > 0 - return number of heat gens for
c this element
c (record length)
c = 0 - return maximum number of heat gens
c for any element
c (max record length)
c = DB_NUMDEFINED - return the number of calculated element heat
c generations defined in model
c output arguments:
c ehciqr (int,func,out) - the returned value of ehciqr is based on
c setting of key
c input arguments:
c ielem (int,sc,in) - element number
c output arguments:
c ehcget (int,func,out) - status of element.
c = 0 - element undefined
c > 0 - number of calculated element
c heat generations
c value (dp,ar(*),out) - calculated element heat generations.
c input arguments:
c ielem (int,sc,in) - element number
c nval (int,sc,in) - the total number of values
c value (dp,ar(nval),in) - calculated element heat generations.
2–64 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 2.10: Results Information Routines
c input arguments:
c ielem (int,sc,in) - element number
c = 0 - delete for all defined elements
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 2–65
2–66
Chapter 3: Subroutines for Users' Convenience
3.1. What Subroutines Does This Chapter Describe?
This chapter describes ANSYS routines available to you for use in programming. Using these routines isn't required,
but may make your life easier. These routines include a set of general routines that perform utility-type functions,
a set of routines supporting vector functions, a set of routines supporting matrix functions, and routines supporting
message processing options.
int - integer
dp - double precision
log - logical
chr - character
dcp - double precision complex
• Argument size is one of the following:
sc - scalar variable
ar(n) - array variable of length n
func - functional return value
• Argument intent is one of the following:
in - input argument
out - output argument
inout - both an input and an output argument
c !!! NOTICE to progammers: this routine does not convert from a !!!
c !!! machine-independent format! Use dpexttoch if this dp word !!!
c !!! came from a common or non-char database record !!!
c input arguments:
c dp8 (dp,sc,in) - dp variable containing characters
c output arguments:
c ch8 (ch*8,sc,out) - characters retreived from the dp word
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Chapter 3: Subroutines for Users' Convenience
c input arguments:
c variable (typ,siz,intent) description wrcom name
c key (int,sc,in)
c = WR_PRINT - print flag (kprint) prtkey
c wrinqr = 0 - no output
c = 1 - print
c = WR_OUTPUT - current output unit number (iott) outfil
c = WR_MASTEROUT - master output file frstot
c = WR_COLINTER - interactive columns per page intcol
c = WR_COLBATCH - batch columns per page batcol
c = WR_LINEINTER - interactive lines per page intlin
c = WR_LINEBATCH - batch lines per page batlin
c = WR_CHARITEM - characters per output item chrper
c = WR_CHARDECIMAL - characters past decimal chrdec
c = WR_CHARINTEGER - characters in leading integer chrint
c = WR_CHARTYPE - chrtyp
c wrinqr = 1 - using E format in output
c = 2 - using F format in output
c = 3 - using G format in output
c = WR_SUPTITLE - tlabel supress key keyhed
c = WR_SUPSUBTITLE - subtitle supress key keytit
c = WR_SUPLSITER - ls,iter id supress key keyid
c = WR_NOTELINE - note line supress key keynot
c = WR_SUPCOLHEADER - column header supress key keylab
c = WR_SUPCOLMAX - column maximum supress key keysum
c = WR_LISTOPT - ListOpt from /output command ListOpt
c output arguments:
c wrinqr (int,func,out) - the value corresponding to key
3–2 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 3.2: General Subroutines
co keyerr -
master error flag (ER_ERRORFLAG)
co errfil -
errors file unit number (ER_ERRORFILE)
co numnot -
total number of notes displayed (ER_NUMNOTE)
co numwrn -
total number of warnings displayed (ER_NUMWARNING)
co numerr -
total number of errors displayed (ER_NUMERROR)
co numfat -
total number of fatals displayed (ER_NUMFATAL)
co maxmsg -
max allowed number of displayed messages before abort(ER_MAXMESSAGE)
co lvlerr -
used basicly in solution (from cnvr command.) (ER_ERRORLEVEL)
co -1=do not set keyerr for notes/errors/warnings.
co -2=same as -1 but do not display message either.
co mxpcmd - maximum number of messages allowed per command (ER_MAXCOMMAND)
co nercmd - number of messages displayed for any one command (ER_NUMCOMMAND)
co nertim - key as to how message cleared from u/i pop-up (ER_UICLEAR)
co (as per rsg/pft 5/1/92 - only for "info" calls
co -1=message is timed before removal
co 0=message needs pick or keyboard before removal
co 1=message stays up untill replaced by another message
co nomore display any more messages (ER_NOMOREMSG)
co 0=display messages
co 1=display discontinue message and stop displaying
co eropen - 0=errors file is closed (ER_FILEOPEN)
co 1=errors file is opened
co ikserr - 0=if interactive do not set keyerr (ER_INTERERROR)
c - 1=if interactive set keyerr (used by mesher and tessalation)
co kystat - flag to bypass keyopt tests in the elcxx routines (ER_KEYOPTTEST)
c associated with status/panel info inquiries.
c 0=do not bypass keyopt tests
c 1=perform all keyopt tests
c also flag to bypass setting of _STATUS upon resume
co mxr4r5 - mixed rev4-rev5 input logic (*do,*if,*go,*if-go) (ER_MIXEDREV)
c (used in chkmix called from rdmac)
c 1=rev5 found (*do,*fi-then-*endif)
c 2=rev4 found (*go,:xxx,*if,....,:xxx)
c 3=warning printed. do not issue any more.
co mshkey - cpu intensive meshing etc. this will cause (ER_MESHING)
c "nertim (11)" to be set to -1 for "notes", 1 for "warnings",
c and 0 for "errors". checking of this key is done in "anserr".
c 0=not meshing or cpu intensive
c 1=yes, meshing or cpu intensive
co syerro - systop error code. read by anserr if set. (18)
co opterr - 0=no error in main ansys during opt looping (ER_OPTLOOPING)
c 1=an error has happened in main ansys during opt looping
co flowrn - flag used by "floqa" as to list floqa.ans (20)
c 0=list "floqa.ans"
c 1="floqa.ans" has been listed. do not list again.
co noreport- used in GUI for turning off errors due to strsub calls (22)
c 0=process errors as usual
c 1=do NOT report errors
co pdserr - 0=no error in main ansys during pds looping (ER_PDSLOOPING)
c 1=an error has happened in main ansys during pds looping
co mxpcmdw- number of messages written to file.err for any one (24)
co command
c 0=write all errors to file.err
c 1=only write displayed errors to file.err
co icloads - key to forbid the iclist command from listing solution (26)
c data instead of the input data.
c 0=iclist is OK
c 1=do not permit iclist
co ifkey - key on whether or not to abort during /input on error (27)
c 0=do not abort
c 1=abort
c
co espare - spare integer variables
c
c --- end of information from errcom
c
c output arguments:
c erinqr (int,sc,out) - value corresponding to key
c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 3–3
Chapter 3: Subroutines for Users' Convenience
c input arguments:
c sub32 (char*(*),sc,in) - name of subroutine being entered and left
c (32 characters max)
c input arguments:
c sub32 (char*(*),sc,in) - name of subroutine being left
c (32 characters max)
c input arguments:
c filein (ch*40,sc,in) - Filename used for character portion of
c message ID (this is the file name of the
c file which contains the source for this
c routine)
c
c if 'ErrorMessageProbe', then error was
c generated on another processor (distributed
c ANSYS). In that case, dperr contains the
c message already made ASCII and expanded
c
c msgid (int,sc,in) - Numeric portion of the message ID
c 1 - 9999, unique for each erhandler
c call in the FILE. Recommend using
c a sequence, similar to format conventions,
c i.e., 3010, 3020, 3030
c if filein='ErrorMessageProbe', this is the
c CPU # that originally generated the error
c msglvl (int,sc,in) - level of error (same as lngerr)
c 0=no label (used for u/i pop-ups)
c -1=no label (used for u/i pop-ups) timed
c as a note message
c 1=note, 2=warning, 3=error, 4=fatal
c lngstrng (ch*(*),sc,in) - error message to display. use keywords
c of %i %g %c %/ for formating (same as
c lngerr)
c dperr (dp,ar(*),in) - vector of data to display. contains both
c integer and double precision data.
3–4 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 3.2: General Subroutines
c (same as lngerr)
c if filein='ErrorMessageProbe', dperr
c contains the unpacked message and lngstrng
c and cherr are ignored
c cherr (ch*(*),ar(*),in) - vector of character data to display
c max length of character data is 32
c characters
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 3–5
Chapter 3: Subroutines for Users' Convenience
c
c *** Notice - This file contains ANSYS Confidential information ***
c
c input arguments:
c nnod (int,sc,in) - number of nodes (2 or 3)
c xyz (dp,ar(nx,*),in) - coordinates (x,y,z down)
c nx (int,sc,in) - row dimension of xyz array
c
c output arguments:
c tr (dp,ar(3,3),in) - transformation matrix
c
c input arguments:
c v1 (dp,ar(n),in) - vector v1
c v2 (dp,ar(n),in) - vector v2
c n (int,sc,in) - length of vectors v1 and v2
c output arguments:
3–6 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 3.3: Vector Functions
c input arguments:
c va (dp,ar(n),in) - vector va
c n (int,sc,in) - length of vector va
c output arguments:
c vsum (dp,sc,out) - vector sum
3.3.3. vmax Function (Retrieving the Maximum Vector Value at a Given Loca-
tion)
*deck,vmax
function vmax (v,n,locmax)
c *** primary function: return the max value and location in a vector
c input arguments:
c v (dp,ar(n),in) - vector v
c n (int,sc,in) - length of vector v
c output arguments:
c locmax (int,sc,out) - location of max value in vector v
c vmax (dp,sc,out) - max value in vector v
3.3.4. lastv Function (Retrieving the Position of the Last Nonzero Term in a
Double Precision Vector)
*deck,lastv
function lastv (v,n)
c ********* find position of last non-zero term in a d.p. vector *********
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 3–7
Chapter 3: Subroutines for Users' Convenience
c input arguments:
c v (dp,ar(n),inout) - vector to zero out
c n (int,sc,in) - number of words to zero out
c output arguments:
c v (dp,ar(n),inout) - zeroed vector
c
c input arguments:
c n (int,sc,in) - length of vector v
c const (dp,sc,in) - constant to set vector v to
c output arguments:
c v (dp,ar(n),out) - vector v
c
3–8 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 3.3: Vector Functions
c input arguments:
c a (dp,ar(n),in) - a vector
c b (dp,ar(n),in) - b vector
c n (int,sc,in) - length of vectors a,b,c
c output arguments:
c c (dp,ar(n),out) - c vector
c
3.3.15. vamb Subroutine (Gets a Third Vector by Subtracting One Vector from
Another)
*deck,vamb
subroutine vamb (a,b,c,n)
c *** primary function: subtract vector b from vector a to get vector c
c input arguments:
c a (dp,ar(n),in) - vector a
c b (dp,ar(n),in) - vector b
c n (int,sc,in) - length of vectors a,b,c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 3–9
Chapter 3: Subroutines for Users' Convenience
c output arguments:
c c (dp,ar(n),out) - vector c
c
c input arguments:
c a (dp,ar(n),inout) - a vector
c b (dp,ar(n),in) - b vector
c n (int,sc,in) - length of vectors a,b
c output arguments:
c a (dp,ar(n),inout) - a vector
c
c input arguments:
c v1 (dp,ar(n),in) - vector v1
c n (int,sc,in) - length of vectors v1, v2
c const (dp,sc,in) - constant to multiply v1
c output arguments:
c v2 (dp,ar(n),out) - vector v2
c input arguments:
c v1 (dp,ar(n),inout) - vector v1
c n (int,sc,in) - length of vector n
c const (dp,sc,in) - constant to multiply v1
c output arguments:
c v1 (dp,ar(n),inout) - vector v1
c
3–10 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 3.3: Vector Functions
c input arguments:
c a (dp,ar(3),in) - first vector to be cross-multiplied
c b (dp,ar(3),in) - second vector to be cross-multiplied
c output arguments:
c c (dp,ar(3),out) - resulting vector
c
c input arguments:
c iel (int,sc,inout) - element number
c v (dp,ar(3),inout) - vector to be normalized
c output arguments:
c iel (int,sc,inout) - if 0, vector has zero length
c v (dp,ar(3),inout) - normalized vector
c input arguments:
c v (dp,ar(n),inout) - vector v
c n (int,sc,inout) - dimension length of vector v
c output arguments:
c v (dp,ar(n),inout) - normalized vector v
c n (int,sc,inout) - n = 0 if error in operation
c input arguments:
c node (int,sc,in) - node number for operation.
c output arguments:
c ndgxyz (int,sc,out) - status of node.
c 0=node is undefined.
c -1=node is unselected.
c 1=node is selected.
c xyz (dp,ar(3),out) - vector containing x,y,z
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 3–11
Chapter 3: Subroutines for Users' Convenience
c input arguments:
c node (int,sc,in) - node number for operation.
c xyz (dp,ar(3),in) - vector containing x,y,z
c (vector should be in global system)
c input arguments:
c a (dp,ar(nr,*),in) - matrix a
c v (dp,ar(*),in) - vector v
c nr (int,sc,in) - number of rows in matrix a
c nc (int,sc,in) - number of columns to multiply in matrix a
c output arguments:
c w (dp,ar(*),out) - product vector w
c
c input arguments:
c a (dp,ar(nr,nc),in) - matrix a
c v (dp,ar(nc),inout) - vector v
c nr (int,sc,in) - number of rows in matrix a
c *** nr limited to 60 ***
c nc (int,sc,in) - number of columns to multiply in matrix a
c output arguments:
c v (dp,ar(nr),inout) - product, stored in vector v
c input arguments:
c a (dp,ar(nr,*),in) - matrix a (first dimension must = nr)
c v (dp,ar(nv),in) - vector v (nv must be greater or equal
3–12 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 3.4: Matrix Subroutines
c to nr)
c nr (int,sc,in) - first dimension and number of active
c rows of the untransposed matrix a
c (also the number of active rows
c of vector v)
c nc (int,sc,in) - number of columns of the untransposed
c matrix a
c (also the number of computed items
c in the product vector w)
c if negative, accumulate
c output arguments:
c w (dp,ar(na,*),out) - product vector w
c
c input arguments:
c a (dp,ar(nr,*),in) - matrix a
c v (dp,ar(nr),inout) - vector v
c nr (int,sc,in) - number of rows in matrix (un-transposed)
c nc (int,sc,in) - number of columns in matrix (un-transposed)
c *** nc limited to 60 ***
c output arguments:
c v (dp,ar(nc),inout) - product, stored in vector v
c
c input arguments:
c a (dp,ar(na,*),in) - matrix a
c b (dp,ar(nb,*),in) - matrix b
c na (int,sc,in) - number of rows in matrix a
c nb (int,sc,in) - number of rows in matrix b
c nc (int,sc,in) - number of rows in matrix c
c n1 (int,sc,in) - number of rows in matrix c to fill
c n2 (int,sc,in) - number of columns in matrix c to fill
c n3 (int,sc,in) - number of columns in matrix a and
c number of rows of matrix b
c to work with (the two need
c to be the same for the inner product)
c if n3 is negative, accumulate results in c
c output arguments:
c c (dp,ar(nc,*),out) - product matrix c
c
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 3–13
Chapter 3: Subroutines for Users' Convenience
c input arguments:
c a (dp,ar(*),in) - vector to be multiplied by itself to
c generate an nxn square matrix
c (a by a-transposed)
c c (dp,ar(nc,*),inout) - matrix to be accumulated onto
c nc (int,sc,in) - number of rows in the c matrix
c n (int,sc,in) - size of square matrix
c con (dp,sc,in) - multiplier on above square matrix
c output arguments:
c c (dp,ar(nc,*),inout) - matrix to be accumulated onto
c only the lower triangular matrix is done
3.4.7. matsym Subroutine (Filling the Upper Triangle from the Lower Triangle)
*deck,matsym
subroutine matsym (a,nd,n)
c primary function: fill upper triangle from lower triangle
c input arguments:
c a (dp,ar(nd,*),inout) - matrix to have its lower triangular part
c copied to its upper triangular part
c nd (int,sc,in) - number of rows of the a matrix
c n (int,sc,in) - size of matrix to be processed
c output arguments:
c a (dp,ar(nd,*),inout) - matrix that has its lower triangular part
c copied to its upper triangular part
c
c input arguments:
c a (dp,ar(na,na),inout) matrix to be pre and post multiplied
c (part operated on must be
c square(nold x nold) and symmetric)
c na (int,sc,in) first dimension of the a matrix
c c (dp,ar(nc,nnew),in) matrix to pre and post multiply a by
c (part used may be rectangular(nold x nnew))
c nc (int,sc,in) first dimension of the c matrix
c nold (int,sc,in) size of part of 'A' matrix that is
c to be processed(input size). maximum = 64
c nnew (int,sc,in) size of part of 'A' matrix that
c results from this operation(output size).
c maximum = 64
c output arguments:
c a (dp,ar(na,na),inout) resulting matrix
c (still square(nnew x nnew) and symmetric).
3–14 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section 3.4: Matrix Subroutines
c input arguments:
c variable (typ,siz,intent) description
c zs (dp,ar(nz,nz),inout) - matrix to be transformed
c tr (dp,ar(ntr,ntr),in) - transformation matrix
c nz (int,sc,in) - dimensioned size of zs matrix
c ntr (int,sc,in) - dimensioned size of tr matrix
c nrow (int,sc,in) - number of rows of zs matrix to transform
c irot (int,sc,in) - block size to transform(size of tr matrix)
c output arguments:
c variable (typ,siz,intent) description
c zs (dp,ar(nz,nz),inout) - transformed matrix
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. 3–15
Chapter 3: Subroutines for Users' Convenience
3–16 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Appendix A. Creating External Commands in
UNIX
A.1. Introduction to External Commands
External commands allow you to add your own customized extensions to ANSYS without relinking the program.
You can create custom routines in C that access any of the ANSYS API functions, link them into shared libraries
using the supplied utilities, and execute the routines via the "external command" feature within ANSYS. In addition,
ANSYS provides special commands that list all available external commands and allow you to reset all currently
referenced external commands.
External command capability is supported on all UNIX platforms. Refer to your installation guide for currently
supported compilers; the following instructions assume the presence of compatible compilers and linkers.
The most important point in the following example it that the C program interface is an integer function that
has one argument (a char pointer).
#include "cAnsInterface.h"
#include "CAnsQuery.h"
/*
-------------------------- Function Description ---------------------
extfnc
int extfnc(uecmd)
char *uecmd;
Purpose:
Demonstrate C API entry function for an external command.
Parameters:
Input
-----------------------------
uecmd
The ANSYS external command string.
Output
-----------------------------
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Appendix A. Creating External Commands in UNIX
Return Value:
The return value is ignored by the calling function;
return (i);
where
-h
Produces command help.
-64
Configures the Makefile to use the -mips4 option for IRIX64 .
shared_object_name
Is the name that will be given to the shared library.
As gen_share is executing, you may see one or more "No match" messages. This is normal. The script is
searching for .c, .f, and .F file types in the current directory and returns this message if it cannot locate any files
matching one of those types.
To create a shared library called mylibrary.so, you would issue the following command:
% gen_share mylibrary.so
The utility will produce a Makefile in the current directory. You will be able to generate the shared library by is-
suing the following command:
make
For example, to create the shared library for mylibrary.so, you would issue the following command:
% make
A–2 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section A.2: Tasks in Creating an External Command
You will then find the specified shared library file in the current directory. You may also see warnings from the
make process, and you may need to modify the Makefile or your source code.
where
/shared/library/path/library.so
Is the path to the directory that contains the shared library file. (Remotely mounted file systems are not recom-
mended.)
~cm_name
Is the command used to invoke the function within ANSYS. The command name must begin with a tilde (~) and
each command name must be unique within the first four characters. The command name must be eight char-
acters or less, including the tilde (~).
function_name
Is the name of the function that is referenced by the specified command name. (This must be unique within the
first four characters if multiple external commands are specified.)
For example, the following entry references the /home/mydir/mylibs/myobject.so shared library and the my-
object_ function. It specifies ~myobj as the related command:
/home/mydir/mylibs/myobject.so ~myobj myobject_
ANSYS also makes use of external commands, and places its own shared libraries and the associated external
table file in the /ansys_inc/v100/ansys/lib/<platform> directory (where <platform> is the directory specific
to your computing platform, such as /sgi64 or /hppa8000-64).
• ANSYS first checks the ans_ext.tbl file in the /ansys_inc/v100/ansys/lib/<platform> directory and
loads any external commands referenced there.
• ANSYS then loads external commands referenced by the external table file in the directory designated
with the ANSYS_EXTERNAL_PATH environment variable (see section Section A.2.4: Setting the ANSYS_EX-
TERNAL_PATH Environment Variable).
If you designate a command name that has the same first four characters as a command listed in the /an-
sys_inc/v100/ansys/lib/<platform>/ans_ext.tbl file, you will not be able to access your command. Therefore,
it is a good practice to check the ANSYS external table file to make sure you have no external command name
conflicts. Do not modify the /ansys_inc/v100/ansys/lib/<platform>/ans_ext.tbl file. You can also use the
~DEBUG command to verify that no external command name conflicts exist.
Note — The shared library must be consistent with the computer type and OS level on which ANSYS will
be executed.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. A–3
Appendix A. Creating External Commands in UNIX
Note — Avoid recursive external commands; that is, avoid situations where an external command calls
another external command.
In this example, the output lists the command, the related shared library, the function, and if the command has
been accessed.
by issuing the ~RESET command. The command issues the following message to confirm that the reset operation
was complete.
~RESET was processed: The external command buffers have been cleared.
Note — The /CLEAR command also closes/resets all external command shared libraries.
A–4 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Appendix B. Creating External Commands in
Windows
B.1. Tasks in Creating an External Command
To create a functional external command, you will need to complete the following general steps:
• The C program interface is an integer function that has one argument (a char pointer).
#include <windows.h>
#include "cAnsInterface.h"
#include "CAnsQuery.h"
/*
------------------------------ Function Description -----------------------
extfnc
int extfnc(uecmd)
char *uecmd;
Purpose:
Parameters:
Input
-----------------------------
uecmd
The ANSYS external command string.
Output
-----------------------------
Return Value:
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Appendix B. Creating External Commands in Windows
*/
int extfnc(char* uecmd)
{
/* Note: uecmd is the entire command given to invoke this function */
char* cmdsend = {"/COM, COMMAND SENT FROM EXTERNAL COMMAND"};
char* querystr = {"NODE,,NUM,MAX"};
char strrtn[32];
int i, itype;
double dblrtn;
return (i);
• After launching Developer Studio, press Ctrl+N (or choose New from the FILE menu). In the New window,
click on the Projects tab. Select Win 32 Dynamic-Link Library, and specify your project name and directory.
• In the Workspace frame, click on the File View tab. Right click on the sub category projname files and
press F or select Add Files to Project). Choose your source and definition files, ansys.lib, cAnsInterface.h
and any other necessary header files. The import library file ansys.lib is in /ansys100/lib and the header
file cAnsysInterface.h is in /ansys100/extra/custom/include.
extfunc
B–2 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Section B.1: Tasks in Creating an External Command
where:
C:\shared\library\path\projname.dll is the path to the directory that contains the shared library file. (Remotely
mounted file systems are not recommended.)
~cm_name Is the command used to invoke the function within ANSYS. The command name must begin with a
tilde (~) and the first four characters of each command name must be unique.
function_name Is the name of the function that is referenced by the specified command name. (This must be
unique within the first four characters if multiple external commands are specified.)
For example, the following entry references the C:\home\mydir\mylibs\myobject.dll shared library and the
myobject function, and specifies ~myobj as the related command:
C:\home\mydir\mylibs\myobject.dll ~myobj myobject
ANSYS also makes use of external commands, and places its own shared libraries and the associated external
table file in the C:\Program Files\Ansys Inc\V100\lib\platform directory (where platform is the directory spe-
cific to your computing platform, such as \Intel). ANSYS loads external commands in the following order:
• ANSYS first checks the ans_ext.tbl file in the C:\Program Files\Ansys Inc\V100\lib\platform directory
and loads any external commands referenced there. ˙
• ANSYS then loads external commands referenced by the external table file in the directory designated
with the ANSYS_EXTERNAL_PATH environment variable (see Section B.1.6: Setting the ANSYS_EXTERN-
AL_PATH Environment Variable).
If you designate a command name that has the same first four characters as a command listed in the C:\Program
Files\Ansys Inc\V100\lib\platform file, you will not be able to access your command. Therefore, it is a good
practice to check the ANSYS external table file to make sure you have no external command name conflicts. Do
not modify the C:\Program Files\Ansys Inc\V100\lib\platform\ans_ext.tbl file. You can also use the ~DEBUG
command to verify that no external command name conflicts exist.
Note — The shared library must be consistent with the computer type and OS level on which ANSYS will
be executed.
Note — Avoid recursive external commands; that is, avoid situations where an external command calls
another external command.
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. B–3
Appendix B. Creating External Commands in Windows
Note that the output lists the command, the related shared library, the function, and whether or not the command
has been accessed.
by issuing the ~RESET command. This command issues the following message to confirm that the reset operation
is complete.
~RESET was processed: The external command buffers have been cleared.
Note — The /CLEAR command also closes/resets all external command shared libraries.
B–4 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
creating, 1–57
Index Common blocks, 1–4
cmopt, 1–68
Symbols Constitutive material models
3-D line elements, 3–5 creating, 1–40
3-D nodal coordinates, 1–30 Constraint equations
3-D spar element, 1–12 deleting or selecting, 2–18
getting , 2–17
getting information about, 2–17
A storing, 2–18
Accessing program logic, 1–65
Constraints
acelcm.inc file, 1–4
deleting at a node, 2–19
Activating UPFs, 1–7
getting from the database, 2–19, 2–20
ANSYS
getting information, 2–18
customized version of, 1–5
storing at a node, 2–19, 2–41
executing command from a user routine, 1–74
Convection loads
linking, 1–5, 1–67
defining, 1–31
optimization program to, 1–67
Converting nodal data to fixed format data blocks, 1–12
UPFs to, 1–5
Coordinate system
parameters, 1–4
deleting a coordinate system, 2–15
running as a subroutine, 1–56
getting a coordinate system, 2–14
start-up, 1–65
getting information about a coordinate system, 2–14
accessing program logic at, 1–65
storing a coordinate system, 2–15
stopping, 3–6
Coupled set
tailoring with UPFs, 1–1
getting a coupled set, 2–16
UPFs for, 1–1
getting information about, 2–15
ansyscust file, 1–6
selecting or deleting, 2–17
ansysdef.inc file, 1–4
storing a coupled set, 2–16
Arc-length debugging, 1–9
Coupling and constraint routines, 2–15
Auto time stepping debugging, 1–9
cpget, 2–16
cpinqr, 2–15
B cpput, 2–16
Basic element pass debugging, 1–10 cpsel, 2–17
Creating
C constitutive material models, 1–40
C, 1–1, 1–3 hyperelastic material models, 1–47
FORTRAN shell for, 1–3 plasticity laws, 1–42
.c extension, 1–5 swelling laws, 1–47
Calculating creep1 subroutine, 1–25
dot product of two vectors, 3–6 creep3 subroutine, 1–25
rotation caused by internal pressure, 1–36 csydel, 2–15
sum of vector components, 3–7 csyget, 2–14
ceget, 2–17 csyiqr, 2–14
ceinqr, 2–17 csyput, 2–15
ceput, 2–18 Custom failure criteria, 1–50
cesel, 2–18 Custom optimization routine, 1–68
Characters retrieved from a double precision variable, Customizing
3–1 ANSYS, 1–2
cmopt common block, 1–68 loads, 1–52
cmopt.inc file, 1–4 material properties, 1–39
cnvget subroutine, 1–31
COMBIN7 and COMBIN37 parameters, 1–35
Commands
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Index
D efxdel, 2–58
Database access routines, 2–1 efxget, 2–58
/DEBUG command, 1–9 efxiqr, 2–57
Debugging efxput, 2–58
elements, 1–10 egen function, 1–51
solutions, 1–9 egrdel, 2–48
Decks, 1–4 egrget, 2–48
disdel, 2–19 egriqr, 2–47
disget, 2–18, 2–19 egrput, 2–48
Displacement and coordinate debugging, 1–10 ehcdel, 2–65
Displacement values, 1–64 ehcget, 2–64
Displacement vector debugging, 1–9 ehciqr, 2–64
disput, 2–19 ehcput, 2–64
DOF pointers, 1–4 ehgdel, 2–33
Double precision vectors, 3–7 ehgget, 2–32
dptoch subroutine, 3–1 ehgiqr, 2–32
dspdel, 2–41 ehgput, 2–33
dspget, 2–41 eimdel, 2–38
dspiqr, 2–40 eimget, 2–37
dspput, 2–41 eimiqr, 2–37
eimput, 2–37
E elccmt subroutine, 1–13
elccmt.inc file, 1–4
ecddel, 2–62
eldwrnL subroutine, 1–29
ecdget, 2–62
eldwrtL subroutine, 1–28
ecdiqr, 2–61
elecom.inc file, 1–4
ecdput, 2–62
Element array data pointers, 1–4
echprm.inc file, 1–4
Element Attribute Routines, 2–7
echrtr, 2–9
Element calculated heat generation
ecrdel, 2–54
deleting, 2–65
ecrget, 2–53
getting, 2–64
ecriqr, 2–52
getting information about, 2–64
ecrput, 2–53
storing, 2–64
ecvdel, 2–30
Element convection
ecvget, 2–29
deleting, 2–30
ecviqr, 2–28
getting, 2–29
ecvput, 2–29
getting information about, 2–28
edcdel, 2–35
storing, 2–29
edcget, 2–35
Element current densities
edciqr, 2–34
deleting, 2–62
edcput, 2–35
getting, 2–62
eeldel, 2–50
getting information about, 2–61
eelget, 2–49
storing, 2–62
eeliqr, 2–49
Element current density
eelput, 2–50
deleting, 2–35
efsdel, 2–39
getting, 2–35
efsget, 2–39
getting information about, 2–34
efsiqr, 2–40
storing, 2–35
efsput, 2–40
Element data
efudel, 2–34
converting to fixed format blocks, 1–12
efuget, 2–34
writing to a file, 1–28
efuiqr, 2–33
Element energy
efuput, 2–34
Index–2 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Index
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. Index–3
Index
Index–4 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Index
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. Index–5
Index
Index–6 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Index
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. Index–7
Index
R matrix, 3–12
Reading large data files rapidly, 1–12 running ANSYS as, 1–56
Real constants supporting for user-created elements, 1–17
debugging, 1–10 supporting user-defined commands, 1–63
fetching, 1–21 tracking calls to, 3–4
getting information about a real constant set, 2–12 subwrt subroutine, 1–21
getting real constant data, 2–13 svgidx subroutine, 1–17
selecting or deleting a real constant set, 2–13 svpidx subroutine, 1–19
Restrictions on UPF creation, 1–1 svrget subroutine, 1–18
Results svrput subroutine, 1–18
deleting at a node, 2–41 swell1 subroutine, 1–26
Results information routines, 2–40 swell3 subroutine, 1–26
Results values Swelling laws, 1–47
getting at selected points, 1–65 symeqn subroutine, 3–15
Retrieving System dependencies, 1–3
maximum vector value for a location, 3–7 systop subroutine, 3–6
position of last nonzero term in a vector, 3–7
Reusing element matrices, 1–19 T
rlget, 2–13 Table data
rlinqr, 2–12 retrieving, 1–23
rlsel, 2–13 tbuser subroutine, 1–23
rottr subroutine, 1–29 Temperature loads
RunCommand function, 1–74 defining, 1–30
rvrget subroutine, 1–21 tmpget subroutine, 1–30
/TRACK command, 1–9
S TrackBegin subroutine, 1–9, 3–4
Saved variables TrackEnd subroutine, 1–9, 3–4
debugging, 1–10 tran subroutine, 3–15
fetching, 1–18 Transient debugging, 1–9
Scalar constants Transposing a matrix, 3–13
assigning to vectors, 3–8 tranx3 subroutine, 3–5
Scalar fields to user-defined values, 1–52 trrot subroutine, 1–29
Simultaneous linear equations, 3–15
Solution control debugging, 1–9 U
Solutions UAnBeg subroutine, 1–65
accessing program logic, 1–65 UAnFin subroutine, 1–65
debugging, 1–9 /UCMD command, 1–11
soptcm.inc file, 1–4 uec100 routine, 1–13
Source files, 1–5 uec100 subroutine, 1–13, 1–13
Stack storage definition, 1–4 uel100 subroutine, 1–13, 1–14
stack.inc file, 1–4 uel101 subroutine, 1–3
START.ANS file, 1–57 UElMatx subroutine, 1–36
stepcm.inc file, 1–4 uep100 subroutine, 1–13, 1–15
Stopping ANSYS, 3–6 uex100 subroutine, 1–13, 1–14
Storing UItBeg subroutine, 1–65
user-supplied element output, 1–33 UItFin subroutine, 1–65
Structural mass element, 1–12 ULdBeg subroutine, 1–65
subrd subroutine, 1–20 ULdFin subroutine, 1–65
Subroutines /UNDO command, 1–75
for elements, 1–3 UNIX systems
for memory management, 1–70 compiling and linking UPFs on, 1–5
for processing parameters, 1–72 FORTRAN programming on, 1–3
Index–8 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.
Index
Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc. Index–9
Index
W
Wavefront reordering debugging, 1–11
Windows systems
compiling and linking UPFs on, 1–6
wrinqr function, 3–2
X
xyzup3 subroutine, 1–30
Index–10 Guide to ANSYS User Programmable Features . ANSYS Release 10.0 . 002187 . © SAS IP, Inc.