[petsc-users] Writing VTK output
Sami BEN ELHAJ SALAH
sami.ben-elhaj-salah at ensma.fr
Wed Jun 8 03:57:18 CDT 2022
Dear Petsc Developer team,
I solved a linear elastic problem in 3D using a DMPLEX. My system is converging, then I would like to write out my solution vector to a vtk file where I use unstructured mesh. Currently, I tried two algorithms and I have the same result.
1) Algorithm 1
err = SNESSolve(_snes, bc_vec_test, solution);
CHKERRABORT(FOX::Parallel::COMM_WORLD,err);
PetscViewer vtk;
PetscViewerVTKOpen(FOX::Parallel::COMM_WORLD,"solution.vtk",FILE_MODE_WRITE,&vtk);
VecView(solution,vtk);
PetscViewerDestroy(&vtk);
2) Algorithm 2
err = SNESSolve(_snes, bc_vec_test, solution);
CHKERRABORT(FOX::Parallel::COMM_WORLD,err);
PetscViewer vtk;
PetscViewerCreate(FOX::Parallel::COMM_WORLD, &vtk);
PetscViewerSetType(vtk, PETSCVIEWERVTK);
PetscViewerFileSetName(vtk, "sol.vtk");
VecView(solution, vtk);
PetscViewerDestroy(&vtk);
The result seems correct except for the rotation order of the nodes (see the red lines on gmsh and vtk file respectively). Then, I visualized my vtk file with paraview, and I remarked that my geometry is not correct and not conserved when comparing it with my gmsh file. So, I didn’t understand why the rotation order of nodes is not conserved when saving my result to a vtk file?
Other information used:
- gmsh format 2.2
- Vtk version: 7.1.1
- Petsc version: 3.13/opt
Below my two files gmsh and vtk:
Gmsh file:
$MeshFormat
2.2 0 8
$EndMeshFormat
$Nodes
12
1 0.0 10.0 10.0
2 0.0 0.0 10.0
3 0.0 0.0 0.0
4 0.0 10.0 0.0
5 10.0 10.0 10.0
6 10.0 0.0 10.0
7 10.0 0.0 0.0
8 10.0 10.0 0.0
9 20.0 10.0 10.0
10 20.0 0.0 10.0
11 20.0 0.0 0.0
12 20.0 10.0 0.0
$EndNodes
$Elements
2
1 5 2 68 60 1 2 3 4 5 6 7 8
2 5 2 68 60 5 6 7 8 9 10 11 12
$EndElements
Vtk file :
# vtk DataFile Version 2.0
Simplicial Mesh Example
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 12 double
0.000000e+00 1.000000e+01 1.000000e+01
0.000000e+00 0.000000e+00 1.000000e+01
0.000000e+00 0.000000e+00 0.000000e+00
0.000000e+00 1.000000e+01 0.000000e+00
1.000000e+01 1.000000e+01 1.000000e+01
1.000000e+01 0.000000e+00 1.000000e+01
1.000000e+01 0.000000e+00 0.000000e+00
1.000000e+01 1.000000e+01 0.000000e+00
2.000000e+01 1.000000e+01 1.000000e+01
2.000000e+01 0.000000e+00 1.000000e+01
2.000000e+01 0.000000e+00 0.000000e+00
2.000000e+01 1.000000e+01 0.000000e+00
CELLS 2 18
8 0 3 2 1 4 5 6 7
8 4 7 6 5 8 9 10 11
CELL_TYPES 2
12
12
POINT_DATA 12
VECTORS dU_x double
2.754808e-10 -8.653846e-11 -8.653846e-11
2.754808e-10 8.653846e-11 -8.653846e-11
2.754808e-10 8.653846e-11 8.653846e-11
2.754808e-10 -8.653846e-11 8.653846e-11
4.678571e-01 -9.107143e-02 -9.107143e-02
4.678571e-01 9.107143e-02 -9.107143e-02
4.678571e-01 9.107143e-02 9.107143e-02
4.678571e-01 -9.107143e-02 9.107143e-02
1.000000e+00 -7.500000e-02 -7.500000e-02
1.000000e+00 7.500000e-02 -7.500000e-02
1.000000e+00 7.500000e-02 7.500000e-02
1.000000e+00 -7.500000e-02 7.500000e-02
Thank you in advance and have a good day !
Sami,
--
Dr. Sami BEN ELHAJ SALAH
Ingénieur de Recherche (CNRS)
Institut Pprime - ISAE - ENSMA
Mobile: 06.62.51.26.74
Email: sami.ben-elhaj-salah at ensma.fr
www.samibenelhajsalah.com <https://samiben91.github.io/samibenelhajsalah/index.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220608/3cab6d95/attachment-0001.html>
More information about the petsc-users
mailing list