# Continues simulations

**URL:** https://community.freefem.org/t/continues-simulations/953
**Category:** General Discussion
**Created:** [April 29, 2021, 10:55am UTC](https://community.freefem.org/t/continues-simulations/953 "2021-04-29T10:55:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Dua](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@Dua](https://community.freefem.org/u/Dua)
#### Post date: [April 29, 2021, 10:55am UTC](https://community.freefem.org/t/continues-simulations/953/1 "2021-04-29T10:55:52Z")

</div>

Hello developers,

I need to run my freefem code for multiple meshes, so that each time my code read a different mesh and do the simulation for this mesh, then stores the result for every mesh and again repeat it continuesly for several meshes.  
May you help me how can I do it?

Thanks.

---

<div class="post-metadata">

### Author: ![fivanci](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fivanci](https://community.freefem.org/u/fivanci)
#### Post date: [May 3, 2021, 1:56am UTC](https://community.freefem.org/t/continues-simulations/953/2 "2021-05-03T01:56:05Z")

</div>

Hi !

It is possible to do this in several ways. Two simple ideas might be something like

1. Assume the meshes are named as mesh0.msh, mesh1.msh, etc., and that they are in the same directory as your main.edp script. Then you could do something like

Assumption here is also that solution(s) for each k are saved in pre-existing directories sols0, sols1, etc…

1. Alternatively, if your code differs a lot from case-to-case, you might want to consider simply writing different scripts for different meshes (cases), i.e. main1.edp, main2.edp, etc., where each maink.edp works on meshk.edp, for k=0,1,…  
Then, at the end of the maink.edp script just add the command

This command will simply start running the next script after it finishes with the current. Assumption is that they are all in the same directory, but of course you can add path in above ‘system’ command to each script if you wish to keep them separate.

if

---

<div class="post-metadata">

### Author: ![Dua](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@Dua](https://community.freefem.org/u/Dua)
#### Post date: [May 3, 2021, 12:58pm UTC](https://community.freefem.org/t/continues-simulations/953/3 "2021-05-03T12:58:15Z")

</div>

Hello,

Thanks alot for your response, your notes did solve my issue, I just have a few questions left here.  
Why did you add (k+1) to your problem in - int2d(Th)((k+1)\*(x+y)\*vh); ? because I don’t want number of my mesh changes my equation.

I would like to explore more about the methods that you proposed to me, like changing names “mesh”+k+".msh" scripts , or defining folders system(“FreeFem++ main(k+1).edp”); May you introduce more examples or training on the freefem tutorials website so that I can read? I couldn’t find it myself.

My other question is that do you know how can I use shell scripting for this problem?

Best regards.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [May 3, 2021, 3:20pm UTC](https://community.freefem.org/t/continues-simulations/953/4 "2021-05-03T15:20:24Z")

</div>

you can passe argument to freefem+= script  
like

```
  include "getARGV.idp"
  int k=getARGV("-k",1);// default value 1. 
  real rho = getARGV("-rho",3.14);// default value 3.14 
  mesh Th= “mesh”+k+".msh";

```

usage :

FreeFem++ your-script.edp -k 10 -rho 10.5

---

<div class="post-metadata">

### Author: ![fivanci](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@fivanci](https://community.freefem.org/u/fivanci)
#### Post date: [May 4, 2021, 1:29am UTC](https://community.freefem.org/t/continues-simulations/953/5 "2021-05-04T01:29:30Z")

</div>

1. No particular reason for putting k+1 - just to emphasize that your problem definition can be made parameter k dependent. Of course, if you run the same problem just on series of meshes (like in convergence study), clearly you can use the same “problem” definition.

2. Here is the link to “system” command documentation [Functions](https://doc.freefem.org/references/functions.html#system) - but, basically, you can think of it just as executing a specific command from your terminal when your code reaches a certain execution point - in case I wrote above, at the end of the code. So you don’t have to do it by hand, rather, it will be automatically executed by your program. You can play around with it - I most commonly use it to start another script when one is finished and I run long simulations.

3. I never tried to use shell scripting for something like your problem - it doesn’t seem impossible though. Maybe rather explore your options with passing argument to your script as explained in [Continues simulations - #4 by frederichecht](https://community.freefem.org/t/continues-simulations/953/4) .

if
