[petsc-users] Outputting cell data in stead of point data while writing .vtr file

Smit Thijs thijs.smit at hest.ethz.ch
Thu Mar 11 08:02:52 CST 2021


Hi Matt,

Oke, would a code change be difficult? I mean, feasible for me to do as a mechanical engineer? ;)

Or can I use an other version of PETSc where the output to ASCII VTK is still available?

Best, Thijs

From: Matthew Knepley <knepley at gmail.com>
Sent: 11 March 2021 14:54
To: Smit Thijs <thijs.smit at hest.ethz.ch>
Cc: petsc-users at mcs.anl.gov
Subject: Re: [petsc-users] Outputting cell data in stead of point data while writing .vtr file

On Thu, Mar 11, 2021 at 8:17 AM Smit Thijs <thijs.smit at hest.ethz.ch<mailto:thijs.smit at hest.ethz.ch>> wrote:
Hi Matt,

Actually I have two 3D DMDA’s, one for the nodal data, where the FEM is solved on. The other DMDA is a cell centered one for the volume data, like the density of a particular voxel. Ideally I would like to write both point data (displacement field) and cell data (density) to the vtr.

Code for DMDA.

    DMBoundaryType bx = DM_BOUNDARY_NONE;
    DMBoundaryType by = DM_BOUNDARY_NONE;
    DMBoundaryType bz = DM_BOUNDARY_NONE;

    DMDAStencilType stype = DMDA_STENCIL_BOX;

PetscInt stencilwidth = 1;

    // Create the nodal mesh
    ierr = DMDACreate3d(PETSC_COMM_WORLD, bx, by, bz, stype, nx, ny, nz, PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE,
                        numnodaldof, stencilwidth, 0, 0, 0, &(da_nodes));
    CHKERRQ(ierr);

    DMSetFromOptions(da_nodes);
    DMSetUp(da_nodes);

    ierr = DMDASetUniformCoordinates(da_nodes, xmin, xmax, ymin, ymax, zmin, zmax);
    CHKERRQ(ierr);

    ierr = DMDASetElementType(da_nodes, DMDA_ELEMENT_Q1);
    CHKERRQ(ierr);

When I wrote the original version which output to ASCII VTK, we allowed switching between point data and cell data. It is
fragile since you have to assure that the different grids match properly. When the viewer was rewritten to use the XML,
all output was point data. It looks like it would take code changes to get this done.

  Thanks,

     Matt

Best, Thijs

From: Matthew Knepley <knepley at gmail.com<mailto:knepley at gmail.com>>
Sent: 11 March 2021 14:08
To: Smit Thijs <thijs.smit at hest.ethz.ch<mailto:thijs.smit at hest.ethz.ch>>
Cc: petsc-users at mcs.anl.gov<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] Outputting cell data in stead of point data while writing .vtr file

What kind of DM is it?

  Thanks,

     Matt

On Thu, Mar 11, 2021 at 3:36 AM Smit Thijs <thijs.smit at hest.ethz.ch<mailto:thijs.smit at hest.ethz.ch>> wrote:
Hi All,

I am outputting several vectors to a .vtr file successfully for viewing in Paraview. At this moment the information is written to point data. How can I change this and make sure the data is written to cell data?

The code I am currently using for outputting:

PetscViewer viewer;

ierr = PetscViewerVTKOpen(PETSC_COMM_WORLD, “test.vtr”, FILE_MODE_WRITE, &viewer);
CHKERRQ(ierr);

ierr = DMView(nd, viewer);
CHKERRQ(ierr);

PetscObjectSetName((PetscObject)xPhys,"xPhys");
ierr = VecView(xPhys, viewer);
CHKERRQ(ierr);

PetscObjectSetName((PetscObject)S,"SvonMises");
ierr = VecView(S, viewer);
CHKERRQ(ierr);

ierr = PetscViewerDestroy(&viewer);
CHKERRQ(ierr);

Best regards,

Thijs Smit

PhD Candidate
ETH Zurich
Institute for Biomechanics



--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>


--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210311/709448a7/attachment.html>


More information about the petsc-users mailing list