# How can I obtain the neighbouring nodes to a node of interest in a mesh and the corresponding resultants at these nodes when using the Partial Differential Equation Toolbox?

3 views (last 30 days)
It is performed a transient analysis for a Structural Model using the Partial Differential Equation Toolbox and the solution is obtained by means of a 'TransientStructuralResults' object with the name 'structuralresults'.
It is sought to obtain the resultants (for instance the velocity) at the neighbouring nodes to a node of interest of the mesh at a particular time of the transient simulation.
How can I obtain the neighbouring nodes to a node of interest in a mesh and the corresponding resultants at these nodes when using the Partial Differential Equation Toolbox?

MathWorks Support Team on 21 Jul 2021
Firstly it is important to note that the order of the elements in the mesh plays an important role. Herein it is assumed that it is used quadtratic tetrahedral elements, namely,
In this case the elements are tetrahedrals and contain nodes at the middle of their edges as well. Three of these nodes are going to be neighbouring the node of interest for the elements that actually contain the node of interest. Once the ID of these nodes is found in the mesh, then it can be used the resultant array 'structuralresults.Velocity' to obtain the velocity at the particular node. Herein a small demo is presented to show how this can be achieved for the magnitude of the velocity and for an example node with ID 12, namely,

% Node of interest
nodeID = 12;
% Get the coordinates of the node of interest
node = structuralModel.Mesh.Nodes(:, nodeID);
% Get the velocity of the node of interest
vel = structuralresults1.Velocity.Magnitude(nodeID, end);
% Find the elements in the mesh that contain the node of interest
[idx,idy] = find(structuralModel.Mesh.Elements == nodeID);
% Check if the node has been found properly
assert(length(idx) == length(idy))
% Get the number of elements that contain the node of interest
numEl = length(idx);
% Plot the node of interest
figure
plot3(node(1),node(2),node(3),'.black')
hold on;
% Loop over all the elements that contain the node of interest
for i = 1:numEl
% Get the node IDs of the element that contain the node of interest
el = structuralModel.Mesh.Elements(:,idy(i));
% Remove the node of interest from the element array
el(el == nodeID) = [];
% Compare the distances of all the nodes in the current element against
% the node of interest
dist = zeros(length(el), 1);
for j = 1:length(el)
dist(j, 1) = norm(node - structuralModel.Mesh.Nodes(:, el(j)));
end
[dist, idsr] = sort(dist);
% Get the IDs of the nodes that are neighbouring the node of interest
neighboring_nodes = el(idsr(1:3));
% Get the IDs of the nodes that are not neighbouring the node of
% interest
non_neighboring_nodes = el(idsr(4:end));
% Plot the nodes that are neighbouring the node of interest (red)
for j = 1:length(neighboring_nodes)
neig_node_coord = structuralModel.Mesh.Nodes(:, neighboring_nodes(j));
plot3(neig_node_coord(1),neig_node_coord(2),neig_node_coord(3),'.red');
end
% Plot the nodes that are not neighbouring the node of interest (green)
for j = 1:length(non_neighboring_nodes)
non_neig_node_coord = structuralModel.Mesh.Nodes(:, non_neighboring_nodes(j));
plot3(non_neig_node_coord(1),non_neig_node_coord(2),non_neig_node_coord(3),'.green');
end
% Get the velocity of the neighbouring nodes
vel_neighboring = structuralresults1.Velocity.Magnitude(neighboring_nodes, end);
end
hold off;
where 'vel' and 'vel_neighboring' are the variables holding the velocity of the node of interest and its neighbouring nodes, respectively, at the end time step of the transient simulation.

In the resulting figure, with black it is indicated the node of interest, with red the neighbouring nodes to this node of interest and with green the rest of the nodes in the elements containing the node of interest.

### Tags

No tags entered yet.

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!