<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Il giorno gio 10 apr 2025 alle ore 11:25 Peder Jørgensgaard Olesen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-2908047130999226995">
<div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
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).</div></div></div></blockquote><div><br></div><div>You can use VecGetArrayRead to get the vector data and pass the array to MatCreateDense. Isn't that efficient enough?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-2908047130999226995"><div dir="ltr"><div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">However, none of the viewer formats seems to support the desired output formatting
for Vec.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
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?</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Also, somewhat relatedly, is there a more detailed specification of available viewer formats? The documentation for PetscViewerFormat (<a href="https://urldefense.us/v3/__https://petsc.org/release/manualpages/Viewer/PetscViewerFormat/*petscviewerformat__;Iw!!G_uCfscf7eWS!fmgo_gSUThwXeUVpPBhwFVgTXRhk3tS8gDcRbkXu6TQu9lj3Emm5wwGKPUktzKcWMN-isoQKklivtNv-eU4$" id="m_-1300807470454454986LPlnk575241" target="_blank">https://petsc.org/release/manualpages/Viewer/PetscViewerFormat/#petscviewerformat</a>)
briefly describes a number of them, and notes that "A variety of specialized formats also exist", although this isn't elaborated.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks!</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Best,</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Peder</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="m_-1300807470454454986Signature" style="color:inherit">
<table style="width:400px;box-sizing:border-box;border-collapse:collapse;border-spacing:0px">
<tbody>
<tr>
<td style="width:400px;height:207.997px">
<table style="width:400px;color:black;box-sizing:border-box;border-collapse:collapse;border-spacing:0px">
<tbody>
<tr>
<td style="width:50px;height:206.009px;vertical-align:top">
<table style="width:50px;box-sizing:border-box;border-collapse:collapse;border-spacing:0px">
<tbody>
<tr>
<td align="left" style="width:50px;height:58.6222px;vertical-align:top"><span style="font-family:Arial;font-size:11.5px;color:black"><img width="36" height="53" style="width: 36px; height: 53px;" src="http://www.dtu.dk/-/media/DTU_Generelt/Andet/mail-signature-logo.png"></span></td>
</tr>
</tbody>
</table>
</td>
<td style="width:350px;height:206.009px;vertical-align:top">
<table style="width:350px;color:black;box-sizing:border-box;border-collapse:collapse;border-spacing:0px">
<tbody>
<tr>
<td style="width:350px;height:21.1932px;line-height:19.2px">
<div style="line-height:19.2px;font-family:Arial;font-size:16px;color:black">
<b>Peder Jørgensgaard Olesen</b></div>
</td>
</tr>
<tr>
<td style="width:350px;height:52.9971px;line-height:17px">
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
Postdoc</div>
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
DTU Construct</div>
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
Institut for Byggeri og Mekanisk Teknologi</div>
</td>
</tr>
<tr>
<td style="width:350px;height:18.9915px;line-height:17px">
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
</div>
</td>
</tr>
<tr>
<td style="width:350px;height:18.9915px;line-height:17px">
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
<span style="line-height:17px"><a href="mailto:pjool@dtu.dk" style="color:black;text-decoration:none;margin:0px" target="_blank">pjool@dtu.dk</a></span></div>
</td>
</tr>
<tr>
<td style="width:350px;height:18.9915px;line-height:17px">
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
Koppels Allé</div>
</td>
</tr>
<tr>
<td style="width:350px;height:18.9915px;line-height:17px">
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
Building 403</div>
</td>
</tr>
<tr>
<td style="width:350px;height:18.9914px;line-height:17px">
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
2800 Kgs. Lyngby</div>
</td>
</tr>
<tr>
<td style="width:350px;height:18.9916px;line-height:17px">
<div style="line-height:17px;font-family:Arial;font-size:11.5px;color:black">
<span style="line-height:17px"><a href="https://urldefense.us/v3/__https://www.dtu.dk/english__;!!G_uCfscf7eWS!fmgo_gSUThwXeUVpPBhwFVgTXRhk3tS8gDcRbkXu6TQu9lj3Emm5wwGKPUktzKcWMN-isoQKklivEFUBK2I$" style="color:black;text-decoration:none;margin:0px" target="_blank">www.dtu.dk/english</a></span></div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
</div>
</div>
</div></blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Stefano</div></div>