[petsc-users] TSMonitorSolutionVTK

Jed Brown jed at jedbrown.org
Thu Feb 13 17:28:35 CST 2020


Good to hear it works now.  And here's the relevant merge request (from April 2019).

https://gitlab.com/petsc/petsc/-/merge_requests/1602

Sepideh Kavousi <skavou1 at lsu.edu> writes:

> Dear Dr. Brown,
> In the VTS files the field components did not exist. I checked 3.11 and 3.12, and it seems 3.11 still has the problem but for the 3.12 the problem is solved.
> Thanks,
> Sepideh
> ________________________________
> From: Jed Brown <jed at jedbrown.org>
> Sent: Thursday, February 13, 2020 4:06 PM
> To: Sepideh Kavousi <skavou1 at lsu.edu>; petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
> Subject: Re: [petsc-users] TSMonitorSolutionVTK
>
> Sepideh Kavousi <skavou1 at lsu.edu> writes:
>
>> Dear Petsc users,
>> I am trying to write VTK output file every few steps. When I was using the petsc 3.7 I used the following lines:
>> if (user->ts_write % 500 ==0) {
>> ierr= PetscSNPrintf(user->filename,sizeof(user->filename),"one-%03d.vts",user->ts_write);CHKERRQ(ierr);
>> ierr= TSMonitorSolutionVTK(user->ts,user->ts_write,t,user->sol_old,&user->filename);CHKERRQ(ierr);}
>> user->ts_write+=1;
>> }
>> and it worked fine, but when I use the same line in Petsc  3.9 and 3.10, using these lines it still outputs the files but when I open them with Visit and try to visualize the individual field component, it does not show them.
>
> Do they not exist or are just unnamed?  I believe we had a couple
> regressions with this output style circa 3.10 (side-effect of better
> handling vector fields), but I believe it was fixed by 3.11 or certainly
> 3.12.  Would it be possible for you to upgrade?
>
>
> Note that you can (and should) pass the format specifier directly, as in:
>
>   TSMonitorSolutionVTK(user->ts,user->ts_write,t,user->sol_old,"one-%03D.vts");
>
> Visit won't care about the numbers not being contiguous.  If you want to
> name them manually, just handle the viewer yourself; body of TSMonitorSolutionVTK:
>
>   ierr = PetscSNPrintf(filename,sizeof(filename),(const char*)filenametemplate,step);CHKERRQ(ierr);
>   ierr = PetscViewerVTKOpen(PetscObjectComm((PetscObject)ts),filename,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr);
>   ierr = VecView(u,viewer);CHKERRQ(ierr);
>   ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr);


More information about the petsc-users mailing list