How to Create a GiD Problem Type

Moderator: GiD Team

Chambernan
Posts: 23
Joined: Tue Mar 22, 2022 3:13 pm

How to Create a GiD Problem Type

Post by Chambernan »

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!
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: How to Create a GiD Problem Type

Post by escolano »

This is explained in the 'GiD customization manual' (do you have a local copy in the GiD help)
https://gidsimulation.atlassian.net/wik ... M/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 <GiD>/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)
Chambernan
Posts: 23
Joined: Tue Mar 22, 2022 3:13 pm

Re: How to Create a GiD Problem Type

Post by Chambernan »

Thank you very much for your answer, I found it, thank you!
Chambernan
Posts: 23
Joined: Tue Mar 22, 2022 3:13 pm

Re: How to Create a GiD Problem Type

Post by Chambernan »

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 Image

Fig. 2 Image

Fig. 3 Image

Fig. 4 Image
Last edited by Chambernan on Wed Mar 30, 2022 3:18 pm, edited 1 time in total.
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: How to Create a GiD Problem Type

Post by escolano »

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
Chambernan
Posts: 23
Joined: Tue Mar 22, 2022 3:13 pm

Re: How to Create a GiD Problem Type

Post by Chambernan »

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,

Code: Select all

/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

Code: Select all

*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!
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: How to Create a GiD Problem Type

Post by escolano »

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):

Code: Select all

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

*endif
*end elems
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: How to Create a GiD Problem Type

Post by escolano »

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 <GiD>/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, ...
Chambernan
Posts: 23
Joined: Tue Mar 22, 2022 3:13 pm

Re: How to Create a GiD Problem Type

Post by Chambernan »

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.
Chambernan
Posts: 23
Joined: Tue Mar 22, 2022 3:13 pm

Re: How to Create a GiD Problem Type

Post by Chambernan »

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!
Post Reply