<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10px">My setup:<br id="yui_3_16_0_ym19_1_1507133694866_2935"><br id="yui_3_16_0_ym19_1_1507133694866_2936">.bashrc<br id="yui_3_16_0_ym19_1_1507133694866_2937">export PETSC_DIR=/home/klaus/OpenFOAM/klaus-5.0/petsc-3.7.6<br id="yui_3_16_0_ym19_1_1507133694866_2938">export PETSC_ARCH=arch-linux2-c-debug<br id="yui_3_16_0_ym19_1_1507133694866_2939">export PETSC_CONFIGDIR=${PETSC_DIR}/lib/petsc<br id="yui_3_16_0_ym19_1_1507133694866_2940"><br id="yui_3_16_0_ym19_1_1507133694866_2941"><br id="yui_3_16_0_ym19_1_1507133694866_2942">make options<br id="yui_3_16_0_ym19_1_1507133694866_2943"> -I$(PETSC_CONFIGDIR)/conf \<br id="yui_3_16_0_ym19_1_1507133694866_2944"> -I$(PETSC_DIR)/include \<br id="yui_3_16_0_ym19_1_1507133694866_2945"> -I$(PETSC_DIR)/arch-linux2-c-debug/include<br id="yui_3_16_0_ym19_1_1507133694866_2946"><br id="yui_3_16_0_ym19_1_1507133694866_2947">Installation and tests worked fine.<br id="yui_3_16_0_ym19_1_1507133694866_2948"><br id="yui_3_16_0_ym19_1_1507133694866_2949">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 id="yui_3_16_0_ym19_1_1507133694866_2950"><br id="yui_3_16_0_ym19_1_1507133694866_2951">simpleFoam: symbol lookup error: /home/klaus/OpenFOAM/klaus-5.0/platforms/linux64GccDPInt32Opt/lib/libpetFoam.so: undefined symbol: PetscInitialize<br id="yui_3_16_0_ym19_1_1507133694866_2952"><br id="yui_3_16_0_ym19_1_1507133694866_2953">No simulation is triggered<br id="yui_3_16_0_ym19_1_1507133694866_2954"><br id="yui_3_16_0_ym19_1_1507133694866_2955"><br id="yui_3_16_0_ym19_1_1507133694866_2956">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 id="yui_3_16_0_ym19_1_1507133694866_2957"><br id="yui_3_16_0_ym19_1_1507133694866_2958">Petsc - Hello nonepetGMRES: Solving for Ux, Initial residual = 1, Final residual = 1, No Iterations 0<br id="yui_3_16_0_ym19_1_1507133694866_2959">Petsc - Hello nonepetGMRES: Solving for Uz, Initial residual = 1, Final residual = 1, No Iterations 0<br id="yui_3_16_0_ym19_1_1507133694866_2960">simpleFoam: symbol lookup error: /home/klaus/OpenFOAM/klaus-5.0/platforms/linux64GccDPInt32Opt/lib/libpetFoam.so: undefined symbol: MatSetOption<br id="yui_3_16_0_ym19_1_1507133694866_2961"><br id="yui_3_16_0_ym19_1_1507133694866_2962">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 id="yui_3_16_0_ym19_1_1507133694866_2963"><br id="yui_3_16_0_ym19_1_1507133694866_2964">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 id="yui_3_16_0_ym19_1_1507133694866_2965"><br id="yui_3_16_0_ym19_1_1507133694866_2966"><div id="yui_3_16_0_ym19_1_1507133694866_2747"><span></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 17:17 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">> 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.<div class="yqt6049107602" id="yqtfd53855"><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</div></div><br><br></div> </div> </div> </div></div></body></html>