# Example code not working

**URL:** <https://community.freefem.org/t/example-code-not-working/580>\
**Category:** General Discussion\
**Created:** [September 12, 2020, 12:09pm UTC](https://community.freefem.org/t/example-code-not-working/580 "2020-09-12T12:09:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [September 12, 2020, 12:09pm UTC](https://community.freefem.org/t/example-code-not-working/580/1 "2020-09-12T12:09:46Z")

</div>

Dear @prj,

I would like to use the ‘Augmented Lagrangian Preconditioner for Large-Scale Hydrodynamic Stability Analysis’ method based on your codes. However, when I try to run the codes, the base-flow calculation runs fine, but the eigenvalue computation does not work. It stops when the method ‘EPSSolve’ is called, with the following message:

[0]PETSC ERROR: #1 PetscCommDuplicate() line 118 in /builds/workspace/FreeFEM-sources-deployDEB-withPETSc/3rdparty/ff-petsc/petsc-3.13.0/src/sys/objects/tagm.c  
[0]PETSC ERROR: #2 PetscHeaderCreate\_Private() line 63 in /builds/workspace/FreeFEM-sources-deployDEB-withPETSc/3rdparty/ff-petsc/petsc-3.13.0/src/sys/objects/inherit.c  
[0]PETSC ERROR: #3 MatCreate() line 83 in /builds/workspace/FreeFEM-sources-deployDEB-withPETSc/3rdparty/ff-petsc/petsc-3.13.0/src/mat/utils/gcreate.c  
[0]PETSC ERROR: ------------------------------------------------------------------------  
[0]PETSC ERROR: [1]PETSC ERROR: #1 PetscCommDuplicate() line 118 in /builds/workspace/FreeFEM-sources-deployDEB-withPETSc/3rdparty/ff-petsc/petsc-3.13.0/src/sys/objects/tagm.c  
Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range  
[0]PETSC ERROR: Try option -start\_in\_debugger or -on\_error\_attach\_debugger  
[0]PETSC ERROR: or see [https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind](https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind)  
[0]PETSC ERROR: or try [http://valgrind.org](http://valgrind.org) on GNU/linux and Apple Mac OS X to find memory corruption errors  
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run  
[0]PETSC ERROR: to get more information on the crash.  
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------  
[0]PETSC ERROR: Signal received  
[0]PETSC ERROR: See [https://www.mcs.anl.gov/petsc/documentation/faq.html](https://www.mcs.anl.gov/petsc/documentation/faq.html) for trouble shooting.  
[0]PETSC ERROR: Petsc Release Version 3.13.0, Mar 29, 2020  
[0]PETSC ERROR: FreeFem+±mpi on a named DESKTOP-8VC8OSF by root Sat Sep 12 11:17:02 2020  
[0]PETSC ERROR: Configure options MAKEFLAGS= --prefix=/usr/local/ff-petsc//c --with-debugging=0 COPTFLAGS="-O3 -mtune=generic" CXXOPTFLAGS="-O3 -mtune=generic" FOPTFLAGS="-O3 -mtune=generic" --with-cxx-dialect=C++11 --with-ssl=0 --with-x=0 --with-fortran-bindings=0 --with-cc=/usr/bin/mpicc --with-cxx=/usr/bin/mpic++ --with-fc=/usr/bin/mpif90 --with-scalar-type=complex --with-blaslapack-include= --with-blaslapack-lib="-llapack -lblas" --with-scalapack-dir=/usr/local/ff-petsc//r --with-metis-dir=/usr/local/ff-petsc//r --with-ptscotch-dir=/usr/local/ff-petsc//r --with-suitesparse-include=/usr/local/ff-petsc/r/include --with-suitesparse-lib="-Wl,-rpath,/usr/local/ff-petsc/r/lib -L/usr/local/ff-petsc/r/lib -lumfpack -lklu -lcholmod -lbtf -lccolamd -lcolamd -lcamd -lamd -lsuitesparseconfig" --with-mumps-dir=/usr/local/ff-petsc//r --with-parmetis-dir=/usr/local/ff-petsc//r --with-tetgen-dir=/usr/local/ff-petsc//r --download-slepc --download-hpddm --download-hpddm-commit=e8639ff PETSC\_ARCH=fc  
[0]PETSC ERROR: #4 User provided function() line 0 in unknown file  
[DESKTOP-8VC8OSF:00232] 3 more processes have sent help message help-mpi-api.txt / mpi-abort

Do you have any idea what causes this issue? I am running the code in the Windows Ubuntu app version Ubuntu 18.04.4 LTS, FreeFem version 4.6.

Thank you for your help in advance  
András

---

<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:** [September 13, 2020, 11:16am UTC](https://community.freefem.org/t/example-code-not-working/580/2 "2020-09-13T11:16:18Z")

</div>

Could you please try with the latest FreeFEM version ([4.7](https://github.com/FreeFem/FreeFem-sources/releases/tag/v4.7))?  
Also, in `Eigensolver.edp`, could you try to replace `-st_pc_type fieldsplit` by `-st_pc_type lu`, and tell me if it is still not working?

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [September 14, 2020, 6:32am UTC](https://community.freefem.org/t/example-code-not-working/580/3 "2020-09-14T06:32:59Z")

</div>

Dear @prj,

thanks for the fast reply. I managed to resolve the issue: the macro\_ddm.idp file was outdated (a previous reinstallation of FreeFem++ did not set the path properly).

However, I have and other question related to the variational formulation. In [this example](https://github.com/FreeFem/FreeFem-sources/blob/master/examples/hpddm/navier-stokes-2d-PETSc.edp), in the variational formulation of both the residual and the jacobian the boundary conditions are the same. However, in the augmented Lagrangian preconditioner example, the boundary condition in the jacobian and in the residual are different: in the residual, the nonzero velocities are prescribed, but in the jacobian every boundary condition is zero. Why is that?

Thank you for your help  
András

---

<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:** [September 14, 2020, 8:35am UTC](https://community.freefem.org/t/example-code-not-working/580/4 "2020-09-14T08:35:17Z")

</div>

Good to know the code is now working properly. The value you set with the `on` keyword on a bilinear form does not matter, it’s only taken into account for the assembly of the linear form. So, for the Jacobian, `on(1, u = 1)` or `on(1, u = 0)` does not matter. However, for the residual, it does matter. Here is an example so that you can see it for yourself.

```auto
mesh Th = square(4, 4);
varf vPb1(u, v) = on(1,2,3,4, u = 1);
varf vPb2(u, v) = on(1,2,3,4, u = 1234);
fespace Vh(Th, P1);
matrix A1 = vPb1(Vh, Vh, tgv = -1);
matrix A2 = vPb2(Vh, Vh, tgv = -1);
matrix diff = A1 + (-1.0)*A2;
cout << diff << endl;

```

Effectively, this means that the 2D and 3D code are computing the same quantities, sorry for the confusion.

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [September 15, 2020, 6:46am UTC](https://community.freefem.org/t/example-code-not-working/580/5 "2020-09-15T06:46:15Z")

</div>

Thank you for the quick answer, now the boundary condition specification is clear!

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [September 15, 2020, 2:41pm UTC](https://community.freefem.org/t/example-code-not-working/580/6 "2020-09-15T14:41:52Z")

</div>

I have two more questions about the method.

1. It is customary in flow stability that the base-flow calculation is carried out in multiple steps: first, at a low Reynolds number, the initial guess in the solution of the nonlinear equation is ad-hoc, and then the Reynolds number is increased in multiple steps. However, then I tried to use this procedure, the nonlinear equation solution failed to converge, but the solution converged with a worse initial guess, e.g. [u1, u2, p] = [1, 0, 0]. I also noticed that in your paper, you only took one previous step in the base flow calculation (Re=50 first, then Re=100). My question is basically the following: is this normal, and when using iterative solvers, a too good initial guess can cause convergence problems?
2. In the [eigenvalue solution file](https://github.com/prj-/moulin2019al/blob/master/Eigensolver.edp) , at line 74 the operator s^-1 Lp is assembled, and a boundary condition is specified. This is unclear to me: how should I specify this boundary condition for a general problem?

Thanks for the help

András

---

<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:** [September 15, 2020, 3:08pm UTC](https://community.freefem.org/t/example-code-not-working/580/7 "2020-09-15T15:08:34Z")

</div>

1. Yes, this is customary to all nonlinear problems. You can do that, but it’s not implemented (I think? I.e., doing -Re 50, then -Re 75, and finally -Re 100, will use the baseflow for Re 50 for the Re 100 solve, but I’m not sure)
2. There is no boundary condition specified in `Lp`
