<html><head></head><body><div class="ydp54d5fe6yahoo-style-wrap" style="font-family:garamond, new york, times, serif;font-size:13px;"><div dir="ltr" data-setdir="false"><div dir="ltr" data-setdir="false">Hello PetSc users,<br><div><br></div><div>I request suggestions on how to do a coupled problem, in my case coupling between multiphase flow in porous media and deformation of porous media.</div>I have successfully written and validated the flow code with 3 degrees of freedom (S-saturation, P-pressure, T-Temperature)<br>which uses SNES solver inside a time loop. I have to use KSP solve for the deformation problem which has 1 degree of freedom (u-displacement).<br>For the coupled problem, the flow part now requires the displacement vector and the deformation part requires<br>the pressure field.<br><br>I have written a pseudo-code below. <br>My idea is to use the second solution vector (displacement) in FormFunctionLocal belonging to SNES.<br>Since the DM used by SNES can be used for only one problem, a clone is made to be used for KSP.<br>Is this approach the correct way to solve this coupled problem.<br><br>typedef struct { <br> PetscScalar s; // Saturation<br> PetscScalar p; // Pressure<br> PetscScalar T; // Temperature<br>} Field;<br><br>typedef struct { <br> PetscScalar u; // Displacement<br>} Field2;<br><br>FormFunctionLocal(DMDALocalInfo *info, Field *sol, Field2 *sol2, Field *f, AppCtx *user)<br>{<br>........................<br>}<br><br>main()<br>{<br> DM da, newda; <br> Vec sol;<br> Vec sol2;<br> SNES snes;<br> KSP ksp;<br><br> SNESCreate(......, &snes);<br> DMDACreate1d(........,&da);<br> .<br> .<br> SNESSetDM(snes, da);<br> DMClone(da, &newda);<br> KSPCreate(.........,&ksp);<br> KSPSetDM(ksp, newda);<br> .<br> .<br> DMDASetUniformCoordinates(da,...........);<br> DMDASNESSetFunctionLocal(da,...........,FormFunctionLocal);<br> .<br> DMCreateGlobalVector(da, &sol);<br> DMCreateGlobalVector(newda, &sol2); // This sol2 of type Field2 is passed to FormFunctionLocal.<br> .<br> do { // Time loop<br> <br> SNESSolve(snes,....);<br> .<br> .<br> KSPSolve(ksp,......); <br> .<br> .<br> }while(criteria); <br>}<br><div><br></div><div dir="ltr" data-setdir="false">Thank you,</div><div dir="ltr" data-setdir="false">Rahul.<br></div><br><br><br></div><div><br></div></div></div></body></html>