This is gid.info, produced by Makeinfo version 3.12h from gid.texinfo.

   This is the GiD manual

   Copyright 1997-2002 CIMNE


File: gid.info,  Node: Detailed example,  Prev: Commands used in the .bas file,  Up: Template File

Detailed example - Template file creation
-----------------------------------------

   Next is an  example of template file creation, step by step:

   Note that this is a concrete file for a particular solver, so it's a
sure state that some or all of the commands that this solver program
expects, will be non standard or incompatible with the one that another
user owns.

   In this example, this particular solver treats a line like a comment,
inside the calculation input file, if its prefix is a `$' sign. In your
case, it can be another convention.

   Anyway, the actual target of this example is the comprehension of the
commands that GiD exposes to the user. This is the universal method to
access to GiD's internal database, and then output the desired data to
the solver.

   Also, it's assumed that the user will create the file or files with
`.bas' extension, inside the working directory where the problem type
file is located. The name must be `problem_type_name.bas' for the first
file and any other name for the additional .`bas' files. Each .`bas'
file will be read by GiD, and translated to a .`dat' file.

   It is very important to remark that any word in the `.bas' file
having no meaning as a GiD compilation command or not belonging to any
command instructions (parameters), will be verbatim written to the
output file.

  1. First, we create the header that the solver, on this particular
     case, needs.

     This is the name of the solver aplication and a brief description
     of its behavior.

          $-----------------------------------------------------
          CALSEF: PROGRAMA PARA CALCULO DE SOLIDOS Y ESTRUCTURAS

     Then, another particular sentence that may be incompatible in your
     case, although a similar one may exist for your solver. It's a
     commented line with the `ECHO ON' command. This line, when
     uncommented, is useful if you want to monitor the progress of the
     calculation.
          $-----------------------------------------------------
          $ECHO ON

     The next line specifies the type of calculation and the materials
     involved on the calculation, and it's not a GiD related command
     either.
          $-----------------------------------------------------
          ESTATICO-LINEAL, EN SOLIDOS
     As you can see, it's used a commented line with dashes to separate
     the different parts of the file improving the readability of the
     text.

  2. Here comes the initialitation of some variables. This is needed by
     the solver to start the calculating process.

     The following assignments take the first (parameter `(1)') and
     second (parameter `(2)') fields in the general problem, as the
     number of problems and the title of the problem.

     The actual position of a field is determined checking its order on
     the problem file, so you will guess this is a method that depends
     on a strict position.

     Assignment of the first (1) Field of the `Problem data' file, with
     the command `*GenData(1)':

          $-----------------------------------------------------
          $NUMBER OF PROBLEMS:
          NPROB = *GenData(1)
          $-----------------------------------------------------

     Assignment of the second (2) field assignment, `*GenData(2)':

          $ TITLE OF THE PROBLEM:
          TITULO= *GenData(2)
          $-----------------------------------------------------

     The next instruction takes the field where the starting time is
     saved.  On this case, it is on the 10th position of the general
     problem data file, but we will use another feature of the
     `*GenData' command, the parameter of the command will be the name
     of the field.

     This is a preferable method, because if the list is shifted due to
     the adding or substracting of a field, you will not loose the
     actual position. This command accepts an abbreviation, if there is
     no conflict with other field name.

          $-----------------------------------------------------
          $ TIME OF START:
          TIME= *GenData(Starting_time)
          $-----------------------------------------------------

     Here comes the init of some general variables refering to the
     project we are considering, as the number of points, the number of
     elements or the number of materials.

     The first line is a description of the section.

          $ DIMENSIONS OF THE PROBLEM:

     Then it is a line that introduces the next assignments
          DIMENSIONES :

     Which is followed by another one with the three assignments of
     variables.  `NPNOD' gets, from the `*npoin' function, the number
     of nodes of the model; `NELEM' gets, from `*nelem', or the total
     number of elements of the model or the number of elements of every
     kind of element and `nmats' is initialized with the number of
     materials:

           NPNOD= *npoin,   NELEM= *nelem,   NMATS= *nmats,   \

     Then comes a line where `NNODE' gets the maximum number of nodes
     per element and `NDIME' gets the variable `*ndime'. This variable
     must be a number that specifies if all the nodes are on the plane
     whose Z values are equal to 0 (`NDIME=2') or if they are not
     (`NDIME=3'):

          NNODE= *nnode,   NDIME= *ndime,                    \

     The next lines take data from the general data fields in the
     problem file.  `NCARG' gets the number of charge cases; `NGDLN'
     the number of degrees of freedom; `NPROP' the properties number;
     `NGAUSS' the gauss number; `NTIPO', is assigned dynamically:

          NCARG= *GenData(Charge_Cases), *\

     You could use `NGDLN= *GenData(Degrees_Freedom), *\', but because
     the length of the argument will make exceed a line, we have
     abbreviated its parameter (there is no conflict with other
     question name in this problem file), to simplify the command.

          NGDLN= *GenData(Degrees_Fre), *\
          NPROP= *GenData(Properties_Nbr), \
          NGAUS= *GenData(Gauss_Nbr) , NTIPO= *\

     Note that the last assignment is ended with the specific command
     `*\', to avoid the line feeding. This permits to include a
     conditional assignment of this variable, depending on the data in
     the General data problem.

     Inside the conditional it is used a C format like `strcmp'
     instruction. This instruction compares the two strings passed as
     parameter, and returns an integer number which express the
     relationship between the two strings. If the result of the
     operation is equal to `0', the two strings are identical; if it is
     a positive integer, the first argument is greater than the second,
     and otherwise, the second argument string is less.

     The script checks what problem type is declared in the general
     data file, and then it assigns the coded number for the this type
     to the `NTIPO' variable:

          *if(strcmp(GenData(Problem_Type),"Tens-Plana")==0)
          1 *\
          *elseif(strcmp(GenData(Problem_Type),"Def-Plana")==0)
          2 *\
          *elseif(strcmp(GenData(Problem_Type),"Sol-Revol")==0)
          3 *\
          *elseif(strcmp(GenData(Problem_Type),"Sol-Tridim")==0)
          4 *\
          *elseif(strcmp(GenData(Problem_Type),"Placas")==0)
          5 *\
          *elseif(strcmp(GenData(Problem_Type),"Laminas-Rev")==0)
          6 *\
          *endif

     You have to cover all the cases within the `if' sentences, or end
     the commands with an `else', if you don't want unpredictable
     results, like the next line raised to the place where the
     parameter will have to be:

          $ Default Value:
          *else
          0*\
          *endif

     Although in our case this last rule has not been followed, it
     could be a very good option, when the problem file has been
     modified or created by another user, and the new specification may
     differ from the one we expect.

     The next assignment is formed by a string compare conditional, to
     inform the solver about a setting of the configuration.

     First is the output of the variable to be assigned.

          , IWRIT= *\

     Then there is a conditional where it's compared the string
     contained on the value of the `Result_File' field with the string
     "Yes". If the result is `0', then the two strings are the same,
     and we output an `1', to declare a boolean TRUE.

          *if(strcmp(GenData(Result_File),"Yes")==0)
          1 ,\

     Then we compare the same value string with the string "No", to
     check the complementary option. If we find that the strings match,
     then we output a `0'.

          *elseif(strcmp(GenData(Result_File),"No")==0)
          0 ,\
          *endif

     The second last assignment is a simple output of the solver field
     contents into the INDSO variable:

                       INDSO= *GenData(Solver) , *\

     The last assign is a little more complicated. It requires the
     creation of some internal values, with the aid of the command
     *`set cond'.

     The first action to execute is to set the conditions, so we can
     access its parameters.  This setting may serve for several loops
     or instructions, as long as the parameters needed for the other
     blocks of instructions are the same.

     This line sets the condition `Point-Constraints' as an active
     condition.  The `*nodes' modifier means that the condition will be
     listed over nodes.  The `*or(...' modifiers are necessary when an
     entity shares some conditions, because it belongs to two or more
     elements.

     As an example, take a node which is part of two lines, and each of
     these lines have assigned a different condition. This node, a
     common point of the two lines, will have this two conditions into
     its list of properties. So declaring the `*or' modifiers, GiD will
     decide which condition to use, between the list of conditions of
     the entity.

     A first instruction will be this, where the parameters of the `*or'
     commands are an integer number (`(1,' and `(3,', respectively on
     this example)  and the specification `int', that forces GiD to
     read the condition whose number position is the integer number.

     In our case, we find that the first (1) field of the condition
     file is `X-constraint', and the third (3), is `Y-constraint':

     Gid still has no support for the substitution of the position of
     the condition in the file by its corresponding label, as succeeds
     in the case of the fields of the problem data file.

          *Set Cond Surface-Constraints *nodes *or(1,int) *or(3,int)

     Now we want to complete the setting of the loop, with the addition
     of new conditions.

          *Add Cond Line-Constraints *nodes *or(1,int) *or(3,int)
          *Add Cond Point-Constraints *nodes *or(1,int) *or(3,int)

     Observe the order in which the conditions have been included:
     first the surface constraints with the `*Set Cond' command, since
     it is the initial sentence. Then the pair of `*Add Cond'
     sentences, the line constraints and as the last one, the point
     constraints sentence.  This logical hierarchy forces the points as
     the most important items, due to the fact that the program takes

     Finally, we set a variable with the number of entities assigned to
     this particular condition.

     Note that the execution of this instruction is only possible if a
     condition has been set previously.

          NPRES= *CondNumEntities

     To end this section, we put a separator on the output file:

          $-----------------------------------------------------

     Thus, after the init of those variables, this part of the file
     ends up as:

          $ DIMENSIONS OF THE PROBLEM:
          DIMENSIONES :
           NPNOD= *npoin,  NELEM= *nelem,  NMATS= *nmats,     \
           NNODE= *nnode,  NDIME= *ndime,                     \
           NCARG= *GenData(Charge_Cases), *\
           NGDLN= *GenData(Degrees_Fre), *\
           NPROP= *GenData(Properties_Nbr), \
           NGAUS= *GenData(Gauss_Nbr) , NTIPO= *\
          *if(strcmp(GenData(Problem_Type),"Tens-Plana")==0)
          1 *\
          *elseif(strcmp(GenData(Problem_Type),"Def-Plana")==0)
          2 *\
          *elseif(strcmp(GenData(Problem_Type),"Sol-Revol")==0)
          3 *\
          *elseif(strcmp(GenData(Problem_Type),"Sol-Tridim")==0)
          4 *\
          *elseif(strcmp(GenData(Problem_Type),"Placas")==0)
          5 *\
          *elseif(strcmp(GenData(Problem_Type),"Laminas-Rev")==0)
          6 *\
          *endif
          , IWRIT= *\
          *if(strcmp(GenData(Result_File),"Yes")==0)
          1 ,\
          *elseif(strcmp(GenData(Result_File),"No")==0)
          0 ,\
          *endif
             INDSO= *GenData(Solver) , *\
          *Set Cond Surface-Constraints *nodes *or(1,int) *or(3,int)
          *Add Cond Line-Constraints *nodes *or(1,int) *or(3,int)
          *Add Cond Point-Constraints *nodes *or(1,int) *or(3,int)
          NPRES=*CondNumEntities
          $-----------------------------------------------------

     After creation or reading of our model, once generated the mesh
     and applied the conditions, we can export the file (file
     `project_name.dat') and send it to the solver.

     The command to create the `.dat' file can be found on the ` File'
     / `Import/Export' / `Write Calculation File'  GiD menu. It's also
     possible to use the keyboard shortcut `Control-x Control-c'

     This would be the contents of the `project_name.dat' file:

          $-----------------------------------------------------
          CALSEF: PROGRAMA PARA CALCULO DE SOLIDOS Y ESTRUCTURAS
          $-----------------------------------------------------
          $ECHO ON
          $-----------------------------------------------------
          ESTATICO-LINEAL, EN SOLIDOS
          $-----------------------------------------------------
          $NUMERO DE PROBLEMAS:
          NPROB = 1
          $-----------------------------------------------------
          $ TITULO DEL PROBLEMA
          TITULO= Title_name
          $-----------------------------------------------------
          $DIMENSIONES DEL PROBLEMA
          DIMENSIONES :
            NPNOD=    116 ,  NELEM= 176 ,   NMATS=  0 ,     \
            NNODE=      3 ,  NDIME=   2 ,                   \
            NCARG=      1 ,  NGDLN=   1 ,   NPROP=  5 ,     \
            NGAUS=      1 ,  NTIPO=   1 ,   IWRIT=  1 ,     \
            INDSO=     10 ,  NPRES=   0
          $-----------------------------------------------------

  3. Here begins the calculation input, the actual starting of data
     transfer

A) Elements, materials and connectivities listing
.................................................

     Now we want to output the desired results to the output file.
This first line, apparently a title or label, is the way that offers
the solver, in this example, to determine the beginning and end of a
loop section. This block of instructions ends with the next
`FIN_GEOMETRIA' sentence, also for this example.

          GEOMETRIA

     Here, we introduce an user informative couple of lines.

     A title of the first subsection, `CONECTIVIDADES ELEMENTALES':

          $ CONECTIVIDADES ELEMENTALES

     And here is the header that precedes the output list, a user
oriented data:

          $ ELEM. MATER.    SECUENCIA DE CONECTIVIDADES

     And then we travel trough the elements of the model, by the action
of the `*loop' instruction, followed in this case by the `elems'
argument.

          *loop elems

     For each element in the model, GiD will output: its element
number, by the action of the `*elemsnum' command, the material assigned
to this element, using the `*elemsmat' command, and the connectivities
associated to the element, with the command `*elemsConec':

            *elemsnum *elemsmat *elemsConec
          *end elems

     You can use the parameter `swap' if you are working with quadratic
elements and the listing modes of the nodes is not standard.  A non
standard nodes listing would be, for example, an anti-clockwise listing
of all the elements.

            *elemsnum *elemsmat *elemsConec(swap)
          *end elems

     Here finishes the first part of this section.

B) Formatted nodes and coordinates                                              listing
.......................................................................................

     And here starts the next section `COORDENADAS DE PUNTOS NODALES':

          $ COORDENADAS DE PUNTOS NODALES

     Next is the header of the output list:

          $  NODO  COOR.-X   COOR.-Y   COOR.-Z

     Now GiD will trace all the nodes of the model:
          *loop nodes

     For each node in the model, it will generate the output of the
number of node, `*NodesNum' and the coordinates for this node
`*NodesCoord'.

     The command executed before the output, `*format', will force that
the resulting output follow the guidelines of formatting specified.

     On this case, the `*format' command gets a string parameter with a
set of codes: %6i, which specify that the first word in the list is
coded as a integer and is printed six points from the left, the rest of
the three codes, `%15.5f', are ordering the printing of a real number,
represented on a floating point format, with a distance of 15 spaces
between columns (the number will be shifted to have the last digit in
the 15th position of the column) and the fractional part of the number
will be represented with five digits.

     Note that this is the C language format command.

          *format "%6i%15.5f%15.5f%15.5f"
            *NodesNum *NodesCoord
          *end

     And at the end of the section, it's the finishing mark sentence,
in this solver example.

          FIN_GEOMETRIA

     The full set of commands to make this part of the output is showed
the next lines.

          GEOMETRIA
          $ CONECTIVIDADES ELEMENTALES
          $ ELEM. MATER.    SECUENCIA DE CONECTIVIDADES
          *loop elems
            *elemsnum *elemsmat *elemsConec
          *end elems
          $ COORDENADAS DE PUNTOS NODALES
          $  NODO  COOR.-X   COOR.-Y   COOR.-Z
          *loop nodes
          *format "%6i%15.5f%15.5f%15.5f"
            *NodesNum *NodesCoord
          *end
          FIN_GEOMETRIA

     The result of the compilation, output to a file
(`project_name.dat') to be processed by the solver program.

     The first part of the section:

          $-----------------------------------------------------
          GEOMETRIA
          $ CONECTIVIDADES ELEMENTALES
          $ ELEM. MATER.    SECUENCIA DE CONECTIVIDADES
               1      1     73    89    83
               2      1     39    57    52
               3      1     17    27    26
               4      5      1     3     5
               5      5      3    10     8
               6      2     57    73    67
               .      .      .     .     .
               .      .      .     .     .
               .      .      .     .     .
             176      5     41    38    24

     And the second part of the section:

          $ COORDENADAS DE PUNTOS NODALES
          $     NODO       COOR.-X        COOR.-Y   COOR.-Z
                 1         5.55102        5.51020
                 2         5.55102        5.51020
                 3         4.60204        5.82993
                 4         4.60204        5.82993
                 5         4.88435        4.73016
                 6         4.88435        4.73016
                 .         .              .
                 .         .              .
                 .         .              .
               116        -5.11565        3.79592
          FIN_GEOMETRIA

  4. If the solver module you are using needs a list of the nodes that
     have assigned a condition, like for example, a neighborhood
     condition, you have to provide it as is explained in the next
     example:

C) Nodes listing declaration
............................

     First, we set the necessary conditions, as it was done in the
previous section.

          *Set Cond Surface-Constraints *nodes *or(1,int) *or(3,int)
          *Add Cond Line-Constraints *nodes *or(1,int) *or(3,int)
          *Add Cond Point-Constraints *nodes *or(1,int) *or(3,int)
          NPRES=*CondNumEntities

     After the data init and declarations, the solver requires a list
of nodes, with boundary conditions and the fields that have been
assigned

     In this example, all the selected nodes will be output, also
printing the 3 conditions. The columns will be output with no aparent
format:

     First, there is a line with the header of the section for the
solver program and a commentary line for the user

          CONTORNO CONDICIONES
          $ NODOS RESTRINGIDOS Y PRESCRIPCIONES

     Then comes the first line of the output list, the header:

          $ NODO CODIGO         VALORES PRESCRITOS

     Then the `loop' instruction, over nodes, and with the specification
argument `*OnlyInCond', to iterate only over the entities that have the
condition assigned. This is the condition that has been set on the
previous lines.

          *loop nodes *OnlyInCond

     The next line is the `format' command, followed by the lines with
the commands to fill the fields of the list.

          *format "%5i%1i%1i%f%f"
             *NodesNum *cond(1,int) *cond(3,int)  *\

     Also into the `*format' command influence there are the next couple
of `if' sentences. If the degrees of freedom field contains an integer
equal or greater than `3', the number of properties will be output.

          *if(GenData(Degrees_Freedom_Nodes,int)>=3)
          *cond(5,int) *\
          *endif

     And if the value of the same field is equal to `5' the output will
be a pair of zeros.

          *if(GenData(Degrees_Free,int)==5)
          0 0  *\
          *endif

     The next line ouputs the values contained in the second and fourth
fields, both real numbers.

          *cond(2,real) *cond(4,real) *\

     In a similar manner as done in the previous `if' sentences here
come a group of lines to output the sixth condition field value, if the
number of degrees of freedom is equal or greater than threee, and
output a pair of zeros if it's equal to five.

          *if(GenData(Degrees_Free,int)>=3)
          *cond(6,real) *\
          *endif
          *if(GenData(Degrees_Free,int)==5)
          0.0 0.0  *\
          *endif

     Finally, to end the section, the `*end' command closes the previous
`*loop'. The last line is the label of the end of the section.

          *end
          FIN_CONTORNO CONDICIONES
          $-------------------------------------------------------

     The full set of commands included in this section are the next:

          CONTORNO CONDICIONES
          $ NODOS RESTRINGIDOS Y PRESCRIPCIONES
          $ NODO CODIGO         VALORES PRESCRITOS
          *loop nodes *OnlyInCond
          *format "%5i%1i%1i%f%f"
             *NodesNum *cond(1,int) *cond(3,int)  *\
          *if(GenData(Degrees_Free,int)>=3)
          *cond(5,int) *\
          *endif
          *if(GenData(Degrees_Free,int)==5)
          0 0  *\
          *endif
          *cond(2,real) *cond(4,real) *\
          *if(GenData(Degrees_Free,int)>=3)
          *cond(6,real) *\
          *endif
          *if(GenData(Degrees_Free,int)==5)
          0.0 0.0  *\
          *endif
          *end
          FIN_CONTORNO CONDICIONES
          $-----------------------------------------------------

  5. If it is needed the output of a list of the materials

D) Materials listing declaration
................................

     As a must, the first lines are the title of the section and a
commentary.

          PROPIEDADES MATERIALES
          $ PROPIEDADES DE LOS MATERIALES PARA MULTILAMINADO

     Then there is the loop sentence, this time related to materials.

          *loop materials

     Then comes the line were the number of the material and its
different properties are output.

             *matnum() *MatProp(1) *MatProp(2) *MatProp(3) *MatProp(4)

     Finally comes the ending of the section.
          *end
          FIN_PROPIEDADES MATERIALES
          $-----------------------------------------------------

     The full set of commands is the next:

          PROPIEDADES MATERIALES
          $ PROPIEDADES DE LOS MATERIALES PARA MULTILAMINADO
          *loop materials
             *matnum() *MatProp(1) *MatProp(2) *MatProp(3) *MatProp(4)
          *end
          FIN_PROPIEDADES MATERIALES
          $-----------------------------------------------------

  6. If it is needed the output of a list of the elements

E) Elements listing declaration
...............................

     First, we set the loop to the interval of the data.
          *loop intervals

     The next couple of lines indicate the starting of one section and
the title of the example, taken from the first field in the interval
data with an abbreviation on the label.  They are followed by a comment
explaining the type of data we are using.

          FUERZAS
              TITULO: *IntvData(Charge_case)
          $ TIPO DE CARGA

     First, we set the condition as done before. If one condition is
assigned twice or more to the same element, without the include of the
`*CanRepeat' parameter in the `*Set Cond' the condition will appear
once, if exists the  `*CanRepeat' parameter, then the number of
conditions that will appear is the number of times is the number of
times it was assigned to the condition.

          *Set Cond Face-Load *elems *CanRepeat

     Then, a condition checks if exist any element into the condition.

          *if(CondNumEntities(int)>0)

     Next is a title of the next section, followed by a comment for the
user.

          DISTRIBUIDA UNIFORMEMENTE EN LADOS
          $ CARGAS UNIFORMEMENTE REPARTIDAS EN LADOS DE ELEMENTOS

     We assign the number of nodes to a variable.

          $ NUMERO DE NODOS EN LADO
          NODGE =  2

     Then comes the title of the next loop, followed by the start of
the loop, now applied over the elements and its operation restricted to
the group of elements selected into the condition.

          $ LADOS CARGADOS Y CARGAS ACTUANTES
          *loop elems *OnlyInCond

     The number of elements is written after `ELEMENTO='.  >From an
user point of view, this is treated like a variable assignment.  The
number of nodes that belong to the face of the loop's element is
written after the `CONECTIV' label. This means the number of adjacent
nodes to the face.

                ELEMENTO=*elemsnum(), CONECTIV *globalnodes

     The conditions that are output are the first and second.

                *cond(1) *cond(1)  *cond(2) *cond(2)

     Here ends the loop  and after it there's a label line to end the
section. The last `*endif' ends the `if' statement group.

          *end
          FIN_DISTRIBUIDA UNIFORME EN LADOS
          *endif

     The preceding section is compiled complete into the following
lines:

          $-----------------------------------------------------
          *loop intervals
          FUERZAS
              TITULO: *IntvData(1)
          $ TIPO DE CARGA
          *Set Cond Face-Load *elems *CanRepeat
          *if(CondNumEntities(int)>0)
          DISTRIBUIDA UNIFORMEMENTE EN LADOS
          $ CARGAS UNIFORMEMENTE REPARTIDAS EN LADOS DE ELEMENTOS
          $ NUMERO DE NODOS EN LADO
          NODGE =  2
          $ LADOS CARGADOS Y CARGAS ACTUANTES
          *loop elems *OnlyInCond
                ELEMENTO=*elemsnum(), CONECTIV *globalnodes
                *cond(1) *cond(1)  *cond(2) *cond(2)
          *end
          FIN_DISTRIBUIDA UNIFORME EN LADOS
          *endif

  7. Finally, output of a list of the nodes and conditions

F) Nodes and its conditions listing declaration
...............................................

     As ever, the first thing to do in the setting of the conditions.

          *Set Cond Point-Load *nodes

     As in the previous section, the next loop will be executed only if
exists any condition in the selection.

          *if(CondNumEntities(int)>0)

     Here starts the loop over the nodes.

          PUNTUAL EN NODOS
          *loop nodes *OnlyInCond
                *NodesNum *cond(1) *cond(2) *\

     The next `*if' sentences, condition the output writting of the end
of the line.

          *if(GenData(Degrees_Free,int)>=3)
          *cond(3) *\
          *endif
          *if(GenData(Degrees_Free,int)==5)
          0 0  *\
          *endif
          *end

     To end the section, here comes the label and the `if' closing.

          FIN_PUNTUAL EN NODOS
          *endif

     Finally, it is written an information label, if the value of the
second field in the interval data section, inside the problem file, is
equal to `"si"' (yes).

          *if(strcasecmp(IntvData(2),"Si")==0)
          PESO_PROPIO
          *endif

     After the end of this loop, it comes the label that identifies the
end of the forces section, but the actual end of the section will be
the next `*end' command, located some lines after.

          FIN_FUERZAS

     Before the end of the section, nevertheless, we indicate the
solver which will be the postproces file. This information is gathered
from the `*IntvData' command. The argument that this command receives
(`3') specifies that the name of the file is in the third field of the
loop iteration of the interval.

          $-----------------------------------------------------
          $ARCHIVO DE POSTPROCESO
          FEMV = *IntvData(3)

     To end the forces interval loop, finally comes the `*end' command:

          $-----------------------------------------------------
          *end

     Finally, the file is ended with the sentence required by the
solver:

          FIN_CALSEF
          $-----------------------------------------------------

     The preceding section is compiled complete into the following
lines:

          *Set Cond Point-Load *nodes
          *if(CondNumEntities(int)>0)
          PUNTUAL EN NODOS
          *loop nodes *OnlyInCond
                *NodesNum *cond(1) *cond(2) *\
          *if(GenData(Degrees_Free,int)>=3)
          *cond(3) *\
          *endif
          *if(GenData(Degrees_Free,int)==5)
          0 0  *\
          *endif
          *end
          FIN_PUNTUAL EN NODOS
          *endif
          *if(strcasecmp(IntvData(2),"Si")==0)
          PESO_PROPIO
          *endif
          FIN_FUERZAS
          $-----------------------------------------------------
          $ARCHIVO DE POSTPROCESO
          FEMV = *IntvData(3)
          $-----------------------------------------------------
          *end
          FIN_CALSEF
          $-----------------------------------------------------


   With this section ends the template file example.


File: gid.info,  Node: Executing an external program,  Prev: Template File,  Up: Customization

Executing an external program
=============================

   Once all the files of the problem type are finished (`.cnd, .mat,
.prb, .sim, .bas' files), you are able to run the solver. It may be
interesting to run it directly from inside GiD.

   To do so, it is necessary to create the file `problem_type_name.bat'
in the problem type directory.  This must be a shell script that can
contain any type of information and that will be different for every
operating system. When the user selects the option `CALCULATE' in the
GiD preprocess this shell script is executed. (*note Calculate::.)

   Because the `.bat' file will be different depending on the operating
system, it's possible to create two files: one for Windows and another
for Unix/Linux.
The Windows file has to be named as: `problem_type_name.win.bat'.
The Unix/Linux file has to be named as:  `problem_type_name.unix.bat'.
If GiD founds a `.win.bat' or `.unix.bat' file, the file
`problem_type_name.bat' will be ignored.

   If a `.bat' file exists in the problem type directory, when choosing
`Start' in the calculations window, GiD will automatically write the
analysis file inside the example directory assigning the name
`project_name.dat' to this file (if more files, names
`project_name-1.dat' ...  are used). Next, this shell script will be
executed. GiD will assign to this script 3 arguments:

   * 1st argument: `project_name' (name of the current project)

   * 2nd argument: `c:\a\b\c\project_name.gid' (path of the current
     project)

   * 3rd argument: `c:\a\b\c\problem_type_name.gid' (path of the
     problem type selected)

   Among other utilities, this script can move or rename files and
execute the process until it finishes.

   *Note1:* This file must have the executable flag set (see UNIX
command `chmod') in UNIX systems.

   *Note2:* GiD sets as current directory the model directory
(example: `c:\\examples\test1.gid') just before executing the `.bat'
    file. So, the lines (`cd $directory') are not necessary in the
scripts.

* Menu:

* Commands accepted by the GiD command.exe::
* showing feedback when runing the solver::
* Managing errors ::
* Shell script examples::


File: gid.info,  Node: Commands accepted by the GiD command.exe,  Next: showing feedback when runing the solver,  Prev: Executing an external program,  Up: Executing an external program

Commands accepted by the GiD command.exe
----------------------------------------

   The keywords are the following ones:
   - %

   - Rem

   - Chdir (Cd)

   - Del (Delete, Erase)

   - Copy

   - Rename (Ren, Move)

   - Mkdir (Md)

   - Set

   - Echo (@echo)

   - If

   - Call

   - Goto

   - :

   - Type


   Unknown instructions will be executed as if it was an external file.

   In the GiD command.exe are not implemented all the possible
parameters and modifiers available in the operating system.

   Note
At the moment, command.exe is only used in Windows operating systems,
as an alternative to the command.com or cmd.exe. With the GiD
command.exe some of the disadvantages of Windows can be avoided (the
limited length of the parameters, temporary use of letters of virtual
units that sometimes are not possible to eliminate, fleeting appearance
of the console window, etc).

   If GiD finds the file command.exe, located next to gid.exe, it will
be used to interpret the `*.bat' file of the problem type; if the file
command.exe cannot be found, the `*.bat' file will be interpreted by
the windows command.com.

   If conflicts appear by the use of some instruction still
nonimplemented in the GiD command.exe, it's possible to rename the
command.exe file, so that GiD doesn't find it, and the operating system
command.com is used.

%
Returns the value of a variable.

   %number
%name%

   Parameters
number
The number is the position of one of the parameters which the *.bat
file receives.

   name
Is the name of an environment variable. That variable has to be
declared with instruction "set".

   Note
GiD sends to the `*.bat' file three parameters: `%1, %2, %3'
`%1' is the name of the current project `(project_name)'
`%2' is the path of the current project `(c:\a\b\c\project_name.gid)'
`%3' is path of the problem type `(c:\a\b\c\problem_type_name.gid )'

   For example, if GiD is installed in c:\gidwin, the "problemtype"
name is cmas2d.gid and the project is test.gid, located in c:\temp (the
project is a directory called c:\temp\test.gid with some files inside),
parameters will have the following values:

   `%1' test
`%2' c:\temp\test.gid
`%3' c:\gidwin\problemtypes\cmas2d.gid
Note: it's possible that the file and directory names of these
parameters are in the short mode Windows format. So, parameter %3 would
be: c:\GIDWIN\PROBLE~\CMAS2D.GID.

   Examples
     echo %1 > %2\%1.txt
     echo %TEMP% >> %1.txt

Rem
Rem is used to include comments in a `*.bat' file or in a configuration
file.

   rem [coment]

   Parameter
coment
Any character string.

   Note
Some comments are GiD commands.

Chdir (Cd)
Changes to a different directory.

   chdir [drive:path] [..]
-or-
cd  [drive:path] [..]

   Parameters
[drive:path]
Disk and path of the new directory.

   [..]
Goes back one directory. For example if you are within the
`C:\WINDOWS\COMMAND>' directory this would take you to `C:\WINDOWS>'.

   Note
When GiD calls the `*.bat' file, the path of project is the current
path, so it's not necessary to use `cd %2' at the begining of the
`*.bat' file.

   Examples
     chdir e:\tmp
     cd ..

Delete (Del, Erase)
Command used to delete files permanently from the computer.

   delete [drive:][path] fileName [fileName]

   Parameters
[drive:][path] fileName [fileName]
Parameters specify the location and the name of the file that has to be
erased from disk. Several file names can be given.

   Note
Files will be eliminated although they have the hidden or read only
flag.  Use of wildcards is not allowed. For example del *.* is not
valid.  File names must be separated by spaces and if the path contains
blank spaces, the path should be inside inverted commas (the short path
without spaces can also be used).

   Examples
     delete %2\%1\file.cal
     del C:\tmp\fa.dat C:\tmp\fb.dat
     del "C:\Program files\test 4.txt"

Copy
Copies one or more files to another location.

   copy  source  [+  source [+ ...]] destination

   Parameters
source
Specifies the file or files to be copied

   destination
Specifies the filename for the new file(s).

   To append files, specify a single file for destination, but multiple
files for source (using `file1 + file2 + file3' format).

   Note
If the destination file already exists, it will be overwrited without
prompting if you wanted to overwrite the file or not.

   File names must be separated by spaces.  If destination only
contains the path but not the filename, the new name will be the same
as the source filename.

   Examples
     copy f1.txt f2.txt
     copy f1.txt c:\tmp
     rem if directory c:\tmp exists, c:\tmp\f1.txt will be created, if it doesn't exist, file c:\tmp will be created.
     copy a.txt + b.txt + c.txt abc.txt

Rename (Ren, Move)
Used to rename files and directories from the original name to a new
name.

   rename [drive:][path] fileName1 fileName2

   Parameter
[drive:][path] fileName1 Specifies the path and the name of the file
which has to be renamed.

   fileName2
Specifies the new name file.

   Note
If the destination file already exists, it will be overwrited without
prompting if you wanted to overwrite the file or not.  Wildcards are
not accepted (`*',`?'), so only one file can be renamed every time.
Note that you cannot specify a new drive for your destination.  A
directory can be renamed in the same way as if it was a file.

   Examples
     Rename fa.txt fa.dat
     Rename "c:\Program Files\fa.txt" c:\tmp\fa.txt
     Rename c:\test.gid c:\test2.gid

Mkdir (md)
Allows you to create your own directories.

   mkdir [drive:]path
md [drive:]path
Parameter
drive:
Specifies the drive where the new directory has to be created.

   path
Specifies the name and location of the new directory. The maximum
length of the path is limited by the file system.

   Note
mkdir can be used to create a new path with many new directories.

   Examples
     mkdir e:\tmp2
     mkdir d1\d2\d3

Set
Displays, sets, or removes Windows environment variables.

   set variable=[string]

   Parameters
variable
Specifies the environment-variable name.

   string
Specifies a series of characters to assign to the variable.

   Note
The set command creates variables which can be used in the same way as
the variables `%0' to `%9'. Variables `%0' to `%9' can be assigned to
new variables using the set command.

   To get the value of a variable, the variable has to be written
inside two `%' symbols. For example, if the environment-variable name
is `V1', its value is `%V1%'.  Variable names are not case sensitive.

   Examples
     set basename = %1
     set v1 = my text

Echo (@echo)
Displays messages.

   echo [message]

   message
Specifies the text that will be displayed in the screen.

   Note
The message will not be visible because the console is not visible, GiD
hides the console. So that this command it's only useful if the output
is redirected to a file (using > or >>). Symbol > sends the text to a
new file, and symbol >> sends the text to a file if it already exists.
Commands if and echo can be used in the same command line.

   Examples
     Echo %1 > out.txt
     Echo %path% >> out.txt
     If Not Exist %2\%1.flavia.res Echo "Program failed" >> %2\%1.err

If
Executes a conditional sentence. If the specified condition is true,
the command which follows the condition will be executed; if the
condition is false, next line is ignored.
     if [not] exist fileName command
     if [not] string1==string2 command
     if [not] errorlevel number command

   Parameters
not
Specifies that the command has to be executed only if the condition is
false.

   exist file
Returns true if `file' exists.

   comand
Is the command that has to be executed if the condition returns true.

   string1==string2
Returns true if string1 and string2 are equal. It's possible to compare
two strings, or variables (for example, `%1').

   errorlevel number
Returns true if the last program executed returned a code equal or
bigger to number.

   Note
Exist can also be used to check if a directory exists.

   Examples
     if exist sphere.igs echo File exists >> out.txt
     if not exist test.gid echo Dir doesn't exist >> out.txt
     if %1 == test echo Equal %1 >> out.txt

Call
Executes a new program.

   call [drive:][path] file [parameters]

   Parameter
[drive:][path] file Specifies the location ant the name of the program
that has to be executed.

   parameters
Parameters required by the program executed.

   Note
The program can be `*.bat' file, a `*.exe' file or a `*.com' file.  If
the program does a recursive call, some condition has to be imposed to
avoid an endless curl.

   Examples
     call test.bat %1
     call gid.exe -n -PostResultsToBinary %1.flavia.res %1.flavia.bin

Goto
The execution jumps to a line identified by a label.

   goto label

   Parameter
label
It specifies a line of the `*.bat' file where the execution will
continue. That label must exist when the Goto command is executed.  A
label is a line of the `*.bat' file and starts with (:).
Goto is often used with the command if, in order to execute conditional
operations.  The Goto command can be used with the label `:EOF' to make
the execution jump to the end of the `*.bat' file and finish.

   Note
The label can have more than eight characters and cannot have spaces
between them. The label name is not case sensitive.

   Example
     goto :EOF
     
     if exist %1.err goto end
     ...
     :end

:
Declares a label.

   : labelName

   Parameter
labelName
Is a string which identifies a line of the file, so that the Goto
command can jump there.  The label line will not be executed.

   Note
The label can have more than eight characters and cannot have spaces
between them. The label name is not case sensitive.

   Examples
     :my_label
     :end

Type
Displays the contents of text files.

   type [drive:][path] fileName

   Parameters
[drive:][path] fileName
Specifies the location ant the name of the file to be displayed. If the
file name contains blanc spaces it should be inside inverted commas
(`"').

   Note
The text will not be visible because the console is not visible, GiD
hides the console. So that this command it's only useful if the output
is redirected to a file (using > or >>). Symbol > sends the text to a
new file, and symbol >> sends the text to a file if it already exists.
It's recommended to use the copy command instead of type.
In general, the type command should not be used with binary files.

   Examples
     type %2\%1.dat > %2\%1.txt


File: gid.info,  Node: showing feedback when runing the solver,  Next: Managing errors,  Prev: Commands accepted by the GiD command.exe,  Up: Executing an external program

Showing feedback when runing the solver
---------------------------------------

   The information about what is displayed when the user presses
`Output view:', is also given here. The way of doing so is to include a
commented line in the script of the form:

   `#    OutputFile: $1.log' or `rem    OutputFile: %1.log'

   where `$1.log' means to display in that window, a file whose name is:
`project_name.log' The name can also be and absolute name like
`output.dat'.  If this line is omitted, when the user presses `Output
view:', nothing will be displayed.


File: gid.info,  Node: Managing errors,  Next: Shell script examples,  Prev: showing feedback when runing the solver,  Up: Executing an external program

Managing errors
---------------

   A commented line like

   `# ErrorFile: $1.err' or `rem ErrorFile: $1.err'

   included in the `.bat' file, means to consider that the given
filename is the error file. At the end of the execution of the `.bat'
file, if the errorfile does not exist or is zero, execution is
considered to be successful. If not, an error window appears an the
contents of the error file are considered to be the error message. If
this line exists, GiD will delete this file just before calculating to
avoid errors with previus calculations.
A commented line like

   `# WarningFile: $1.err' or `rem WarningFile: $1.err'
included in the `.bat' file, means to consider that the given filename
is the warning file. This file stores the warnings that may appear
during the execution of the `.bat' file.


File: gid.info,  Node: Shell script examples,  Prev: Managing errors,  Up: Executing an external program

Examples
--------

   Two examples are given of easy scripts to do so. One of them is for
Unix machines and the other one is for ms-dos or Windows.

   * UNIX example:
          #!/bin/csh
          set basename = $1
          set directory = $2
          set ProblemDirectory = $3
          
          #    OutputFile: $1.log          IT IS USED BY GiD
          #    ErrorFile: $1.err           IT IS USED BY GiD
          
          rm -f $basename.flavia.res
          
          $ProblemDirectory/myprogram $basename
          
          mv $basename.post $basename.flavia.res

   * MS-DOS example:
          rem basename=%1                    JUST INFORMATIVE
          rem directory=%2                   JUST INFORMATIVE
          rem ProblemDirectory=%3            JUST INFORMATIVE
          
          rem    OutputFile: %1.log          IT IS USED BY GiD
          rem    ErrorFile: %1.err           IT IS USED BY GiD
          
          del %1.flavia.res
          
          %3\myprogram %1
          
          move %1.post %1.flavia.res


File: gid.info,  Node: POSTPROCESS DATA FILES,  Next: TCL-TK extension,  Prev: Customization,  Up: Top

POSTPROCESS DATA FILES
**********************

   In the GiD postprocess you can study the results obtained from a
solver program. The communication between the solver and the GiD
Postprocess is made using files. The solver program has to write the
results in a file that must have the extension `.flavia.res' and its
name must be the project name.

   The solver program can also (it is not mandatory) give to GiD the
postprocess mesh. If this mesh is not provided by the solver program,
GiD uses in the post-process, the preprocess mesh.

   So, post-processing data files are ASCII files, and can be separated
into two categories:

   * Mesh Data File: `project_name.flavia.msh' for volume and surface
     (3D or 2D) mesh information and

   * Results Data File: `project_name.flavia.res' for results
     information.

   *Note:* `ProjectName.flavia.msh' handles meshes of different element
types: points, lines, triangles, quadrilaterals, tetrahedras and
hexahedras.  The old format, which only handles one type of element per
file, is still supported inside GiD (*note old mesh format::.).

   If a project is loaded into GiD, when changing to `PostProcess' it
will look for `ProjectName.flavia.res'. If a mesh information file with
name `ProjectName.flavia.msh' is present, it will also be read,
regardless of the information available from `PreProcess'.

   * ProjectName.flavia.msh: The first file, which is named
     `ProjectName.flavia.msh', should contain nodal coordinates of the
     3D, and its nodal connectivities and the material of each element.
     At the moment Only one set of nodal coordinates can be entered.
     Diferent kind of elements can be used but separated into diferent
     sets. If no material is supplied, GiD takes the material number
     equal to zero.

   * ProjectName.flavia.res: The second file, which is named
     `ProjectName.flavia.res', must contain the nodal variables. GiD
     allows the user to define as many nodal variables as desired, as
     well as several steps and analysis cases (limited only by the
     memory of the machine).  Gauss points and results on these gauss
     points should also be in this file.

   The files are created and read in the order that corresponds with
the natural way of solving a finite element problem: mesh, surface
definition and conditions and finally, evaluation of the results.  The
format of the read statements is normally free, i.e. it is necessary
only to separate them by spaces.

   Thus, the users can modify the files with any format, leaving spaces
between each field and can also write out the results with as many
decimals as desired. In case of error, the program warns the user about
the type of mistake found.

   GiD reads all the information directly from the pre-processing files
in order to gain efficiency, whenever possible.

* Menu:

* File ProjectName.flavia.msh::
* File ProjectName.flavia.res::
* old results format::
* old mesh format::

