<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sun, Dec 9, 2018 at 5:47 PM Tsung-Hsing Chen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div>I want to output a VTK file containing Vec which associate with DMPLEX, but I keep getting some errors.</div></div></div></div></div></div></blockquote><div><br></div><div>The really easy way is to put</div><div><br></div><div> ierr = VecViewFromOptions(x, NULL, "-myvec_view");CHKERRQ(ierr);</div><div><br></div><div>in your code and then give</div><div><br></div><div> -myvec_view vtk:sol.vtk</div><div><br></div><div>on the command line.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>I use PetscViewerVTKOpen() to create the vtk file.</div><div>Then I saw many examples just use DMCreateGlobalVector() to create the Vec associate with DM.</div><div>However, almost all of them aren't DMPLEX but are DMDA.</div><div>I don't know whether it will cause some problems.</div><div>These is what I write:</div></div></div></div></div></div></blockquote><div><br></div><div>1) ALWAYS check return values. Your VecSetValue is failing.</div><div><br></div><div>2) VTK can only display two kinds of information, vertex-based and cell-based. DMDA only allows vertex based</div><div> information in Vecs. Since DMPLEX allows any kind of distribution, when we output VTK we need to determine</div><div> what kind of vector we have, vertex-based or cell-based. Here I cannot determine it, probably because your</div><div> PetscSection is not setup correctly. How is data supposed to be laid out on the Plex?</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div> PetscViewerCreate(PETSC_COMM_WORLD, &viewer);<br></div><div><div> PetscViewerVTKOpen(PETSC_COMM_WORLD, "vtk_output_test.vtk", FILE_MODE_WRITE, &viewer);</div><div> DMCreateGlobalVector(dm, &x);</div><div> VecSetValue(); //Set value for x</div><div> VecView(x, viewer);</div></div><div><br></div><div>Here is the error output:</div><div><div>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</div><div>[0]PETSC ERROR: Argument out of range</div><div>[0]PETSC ERROR: Out of range index value 1 maximum 0</div><div>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</div><div>[0]PETSC ERROR: Petsc Release Version 3.10.2, unknown </div><div>[0]PETSC ERROR: ./test3 on a arch-linux2-c-debug named barry-PhysioMech by barry Mon Dec 10 05:52:19 2018</div><div>[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --download-mumps --download-scalapack --download-ctetgen</div><div>[0]PETSC ERROR: #3 VecSetValues_Seq() line 726 in /home/barry/petsc/src/vec/vec/impls/seq/bvec2.c</div><div>[0]PETSC ERROR: #4 VecSetValues() line 856 in /home/barry/petsc/src/vec/vec/interface/rvector.c</div></div><div><br></div><div><div>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</div><div>[0]PETSC ERROR: Invalid argument</div><div>[0]PETSC ERROR: Could not classify input Vec for VTK</div><div>[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</div><div>[0]PETSC ERROR: Petsc Release Version 3.10.2, unknown </div><div>[0]PETSC ERROR: ./test3 on a arch-linux2-c-debug named barry-PhysioMech by barry Mon Dec 10 05:52:19 2018</div><div>[0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --download-mumps --download-scalapack --download-ctetgen</div><div>[0]PETSC ERROR: #17 DMPlexGetFieldType_Internal() line 134 in /home/barry/petsc/src/dm/impls/plex/plex.c</div><div>[0]PETSC ERROR: #18 VecView_Plex_Local_VTK() line 294 in /home/barry/petsc/src/dm/impls/plex/plex.c</div><div>[0]PETSC ERROR: #19 VecView_Plex_Local() line 335 in /home/barry/petsc/src/dm/impls/plex/plex.c</div><div>[0]PETSC ERROR: #20 VecView_Plex() line 382 in /home/barry/petsc/src/dm/impls/plex/plex.c</div><div>[0]PETSC ERROR: #21 VecView() line 590 in /home/barry/petsc/src/vec/vec/interface/vector.c</div></div><div><br></div><div>I think the first part of the error comes from VecSetValue(), but I don't know how to fix it.</div><div>And I totally don't know what its mean in the second part of the error.</div><div><br></div><div>Thank you,</div><div>Barry</div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>