问题
Reading netcdf files with Paraview using xdmf
I used to parse netcdf files with an xdmf script in order to create 3DSMesh
on paraview. On top of it, I was adding scalar or vector fields. (So 3DSMesh provides physical coordinates).
I never though if it is best way to do that actually. It works, so I was OK. Please let me know if there is more convenient way.
I am able to create a 3-dimensional grid with the following script.
<?xml version="1.0" ?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
<Xdmf xmlns:xi="http://www.w3.org/2001/XInclude" Version="2.0">
<Domain>
<Grid Name="gridxyz">
<Topology TopologyType="3DSMesh" NumberOfElements="0032 0032 0063">
</Topology>
<!-- Read Coordinates -->
<Geometry GeometryType="X_Y_Z">
<DataItem Name="X" Format="HDF" NumberType="Float" Precision="8" Dimensions="0032 0032 0063">
grid_x.nc:/gridx
</DataItem>
<DataItem Name="Y" Format="HDF" NumberType="Float" Precision="8" Dimensions="0032 0032 0063">
grid_y.nc:/gridy
</DataItem>
<DataItem Name="Z" Format="HDF" NumberType="Float" Precision="8" Dimensions="0032 0032 0063">
grid_z.nc:/gridz
</DataItem>
</Geometry>
<!-- Read Scalar -->
<!-- Here I have bunch of scalars stored in different netcdf files -->
</Grid>
</Domain>
</Xdmf>
Pros
- xdmf scripts are great when someone needs repetitive tasks.
Cons
this script(s) needs to be generated somehow, or typed by hand. And required to be updated, when the dimensions or variable names are changed
if I want to read another scalar, I need to add a line
- grid can be uniform in 2 directions and not uniform on the third one, no need to create 3D grid files, but geometry type
dx_dy_dz
is not enough to achieve that.
What I am looking for
Recently I realize, I can open netcdf files with paraview just by clicking open(Paraview4.3). So, I do not need these xdmf scripts anymore (few years ago I was not able to open netcdf files on Paraview).
How can I create
3DSMesh
via Paraview GUI. Is that possible? Or is there any other simple/faster way (instead of writing a python script) ? Is there any way read 1D coordinates and create 3D geometry using them ?
回答1:
That's how I manage to do that. Certainly it's not the fastest way, but it works for me.
When you open a NetCDF file, paraview asks you to choose a reader, I always use NetCDF files generic and CF conventions .
After that, before hitting "Apply" button you have to select the appropriate "Dimensions" in the dropdown menu.
Your data now must be displayed as a UniformGrid, with your data(X,Y,Z) as scalars fields so you must transform to a grid to be more specific a StructuredGrid. In order to do that, apply the "ImageDataToPointSet" filter.
After that, apply a "Calculator" filter check "Coordinate Results" field and do the following:
If your data appears as X, Y , Z colummns put in the calculator field the expression
(X * iHat) + (Y * jHat) + (Z * kHat)
if your data appears with other names, substitute x, y, z with those names
The expression means that x is in the direction of the î vector, y is in the direction of the j vector and so on
Hope it helped!
来源:https://stackoverflow.com/questions/30616741/visualization-of-3-dimensional-grid-from-x-y-zseperate-datasets-on-paraview-wi