On Thu, 10 Mar 2011, John Peterson wrote:
> On Thu, Mar 10, 2011 at 8:39 AM, Tim Kroeger
> <[email protected]> wrote:
>
>> PetscMatrix::print_personal() can only print to stdout, which makes it
>> difficult for me to cut out the correct part of the output, in
>> particular if I'm writing more than one matrix.
>
> I think we should try to fix/update the PetscMatrix implementation of
> print_personal. I don't think there's any limitation of MatView which
> prevents its contents from being written to file instead of stdout.
I don't know either. But as far as I understand, print_personal()
does different things for different solver packages, and I think it
would be a nice thing to have a method that supplies a uniform output
format for all packages, and takes the sparsity pattern into account.
>> I would like to implement a method, e.g. called
>> SparseMatrix::print_sparse(), which works the same way as
>> SparseMatrix::print() does, but does not print all the 0 entries. It
>> would e.g. rather print one entry per line in the format
>>
>> row column value
>>
>> Any objections or thoughts?
>
> I'd prefer not adding yet another print* function to SparseMatrix if
> possible. If it turns out that print_personal() can't be fixed up the
> way you want, I think it'd be easier to pass an additional flag (with
> default value) to print() to make it do what you want. You'd have to
> duplicate a lot of code from print() to implement print_sparse()
> anyway, wouldn't you?
That's a good point. What about this:
SparseMatrix::print(std::ostream& os, const bool sparse=false);
By the way, there is another issue with that method, I've just ran
into. I did:
std::ofstream sMatrix("matrix");
matrix->print(sMatrix);
But that opens libMesh::processor_id() instances of the same file at
once and writes the matrix to only one of them. Since these files
keep overwriting each other, the result is rubbish. This can of
course be avoided on user side by
if(libMesh::processor_id()==0)
{
std::ofstream sMatrix("matrix");
matrix->print(sMatrix);
}
else
{
matrix->print(std::cout);
}
but that's not really nice, is it?
How are you guys calling print() when you print to a file?
Tim
--
Dr. Tim Kroeger
CeVis -- Center of Complex Systems and Visualization
University of Bremen [email protected]
Universitaetsallee 29 [email protected]
D-28359 Bremen Phone +49-421-218-59246
Germany Fax +49-421-218-59277
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Libmesh-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-devel