<div dir="ltr"><div dir="ltr"><div> Hi all,</div><div><br></div><div>Thanks for your previous suggestion, I have been able to successfully link Petsc to OpenFOAM. I have written a simple interface and it works quite well in serial mode, but cannot run in parallel. I have been thinking about this problem for weeks but couldn't solve it. So I think maybe you could give me some idea. I describe my problem below.<br></div><div><br></div><div>My interface is just a class named "petscSolver<i>"</i>, which is used to convert an <span class="gmail-gr_ gmail-gr_352 gmail-gr-alert gmail-gr_spell gmail-gr_inline_cards gmail-gr_disable_anim_appear gmail-ContextualSpelling gmail-ins-del gmail-multiReplace" id="gmail-352">openfoam's</span> matrix or blocked matrix to Petsc Mat, then solve the matrix using Petsc's solver. <br></div><div>To use Petsc, an Openfoam's solver need to be recompiled after adding the following lines to make file:</div><div><br></div><div>EXE_INC = \</div><div>...<br></div><div> -I$(LIB_SRC)/petscSolver \<br></div><div> -I$(PETSC_DIR)/include \ <br></div><div> -I$(PETSC_DIR)/$(PETSC_ARCH)/include</div><div>EXE_LIBS = \</div><div>...</div><div> -L$(PETSC_DIR)/$(PETSC_ARCH)/lib -lpetsc</div><div><br></div><div>To run an openfoam's case in parallel, first I need to discretize the domain into subdomains (e.g. 2 subdomains ), then use the following command:</div><div><br></div><div>mpirun -np 2 mySolver -parallel</div><div><br></div><div>(where mpirun is literally mpiexec) The simulation crashed even before doing anything and the error message is as in the attached image.<br></div><div>I have tested and realized that the solver can run in parallel as normal by removing the two lines: <br></div><div><div> -I$(PETSC_DIR)/include \ <br></div><div> -I$(PETSC_DIR)/$(PETSC_ARCH)/include</div></div><div>But then it is clearly no longer linked to Petsc.</div><div><br></div><div>I would appreciate any suggestion.</div><div><br></div><div><div><img src="cid:ii_jw1h4d3k0" alt="Screenshot from 2019-05-24 09-22-17.png" width="566" height="57"><br></div></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 11, 2019 at 1:37 PM Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Mark,<br>
<br>
Thanks for the clarifying email. My google searches didn't locate the rheoTool you mention nor "a PRACE project running via CINECA (Bologna)".<br>
<br>
It would be nice if someday OpenFOAM had (either directly or somehow with the modules directory) an interface to the PETSc solvers. This would allow the use of a variety of other solvers including hypre BoomerAMG, SuperLU_Dist, MUMPS, and even the use of PETSc/ViennaCL GPU based solvers automatically from OpenFOAM. Unfortunately the PETSc group doesn't have the resources or expertise to develop and support such an interface ourselves. We would, of course, try to answer emails about PETSc usage and bugs for such an interface. <br>
<br>
Barry<br>
<br>
If OpenFOAM did have such an interface one thing we could provide is the CI infrastructure for tracking changes to PETSc that may effect OpenFOAM. For example we could automatically build OpenFOAM each day with the latest master of PETSc thus immediately detecting changes that effect the interface.<br>
<br>
<br>
<br>
<br>
> On Apr 10, 2019, at 4:55 PM, Mark Olesen <<a href="mailto:Mark.Olesen@esi-group.com" target="_blank">Mark.Olesen@esi-group.com</a>> wrote:<br>
> <br>
> The paper that Barry mentioned gives some generalities, but probably <br>
> won't help much. There are some PETSc/OpenFOAM interfaces in rheoTool <br>
> that are probably much more helpful.<br>
> <br>
> As Barry also rightly noted, there are some config files in the OpenFOAM <br>
> tree that were put in some time ago for helping with setting up PETSc <br>
> and OpenFOAM. Assuming that you have set the appropriate values in the <br>
> etc/<a href="http://config.sh/petsc" rel="noreferrer" target="_blank">config.sh/petsc</a> file you will be able to use those when using wmake. <br>
> For running you will still need to ensure that the LD_LIBARY_PATH is set <br>
> correctly. For example, what some build scripts exhibit:<br>
> <br>
> wmake(petsc) :<br>
> ==> Before running, verify that PETSc libraries can be found<br>
> <br>
> Enable in the OpenFOAM etc/bashrc, define manually or try with the<br>
> following (POSIX shell):<br>
> <br>
> eval $(foamEtcFile -sh -config petsc -- -force)<br>
> <br>
> ==<br>
> <br>
> <br>
> There is currently a PRACE project running via CINECA (Bologna) with <br>
> binding in PETSc as a runtime selectable linear solver in OpenFOAM. This <br>
> is still at the stage of early testing and performance benchmarking.<br>
> <br>
> Cheers,<br>
> /mark<br>
> <br>
> On 4/10/19 6:37 PM, Smith, Barry F. via petsc-users wrote:<br>
>> <br>
>> We don't know much about OpenFoam but<br>
>> <br>
>> 1) if I do a<br>
>> <br>
>> git grep -i petsc<br>
>> <br>
>> in the <a href="https://develop.openfoam.com/Development/OpenFOAM-plus.git" rel="noreferrer" target="_blank">https://develop.openfoam.com/Development/OpenFOAM-plus.git</a> repository I see various configuration files specifically for PETSc.<br>
>> <br>
>> etc/config.csh/petsc etc/<a href="http://config.sh/petsc" rel="noreferrer" target="_blank">config.sh/petsc</a> wmake/scripts/have_petsc<br>
>> <br>
>> so it appears that OpenFOAM has the tools to be linked against PETSc (to me the documentation on how to use them is rather terse). Are<br>
>> you using these? If you have trouble with them perhaps you can ask the OpenFOAM user community how to use them.<br>
>> <br>
>> <br>
>> 2) if you are editing the Make/options file directly you can try changing<br>
>> <br>
>> -L$(PETSC_DIR)/$(PETSC_ARCH)/lib -lpetsc<br>
>> <br>
>> to<br>
>> <br>
>> -Wl,-rpath,$(PETSC_DIR)/$(PETSC_ARCH)/lib -L$(PETSC_DIR)/$(PETSC_ARCH)/lib -lpetsc<br>
>> <br>
>> <br>
>> <br>
>> Note also that simply including petsc.h into the OpenFoam source code and linking against -lpetsc will not immediately allow calling the PETSc solvers from OpenFOAM. One needs to write all the interface code that sets up and calls the PETSc solvers from OpenFOAM. There is a paper <a href="https://www.researchgate.net/publication/319045499_Insertion_of_PETSc_in_the_OpenFOAM_Framework" rel="noreferrer" target="_blank">https://www.researchgate.net/publication/319045499_Insertion_of_PETSc_in_the_OpenFOAM_Framework</a> that describes at an abstract level how they wrote code that calls the PETSc solvers from OpenFOAM but the source code that actually does the work does not appear to be available.<br>
>> <br>
>> Note that PETSc is now at version 3.11 we recommend working with that version (unless you already have a lot of code that calls PETSc written with a previous version of PETSc, for that we recommend first upgrading to petsc 3.11 and then continuing to add code).<br>
>> <br>
>> Barry<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> <br>
>>> On Apr 10, 2019, at 8:23 AM, Balay, Satish via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
>>> <br>
>>> Runtime error? You might have to add the path to $PETSC_ARCH/lib in LD_LIBRARY_PATH env variable<br>
>>> or - to your link command. If linux/gcc - the linker option is -Wl,-rpath,$PETSC_ARCH/lib<br>
>>> <br>
>>> If not - send detail logs.<br>
>>> <br>
>>> Satish<br>
>>> <br>
>>> On Wed, 10 Apr 2019, Vu Do Quoc via petsc-users wrote:<br>
>>> <br>
>>>> Hi all,<br>
>>>> <br>
>>>> I am trying to insert Petsc to OpenFOAM opensource software.<br>
>>>> I have been successfully compiling Petsc with an available solver in<br>
>>>> OpenFOAM by linking it with the shared library libpetsc.so. However, when I<br>
>>>> call the solver to run a test case, I got an error saying that:<br>
>>>> "libpetsc.so cannot be found", even though the library still exists in the<br>
>>>> $PETSC_ARCH/lib folder.<br>
>>>> <br>
>>>> I have been struggling for weeks but still, have not been able to figure it<br>
>>>> out. Therefore I would be very grateful for any suggestion to solve this<br>
>>>> problem.<br>
>>>> <br>
>>>> Thanks in advance for your time,<br>
>>>> <br>
>>>> Best regards,<br>
>>>> <br>
>>>> Vu Do<br>
>>>> <br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr" style="font-size:12.8px"><div><b>Vu Q. Do<br></b>------------------------------------------------<br><i style="font-size:12.8px">Student of Aeronautical Engineering</i><br>Programme de Formation d'Ingénieurs d'Excellence au Vietnam <i>- PFIEV</i><br></div><div>School of Transportation Engineering<i><br></i></div>Hanoi University of Science and Technology</div><div dir="ltr" style="font-size:12.8px">01 Dai Co Viet Avenue, Hanoi, Vietnam<br>E-mail: <a href="mailto:vu.doquochust@gmail.com" target="_blank">vu.doquochust@gmail.com</a></div></div></div></div></div></div></div></div></div></div></div>