# Working with multiple vtk files

**URL:** https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101
**Category:** ParaView Support
**Created:** [March 7, 2024, 9:16am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101 "2024-03-07T09:16:26Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![aneps](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@aneps](https://discourse.paraview.org/u/aneps)
#### Post date: [March 7, 2024, 9:16am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/1 "2024-03-07T09:16:26Z")

</div>

Hello everyone, I have two vtk files, one with openfoam solutions of gas flow and another one with electric field. I want to do calculations with expressions which combine the gas velocity from the first vtk and the electric field from the second. I tried to append attributes, append dataset and programmable filter… but I could not find a way to apply my equations with velocity from one vtk and electric field from the other. Can anyone please help with this? Thank you.

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [March 7, 2024, 2:45pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/2 "2024-03-07T14:45:30Z")

</div>

Hi @aneps, it sounds like you have two different meshes with different data fields. The best way to integrate two datasets into one is to use the **Resample With Dataset** filter. This filter samples data fields from one dataset onto the point locations of another dataset, resulting in a single mesh with all fields.

After you have the data arrays on a single mesh, computing equations based on values from the different arrays is possible with the **Calculator** , **Python Calculator** , or **Programmable Filter**.

---

<div class="post-metadata">

### Author: ![aneps](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@aneps](https://discourse.paraview.org/u/aneps)
#### Post date: [March 9, 2024, 8:19am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/3 "2024-03-09T08:19:35Z")

</div>

That seems a good idea but unfortunately when I try to Resample with Dataset, I still have the parameters from only one vtk in the new resampled dataset. I couldn’t find a way to do the cross calculations. In the calculator, I have access to the data from only one case, that case where I made the calculator. I searched on youtube to find if there are any such examples, but I couldn’t find. May I request you, if you have any examples or if you know any online somewhere, kindly share it? Thanks a lot.

---

<div class="post-metadata">

### Author: ![hngnet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hngnet](https://discourse.paraview.org/u/hngnet)
#### Post date: [March 9, 2024, 12:21pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/4 "2024-03-09T12:21:17Z")

</div>

Would it be possible to share the files? That would help fix your problem.

---

<div class="post-metadata">

### Author: ![aneps](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@aneps](https://discourse.paraview.org/u/aneps)
#### Post date: [March 10, 2024, 1:15pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/5 "2024-03-10T13:15:44Z")

</div>

yes, I have uploaded both cases in the dropbox folder. First case is in the folder ‘sample’ and the second case is in the folder ‘sampleLaplace’. The first case is just the gas flow simulations and the second case is the electric field simulations. The first case is done by cutting the geometry into half along the axis (symmetry axis) and the simulation is done only for the half geometry. The second case, in parafoam, I would like to ‘clip’ into half. Then the clipped half of the case2 is similar to the case1. I want to do the calculation on the case 2, for eg. v = 1.09\* (T/273)\*(760/P)\*Ez , where temperature T and pressure P from the case1 and z component of the electric field Ez from the case2. I want to make a color plot of this quantity (v) on case2 (or case1, it doesn’t matter). Thanks a lot… [dropbox](https://www.dropbox.com/scl/fo/nz4ke65hrual2hi10sdnh/h?rlkey=kieodudtpthhvcmjvwzopuox4&dl=0)

---

<div class="post-metadata">

### Author: ![hngnet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hngnet](https://discourse.paraview.org/u/hngnet)
#### Post date: [March 11, 2024, 10:30pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/6 "2024-03-11T22:30:18Z")

</div>

![image](https://discourse.paraview.org/uploads/default/original/2X/6/603641169c2ac4fcda5050f85ee0690cfc876a97.png)

I am unsure whether this is what you want, but I did the following:

1. Open sample\_500.vtk file.
2. Open sampleLaplace\_40.vtm.
3. Select “sampleLaplace\_40.vtm” and apply “MergeBLocks” filter.
4. Select “MergeBLocks1” and apply “Clip” filter.
5. Select “sample\_500.vtk” and apply “ResampleWithDataset”. Select “sample\_500.vtk” for “Source Data Arrays” and “Clip1” for “Destination Mesh”.
6. Select “Clip1” and “ResampleWithDataset1” and apply “GroupDataset” filter.

Now I can see all variables in “GroupDatasets1”.

Best,  
Hom Nath

---

<div class="post-metadata">

### Author: ![aneps](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@aneps](https://discourse.paraview.org/u/aneps)
#### Post date: [March 12, 2024, 7:38am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/7 "2024-03-12T07:38:00Z")

</div>

Thank you so much. For me, this is a huge step forward. But still the calculations are not possible with this. I think the issue is the data is not being resampled properly (not sure, just a guess). For eg. when I generate a calculator (on GroupDatasets1), and suppose I do a calculation Results = 1.09\*(T/273)\*(760/p)\*Efield, then the the results just wont appear and even if it appears it shows with a question mark “Results(?)”. On GroupDataset if I just choose U(partial) for eg, then I can see a lot of cells grayed out (screenshot below). Probably this is why it cannot do cross calculations. Between, may I ask you what does it mean by ‘partial’ in the U, p, T, V etc?

 ![image](https://discourse.paraview.org/uploads/default/original/2X/2/23ecb18369c30531e09b40e8cc3541623d8fefce.jpeg)

The ultimate goal is to do the calculations and plot the results (colormap). If there is any other way to do these type of calculations involving parameters from both the cases, that would also be great.  
Thanks once again for your valuable time.

---

<div class="post-metadata">

### Author: ![hngnet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hngnet](https://discourse.paraview.org/u/hngnet)
#### Post date: [March 12, 2024, 11:19am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/8 "2024-03-12T11:19:38Z")

</div>

This usually happens if some regions or time steps don’t have the values to resample or interpolate. Your VTM seems to be a nonconforming mesh. I am unsure, but that may be the reason. How about trying to clip the VTK model to the shape like the VTM model (you can use the cylinder to clip) and resample the VTM model onto the clipped VTK model?

---

<div class="post-metadata">

### Author: ![aneps](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@aneps](https://discourse.paraview.org/u/aneps)
#### Post date: [March 12, 2024, 3:05pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/9 "2024-03-12T15:05:01Z")

</div>

I clipped a rectangular region which is common to both. Then I resampled the first on to the second clip. Then grouped the data. Still the same issue ☹ !

 ![image](https://discourse.paraview.org/uploads/default/original/2X/d/dd9a13de68d4cf7fc4273b99dd0af155a5aa186e.jpeg)

---

<div class="post-metadata">

### Author: ![hngnet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hngnet](https://discourse.paraview.org/u/hngnet)
#### Post date: [March 12, 2024, 5:55pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/10 "2024-03-12T17:55:15Z")

</div>

Interesting! Are you sure one mesh perfectly overlaps the other? There may be some mismatch. I will give it some more tries.

---

<div class="post-metadata">

### Author: ![aneps](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@aneps](https://discourse.paraview.org/u/aneps)
#### Post date: [March 12, 2024, 8:49pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/11 "2024-03-12T20:49:53Z")

</div>

Meshes may not perfectly overlap! Because, although these both simulations are done on the same device, the boundaries are different. One is for gas flow and another is for the Laplacian. Both are meshed differently. I think that is why we need the resampling right? or else may any kind of interpolation/extrapolation methods? Thank you.

---

<div class="post-metadata">

### Author: ![hngnet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hngnet](https://discourse.paraview.org/u/hngnet)
#### Post date: [March 13, 2024, 1:45am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/12 "2024-03-13T01:45:32Z")

</div>

Oh, what happens if you use “Append Attributes” filter instead of “Group Datasets” ?

---

<div class="post-metadata">

### Author: ![hngnet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hngnet](https://discourse.paraview.org/u/hngnet)
#### Post date: [March 13, 2024, 1:48am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/13 "2024-03-13T01:48:03Z")

</div>

![image](https://discourse.paraview.org/uploads/default/original/2X/0/015aff5cf55ed9a452d25debc81e4c04d74f1e50.jpeg)

No more partial! I used the same steps as before, but used the “Append Attributes” filter.

---

<div class="post-metadata">

### Author: ![aneps](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/7ea924/32.png) [@aneps](https://discourse.paraview.org/u/aneps)
#### Post date: [March 13, 2024, 10:08am UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/14 "2024-03-13T10:08:01Z")

</div>

That worked, although I have data missing at several grids. Now I can do calculations, that is good. Thank you.

---

<div class="post-metadata">

### Author: ![hngnet](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hngnet](https://discourse.paraview.org/u/hngnet)
#### Post date: [March 13, 2024, 1:44pm UTC](https://discourse.paraview.org/t/working-with-multiple-vtk-files/14101/15 "2024-03-13T13:44:22Z")

</div>

Great! Missing data is likely from inconsistent geometries.
