<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10px"><div id="yui_3_16_0_ym19_1_1507149076733_2635" dir="ltr"><span id="yui_3_16_0_ym19_1_1507149076733_2822">Adding the path to </span><span id="yui_3_16_0_ym19_1_1507149076733_2861">LD_LIBRARY_PATH doesn't help, the problems remain the same, it has no effect<br></span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> Jed Brown <jed@jedbrown.org> schrieb am 21:39 Mittwoch, 4.Oktober 2017:<br></font></div> <br><br> <div class="y_msg_container"><div dir="ltr">Klaus Burkart <<a shape="rect" ymailto="mailto:k_burkart@yahoo.com" href="mailto:k_burkart@yahoo.com">k_burkart@yahoo.com</a>> writes:<br clear="none"><br clear="none">> When I link the petsc library, the application side code is not properly compiled and the solver is not available for selection<br clear="none">><br clear="none">> --> FOAM FATAL IO ERROR:<br clear="none">> Unknown asymmetric matrix solver petGMRES<br clear="none"><br clear="none">There must be some earlier error message.<br clear="none"><br clear="none">> Valid asymmetric matrix solvers are :<br clear="none">><br clear="none">> 4<br clear="none">> (<br clear="none">> GAMG<br clear="none">> PBiCG<br clear="none">> PBiCGStab<br clear="none">> smoothSolver<br clear="none">> )<br clear="none">> I added the following to my makefile to link the petsc library<br clear="none">><br clear="none">> -L$(PETSC_DIR)/arch-linux2-c-debug/lib -lpetsc<br clear="none"><br clear="none">In this case, you'd need to add that path to LD_LIBRARY_PATH so the<br clear="none">loader can find it. None of these are PETSc issues, just linking<br clear="none">dynamic libraries.<div class="yqt4629844354" id="yqtfd73136"><br clear="none"><br clear="none">> Jed Brown <<a shape="rect" ymailto="mailto:jed@jedbrown.org" href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> schrieb am 18:45 Mittwoch, 4.Oktober 2017:<br clear="none">> <br clear="none">><br clear="none">> Klaus Burkart <<a shape="rect" ymailto="mailto:k_burkart@yahoo.com" href="mailto:k_burkart@yahoo.com">k_burkart@yahoo.com</a>> writes:<br clear="none">><br clear="none">>> My setup:<br clear="none">>><br clear="none">>> .bashrc<br clear="none">>> export PETSC_DIR=/home/klaus/OpenFOAM/klaus-5.0/petsc-3.7.6<br clear="none">>> export PETSC_ARCH=arch-linux2-c-debug<br clear="none">>> export PETSC_CONFIGDIR=${PETSC_DIR}/lib/petsc<br clear="none">>><br clear="none">>><br clear="none">>> make options<br clear="none">>> -I$(PETSC_CONFIGDIR)/conf \<br clear="none">><br clear="none">> The above should not be needed.<br clear="none">><br clear="none">>> -I$(PETSC_DIR)/include \<br clear="none">>> -I$(PETSC_DIR)/arch-linux2-c-debug/include<br clear="none">>><br clear="none">>> Installation and tests worked fine.<br clear="none">>><br clear="none">>> The output using: PetscInitialize(0,0,NULL,NULL); at the beginning and PetscFinalize(); at the end of the code section including PETSc (solver section) is:<br clear="none">>><br clear="none">>> simpleFoam: symbol lookup error: /home/klaus/OpenFOAM/klaus-5.0/platforms/linux64GccDPInt32Opt/lib/libpetFoam.so: undefined symbol: PetscInitialize<br clear="none">><br clear="none">> How have you linked libpetFoam.so to libpetsc.so and did you use RPATH?<br clear="none">> That seems to be the problem.<br clear="none">><br clear="none">>> No simulation is triggered<br clear="none">>><br clear="none">>><br clear="none">>> When I just declare Mat M; and call a function with M as a parameter which outputs "Petsc - Hello" and sets the matrix M to symmetric (using: MatSetOption(A, MAT_SYMMETRIC, PETSC_TRUE);), the execution of a simulation is triggered but MatSetOption is causing a problem, I assume because PetscInitialize is missing<br clear="none">>><br clear="none">>> Petsc - Hello nonepetGMRES: Solving for Ux, Initial residual = 1, Final residual = 1, No Iterations 0<br clear="none">>> Petsc - Hello nonepetGMRES: Solving for Uz, Initial residual = 1, Final residual = 1, No Iterations 0<br clear="none">>> simpleFoam: symbol lookup error: /home/klaus/OpenFOAM/klaus-5.0/platforms/linux64GccDPInt32Opt/lib/libpetFoam.so: undefined symbol: MatSetOption<br clear="none">>><br clear="none">>> Maybe important to know, there's no way to enter commmand line input in the terminal while a simulation is running because the application displays continuously the intermediate simulation results. That's why I use PetscInitialize(0,0,NULL,NULL); There's now way to provide command line input.<br clear="none">><br clear="none">> That's fine. You can use the PETSC_OPTIONS environment variable or a<br clear="none">> configuration file to get run-time options to PETSc.<br clear="none">><br clear="none">>> I came back to this simple test after writing "the complete code" which showed these problems and stripped it down, step-by-step, to figure out what causes the problem i.e. everything but a declaration. <br clear="none">>><br clear="none">>> <br clear="none">>><br clear="none">>> Jed Brown <<a shape="rect" ymailto="mailto:jed@jedbrown.org" href="mailto:jed@jedbrown.org">jed@jedbrown.org</a>> schrieb am 17:17 Mittwoch, 4.Oktober 2017:<br clear="none">>> <br clear="none">>><br clear="none">>> Klaus Burkart <<a shape="rect" ymailto="mailto:k_burkart@yahoo.com" href="mailto:k_burkart@yahoo.com">k_burkart@yahoo.com</a>> writes:<br clear="none">>><br clear="none">>>> What's the concept to interface with PETSc from another application to solve a linear system with PETSc?<br clear="none">>>><br clear="none">>>> The standard procedure of the job:<br clear="none">>>><br clear="none">>>> 1: The application provides a matrix which needs to be converted and be loaded into PETSc<br clear="none">>>><br clear="none">>>> 2: The application provides the rhs vector (containing pointers!) which needs to be loaded into PETSc <br clear="none">>>><br clear="none">>>> 3: The linear system is to be solved using PETSc<br clear="none">>>><br clear="none">>>> 4: The application provides the result vector x, the PETSc result needs to be copied back to the application into vector x (also expecting pointers)<br clear="none">>>><br clear="none">>>><br clear="none">>>> The problem - maybe a completely wrong approach when it comes to using PETSc: <br clear="none">>>><br clear="none">>>> With other linear algebra libraries, I included the library functionality in the code of a new solver accessing the functionality usually via header files and created a plugin which can be called from the application when running a simulation. <br clear="none">>>><br clear="none">>>> Even so the mixed code including PETSc code can be compiled, the bit of the plugin, interfacing with the application is broken as soon as I include more than a PETSc declaration in the mixed code.<br clear="none">>><br clear="none">>> Sounds like maybe you haven't correctly linked to the PETSc library.<br clear="none">>> Sending us the commands run and output/errors would be helpful to debug.<br clear="none">>><br clear="none">>>> How to interface with PETSc from a software application? (I am using c++ and Ubuntu)<br clear="none">>>><br clear="none">>>> Klaus<br clear="none">>><br clear="none">>> <br clear="none">><br clear="none">> </div></div><br><br></div> </div> </div> </div></div></body></html>