# HPDDM and Block-CG solver example

**URL:** <https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227>\
**Category:** General Discussion\
**Created:** [January 18, 2020, 5:02am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227 "2020-01-18T05:02:27Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 18, 2020, 5:02am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/1 "2020-01-18T05:02:27Z")

</div>

Hi, I really want to test the Block-CG method through HPDDM. I know that in FreeFem++ we can use all the features of HPDDM and it is mentioned in the tutorial that HPDDM has a Block-CG method. But I didn’t see any examples of it. Did I miss something? Or anyone can tell me where to start with?

---

<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:** [January 18, 2020, 6:12am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/2 "2020-01-18T06:12:05Z")

</div>

You can have a look at [this example](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/elasticity-block.edp#L68) for solving problems with multiple RHS. You need to concatenate one after the other in a single FreeFEM vector, then call `^-1` as usual. By default, this example use a pseudo-block GMRES. If you want to try BCG or BFBCG, please switch to a symmetric preconditioner `-hpddm_schwarz_method asm`, and then also turn on the correct option, `-hpddm_krylov_method bfbcg`. See more about these options in the last page of the HPDDM [cheatsheet](https://github.com/hpddm/hpddm/blob/master/doc/cheatsheet.pdf).

About your issue with BLAS/LAPACK and PETSc compilation, you can now remove your reference installation, pull the develop branch, and relaunch the compilation. If there is no available BLAS, I’ve made the necessary changes so that PETSc compiles it for you as well, cf. this recent [commit](https://github.com/FreeFem/FreeFem-sources/commit/58f59bf09160eacae96f682e0ab733e2114b5e7a).

---

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 18, 2020, 10:30pm UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/3 "2020-01-18T22:30:50Z")

</div>

Thanks for the hint!

About the compilation, I tried to reinstall the develop branch, but it’s still not working.  
When I ‘make check’, it passes all the testing examples, but when I input ‘FreeFem++’,it show:

freeglut (ffglut): failed to open display ‘’

Also when I install FreeFem+±cs, and run ‘FreeFem+±cs’, it shows errors:  
Can’t open display:

- ffloader: error: main(): run: unix: system(/home/ylnz7/FreeFem+±cs\_18.1/Contents/Linux/FreeFem+±gui -MainPath /home/ylnz7/FreeFem+±cs\_18.1 ): returned with error code 1

which never happened before.

[config.log](https://community.freefem.org/uploads/short-url/elTr5XDcwI9tiwm72E5k8wNbk18.log) (356.5 KB)

---

<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:** [January 19, 2020, 6:49am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/4 "2020-01-19T06:49:09Z")

</div>

Yes, you don’t have a X server on your machine, or at least FreeFEM `./configure` can’t find it. This means that you cannot use ffglut.

---

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 27, 2020, 4:21am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/5 "2020-01-27T04:21:43Z")

</div>

Hi,

I figured out the previous problem is caused by some errors in my Ubuntu system and it was fixed. Now new compilation errors show up. Could you please tell me if you have any ideas. Thank you very much!

```
configure: freefem++ used download: yes 
configure: -- Dynamic load facility: yes 
configure: -- ARPACK (eigen value): yes 
configure: -- UMFPACK (sparse solver): yes 
configure: -- BLAS: yes 
configure: -- with MPI: yes
configure: -- with PETSC: yes / PETSC complex: yes 
configure: -- with SLEPC: yes / SLEPC complex: yes 
configure: -- with hpddm: yes (need MPI &amp; c++11: yes) 
configure: -- with htool: yes (need MPI &amp; c++11: yes) 
configure: -- without libs:  
configure: -- without plugin:  
configure: progs: FreeFem++-nw bamg cvmsh2 FreeFem++-mpi ffmedit ffglut 
configure: use of download freeyams see 3rdparty/yams/freeyams.2011.02.22 (suface mesh adaptation)  
configure: use of download mmg3d (v4) see 3rdparty/mmg3d/mmg3d4/LICENCE.txt  
configure: use of download mmg  
configure: use of download parmmg  
configure: try to download: htool yams mshmet parmmg mmg mmg3d 
configure: Please run &quot;3rdparty/getall&quot; to download all necessary packages before running make
```

---

<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:** [January 27, 2020, 5:39am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/6 "2020-01-27T05:39:59Z")

</div>

I don’t see any compilation error.

---

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 28, 2020, 5:15am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/7 "2020-01-28T05:15:29Z")

</div>

But I still got the following error when I try to run the above mentioned sample code:

```
-- FreeFem++ v4.400004 (Mon Jan 27 22:40:12 CST 2020 - git v4.4-3-135-gc66cc179)
 Load: lg_fem lg_mesh lg_mesh3 eigenvalue 
    1 : // run with MPI: ff-mpirun -np 1 script.edp
    2 : // NBPROC 1
    3 : 
    4 : load &quot;hpddm&quot;
Load error: hpddm
	 fail: 
 dlerror : /usr/local/lib/ff++/4.4-4/lib/hpddm.so: cannot open shared object file: No such file or directory
list prefix: &apos;/usr/lib/freefem++/&apos; &apos;./&apos; &apos;/usr/local/lib/ff++/4.4-4/lib/&apos; list suffix: &apos;&apos; , &apos;.so&apos; 
  current line = 4
Load error : hpddm
	line number :4, hpddm
error Load error : hpddm
	line number :4, hpddm
 code = 2 mpirank: 0
```

---

<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:** [January 28, 2020, 7:17am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/8 "2020-01-28T07:17:02Z")

</div>

Is there a file `/usr/local/lib/ff++/4.4-4/lib/hpddm.so` in your installation?  
If so, could you please launch the code with 1 process and the added flags `-ns -v 100`, and send the full log, please.  
If the file is not present, you have an incomplete FreeFEM installation.

---

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 28, 2020, 6:02pm UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/9 "2020-01-28T18:02:46Z")

</div>

The hpddm.so is not in the dir: /usr/local/lib/ff++/4.4-4/lib/hpddm.so  
but it is in the dir: /usr/local/lib/ff++/4.4-4/lib/mpi/hpddm.so  
Does that mean an incomplete installation?

---

<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:** [January 28, 2020, 7:27pm UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/10 "2020-01-28T19:27:43Z")

</div>

You need to use `FreeFem++-mpi`, not `FreeFem++`.

---

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 28, 2020, 11:17pm UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/11 "2020-01-28T23:17:03Z")

</div>

I tried then got:

```
   21 : int[int] LL = [2,3, 2,1, 2,2];
   22 : meshN The Identifier meshN does not exist 

 Error line number 22, in file elasticity-block.edp, before token meshN

  current line = 21 mpirank 0 / 1
Compile error : 
	line number :22, meshN
error Compile error : 
	line number :22, meshN
 code = 1 mpirank: 0
```

---

<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:** [January 29, 2020, 6:17am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/12 "2020-01-29T06:17:05Z")

</div>

Could you please send the result of `ff-mpirun -np 1 elasticity-block.edp > dump.log`?  
If dimension is set to 3, as done [here](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/elasticity-block.edp#L6), then `meshN` should be set to `mesh3`, so I don’t quite understand the error you get.

---

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 29, 2020, 7:00am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/13 "2020-01-29T07:00:59Z")

</div>

Please check!  
[dump.log](https://community.freefem.org/uploads/short-url/5BhYKeRKSZmmQ5rBciNaP3ymVEi.log) (12.4 KB)

---

<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:** [January 29, 2020, 7:12am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/14 "2020-01-29T07:12:09Z")

</div>

There is something seriously wrong with your `macro_ddm.idp`, looks like a version from at least two years ago. Do you have an older version of FreeFEM lying around on your machine? Please make sure that the `.idp` you are loading is indeed the one as available [here](https://github.com/FreeFem/FreeFem-sources/blob/develop/idp/macro_ddm.idp).

---

<div class="post-metadata">

**Author:** ![ylnz7](https://avatars.discourse-cdn.com/v4/letter/y/53a042/32.png) [@ylnz7](https://community.freefem.org/u/ylnz7)\
**Post date:** [January 29, 2020, 11:17pm UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/15 "2020-01-29T23:17:14Z")

</div>

Actually, I can run the example in the dir:

```
**~/FreeFem-sources/examples/hpddm** $
```
  
and it normally end  
but I cannot if run it in the following dir or others like ~/examples:
```
**/usr/local/share/FreeFEM/4.4-4/examples/hpddm**
```

---

<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:** [January 30, 2020, 5:46am UTC](https://community.freefem.org/t/hpddm-and-block-cg-solver-example/227/16 "2020-01-30T05:46:12Z")

</div>

You need to setup a proper `.freefem++.pref` to load the correct libraries and `.idp`, cf. the [documentation](https://doc.freefem.org/introduction/installation.html#environment-variables-and-init-file).
