Variational Technology for Improved Solver Performance
3.3. Modifying the Adaptive Meshing Process
This section describes how to modify adaptive meshing by employing selective adaptivity, enhancing the ADAPT macro's functionality via user subroutines, and customizing the ADAPT macro itself via the UADAPT macro.
3.3.1. Selective Adaptivity
If you know that mesh discretization error (measured as a percentage) is relatively unimportant in some regions of your model (for instance, in a region of low, slowly-changing stress), you can speed up your analysis by excluding such regions from the adaptive meshing operations. Also, you might want to ex-clude regions near singularities caused by concentrated loads. Selecting logic provides a way of handling such situations.
Figure 3.1: Selective Adaptivity
Selective adaptivity can improve the performance of models having concentrated loads.
If you select a set of keypoints, the ADAPT macro will still include all your keypoints (that is, the ADAPT macro will modify the mesh at both selected and non-selected keypoints), unless you also set KYKPS
= 1 in the ADAPT command (Main Menu> Solution> Solve> Adaptive Mesh).
If you select a set of areas or volumes, the ADAPT macro will adjust element sizes only in those regions that are in the selected set. You will have to mesh your entire model in PREP7 before executing ADAPT.
3.3.2. Customizing the ADAPT Macro with User Subroutines
The standard ADAPT macro might not always be applicable to your particular analysis needs. For instance, you might need to mesh both areas and volumes, which is not possible with the standard macro. For this and other such situations, you can modify the ADAPT macro to suit your analysis needs. By using a macro to perform the adaptive meshing task, we have intentionally given you access to the logic in-volved, and have thereby furnished you with the capability for modifying the technique as you might desire.
Fortunately, you do not always need to change the coding within the ADAPT macro to customize it.
Three specific portions of the macro can be readily modified by means of user subroutines, which are separate user files that you can create and that will be called by the ADAPT macro. The three features that can be modified by user subroutines are:
• the meshing command sequence
• the boundary condition command sequence,
• the solution command sequence
The corresponding user subroutine files must be named ADAPTMSH.MAC,ADAPTBC.MAC, and AD-APTSOL.MAC, respectively.
3.3.2.1. Creating a Custom Meshing Subroutine (ADAPTMSH.MAC)
By default, if your model contains one or more selected volumes, the ADAPT macro will mesh only volumes (no area meshing will be done). If you have no selected volumes, then the ADAPT macro will
mesh only areas. If you desire to mesh both volumes and areas, you can create a user subroutine, AD-APTMSH.MAC, to perform all the desired operations. You will need to clear any specially-meshed entities before remeshing. Such a subroutine might look like this:
C*** Subroutine ADAPTMSH.MAC - Your name - Job Name - Date Created TYPE,1 ! Set element TYPE attribute for area meshing
ACLEAR,3,5,2 ! Clear areas and volumes to be meshed by this subroutine VCLEAR,ALL
AMESH,3,5,2 ! Mesh areas 3 and 5 (no other areas will be meshed by ADAPT) TYPE,2 ! Change element type for volume mesh
VMESH,ALL ! Mesh all volumes
Please see the TYPE,ACLEAR,VCLEAR,AMESH, and VMESH command descriptions for more information.
We strongly recommend that you include a comment line (C***) to identify your macro uniquely. This comment line will be echoed in the job printout, and will provide assurance that the ADAPT macro has used the correct user subroutine.
3.3.2.2. Creating a Custom Subroutine for Boundary Conditions (ADAPTBC.MAC)
The ADAPT macro clears and remeshes with every new solution loop. As a result, your model's nodes and elements will be repeatedly changing. This situation generally precludes the use of finite element loads, DOF coupling, and constraint equations, all of which must be defined in terms of specific nodes and elements. If you need to include any of these finite-element-supported items, you can do so by writing a user subroutine,ADAPTBC.MAC. In this subroutine, you can select nodes by their location, and can then define finite element loads, DOF coupling, and constraint equations for the selected nodes.
A sample ADAPTBC.MAC subroutine follows:
C*** Subroutine ADAPTBC.MAC - Your name - Job Name - Date Created NSEL,S,LOC,X,0 ! Select nodes @ X=0.0
D,ALL,UX,0 ! Specify UX=0.0 for all selected nodes NSEL,S,LOC,Y,0 ! Select nodes @ Y=0.0
D,ALL,UY,0 ! Specify UY=0.0 for all selected nodes NSEL,ALL ! Select all nodes
3.3.2.3. Creating a Custom Solution Subroutine (ADAPTSOL.MAC)
The default solution command sequence included in the ADAPT macro is simply:
/SOLU SOLVE FINISH
This default sequence will solve only a single load step. You might be able to implement other solution sequences by incorporating them into the user subroutine ADAPTSOL.MAC.
3.3.2.4. Some Further Comments on Custom Subroutines
You can create the ADAPTMSH.MAC,ADAPTBC.MAC, and ADAPTSOL.MAC subroutine files as you would any user files.
You can use either the APDL command *CREATE (Utility Menu> Macro> Create Macro), the APDL command *END, or a third-party text editor. When the ADAPT macro calls the subroutines, the program will search first through the ANSYS root directory, then through your root directory, and last through the current directory. Thus, you should take care to ensure that no identically-named files from another directory will be read in place of your intended files. The comment lines (C***) shown in the example subroutines above would be echoed in your printout, and would provide one means of checking that the proper files were used. Additionally, executing /PSEARCH,OFF (Utility Menu> Macro> Macro Search
Path) before running the ADAPT macro would restrict the file search to the ANSYS root directory and your current directory, reducing somewhat the possibility that the wrong file will be used.
No matter where they reside, the subroutines will be accessed only if you set KYMAC = 1 on the ADAPT command (Main Menu> Solution> Solve> Adaptive Mesh). See the Guide to User-Programmable Features for more information on user subroutines and the ANSYS Parametric Design Language Guide for more information on APDL.
3.3.3. Customizing the ADAPT Macro (UADAPT.MAC)
For those cases when you need to modify the ADAPT macro but are unable to do so via separate user subroutines, you can modify the main body of the macro.
To maintain the integrity of the ADAPT macro, ANSYS does not recommend modifying the ADAPT.MAC file directly. Instead, use the UADAPT.MAC file (an identical copy of ADAPT.MAC), provided on the ANSYS installation media.
If you modify the UADAPT.MAC file, it is a good idea to rename the modified file (especially to denote the specific version that you have created). Afterwards, instead of issuing the command ADAPT, call the modified adaptive meshing procedure by issuing the new file name.
Be aware that if you use the new file name as an "unknown command," the program will first search through the high-level directory, then through the login directory, and finally through the working directory, until the macro is found. If a modified adaptive procedure is to be accessible by a single user, it makes sense to store the file in a directory no higher than the user's login directory. If the macro file is stored in such a low-level directory, the file search can be streamlined by calling the macro using the
*USE command (Utility Menu> Macro> Execute Data Block) in place of the unknown command format.