[petsc-users] object name overwritten in VecView
Danyang Su
danyang.su at gmail.com
Tue Feb 27 22:44:52 CST 2018
Hi All,
How to set different object names when using multiple VecView? I try to
use PetscObjectSetName with multiple output, but the object name is
overwritten by the last one.
As shown below, as well as the enclosed files as example, the vector
name in sol.vtk is vec_v for both vector u and v.
call PetscViewerCreate(PETSC_COMM_WORLD, viewer, ierr);CHKERRA(ierr)
call PetscViewerSetType(viewer, PETSCVIEWERVTK, ierr);CHKERRA(ierr)
call PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_VTK,
ierr);CHKERRA(ierr)
call PetscViewerFileSetName(viewer, 'sol.vtk', ierr);CHKERRA(ierr)
call PetscObjectSetName(u, 'vec_u', ierr);CHKERRA(ierr)
call VecView(u, viewer, ierr);CHKERRA(ierr)
call PetscObjectSetName(v, 'vec_v', ierr);CHKERRA(ierr)
call VecView(v, viewer, ierr);CHKERRA(ierr)
call PetscViewerDestroy(viewer, ierr);CHKERRA(ierr)
call DMRestoreGlobalVector(dm, u, ierr);CHKERRA(ierr)
call DMRestoreGlobalVector(dm, v, ierr);CHKERRA(ierr)
Thanks,
Danyang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex1f90.F90
Type: text/x-fortran
Size: 4654 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180227/fa938e1c/attachment-0001.bin>
-------------- next part --------------
CFLAGS =
FFLAGS =
CPPFLAGS =
FPPFLAGS =
LOCDIR = src/dm/impls/plex/examples/tutorials/
EXAMPLESC = ex1.c ex2.c ex5.c
EXAMPLESF = ex1f90.F90
MANSEC = DM
include ${PETSC_DIR}/lib/petsc/conf/variables
include ${PETSC_DIR}/lib/petsc/conf/rules
ex1: ex1.o chkopts
-${CLINKER} -o ex1 ex1.o ${PETSC_DM_LIB}
${RM} -f ex1.o
ex1f90: ex1f90.o chkopts
-${FLINKER} -o ex1f90 ex1f90.o ${PETSC_DM_LIB}
${RM} -f ex1f90.o
ex2: ex2.o chkopts
-${CLINKER} -o ex2 ex2.o ${PETSC_DM_LIB}
${RM} -f ex2.o
ex5: ex5.o chkopts
-${CLINKER} -o ex5 ex5.o ${PETSC_DM_LIB}
${RM} -f ex5.o
ex6: ex6.o chkopts
-${CLINKER} -o ex6 ex6.o ${PETSC_DM_LIB}
${RM} -f ex6.o
ex7: ex7.o chkopts
-${CLINKER} -o ex7 ex7.o ${PETSC_DM_LIB}
${RM} -f ex7.o
#--------------------------------------------------------------------------
runex1:
-@${MPIEXEC} -n 2 ./ex1 -dim 3
runex1f90:
-@${MPIEXEC} -n 2 ./ex1 -dim 2
runex2:
-@${MPIEXEC} -n 1 ./ex2 -dim 3 -dm_refine 2 -dm_view hdf5:ex2.h5
-${PETSC_DIR}/bin/petsc_gen_xdmf.py ex2.h5
runex5:
-@${MPIEXEC} -n 2 ./ex5 -filename ${PETSC_DIR}/share/petsc/datafiles/meshes/square.msh -new_dm_view
include ${PETSC_DIR}/lib/petsc/conf/test
-------------- next part --------------
# vtk DataFile Version 2.0
Simplicial Mesh Example
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 8 double
0.000000e+00 0.000000e+00 0.000000e+00
1.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 1.000000e+00 0.000000e+00
1.000000e+00 1.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 1.000000e+00
1.000000e+00 0.000000e+00 1.000000e+00
0.000000e+00 1.000000e+00 1.000000e+00
1.000000e+00 1.000000e+00 1.000000e+00
CELLS 6 30
4 0 7 3 2
4 0 5 7 4
4 0 1 3 7
4 5 1 0 7
4 0 6 7 2
4 7 6 0 4
CELL_TYPES 6
10
10
10
10
10
10
POINT_DATA 8
VECTORS vec_v double
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
VECTORS vec_v double
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 0.000000e+00 0.000000e+00
More information about the petsc-users
mailing list