Create the "cmas2d.bas" file. This file will define the format of the .dat text file created by GiD. It will store the geometric and physical data of the problem. The .dat file will be the input to the calculating module.
NOTE: It is not necessary to have all the information registered in only one .bas file. Each .bas file has a corresponding .dat file.
Write the "cmas2d.bas" file as follows:
The format of the .bas file is based on commands. Text not preceded by an asterisk is reproduced exactly the same in the .dat file created by GiD. A text preceded by an asterisk is interpreted as a command.
Example:
.bas file
%%%% Problem Size %%%% Number of Elements & Nodes: *nelem *npoin
.dat file
%%%% Problem Size %%%% Number of Elements & Nodes: 5379 4678
The contents of the "cmas2d.bas" file must be the following:
.bas file
================================================================== General Data File ================================================================== Title: *GenData(Title) %%%%%%%%%%%%%%%%%% Problem Size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Number of Elements & Nodes: *nelem *npoin
In this first part of "cmas2d.bas" file, general information on the project is obtained.
*nelem: returns the total number of elements of the mesh.
*npoin: returns the total number of nodes of the mesh.
Coordinates: Node X Y *loop nodes *format "%5i%14.5e%14.5e" *NodesNum *NodesCoord(1,real) *NodesCoord(2,real) *end nodes
This command provides a rundown of all the nodes of the mesh, listing their identifiers and coordinates.
*loop, *end: commands used to indicate the beginning and the end of the loop. The command *loop receives a parameter.
*loop nodes: the loop iterates on nodes
*loop elems: the loop iterates on elements
*loop materials: the loop iterates on assigned materials
*format: the command to define the printing format. This command must be followed by a numerical format expressed in C syntax.
*NodesNum: returns the identifier of the present node
*NodesCoord: returns the coordinates of the present node
*NodesCoord (n, real): returns the x, y or z coordinate in terms of the value n:
n=1 returns the x coordinate
n=2 returns the y coordinate
n=3 returns the z coordinate
Connectivities: Element Node(1) Node(2) Node(3) Material *set elems(all) *loop elems *format "%10i%10i%10i%10i%10i" *ElemsNum *ElemsConec *ElemsMat *end elems
This provides a rundown of all the elements of the mesh and a list of their identifiers, the nodes that form them, and their assigned material.
*set elems(all): the command to include all element types of the mesh when making the loop.
*ElemsNum: returns the identifier of the present element
*ElemsConec: returns the nodes of an element in a counterclockwise order
*ElemsMat: returns the number of the assigned material of the present element
Begin Materials Nº Materials= *nmats
This gives the total number of materials in the project
*nmats: returns the total number of materials
Mat. Density *loop materials *format "%4i%13.5e" *set var PROP1(real)=Operation(MatProp(Density, real)) *MatNum *PROP1 *end
This provides a rundown of all the materials in the project and a list of the identifiers and densities for each one.
*MatProp (density, real): returns the value of the property "density" of the material in a "real" format.
*Operation (expression): returns the result of an arithmetic expression. This operation must be expressed in C.
*Set var PROP1(real)=Operation(MatProp(Density, real)): assigns the value returned by MatProp (which is the value of the density of the material) to the variable PROP1 (a "real" variable).
*PROP1: returns the value of the variable PROP1.
*MatNum: returns the identifier of the present material.
Point conditions *Set Cond Point-Weight *nodes *set var NFIX(int)=CondNumEntities(int) Concentrate Weights *NFIX
This provides the number of entities with a particular condition.
*Set Cond Point-Weight *nodes: this command enables you to select the condition to work with from that moment on. For the present example, select the condition "Point-Weight".
*CondNumEntities(int): returns the number of entities with a certain condition.
*Set var NFIX(int)= CondNumEntities(int): assigns the value returned by the command CondNumEntities to the NFIX variable (an "int" variable).
*NFIX: returns the value of the NFIX variable.
Potentials Prescripts: Node Tipus Valor/Etiqueta *loop nodes *OnlyInCond *NodesNum *cond(1) *end
This provides a rundown of all the nodes with the condition "Point-Weight" with a list of their identifiers and the first "weight" field of the condition in each case.
*loop nodes *OnlyInCond: executes a loop that will provide a rundown of only the nodes with this condition.
*cond(1): returns the number 1 field of a condition previously selected with the *set cond command. The field of the condition may also be selected using the name of the condition, for example cond(weight).
cmas2d.bas
================================================================== General Data File ================================================================== %%%%%%%%%%%%%%%%%% Problem Size %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Number of Elements & Nodes: *nelem *npoin %%%%%%%%%%%%%%%%%%% Mesh Database %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Coordinates: Node X Y *set elems(all) *loop nodes *format "%5i%14.5e%14.5e" *NodesNum *NodesCoord(1,real) *NodesCoord(2,real) *end nodes ................................................................. Connectivities: Element Node(1) Node(2) Node(3) Material *loop elems *format "%10i%10i%10i%10i%10i" *ElemsNum *ElemsConec *ElemsMat *end elems ................................................................. Begin Materials Nº Materials= *nmats Mat. Density ................................................................. *loop materials *format "%4i%13.5e" *set var PROP1(real)=Operation(MatProp(Density, real)) *MatNum *PROP1 *end ................................................................. Point conditions *Set Cond Point-Weight *nodes *set var NFIX(int)=CondNumEntities(int) Concentrated Weights *NFIX ................................................................. Potentials Prescripts: Node Tipus Valor/Etiqueta *Set Cond Point-Weight *nodes *loop nodes *OnlyInCond *NodesNum *cond(1) *end .................................................................