Vector field decomposed in tangential and normal component along edge (dot product)

Hi all

I would like to split the 2D vector field along the edge of two materials in its tangential and normal parts.

The normal and tangential vectors on the lower material I did get with following filters: 1) Threshold, 2) Extract Surface, 3) Feature Edges and lastly with a 4) Programmable Filter. You can see the vectors in yellow.

Now, I need to apply the dot product between the vector field (red electric field) and the tangential vector. But only along the line, which separates the the two materials.

case_t0002.vtu (3.5 MB)
dot_product_with_edge_tangential.pvsm (1.1 MB)

I’m struggling with the last step, any suggestion?
Thx in advance

Just wanted to get back to the question again.

I would appreciate any help of decomposing the red vector field in its normal and tangential components along the edge between the blue and red material.

Still struggling and would love to get to the next step.

Huge thanks in advance and cheers

What you are asking is not very clear. You can compute any field within your programmable filter, what is missing here ?

Hi Mathieu

Thank you for your answer.
Sorry, my question was not so clear.

Let me try it again:

My programmable filter does calculate the normal and tangential vectors of the red surface:

from vtk.numpy_interface import algorithms as algs
import numpy as np

input0 = inputs[0]

numCells = input0.GetNumberOfCells()

normx = np.empty(numCells, dtype=np.float64)
normy = np.empty(numCells, dtype=np.float64)
normz = np.zeros(numCells, dtype=np.float64)
tangx = np.empty(numCells, dtype=np.float64)
tangy = np.empty(numCells, dtype=np.float64)
tangz = np.zeros(numCells, dtype=np.float64)
for i in range(numCells):
    cell = input0.GetCell(i)
    p1 = input0.GetPoint(cell.GetPointId(0))
    p2 = input0.GetPoint(cell.GetPointId(1))
    normx[i] = -(p2[1] - p1[1])  # Reverse the direction
    normy[i] = (p2[0] - p1[0])    # Reverse the direction

    # Calculate the magnitude of the vector
    magnitude = np.sqrt(normx[i]**2 + normy[i]**2 + normz[i]**2)

    # Normalize the vector components
    if magnitude != 0:
        normx[i] /= magnitude
        normy[i] /= magnitude
        normz[i] /= magnitude

    tangx[i] = normy[i]  # Reverse the direction
    tangy[i] = -normx[i]
# Create the normalized vectors
norm_normalized = algs.make_vector(normx, normy, normz)
output.CellData.append(norm_normalized, "normals")

tang_normalized = algs.make_vector(tangx, tangy, tangz)
output.CellData.append(tang_normalized, "tangentials")

In order to get the scalar projection of my “electric field” data with the tangential vector, I would need to calculate proj =“electric field”, tang_normalized) and the plot proj as a Line Chart.

I do not understand how to get access to my “electric field” data inside the Programmable Filter to finally apply the dot product ???

I hope this helps a bit.

Thx in advance and cheers.

I do not understand how to get access to my “electric field” data inside the Programmable Filter to finally apply the dot product ???

input0.PointData["electric field"]