*loop, *end, *break. These are declared for the use of loops. A loop begins with a line that starts with loop (none of these commands is case-sensitive) and contains another word to express the variable of the loop. There are some lines in the middle that will be repeated depending on the values of the variable, and whose parameters will keep on changing throughout the iterations if necessary. Finally, a loop will end with a line that finishes with *end. After *end, you may write any kind of comments in the same line. The command **break inside a *loop or *for block, will finish the execution of the loop and will continue after the *end line.
Note: these commands must be written at the beginning of a line and the rest of the line will serve as their modifiers. No additional text should be written.
The variables that are available for *loop are the following:
- elems, nodes, faces, materials, conditions, layers, groups, intervals, localaxes. These commands mean, respectively, that the loop will iterate over the elements, nodes, faces of a group, materials, conditions, layers, groups, intervals or local axes systems. The loops can be nested among them. The loop over the materials will iterate only over the effectively assigned materials to an entity, in spite of the fact that more materials have been defined. The number of the materials will begin with the number 1. If a command that depends on the loop is located outside it, the number will also take by default the value 1.
After the command *loop:
- If the variable is nodes, elems or faces, you can include one of the modifiers: *all, *OnlyInCond,*OnlyInLayer or *OnlyInGroup. The first one signifies that the iteration is going to be performed over all the entities.
The *OnlyInCond modifier implies that the iteration will only take place over the entities that satisfy the relevant condition. This condition must have been previously defined with *set cond.
*OnlyInLayer implies that the iteration will only take place over the entities that are in the specified layer; layers must be specified with the command *set Layer.
*OnlyInGroup implies that the iteration will only take place over the entities that are in the specified group;
group must be specified inside a loop groups with the command *set Group *GroupName *nodes|elems|faces, or *set Group <name> , with <name> the full name of the group.
By default, it is assumed that the iteration will affect all the entities. - If the variable is material you can include the modifier *NotUsed to make a loop over those materials that are defined but not used.
- If the variable is conditions you must include one of the modifiers: *Nodes, *BodyElements, *FaceElements, *Layers or *Groups, to do the loop on the conditions defined over this kind of mesh entity, or only the conditions declared 'over layers' or only the ones declared 'over groups'.
- If the variable is layers you can include modifiers: OnlyInCond if before was set a condition defined 'over layers'
- If the variable is groups you can include modifiers: OnlyInCond if before was set a condition defined 'over groups' (e.g. inside a *loop conditions *groups)
Example 1:
*loop nodes *format "%5i%14.5e%14.5e" *NodesNum *NodesCoord(1,real) *NodesCoord(2,real) *end nodes
This command carries out a rundown of all the nodes of the mesh, listing their identifiers and coordinates (x and y coordinates).
Example 2:
*Set Cond Point-Weight *nodes *loop nodes OnlyInCond *NodesNum *cond(1) *end
This carries out a rundown of all the nodes assigned the condition "Point-Weight" and provides a list of their identifiers and the first "weight" field of the condition in each case.
Example 3:
*Loop Elems *ElemsNum *ElemsLayerNum *End Elems
This carries out a rundown of all the elements and provides a list of their identifier and the identifier of the layer to which they belong.
Example 4:
*Loop Layers *LayerNum *LayerName *LayerColorRGB *End Layers
This carries out a rundown of all the layers and for each layer it lists its identifier and name.
Example 5:
*Loop Conditions OverFaceElements *CondName *Loop Elems OnlyInCond *elemsnum *condelemface *cond *End Elems *End Conditions
This carries out a rundown of all conditions defined to be applied on the mesh 'over face elements', and for each condition it lists its name and for each element where this condition is applied are printed the element number, the marked face and the condition field values.
Example 6:
*loop intervals interval=*loopvar *loop conditions *groups *if(condnumentities) condition name=*condname *loop groups *onlyincond *groupnum *groupname *cond *end groups *end if *end conditions *end intervals
This do a loop for each interval, and for each condition defined 'over groups' list the groups where the condition was applied and its values.