Hi,
From my understanding, you are trying to obtain the new information for tetrahedral elements in a mesh after marking some tetrahedra for encryption by dividing a face into four faces.
Refer to the following steps to resolve this issue:
1.Begin by identifying the mesh requiring modification. For each marked tetrahedron, divide its faces by adding new nodes at the midpoints, effectively creating smaller faces.
markedTetrahedra = [1, 5, 10];
for i = 1:size(Elements, 2)
m12 = (Nodes(:, n1) + Nodes(:, n2)) / 2;
2.Incorporate these new nodes into the nodelist and replace the original tetrahedra with newly formed ones using these nodes.
This process ensures that each original tetrahedron is subdivided into smaller, more manageable tetrahedra.
[NewNodes, idx12] = addNode(NewNodes, m12);
NewElements = [NewElements, ...
[n1; idx12; idx13; idx14], ...
3.Once it is reconstructed, store the updated node and element information, ensuring that the new elements are correctly indexed in the elements array.
function [nodes, index] = addNode(nodes, newNode)
index = find(all(abs(nodes - newNode) < tol, 1), 1);
nodes = [nodes, newNode];
4.Finally, verify the integrity of the mesh by checking that the new tetrahedra seamlessly replace the originals without any gaps or overlaps. This ensures a smooth transition from the original mesh to the modified, encrypted version.
tetramesh(NewElements', NewNodes', 'FaceColor', 'red');
title('Encrypted Tetrahedral Mesh');
Hope this helps!
For more information, refer to the following MathWorks Documentation:
“tetramesh” function: