Page 1 of 1

How to write a loop in .sif file

Posted: 09 Aug 2022, 09:26
by sunyuan
Dear experts

I want to calculate the static electric field for several wires and need to set many bodies. How can I write a loop to done this which in c++ looks like:
```
for(int I;i<10;i++){
int body = i;
//body i
// equation i
// material i
//End
}
```
what will this loop looks like in .sif?

Re: How to write a loop in .sif file

Posted: 09 Aug 2022, 12:54
by raback
Hi

Unfortunately the command file of Elmer is not a programming language so there you are limited by what has been programmed. You can have loops over nonlinear iterations, steady state iterations, time, pseudo time etc. Different parts are of course looped internally when creating FE equations but this is not available at the sif level.

What property do you need to set in many bodies? Do you need to perform same analysis for many different bodies? Perform permutations of different bodies? Devil lies in the detail.

-Peter

Re: How to write a loop in .sif file

Posted: 09 Aug 2022, 23:09
by kevinarden
I have seen this approached by writing a C, FORTRAN, or Python program to write out the body section of the sif to a text file and then copy and paste into the into the sif. Some even generate it with a spreadsheet.