Michel, I would recommend investing the time to write your C/C++ wrapper code a little higher up around the Newton iteration, since PETSc provides a great abstraction interface for it. Then you could write code to build the matrix (or assemble a matrix-free routine!) in C/C++, and pass the parameters in from there.
~Aron On Tue, Jul 22, 2008 at 12:12 AM, Matthew Knepley <knepley at gmail.com> wrote: > On Mon, Jul 21, 2008 at 10:14 PM, Barry Smith <bsmith at mcs.anl.gov> wrote: > > > > On Jul 21, 2008, at 7:57 PM, Michel Cancelliere wrote: > > > >> Hi, I am a new user of PETSc. I am working in Reservoir Simulation and I > >> have been developing the simulator inside Matlab. I have some question > in > >> order to understand better my possibilities of success in what I want to > do: > >> > >> ? I want to solve the linear system obtained from the inner > >> iterations in the newton method using PETSc, is it possible to > communicate > >> in an efficient way PETSc with Matlab to do that? I now that I can > write > >> binary files and then read with PETSc but due the size of the matrix it > is a > >> very time-expensive way. Where i can find some examples? I look at the > >> examples within the package but I could not find it. \ > >> ? It is possible to call PETSc library inside Matlab? Using the > Mex > >> files and Matlab compiler? > > > > There is no code to do this. It is possible but pretty complicated to > > write the appropriate Mex code. (Because > > each Mex function is a separate shared library you cannot just write a > Mex > > function for each PETSc function since they > > would not share the PETSc global variables. You would have to write one > Mex > > function that is a "gatekeeper" and calls > > the requested PETSc function underneath. I've monkeyed with this a few > times > > but did not have the time/energy/intellect > > to write code to automate this process. Give me 300,000 dollars and we > could > > hire someone to write this :-) > > > > You might look at the "newly improved" socket interface in petsc-dev > > (http://www-unix.mcs.anl.gov/petsc/petsc-as/developers/index.html). > > With this you write a stand alone C PETSc program that waits at a socket, > > receive the matrix and right hand side and then > > sends back the solution. The code for marshalling the matrices and vector > is > > common between the sockets and binary files. > > On the Matlab side you create a "file" that is actually a socket > connection. > > See src/sys/viewer/impls/socket/matlab This may > > take a little poking around and you asking us a couple of questions to > get > > it. > > Note there is no inherent support for parallelism on the PETSc side with > > this setup but I think it is possible. > > I personally think this would be much easier in Sage than in Matlab > proper. In fact, > with Sage you could use petsc4py directly, and directly access the > data structures > as numpy arrays if necessary. > > Matt > > > Barry > > > > > >> Thank you very much for your time, > >> > >> Michel Cancelliere > > > > > > > > -- > What most experimenters take for granted before they begin their > experiments is infinitely more interesting than any results to which > their experiments lead. > -- Norbert Wiener > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20080722/3404c113/attachment.htm>
