[petsc-users] ASCII viewer formats
Stefano Zampini
stefano.zampini at gmail.com
Thu Apr 10 04:55:01 CDT 2025
Il giorno gio 10 apr 2025 alle ore 11:25 Peder Jørgensgaard Olesen via
petsc-users <petsc-users at mcs.anl.gov> ha scritto:
> I would like to output the contents of a Vec to an ASCII file in which the
> entries are all on one line, as "x[0] x[1] x[2] ... x[N-1]". This can
> be done in a slightly roundabout way by putting the values in a 1xN dense
> Mat, assembling the matrix, and then use MatView with a suitable format,
> but one would think that skipping the matrix step and use a VecView
> directly would be more efficient (the procedure is to be repeated many
> times).
>
You can use VecGetArrayRead to get the vector data and pass the array to
MatCreateDense. Isn't that efficient enough?
> However, none of the viewer formats seems to support the desired output
> formatting for Vec.
>
> Is there any way to customize viewer formats for a specific layout - or is
> there perhaps a more clever way to do the thing I want?
>
> Also, somewhat relatedly, is there a more detailed specification of
> available viewer formats? The documentation for PetscViewerFormat (
> https://urldefense.us/v3/__https://petsc.org/release/manualpages/Viewer/PetscViewerFormat/*petscviewerformat__;Iw!!G_uCfscf7eWS!Y4XIeKrWEWWPvSSQleoTzKpv3jZILJZ_l47FbAbLvUNnNPA9sunnxxl-LgVNf7U6keAzX4lFkwy9TgeSafvVT5dCJmAUTEU$
> <https://urldefense.us/v3/__https://petsc.org/release/manualpages/Viewer/PetscViewerFormat/*petscviewerformat__;Iw!!G_uCfscf7eWS!fmgo_gSUThwXeUVpPBhwFVgTXRhk3tS8gDcRbkXu6TQu9lj3Emm5wwGKPUktzKcWMN-isoQKklivtNv-eU4$>)
> briefly describes a number of them, and notes that "A variety of
> specialized formats also exist", although this isn't elaborated.
>
> Thanks!
>
> Best,
> Peder
>
> *Peder Jørgensgaard Olesen*
> Postdoc
> DTU Construct
> Institut for Byggeri og Mekanisk Teknologi
>
> pjool at dtu.dk
> Koppels Allé
> Building 403
> 2800 Kgs. Lyngby
> https://urldefense.us/v3/__http://www.dtu.dk/english__;!!G_uCfscf7eWS!Y4XIeKrWEWWPvSSQleoTzKpv3jZILJZ_l47FbAbLvUNnNPA9sunnxxl-LgVNf7U6keAzX4lFkwy9TgeSafvVT5dCsW-2QDE$
> <https://urldefense.us/v3/__https://www.dtu.dk/english__;!!G_uCfscf7eWS!fmgo_gSUThwXeUVpPBhwFVgTXRhk3tS8gDcRbkXu6TQu9lj3Emm5wwGKPUktzKcWMN-isoQKklivEFUBK2I$>
>
>
--
Stefano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250410/effc0725/attachment.html>
More information about the petsc-users
mailing list