*\ To avoid line-feeding you need to write *\, so that the line currently being used continues on the following line of the file filename.bas.
- *# If this is placed at the beginning of the line, it is considered as a comment and therefore is not written.
- ** In order for an asterisk symbol to appear in the text, two asterisks ** must be written.
- *Include. The include command allows you to include the contents of a slave file inside a master .bas file, setting a relative path from the Problem Type directory to this secondary file.
Example:
Code Block |
---|
*include includes\execntrlmi.h |
Note: The *.bas extension cannot be used for the slave file to avoid multiple output files.
- *MessageBox. This command stops the execution of the .bas file and prints a message in a window; this command should only be used when a fatal error occurs.
Example:
Code Block |
---|
*MessageBox error: Quadrilateral elements are not permitted. |
- *WarningBox. This is the same as MessageBox, but the execution is not stopped.
...
Code Block |
---|
WarningBox Warning: Bad elements. A STL file is a collection of triangles bounding a volume. |
...
- *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.
...
- 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.
...
- 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:
Code Block |
---|
*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).
...
Code Block |
---|
*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.
...
Code Block |
---|
*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.
...
Code Block |
---|
*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.
...
Code Block |
---|
*Loop Conditions OverFaceElements
*CondName
*Loop Elems OnlyInCond
*elemsnum *condelemface *cond
*End Elems
*End Conditions |
...
Code Block |
---|
*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.
- *if, *else, *elseif, *endif. These commands create the conditionals. The format is a line which begins with *if followed by an expression between parenthesis. This expression will be written in C-language syntax, value return commands, will not begin with *, and its variables must be defined as integers or real numbers (see *format, *intformat, *realformat), with the exception of strcmp and strcasecmp. It can include relational as well as arithmetic operators inside the expressions.
...
Code Block |
---|
*if((fabs(loopvar)/4)<1.e+2)
*if((p3<p2)||p4)
*if((strcasecmp(cond(1),"XLoad")==0)&&(cond(2)!=0)) |
The first example is a numerical example where the condition is satisfied for the values of the loop under 400, while the other two are logical operators; in the first of these two, the condition is satisfied when p3<p2 or p4 is different from 0, and in the second, when the first field of the condition is called XLoad (with this particular writing) and the second is not null.
...
Code Block |
---|
*if(GenData(31,int)==1)
...(1)
*elseif(GenData(31,int)==2)
...(2)
*else
...(3)
*endif
|
In the previous example, the body of the first condition (written as 1) will be written to the data file if GenData(31,int) is 1, the body of the second condition (written as 2) will be written to the data file if GenData(31,int) is 2, and if neither of these is true, the body of the third condition (written as 3) will be written to the data file.
Note: A conditional can also be written in the middle of a line. To do this, begin another line and write the conditional by means of the command *\.
- *for, *end, *break. The syntax of this command is equivalent to *for in C-language.
*for(varname=expr.1;varname<=expr.2;varname=varname+1)
*end for
...
Code Block |
---|
*for(i=1;i<=5;i=i+1)
variable i=*i
*end for |
- *set. This command has the following purposes:
- *set cond: To set a condition.
- *set Layer "layer name" *nodes|elems: To set a layer.
- *set Group "group name" *nodes|elems|faces: To set a group. (inside a *loop groups can use *GroupName as "group name" ,to get the name of the group of the current loop)
- *set elems: To indicate the elements.
- *set var: To indicate the variables to use.
...
Code Block |
---|
*Set Cond Volu-Cstrt *nodes
*Add Cond Surf-Cstrt *nodes
*Add Cond Line-Cstrt *nodes
*Add Cond Poin-Cstrt *nodes |
These let you apply the conditions directly over any geometric entity.
...
Code Block |
---|
*set Layer example_layer_1 *elems
*loop elems *OnlyInLayer
Nº:*ElemsNum Name of Layer:*ElemsLayerName Nº of Layer :*ElemsLayerNum
*end elems |
...
Code Block |
---|
*loop layers
*set Layer *LayerName *elems
*loop elems *OnlyInLayer
Nº:*ElemsNum Name of Layer:*ElemsLayerName Nº of Layer :*ElemsLayerNum
*end elems
*end layers |
In this example the command *LayerName is used to get the layer name.
...
Code Block |
---|
*Set Cond Line-Constraints *nodes |
In this case, when two lines share one endpoint, instead of two nodes in the list, only one is written.
A typical situation where you would use *CanRepeat might be:
Code Block |
---|
*Set Cond Line-Pressure *elems *CanRepeat |
In this case, if one triangle of a quadrilateral has more than one face in the marked boundary then we want this element to appear several times in the elements list, once for each face.
...
Code Block |
---|
*Set Cond Volu-Cstrt *nodes *or(1,int) *or(2,int)
*Add Cond Surf-Cstrt *nodes *or(1,int) *or(2,int)
*Add Cond Line-Cstrt *nodes *or(1,int) *or(2,int)
*Add Cond Poin-Cstrt *nodes *or(1,int) *or(2,int) |
...
Code Block |
---|
*Set Cond Dummy *elems
*Set elems(All)
*Remove elems(Linear) |
To indicate that all dummy elements apart from the linear ones will be considered, as well as:
Code Block |
---|
*Set Cond Dummy *elems
*Set elems(Hexahedra)
*Add elems(Tetrahedra)
*Add elems(Quadrilateral)
*Add elems(Triangle) |
The format for *set var differs from the syntax for the other two *set commands. Its syntax is as follows:
*Set var varname = expression
where varname is any name and expression is any arithmetical expression, number or command, where the latter must be written without *** and must be defined as Int or Real.
A Tcl procedure can also be called, but it must return a numerical result.The following are valid examples for these assignments:
Code Block |
---|
*Set var ko1=cond(1,real)
*Set var ko2=2
*Set var S1=CondNumEntities
*Set var p1=elemsnum()
*Set var b=operation(p1*2)
*tcl(proc MultiplyByTwo { x } { return [expr {$x*2}] })*\
*Set var a=tcl(MultiplyByTwo *p1) |
- *intformat, *realformat, *format. These commands explain how the output of different mathematical expressions will be written to the analysis file. The use of this command consists of a line which begins with the corresponding version, *intformat, *realformat or *format (again, these are not case-sensitive), and continues with the desired writing format, expressed in C-language syntax argument, between double quotes (").
...
- To left align the result
+ To prefix the numerical output with a sign (+ or -)
# To force the real output value to contain a decimal point.
...
Code Block |
---|
*Intformat "%5i" |
With this sentence, usually located at the start of the file, the output of an integer quantity is forced to be right aligned on the fifth column of the text format on the right side. If the number of digits exceeds five, the representation of the number is not truncated.
Code Block |
---|
*Realformat "%10.3e" |
This sentence, which is also frequently located in the first lines of the template file, sets the output format for the real numbers as exponential with a minimum of ten digits, and three digits after the decimal point.
Code Block |
---|
*format "%10i%10.3e%10i%15.6e" |
This complex command will specify a multiple assignment of formats to some output columns. These columns are generated with the line command that will follow the format line. The subsequent lines will not use this format, and will follow the general settings of the template file or the general formats: *IntFormat, *RealFormat.
- *SetFormatForceWidth, *SetFormatStandard The default width specification of a "C/C+" format, never causes a value to be truncated.
...
Code Block |
---|
*SetFormatForceWidth
*set var num=-31415.16789
*format "%8.3f"
*num
*SetFormatStandard
*format "%8.3f"
*num |
Output:
-31415.1
-31415.168
The first number is truncated to 8 digits, but the second number, printed with "C" standard, has 3 numbers after the decimal point, but more than 8 digits.
- *Tcl This command allows information to be printed using the Tcl extension language. The argument of this command must be a valid Tcl command or expression which must return the string that will be printed. Typically, the Tcl command is defined in the Tcl file (.tcl , see TCL AND TK EXTENSION for details).
...
Code Block |
---|
*set var num=1
*tcl(WriteSurfaceInfo *num)
*set var num2=tcl(MultiplyByTwo *num) |
...
Control commands, etc.