Skip to content

Commit d56385f

Browse files
author
Usseglio-Viretta
committed
Meshing module updated to v0.91
1 parent 966386d commit d56385f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+5915
-6240
lines changed

src/Create_mesh_for_FEM/Funcion_CalculateFacetNormalVariation.m

Lines changed: 0 additions & 123 deletions
This file was deleted.

src/Create_mesh_for_FEM/Function_CalculateFacetsAngle.m

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/Create_mesh_for_FEM/Function_NodeFaceElem_region.m

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
function [M] = Function_assign_voxels_based_on_contact(M,idx_assign,background_code)
2+
3+
sz = size(M);
4+
[I1,I2,I3] = ind2sub(sz,idx_assign);
5+
6+
for k=1:1:length(idx_assign) % Loop over all voxels to re-assign
7+
x=I1(k); y=I2(k); z=I3(k); % Coordinates of current voxel
8+
neighbors_voxels = [];
9+
if x>1
10+
neighbors_voxels = [neighbors_voxels; M(x-1,y,z)];
11+
end
12+
if x<sz(1)
13+
neighbors_voxels = [neighbors_voxels; M(x+1,y,z)];
14+
end
15+
if y>1
16+
neighbors_voxels = [neighbors_voxels; M(x,y-1,z)];
17+
end
18+
if y<sz(2)
19+
neighbors_voxels = [neighbors_voxels; M(x,y+1,z)];
20+
end
21+
if z>1
22+
neighbors_voxels = [neighbors_voxels; M(x,y,z-1)];
23+
end
24+
if z<sz(3)
25+
neighbors_voxels = [neighbors_voxels; M(x,y,z+1)];
26+
end
27+
28+
% Id not to be reassigned
29+
no_assignment_id = abs(M(idx_assign(k)));
30+
neighbors_voxels(neighbors_voxels==no_assignment_id)=[]; % Remove them
31+
neighbors_voxels(neighbors_voxels<0)=[]; % Remove them
32+
33+
% Prioritize assign to a solid phase, not to the background
34+
neighbors_voxels(neighbors_voxels==background_code)=[]; % Remove them
35+
36+
% Sort to find phase that shares the most facet with the voxel
37+
[C,~,ic] = unique(neighbors_voxels);
38+
% Reassign
39+
if ~isempty(C)
40+
counts = accumarray(ic,1);
41+
value_counts = [C, counts];
42+
value_counts = sortrows(value_counts,-2);
43+
M(idx_assign(k)) = value_counts(1,1);
44+
else
45+
M(idx_assign(k)) = background_code;
46+
end
47+
48+
end
49+
50+
51+
end
52+

src/Create_mesh_for_FEM/Function_calculate_facets.m

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)