How to Create a GiD Problem Type

Hello!

I’m a beginner and I want to use GiD as a preprocessing software to define material properties, boundary conditions, etc.

By consulting the manual, I learned that users need to define their own .mat, .cnd, .prb, .bat, .bas and other files, but I don’t know how to follow the format of these files. I would like to know where I can get specific formatting instructions. Grateful!

This is explained in the ‘GiD customization manual’ (do you have a local copy in the GiD help)
https://gidsimulation.atlassian.net/wiki/spaces/GCM/overview

Read the Introduction an Problemtype system chapters
There are two approaches: ‘customLib’ and ‘Classic’ (for the classic case consult the Appendix B)

And have a look also to the ‘GiD user manual’, chapter ‘Defining a problem type’ with a tutorial example (customLib based)
https://gidsimulation.atlassian.net/wiki/spaces/GUM

And have a look to the code of the problemtypes of /problemtypes/Examples

Note: the web version is for the current developer version, the local copy of your GiD is specific for your GiD version
(the current developer can have some new function that won’t exist in older GiD versions)

Thank you very much for your answer, I found it, thank you!

Hello! When I’m writing a bas file, I want to implement a function: in “condition”, when I check “Displacement” (Fig. 1), the sum of node’s X coordinate and X-Value is output.
The content of .cnd is shown in Figure 2.
I tried writing *if (Figure 3), but I found that, regardless of whether “displacement” is checked, cond(5,int) is equal to 1, that is, the content of if is always output. In addition, the output result is shown in Figure 4. The two numbers are not summed.
How can I implement this functionality? thanks~

Fig. 1

Fig. 2

Fig. 3

Fig. 4

I am not sure that it is a good idea to do this unusual trick to sum a displacement of a condition to the nodes.

In any case, this is an error:

*Set Cond Point-Initial-Data *nodes
*if(cond(5,int)==1)

the value of cond(5) cannot be asked outside the *loop nodes *OnlyIncond
because is not a global value, each node with the condition applied store its own value.
If to you want a global value can store it in a ‘General data’ field of the .prb file, and then access it with *GetData(xxx)

You can do something like this

*Set Cond Point-Initial-Data *nodes
*loop nodes *OnlyInCond
*if(cond(Displacement))
*operation(cond(Displacement-X,real)+NodesCoord(1,real)) *operation(cond(Displacement-Y,real)+*NodesCoord(2,real))
*else
*NodesCoord(1) *NodesCoord(2)
*endif
*end nodes


note that if is done for each node, and the sum must be done in a *operation command

Thank you! I have implemented this function to set an initial displacement for the element (eg element translation), but as you said this function is not commonly used.

Then I encountered two new problems.
First, for the loop like the following,

/YD/YDE/I1ELCF *nelem
*loop elems
-1
*end elems

The output obtained is the following,
-1
-1
-1

This output is OK, but when there is a large number of elements or node, too many lines will be output. So, I want to output 20 results per line, such as
-1 -1 -1 -1 -1 -1 …
-1 -1 -1 -1 -1 -1 …
-1 -1 -1 -1 -1 -1 …

How can I do that?

The second, for the conditions, I want to achieve the following functionality,
There are two objects (eg rock specimen and loading plate in UCS). Assign boundary conditions to all rock nodes, and record the id of this set of boundary conditions as 1. Then assign boundary conditions to the loading plate node and record the id as 2. Finally, by looping through the total number of boundary condition groups, output cond() in each group. Such as,
/
Boundary Conditions */
/velocity-x/
/rock/ *cond(velocity-x)
/platen/ *cond(velocity-x)
/velocity-y/
/rock/ *cond(velocity-y)
/platen/ *cond(velocity-y)

For conditions, there doesn’t seem to be an id that can be used to loop directly, so one needs to loop with *nodes, *elem, *layer, etc. I tried to use two layers, rock is in the layer0 and platen is in the layer1. Then

*Set Cond Surface-Constraints *nodes
*Add Cond Line-Constraints *nodes
*Add Cond Point-Constraints *nodes 

*loop layers 
*Set Var Ncondsets=LayerNum
*end layers

/YD/YDPN/D1PNAX  *Ncondsets
*loop conditions *layers
*Cond(X-Value,real)
*end conditions

I’m not achieving what I want, and the output I get seems to be default values. How can I implement this function? Thank you!

About the first question
the command *\ prevent the endline
you can do something like this (I didn’t tested my code, could have small bugs):

*Set var column=0
*loop elems
*Set var column=operation(column(int)+1)
-1*\
*if(column==20)
*Set var column=0

*endif
*end elems

Sorry, I didn’t understood what do you want to obtain in the second question.

It is not possible to define two conditions, and then do two loops on nodes for both conditions?
*set cond a
*loop nodes *onlyincond
*nodesnum *cond
*end nodes

*set cond b
*loop nodes *onlyincond
*nodesnum *cond
*end nodes


It is possible do do a loop over all defined conditions of a category, e.g. defined ‘over nodes’ with something like this

*loop conditions *nodes
*if(condnumentities)
condition name=*condname
*loop nodes *onlyincond
*nodesnum *cond
*end nodes
*endif
*end conditions

but I don’t know if it is usable for your case. Have a look to the file /templates/Dump.bas

It exists also the concept of group, similar to layer, but an entity could belong to more that one group (can belong to a single layer)

Note: for complex combinations of data you can write your file completely with Tcl scripting, the .bas file is not a true language and it is very limited.
It is possible to embed in the .bas a simple call to a *tcl(the_procedure_name) to print in the calculation file the text returned by this Tcl proc.
And with GiD-Tcl commands can ask GiD to get information of the mesh, conditions, layers , groups, …

For each condition, output the condition values of the parts with different conditions:

For example, for condition “velocity-y”, I want to output
0 -0.03 0.03
“0” means rock’s condition, “-0.03” means platen1’s condition, “0.03” means platen2’s condition.

Hello! Many thanks to you! The first problem has been solved, and I have re-expressed the second problem, please help to see if it can be realized, thank you!

I guess that you are defining in the .cnd some condition ‘over layers’ similar to this:

CONDITION: xxx
CONDTYPE: over layers
CONDMESHTYPE: 'over nodes'
QUESTION: PNAX
VALUE: 0.0
QUESTION: PNAY
VALUE: 0.0
END CONDITION

and want that each one of your bodies (platen1, platen2, rock) will be represented by a layer with a condition, and the extra values are stored in the condition applied to each body-layer

the normal way to loop this information is like this

*set cond xxx *layers
*loop layers onlyincond
*layernum *layername *cond(PNAX) *cond(PNAY)
*end layers

with a known (and usually small) number of columns. and a unknow(and maybe big) number of rows, one by entity (layer in this rare case, nodes or elements usually)

but do you want instead that each printed row do the opposite loop: a single row by question and as much columns as entities (in this case I assume that is expected a small amount of bodies)

*set cond xxx *layers
Num bodies: *CondNumEntities
bodies: (to know the body represented by each column)
*loop layers onlyincond
*layername *\
*end layers

PNAX
*loop layers onlyincond
*cond(PNAX) *\
*end layers

PNAY
*loop layers onlyincond
*cond(PNAY) *\
*end layers

and … must repeat the block of code for all wanted questions
(the .bas is very limited and is not possible to do a loop over questions, to do it must swap to use Tcl scripting).

Many thanks to you! The last CODE is what I want. But in this case, the layernum is important to me.

And I found that the layernum is related to the order in which the layers were created, and when a layer is deleted, the corresponding number is also deleted. Creating a new layer again will add a new number (not the deleted number).

I would like to know if it is possible to get the number of each layer in the GiD_GUI interface and try to modify the number.

Essentially, I need to get the condition and the extra values for each entity, and arrange them by condition sets number (number 1 is placed in the first column, like an array), a single row by question and as much columns as entities . Because I need to store the condition set number in the node boundary conditions, the number 0 represents the first column above.

So the solution I thought of was to set up different layers to store bodies with different boundary conditions, just like the last CODE. But this way does not seem to be very safe (when a layer is deleted, there will be problems). I don’t know if there is any other way. Thank you very much! Best wishes to you!

Hello! I would like to know if it is possible to get the number of each layer in the GiD_GUI and try to modify the number. Thank you sincerely!

The current Tcl layers procedures are not providing the internal integer id (or using them to specify a layer). This id is considered some kind of internal data. Instead it is used the layer name.

It is not possible to modify this id (renumber the layers)

At .bas programming level *layernum , *elemslayernum is printing this internal id.

you can relate the name and the id writing this extra information
*loop layers
*layenum *layername
*ends layers

As trick you can call a Tcl proc to store in an array a implicit inde 0,1,2,… for each layenum
e.g. in a file .tcl define these procs to be called from the bas file

proc MySetKey {key value} {
  set ::MyLayerIndex($key) $value
  return ""
}

proc MyGetKey {key} {
  return $::MyLayerIndex($key)
}

and in the .bas file do a first loop to set the values of this array

*set var index=0
*loop layers
*tcl(MySetKey *layernum *index)*\
*set var index=operation(index+1,int)
*end layers

(note the *\ to avoid print anything in this loop)
and then can know this index from the layernum

*loop layers
*layernum *layername *tcl(MyGetKey *layernum)
*end layers

*loop nodes
*nodesnum *tcl(MyGetKey *nodeslayernum)
*end nodes

Thank you very much, I understand what to do.

Hello!

How to get the minimum size(length) of an element in the GUI?

Is it possible to output the smallest element size(length) by writing a .bas file, or even operate on it?

Thank you!

You can use the ‘Mesh->Mesh quality’ tool, selecting as quality criteria ‘Minimum edge’
mesh_edge_sizes_distribution_accumulated.png
Can see a frequency graph or and accumulated frequency graph (default)
Clicking the graph they are selected the elements under this x-value

The data to populate this graph is obtained with the ‘GiD_Info MeshQuality’ GiD-Tcl command
https://gidsimulation.atlassian.net/wiki/spaces/GCM/pages/2385543904/GiD+Info+meshquality

From the .bas can invoke a *tcl command to print the value of minimum edge of the whole mesh of triangles with something like this:

minimum triangles edge=*tcl(lindex [GiD_Info MeshQuality ElemMinEdge Triangle 0 0 1] 1)

Off course yourself can calculate the distance between the node’s coordinates of an element (can ask GiD for the nodes of an element and ask for its coordinates with Tcl commands)

Thank you for your patience to answer me, thank you! :smiley: :smiley:

Hello! In the boundary condition setting (.cnd), when setting over line or over surface, it seems that only a line or surface in one element can be selected. Is it possible to select an entire edge or an entire surface of the model for setting?

I don’t understand your question.
if you declare in the .cnd a condition as
CONDTYPE: over lines
Then this condition can be only assigned to geometrical lines, not only a lines, as much lines as you want, but it don’t allow to be assigned to geometrical points, surfaces or volumes, only to curves.
And similarly if you define as ‘over surfaces’, then logically can be only assigned to geometrical surfaces

A condition can be declared to only one geometrical category (points,line, surface or volume), not to multiple categories

The previous declaration is only related to geometry, not to mesh. For mesh it the next declaration
CONDMESHTYPE: over XXX

In mesh there are other categories XXX: nodes, body elements, face elements
(‘body element’ mean the element, ‘face element’ mean a face of an element, e.d. the element 2565 its face 2

The normal way is that the user only assign manually the conditions to the geometry, and then generate the mesh, and then automatically the conditions over nodes, elements or face of elements are applied (to mesh entities of category CONDMESHTYPE)

It is possible to manually assign conditions to mesh entities, but in general is unrecommended (if generate a new mesh will be lost, and usually is difficult to select mesh entities because can be millions)