1
votes

Here is my problem : I have a 2D domain (say a square) divided in triangles in a unstructured manner. On each triangle (denoted T), I define a constant scalar, denoted f(T).

I want to plot the surface (T,f(T)) using Paraview.

So I have created a vtk file like this:

vtk DataFile Version 3.1

my personnal comment here

ASCII DATASET UNSTRUCTURED_GRID

POINTS 4 FLOAT

0 0 0

0 1 0

1 0 0

1 1 0

CELLS 2 8

3 0 1 2

3 1 2 3

CELL_TYPES 2

5 5

CELL_DATA 2

SCALARS Namedata double

LOOKUP_TABLE default

2

-5

I would like to see (thanks to Paraview) a 3D plot. Ideally, the visualization on this example should be two triangles: the first one should have its z-coordinates equal to 2 and the second one should have its z-coordinates equal to -5. I don't know if something is possible or if the vtk format is the good one for what I'm trying to do.

If it is not possible, I would be happy to represent only the two points (x-coordinate of the triangle number 1, y-coordinate of the triangle number 1, z-coordinate = 2) and (x-coordinate of the triangle number 2, y-coordinate of the triangle number 2, z-coordinate = -5) with or without interpolation.

1
The syntax of your data file is not quite right. There might be some copy paste errors going on here. (1) The first line should begin with a # character. (2) The file should not have double spacing. You have an extra newline after every line. (3) There should be a newline in between ASCII and DATASET. - Kenneth Moreland
@KennethMoreland Thank you for this comment, I had to put the data in an incorrect syntax here in order to be readable. - user37238

1 Answers

2
votes

This is not hard to do in ParaView. There is filter named "Warp By Scalar" which can translate geometry in the z direction (or any other direction) based on a scalar field. The only issue is that Warp By Scalar works on point data, and you want to warp by cell data. So you have to go through a few steps first.

  1. Add the "Shrink" filter to your data. Set the "Scale Factor" parameter to 1. Apply. Your data will look the same, but it will have the effect of breaking apart the triangles, which are actually sharing points in your original data.

  2. Add the "Cell Data to Point Data" filter to the output of the Shrink filter. Apply.

  3. Add the "Warp By Scalar" filter to the output of Cell Data to Point Data. Apply.