# Unstructured moving mesh not displaying properly in ParaView

**URL:** https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009
**Category:** ParaView Support
**Tags:** vtk
**Created:** [February 24, 2024, 6:39pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009 "2024-02-24T18:39:57Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Ivan\_B\_G](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ivan_b_g/32/13731_2.png) [@Ivan\_B\_G](https://discourse.paraview.org/u/Ivan_B_G)
#### Post date: [February 24, 2024, 6:39pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/1 "2024-02-24T18:39:57Z")

</div>

Hi all,

I am trying to visualise in ParaView an (initially structured) unstructured mesh that I have made from my own code, however, when I slice through the middle it displays the edges wrong. It seems to keep the old connectivity? However I know for a fact that those edges are not actually there. This only happens when I try to visualise the mesh in 3D. I have produced similar examples in 2D and it is fine. I am not sure why this is happening or how I can fix it.

It is a moving mesh and I am trying to visualise it at different stages. I have attached below what the mesh looks like (when slicing through the middle of the domain).

![FinalMesh](https://discourse.paraview.org/uploads/default/original/2X/b/b08f952e7af3f01fa8af9b012b7398310017bdd6.png)

Thanks in advance.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 26, 2024, 12:57pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/2 "2024-02-26T12:57:33Z")

</div>

please share your data, both structured and unstructured if possible.

---

<div class="post-metadata">

### Author: ![Ivan\_B\_G](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ivan_b_g/32/13731_2.png) [@Ivan\_B\_G](https://discourse.paraview.org/u/Ivan_B_G)
#### Post date: [February 26, 2024, 3:43pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/3 "2024-02-26T15:43:45Z")

</div>

I have attached below a code snippet of how I output the unstructured mesh data. The same is used for the structured case, as the mesh initially is structured and then deforms into unstructured.

Side note: I have made a small MATLAB script that lets me plot a very small mesh to view if the connectivity is right and it displays as it should, however, when I view it Paraview it shows like the one above.

```auto
void OutputMesh(int ts, std::vector<Node> nodes, std::vector<Tetra> elements)
{
	std::stringstream ss;
	ss << "results/mesh_" << std::setfill('0') << std::setw(4) << ts + 1 << ".vtu";
	std::ofstream out(ss.str());
	if (!out.is_open())
	{
		std::cerr << "Failed to open file " << ss.str() << std::endl;
		exit(-1);
	}

	/*header*/
	out << "<?xml version=\"1.0\"?>\n";
	out << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
	out << "<UnstructuredGrid>\n";
	out << "<Piece NumberOfPoints=\"" << nodes.size() << "\" NumberOfVerts=\"0\" NumberOfLines=\"0\" ";
	out << "NumberOfStrips=\"0\" NumberOfCells=\"" << elements.size() << "\">\n";

	/*points*/
	out << "<Points>\n";
	out << "<DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\">\n";
	for (Node &node : nodes)
		out << node.pos[0] << " " << node.pos[1] << " " << node.pos[2] << "\n";
	out << "</DataArray>\n";
	out << "</Points>\n";

	/*Cells*/
	out << "<Cells>\n";
	out << "<DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">\n";
	for (Tetra &tetra : elements)
		out << tetra.con[0] << " " << tetra.con[1] << " " << tetra.con[2] << " " << tetra.con[3] << "\n";
	out << "</DataArray>\n";

	out << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">\n";
	for (size_t e = 0; e < elements.size(); e++)
		out << (e + 1) * 4 << " ";
		//out << e << " ";
	out << "\n";
	out << "</DataArray>\n";

	out << "<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n";
	for (size_t e = 0; e < elements.size(); e++)
		out << "10 ";
	out << "\n";
	out << "</DataArray>\n";
	out << "</Cells>\n";

	/*save point data*/
	out << "<PointData Scalars=\"phi\">\n";
	out << "<DataArray type=\"Int32\" Name=\"node_index\" format=\"ascii\">\n";
	for (size_t n = 0; n < nodes.size(); n++)
		out << n << " ";
	out << "\n";
	out << "</DataArray>\n";
	///*
	out << "<DataArray type=\"Int32\" Name=\"node_type\" format=\"ascii\">\n";
	for (size_t n = 0; n < nodes.size(); n++)
		out << 0 << " ";
	out << "\n";
	out << "</DataArray>\n";
	//*/

	
	out << "<DataArray type=\"Float32\" Name=\"phi\" format=\"ascii\">\n";
	for (size_t n = 0; n < nodes.size(); n++)
		out << 0 << " ";
	out << "\n";
	out << "</DataArray>\n";

	out << "<DataArray type=\"Float32\" Name=\"ion_den\" format=\"ascii\">\n";
	for (size_t n = 0; n < nodes.size(); n++)
		out << 0 << " ";
	out << "\n";
	out << "</DataArray>\n";
	

	out << "</PointData>\n";

	/*save cell data*/
	out << "<CellData Vectors=\"ef\">\n";
	
	out << "<DataArray type=\"Float32\" NumberOfComponents=\"3\" Name=\"ef\" format=\"ascii\">\n";
	for (size_t e = 0; e < elements.size(); e++)
		out << 0 << " " << 0 << " " << 0 << " ";
	out << "\n";
	out << "</DataArray>\n";
	

	out << "<DataArray type=\"Float32\" Name=\"cell_volume\" format=\"ascii\">\n";
	for (Tetra &tet : elements)
		out << 0 << " ";
	out << "\n";
	out << "</DataArray>\n";

	out << "</CellData>\n";

	out << "</Piece>\n";
	out << "</UnstructuredGrid>\n";
	out << "</VTKFile>\n";

	out.close();
}

```

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 26, 2024, 3:48pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/4 "2024-02-26T15:48:44Z")

</div>

please share your data using a file sharing website

---

<div class="post-metadata">

### Author: ![Ivan\_B\_G](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ivan_b_g/32/13731_2.png) [@Ivan\_B\_G](https://discourse.paraview.org/u/Ivan_B_G)
#### Post date: [March 1, 2024, 1:00am UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/5 "2024-03-01T01:00:09Z")

</div>

This is the .vtu file for a different mesh, but the exact same issue.

Link:

> **[mesh\_0059.vtu](https://www.dropbox.com/scl/fi/nzeygfqufqwptpop33ldn/mesh_0059.vtu?rlkey=o96vefog7nd2lbpfgy9kt8fza&dl=0)**
>
> Shared with Dropbox

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 1, 2024, 10:01am UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/6 "2024-03-01T10:01:38Z")

</div>

It looks likes your cells are not exactly aligned with the axes, resulting with these patterns in the slice.

Here are a few tetras I extracted from the mesh interior. one can see they are not aligned.

 ![a](https://discourse.paraview.org/uploads/default/original/2X/1/1818375f74330b72d9929685358ae0845c0a2bac.png)

---

<div class="post-metadata">

### Author: ![Ivan\_B\_G](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ivan_b_g/32/13731_2.png) [@Ivan\_B\_G](https://discourse.paraview.org/u/Ivan_B_G)
#### Post date: [March 1, 2024, 2:28pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/7 "2024-03-01T14:28:07Z")

</div>

Is there any way in paraview to align the slicing plane with the tetras?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 1, 2024, 2:38pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/8 "2024-03-01T14:38:45Z")

</div>

Your cells are all a bit over the place inside the volume, so there is no aligned plane possible.

---

<div class="post-metadata">

### Author: ![Ivan\_B\_G](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ivan_b_g/32/13731_2.png) [@Ivan\_B\_G](https://discourse.paraview.org/u/Ivan_B_G)
#### Post date: [March 1, 2024, 11:19pm UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/9 "2024-03-01T23:19:50Z")

</div>

When I check the initial mesh file in the “SpreadSheet View” the x,y,z coordinate of the nodes are correct, however, when one performs a slice, it modifies the y and z values slightly, which is what I believe is causing the issue. Is there anyway to prevent this? Otherwise, what would you advise to do in order to be able to visualise it?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [March 4, 2024, 10:47am UTC](https://discourse.paraview.org/t/unstructured-moving-mesh-not-displaying-properly-in-paraview/14009/10 "2024-03-04T10:47:44Z")

</div>

This is not what I see at all:

 ![a](https://discourse.paraview.org/uploads/default/original/2X/d/d497ab8d385b586dc88a3a7b7dabf026c5b84923.png)

As you can see, many point coordinates are not aligned with the same axes.
