# Hydrodynamic Stability Implementation in FreeFEM

**URL:** <https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622>\
**Category:** General Discussion\
**Created:** [October 20, 2020, 12:24pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622 "2020-10-20T12:24:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [October 20, 2020, 12:24pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/1 "2020-10-20T12:24:18Z")

</div>

I am trying to carry out 3-D hydrodynamic stability analysis of 2-dimensional lid-driven square cavity flow at Re = 200.

I have calculated the 2-dimensional base flow at Re=200 and validated the base flow results with existing literature.

I would like to calculate the eigenvalues for the above-mentioned problem. I am not able to implement the stability analysis calculation in FreeFem.

There is a hydrodynamic stability problem implemented in ‘SLEPc-complex’ avaiable in FreeFem website.

I would like to implement my hydrodynamic stability code without any packages like SLEPc and PETSc. I am not able to find enough guidelines on implementation of hydrodynamic stability problem in FreeFem.

I would be extremely grateful if you please guide me on the implementation of hydrodynamic stability problem in FreeFem.

Looking forward to your kind reply. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [October 20, 2020, 12:27pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/2 "2020-10-20T12:27:25Z")

</div>

Why not use SLEPc? You are free to reinvent the wheel, of course, but that’s a lot of effort for very little value, don’t you think?

---

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [October 20, 2020, 12:33pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/3 "2020-10-20T12:33:57Z")

</div>

I am running FreeFEM on Windows 10. ‘SLEPc-complex’ library is giving a lot of trouble and not working properly. So, I had to take the decision of working without ‘SLEPc-complex’ library.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [October 20, 2020, 12:36pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/4 "2020-10-20T12:36:37Z")

</div>

It is working and extensively tested by our continuous integration workers. Are you using the latest release [4.7-1](https://github.com/FreeFem/FreeFem-sources/releases/download/v4.7-1/FreeFEM-4.7-1-win7-64.exe)? What are the problems you are facing?

I just tried again right now on my machine. As you can see below, no problem whatsoever.

 ![Screenshot 2020-10-20 at 2.47.05 PM](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/a256be95a908a2ff9f1b34b6d0f289c7a2df7097.png)

It also works in parallel, as you can see below.

 ![Screenshot 2020-10-20 at 2.53.36 PM](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/1X/feee6321ebc66306647d95f66ce1a08dcdeb972e.png)

---

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [October 23, 2020, 5:42am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/5 "2020-10-23T05:42:06Z")

</div>

So far what I have been able to figure out is that the problem is related to installation of ‘SLEPc-complex’ library on my system.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [October 23, 2020, 6:41am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/6 "2020-10-23T06:41:27Z")

</div>

What problem? You say that it “doesn’t work”, without saying what is not working.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [October 25, 2020, 7:33am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/8 "2020-10-25T07:33:12Z")

</div>

Does that still happen with 4.7-1? You are using only version 4.6, so you should consider updating your installation, there is a link given above.  
Are you using a `freefem++.pref` file? If so, what’s its content?  
The list of prefix `'E:\FreeFem++\\.\'` does not look OK to me.  
Also, once you have updated, if there is still a problem, could you try to use `"..\..\FreeFem++-mpi.exe"` instead of `"FreeFem++-mpi.exe"`?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 19, 2021, 11:58am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/10 "2021-06-19T11:58:52Z")

</div>

In (ii), you have a extra space before the .edp filename…

---

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [June 21, 2021, 9:28am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/12 "2021-06-21T09:28:33Z")

</div>

As the base flow code: [FreeFem-sources/navier-stokes-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-PETSc.edp), is not writing the base flow and the mesh, I am not able to run the code: [FreeFem-sources/navier-stokes-2d-SLEPc-complex.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-SLEPc-complex.edp) for eigen value computation.

Looking forward to your kind reply.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 22, 2021, 1:01pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/13 "2021-06-22T13:01:52Z")

</div>

Are you launching the command prompt as an administrator?

---

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [June 22, 2021, 5:49pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/14 "2021-06-22T17:49:58Z")

</div>

Yes I am running the command prompt as an administrator. But the code “[FreeFem-sources/navier-stokes-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-PETSc.edp)” is neither writing the solution nor the mesh file.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 22, 2021, 6:38pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/15 "2021-06-22T18:38:50Z")

</div>

Can you save a standard mesh, e.g., using `savemesh`?

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://community.freefem.org/u/Robert)\
**Post date:** [June 24, 2021, 6:06am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/17 "2021-06-24T06:06:26Z")

</div>

Hello Sarkar,

Did you try to add your path when saving the mesh? Something like: savemesh(“C:\\Desktop\\…”)? I also use Windows10 and I saw that when I work with SLEPc and PETSc I have to write the full path when reading/writing files. Otherwise, when I don’t run in parallel it just read/save the file from the folder where the .edp file is located.  
Regards,  
Robert

---

<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:** [June 24, 2021, 7:33am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/18 "2021-06-24T07:33:23Z")

</div>

Remark you can change of directory by adding in you script

```
     load "shell"
     exec("pwd"); // to see which current directory 
     chdir("directory path");  
     exec("pwd"); // to see which current directory
```

---

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [June 25, 2021, 5:48pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/19 "2021-06-25T17:48:41Z")

</div>

Thank you all.

Now the code: [FreeFem-sources/navier-stokes-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-PETSc.edp) is writing the mesh and base flow solution file. How to display the base flow solution as 4 mesh files are written by running the code on 4 processors?

Using the mesh file and base flow file, I was also able to also run the code: [FreeFem-sources/navier-stokes-2d-SLEPc-complex.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-SLEPc-complex.edp)…This code displays the eigen values on the command prompt. How to display the corresponding eigen modes?

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 26, 2021, 6:52am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/20 "2021-06-26T06:52:20Z")

</div>

You can plot the solution and eigenmodes at runtime using the command line parameter `-wg` (with graphics, default is off when using `FreeFem++-mpi`).

---

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [June 28, 2021, 5:44pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/21 "2021-06-28T17:44:05Z")

</div>

Yes using “-wg” with FreeFem+±mpi, the base solution and the eigen vector is being plotted.

But I was asking for something like using “ffmatlib.idp” for plotting in Octave/MATLAB so that the results can be used in reports.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 28, 2021, 6:08pm UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/22 "2021-06-28T18:08:20Z")

</div>

Use ParaView, via `savevtk`.

---

<div class="post-metadata">

**Author:** ![D\_N\_Sarkar](https://avatars.discourse-cdn.com/v4/letter/d/0ea827/32.png) [@D\_N\_Sarkar](https://community.freefem.org/u/D_N_Sarkar)\
**Post date:** [June 29, 2021, 6:31am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/23 "2021-06-29T06:31:42Z")

</div>

According to “[Visualization](https://doc.freefem.org/documentation/visualization.html#link-with-paraview)”, “Finite element variables saved using paraview must be in P0 or P1.”

But the codes: “[FreeFem-sources/navier-stokes-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-PETSc.edp)” and “[FreeFem-sources/navier-stokes-2d-SLEPc-complex.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/navier-stokes-2d-SLEPc-complex.edp)” use P2 and P1 elements.

Then how can the solutions be visualized in paraview? Using low order of elements would reduce the accuracy of the solutions.

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [June 29, 2021, 7:01am UTC](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622/24 "2021-06-29T07:01:29Z")

</div>

You can still use ParaView with P2 finite elements, the documentation is not accurate. For visualisation purposes, it won’t make any difference.

[Next page](https://community.freefem.org/t/hydrodynamic-stability-implementation-in-freefem/622.md?page=2)
