[petsc-users] Complex vector / matrix to VTK

Barry Smith bsmith at mcs.anl.gov
Wed Mar 18 15:25:37 CDT 2015


> On Mar 16, 2015, at 12:22 PM, Juris Vencels <juris.vencels at gmail.com> wrote:
> 
> Hello,
> 
> I want to print vector / matrix to VTK file.
> 
> I am running simple tutorial example ex15.c, but since I have compiled PETSc with complex scalars (I need them for my program) I get an error below. Can I force PETSc to print only real, imaginary (or both) part(s) of the solution?
> 
> Another question - ksp/ex42.c explicitly writes header information to VTK file while snes/ex15.c has only one line - to open VTK file. How these two examples are different in terms of writing output to VTK?
> src/ksp/ksp/examples/tutorials/ex42.c
> src/snes/examples/tutorials/ex15.c

  Ex42 shows how you can provide all the information yourself for VTK while ex15 uses the PETSc library code to provide it automatically (of course if you do it all yourself you have complete control over what is saved but it is more work on your part). 

  I recommend trying to use the library version. We don't currently have code in the library to save just the real part, imaginary parts. If VTK has a concept of complex numbers you should read up on it and see how it works. 

  Depending on the vectors/DMs you are using (Plex, DMDA? something else?) you will need to go through where the code actually writes out the numerical values and adjust to handle what portions of the complex numbers you wish to save. In the case you ran below it looks like the routine
DMDAVTKWriteAll_VTS() in the file src/dm/impls/da/grvtk.c


  Barry

> 
> Thanks!
> Juris
> 
>> vencels at bigone:/scratch/petsc-git/src/snes/examples/tutorials$ ./ex15 -snes_monitor_short -da_grid_x 20 -da_grid_y 20 -p 1.3 -lambda 1 -jtype NEWTON -o ex15.vts
>>   0 SNES Function norm 0.690597 
>>   1 SNES Function norm 0.437399 
>>   2 SNES Function norm 0.309415 
>>   3 SNES Function norm 0.132358 
>>   4 SNES Function norm 0.0919276 
>>   5 SNES Function norm 0.0752639 
>>   6 SNES Function norm 0.0669195 
>>   7 SNES Function norm 0.0592599 
>>   8 SNES Function norm 0.0516658 
>>   9 SNES Function norm 0.0441565 
>>  10 SNES Function norm 0.0367695 
>>  11 SNES Function norm 0.0288595 
>>  12 SNES Function norm 0.0277417 
>>  13 SNES Function norm 0.0085536 
>>  14 SNES Function norm 0.00140906 
>>  15 SNES Function norm 7.35341e-05 
>>  16 SNES Function norm 3.63992e-07 
>>  17 SNES Function norm 1.034e-11 
>> CONVERGED_FNORM_RELATIVE Number of nonlinear iterations = 17
>> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
>> [0]PETSC ERROR: No support for this operation for this object type
>> [0]PETSC ERROR: Complex values not supported
>> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.
>> [0]PETSC ERROR: Petsc Development GIT revision: v3.5.3-2213-g589572e  GIT Date: 2015-03-07 10:56:38 -0600
>> [0]PETSC ERROR: ./ex15 on a intelmkl-debug named bigone by vencels Mon Mar 16 10:45:52 2015
>> [0]PETSC ERROR: Configure options --with-cc=icc --with-cxx=icpc --with-fc=ifort --with-blas-lapack-dir=/opt/intel/mkl/ --with-fortran-kernels=generic --with-scalar-type=complex --with-mpi=0 --download-superlu
>> [0]PETSC ERROR: #1 DMDAVTKWriteAll_VTS() line 30 in /scratch/petsc-git/src/dm/impls/da/grvtk.c
>> [0]PETSC ERROR: #2 DMDAVTKWriteAll() line 482 in /scratch/petsc-git/src/dm/impls/da/grvtk.c
>> [0]PETSC ERROR: #3 PetscViewerFlush_VTK() line 78 in /scratch/petsc-git/src/sys/classes/viewer/impls/vtk/vtkv.c
>> [0]PETSC ERROR: #4 PetscViewerFlush() line 30 in /scratch/petsc-git/src/sys/classes/viewer/interface/flush.c
>> [0]PETSC ERROR: #5 PetscViewerDestroy() line 101 in /scratch/petsc-git/src/sys/classes/viewer/interface/view.c
>> [0]PETSC ERROR: #6 main() line 257 in /scratch/petsc-git/src/snes/examples/tutorials/ex15.c
>> [0]PETSC ERROR: PETSc Option Table entries:
>> [0]PETSC ERROR: -da_grid_x 20
>> [0]PETSC ERROR: -da_grid_y 20
>> [0]PETSC ERROR: -jtype NEWTON
>> [0]PETSC ERROR: -lambda 1
>> [0]PETSC ERROR: -o ex15.vts
>> [0]PETSC ERROR: -p 1.3
>> [0]PETSC ERROR: -snes_monitor_short
>> [0]PETSC ERROR: ----------------End of Error Message -------send entire error message to petsc-maint at mcs.anl.gov----------
>> Aborted (core dumped)
> 
> 



More information about the petsc-users mailing list