<div dir="ltr">What you describe will basically work, but it won't give you preconditioning. I would NOT recommend using MatNest or VecNest until you have a fully-implemented algorithm that you're happy with and that performs well with fieldsplit or custom preconditioning that will be amenable to your MatShells, AND for which you have systematically demonstrated that those operations that are comparatively expensive when using monolithic formats are actually bottlenecks for your application. If you write assembly using MatGetLocalSubMatrix [1] and MatSetValuesLocal, then adding in (optional) support for MatNest later will involve only a small amount of setup code and zero modifications to your assembly routines.<br>
<br>Even then, I would not use VecNest. In fact, VecNest should pretty much never be used. It demonstrates a concept and may occasionally be useful, but that occurrence is so rare that you shouldn't even consider it for a new code.<br>
<br>[1] <a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetLocalSubMatrix.html">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetLocalSubMatrix.html</a><br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Feb 21, 2013 at 2:44 PM, Amneet Bhalla <span dir="ltr"><<a href="mailto:mail2amneet@gmail.com" target="_blank">mail2amneet@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote">Hi All, <br><div><br></div><div><div>I want to solve a system of equations which looks like </div><div><br></div><div>             A x  +  Bu  = f1</div><div>             C x  +  Du  = f2</div><div>


<br></div><div>A, B, C, and D as shell operators and {x , u, f1, and f2} are non-native </div>

<div>PETSc vectors.</div><div><br></div><div>This is how I am thinking of solving it in PETSc</div><div><br></div><div>1)  Define shell operators which define Matrix-vector multiplication</div><div>     routines {Ax,Bu, Cx, Du}. </div>




<div><br></div><div>2) Define a composite Matrix MAT_COMP as</div><div>    Mat mat_array[ ] = {A,B,C,D};</div><div>    Mat MAT_COMP;</div><div>    MatCreateNest(PETSC_COMM_WORLD, 2, PETSC_NULL, 2, PETSC_NULL, mat_array, &MAT_COMP);</div>



<div><br></div><div>3) Define a composite Vector VEC_COMP as</div><div>    Vec vec_array[ ] = {f1,f2};</div><div>    Vec VEC_COMP;</div><div>    VecCreateNest(PETSC_COMM_WORLD, 2, PETSC_NULL, vec_array, &VEC_COMP);</div>



<div><br></div><div>4) Create a shell matrix for composite matrix (MAT_COMP) which defines the action</div><div>     f1 = Ax + Bu;</div><div>     f2 = Cx + Du;</div><div><br></div><div>   i.e MATOP_MULT, MATOP_MULT_ADD,  and MATOP_GET_VECS to duplicate vectors</div>


<span><font color="#888888">
<div>    </div></font></span></div></div><div><br></div><div>Does this sound like a reasonable approach?</div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div>Amneet <br><br></div><div><br></div><div>
<br></div>
</font></span></blockquote></div><br></div>