<div dir="ltr">Hi,<br>Thank you for your response, I think the socket communication between Matlab and PETSc is what I need, I took a look to the example ex12.c and ex12.m (Simple example to show how to PETSc programs can be run from Matlab) but in this case PETSc send the Vector solution that matlab "receive", is it possible to make the inverse? Send the variable from matlab to PETSc using socket communication? can PetscMatlabEngineGet do that ? How it works?<br>
<br>Aron, I was studying your recommendation but it means that I have to write all the function from my Matlab Code to C?, because it should take me a lot of time and this work is part of my MSc Thesis and maybe I need a less time consuming solution.<br>
<br>Thank you in advance,<br><br>Michel <br><br><div class="gmail_quote">On Tue, Jul 22, 2008 at 8:56 PM, Aron Ahmadia <span dir="ltr"><<a href="mailto:aja2111@columbia.edu">aja2111@columbia.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr">Michel,<br><br>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.<br>
<font color="#888888">
<br>~Aron</font><div><div></div><div class="Wj3C7c"><br><br><div class="gmail_quote">On Tue, Jul 22, 2008 at 12:12 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div>On Mon, Jul 21, 2008 at 10:14 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> On Jul 21, 2008, at 7:57 PM, Michel Cancelliere wrote:<br>
><br>
>> Hi, I am a new user of PETSc. I am working in Reservoir Simulation and I<br>
>> have been developing the simulator inside Matlab. I have some question in<br>
>> order to understand better my possibilities of success in what I want to do:<br>
>><br>
>> • I want to solve the linear system obtained from the inner<br>
>> iterations in the newton method using PETSc, is it possible to communicate<br>
>> in an efficient way PETSc with Matlab to do that? I now that I can write<br>
>> binary files and then read with PETSc but due the size of the matrix it is a<br>
>> very time-expensive way. Where i can find some examples? I look at the<br>
>> examples within the package but I could not find it. \<br>
>> • It is possible to call PETSc library inside Matlab? Using the Mex<br>
>> files and Matlab compiler?<br>
><br>
> There is no code to do this. It is possible but pretty complicated to<br>
> write the appropriate Mex code. (Because<br>
> each Mex function is a separate shared library you cannot just write a Mex<br>
> function for each PETSc function since they<br>
> would not share the PETSc global variables. You would have to write one Mex<br>
> function that is a "gatekeeper" and calls<br>
> the requested PETSc function underneath. I've monkeyed with this a few times<br>
> but did not have the time/energy/intellect<br>
> to write code to automate this process. Give me 300,000 dollars and we could<br>
> hire someone to write this :-)<br>
><br>
> You might look at the "newly improved" socket interface in petsc-dev<br>
> (<a href="http://www-unix.mcs.anl.gov/petsc/petsc-as/developers/index.html" target="_blank">http://www-unix.mcs.anl.gov/petsc/petsc-as/developers/index.html</a>).<br>
> With this you write a stand alone C PETSc program that waits at a socket,<br>
> receive the matrix and right hand side and then<br>
> sends back the solution. The code for marshalling the matrices and vector is<br>
> common between the sockets and binary files.<br>
> On the Matlab side you create a "file" that is actually a socket connection.<br>
> See src/sys/viewer/impls/socket/matlab This may<br>
> take a little poking around and you asking us a couple of questions to get<br>
> it.<br>
> Note there is no inherent support for parallelism on the PETSc side with<br>
> this setup but I think it is possible.<br>
<br>
</div></div>I personally think this would be much easier in Sage than in Matlab<br>
proper. In fact,<br>
with Sage you could use petsc4py directly, and directly access the<br>
data structures<br>
as numpy arrays if necessary.<br>
<br>
Matt<br>
<div><div></div><div><br>
> Barry<br>
><br>
><br>
>> Thank you very much for your time,<br>
>><br>
>> Michel Cancelliere<br>
><br>
><br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
What most experimenters take for granted before they begin their<br>
experiments is infinitely more interesting than any results to which<br>
their experiments lead.<br>
-- Norbert Wiener<br>
<br>
</font></blockquote></div><br></div></div></div>
</blockquote></div><br></div>