# Superposition effect

**URL:** https://discourse.paraview.org/t/superposition-effect/10950
**Category:** ParaView Support
**Created:** [December 8, 2022, 2:41pm UTC](https://discourse.paraview.org/t/superposition-effect/10950 "2022-12-08T14:41:26Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 2:41pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/1 "2022-12-08T14:41:26Z")

</div>

Good morning,

I would like to apply superposition effect on two .vtk files,in order to visualize the resultant Von Mises stresses. The two files differs only on the presence of two additional components. If needed I can share the two files.

Thank you.

---

<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: [December 8, 2022, 2:48pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/2 "2022-12-08T14:48:28Z")

</div>

> [@Matteo](#):
>
> apply superposition effect on two .vtk files,

HI @Matteo

How do you compute that ?

Best,

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 2:53pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/3 "2022-12-08T14:53:54Z")

</div>

I use paraview for Windows. I opened the two .vtk files, then I visualize Von Mises stress. After that I should use a programmable filter, suggested on a previous topic, but it doesn’t work.

---

<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: [December 8, 2022, 2:55pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/4 "2022-12-08T14:55:25Z")

</div>

Hi @Matteo ,

Ok, but what computation would you like to do ? How do you want to combine the files ?

Best,

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 2:57pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/5 "2022-12-08T14:57:14Z")

</div>

I would like to merge the stress tensor components, in order to visualize the resultant stresses. I don’t know if it’s correct.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 8, 2022, 3:42pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/6 "2022-12-08T15:42:24Z")

</div>

This is a shot in the dark (because I think we are all still confused about what “merge the stress tensor components” means), but if you need to combine data from two .vtk files, perhaps the `Append Attributes` filter will do what you want. See this for more discussion: [Difference between 2 Datasets](https://discourse.paraview.org/t/difference-between-2-datasets/7337)

---

<div class="post-metadata">

### Author: ![FEngineer](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/5f8ce5/32.png) [@FEngineer](https://discourse.paraview.org/u/FEngineer)
#### Post date: [December 8, 2022, 3:53pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/7 "2022-12-08T15:53:53Z")

</div>

Basically, the OP is looking for something like this but one of his 2 data sets contains modified geometry/mesh: [Results superposition](https://discourse.paraview.org/t/results-superposition/10854)

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 4:05pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/8 "2022-12-08T16:05:02Z")

</div>

Exactly

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 8, 2022, 5:26pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/9 "2022-12-08T17:26:19Z")

</div>

If the meshes of the 2 datasets don’t match, then you can use `Resample with Dataset` to map the field from one dataset to another dataset.

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 5:47pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/10 "2022-12-08T17:47:04Z")

</div>

I tried, following this tutorial: [ParaView map, resample, and combine different datasets [On Demand 3] - YouTube](https://www.youtube.com/watch?v=OggPGUEgl3c)  
But it didn’t work

 ![image](https://discourse.paraview.org/uploads/default/original/2X/1/1a74b5eabd967169b34e70d982b49a0cad335a10.png)  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/c/c0b1e9a31a4b6f0dc8b191eba5d22116cacf32d1.png)

these are the two .vtk files, as you can see they differ from the bearings. I want to ‘‘sum’’ the von mises stresses for every single point(the components of the stress tensor, von mises stress is a scalar value) of the two different analysis, and visualize the result.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 8, 2022, 5:57pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/11 "2022-12-08T17:57:36Z")

</div>

> [@Matteo](#):
>
> But it didn’t work

Can you elaborate on what happened and what went wrong? Were the results not as expected? What were the results? Did ParaView crash? Was there a rip in the space-time continuum? Did ParaView try to sell you an extended car warranty?

The description so far still sounds like combining the data with resampling. If we don’t know what goes wrong and don’t have the data there is not much we can do.

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 6:08pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/12 "2022-12-08T18:08:13Z")

</div>

What I expected was to visualize at the same time the red internal ring (high stress value) of the first pic and the white portion around the upper hole (considerable stress value) of the second one (the pics are shown in the previous reply).  
So, if it ran correctly, I would see ONE assembly with both remarkable values (I took them as an example, the stresses on every point should be the sum). It isn’t what I get.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/2/21cda9647ebc3b4ae7c6d49a6d7650c0cbd41751.png)  
As you can see, after resampling with dataset, I have the body of the second pic (the destination mesh), with the values of the first one (source data arrays), but NOT the stresses shown in the second pic.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 8, 2022, 7:09pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/13 "2022-12-08T19:09:22Z")

</div>

It would be a lot easier to help you if you could share your data.

I can think of a couple of ways you might be able to achieve this. One would be to combine the fields with `Resample with Dataset` as described before and then use the `Calculator` filter to find the maximum between the two von mises fields.

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 7:13pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/14 "2022-12-08T19:13:43Z")

</div>

These are the .vtk files:

> **[Elementi condivisi il giorno 8-12-2022 1](https://onedrive.live.com/redir?resid=8C83526C086B684A%211471&authkey=%21AJy7lClgVpI80YA&e=9cbsr4)**
>
> Folder

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 8, 2022, 7:43pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/15 "2022-12-08T19:43:07Z")

</div>

Yes, combining the fields of the two datasets into one and then taking the max seems to do the trick. (There were a few steps to first rename, then resample, and then append the fields.

 ![Screen Shot 2022-12-08 at 12.40.35 PM](https://discourse.paraview.org/uploads/default/original/2X/e/e0d3c402ce8e56e99ef70b6861209faef455a049.jpeg)

Here is a state file of what I did:  
[max-von-mises.pvsm](https://discourse.paraview.org/uploads/short-url/lkBY3zeCXWmqsZY1WUrCmCrFKYg.pvsm) (1.1 MB)

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 8, 2022, 8:37pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/16 "2022-12-08T20:37:36Z")

</div>

As I can see from the pic,it is exactly what I wanted, thank you. I have a few question after opening the file, beacuse it’s the first time I face Paraview:  
1- How are applied the different ‘‘Append attributes’’? I would like to know the steps, especially for the last one, and the difference with the other with an arrow;  
2-As I can see, the calculator finds the max value for every point. But can be eventually summed A von mises and B von mises?

Thank you for your patience.

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 8, 2022, 9:37pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/17 "2022-12-08T21:37:05Z")

</div>

Here are the full steps of what I did:

1. Add `PassArrays` to both A and B inputs and remove all the arrays except for `von Mises Stress`. This is optional, but made things a little easier later.
2. Add `RenameArrays` to both A and B pipelines to rename the fields to `A von Mises Stress` and `B von Mises Stress`, respectively. This makes it possible to differentiate the two arrays as we start combining the fields into one mesh.
3. Add the `Resample With Dataset` filter. Set the `Source Data Arrays` input to the A pipeline and the `Destination Mesh` to the B pipeline. I chose the B pipeline for the destination mesh because there are small parts of the A mesh outside of the B mesh, so the resample worked better to apply to the B mesh.
4. The result of `Resample With Dataset` now has `A von Mises Stress` on the B mesh. To get the B fields back, select both the `ResampleWithDataset` and the `RenameArrays` for the B pipeline in the pipeline browser and add the `Append Attributes` filter. This will combine both fields into a single mesh, which is the whole point of this exercise.
5. Add the `Calculator` filter to `AppendAttributes`. To get the max stress, set the expression to `max("A von Mises Stress", "B von Mises Stress")`. To get the sum, set the expression to `"A von Mises Stress" + "B von Mises Stress"`.

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 13, 2022, 7:10pm UTC](https://discourse.paraview.org/t/superposition-effect/10950/18 "2022-12-13T19:10:56Z")

</div>

Hello, again. I am trying to sum every stress component. So, I started with the ‘‘xx stress’’. I did the same steps you suggested, but it ends with an error:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/b/b21ab46c32819366d932993b6dbe8b3d4597989f.png)  
I tried with " and ‘’, but nothing change. Where am I wrong?

[test\_1.pvsm](https://discourse.paraview.org/uploads/short-url/ptr3QpZ9nr3Fde97P3rgjjDKd7n.pvsm) (1.1 MB)

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [December 14, 2022, 2:44am UTC](https://discourse.paraview.org/t/superposition-effect/10950/19 "2022-12-14T02:44:06Z")

</div>

You have the `Resample With Dataset` filter attached to the wrong inputs. It should be attached to the `Rename Arrays` filters, but instead it is directly attached to the readers. Because of this, it is not getting the `A_xx` named array.

Here is a fixed state file:  
[test\_1\_fixed.pvsm](https://discourse.paraview.org/uploads/short-url/rNZr7qg8yS5998sWMVhv3zWXgva.pvsm) (1.1 MB)

---

<div class="post-metadata">

### Author: ![Matteo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/matteo/32/10540_2.png) [@Matteo](https://discourse.paraview.org/u/Matteo)
#### Post date: [December 14, 2022, 11:21am UTC](https://discourse.paraview.org/t/superposition-effect/10950/20 "2022-12-14T11:21:18Z")

</div>

Thank you. I have a very last question. I would like to implement this equation on paraview:  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/6/68fc565ad63652288811176106af7b6af92be33c.png)  
where, for example, σyy is, the sum of the y-stresses of the two cases A&B, of the following save state:  
[SCRIPT\_CORRECT\_STRESS.pvsm](https://discourse.paraview.org/uploads/short-url/p63yt4hqhcJRX7gh6cLyuMviKbH.pvsm) (1010.4 KB)

Is there a better way than writing on calculator: sqrt(0.5\*(((A\_YY+B\_YY)-(A\_ZZ+B\_ZZ))^2+… ?

[Next page](https://discourse.paraview.org/t/superposition-effect/10950.md?page=2)
