How do I add isocaps to the other voids/around a gyroid?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
clc
clear
close all
Nx = 10;
Ny = 10;
Nz = 10;
% Generate meshgrid for the entire structure
x = linspace(0, 2, Nx*10);
y = linspace(0, 2, Ny*10);
z = linspace(0, 2, Nz*10);
[X, Y, Z] = meshgrid(x, y, z);
ri=-0.35;
ra=-ri;
F=cos(2.*pi.*X).*sin(2.*pi.*Y)+cos(2.*pi.*Y).*sin(2.*pi.*Z)+cos(2.*pi.*Z).*sin(2.*pi.*X);
F=-(F+ri).*(F+ra);
[fs,v]=isosurface(x,y,z,F,0);
[fc,v2,c] = isocaps(x,y,z,F,0);
fn = [fs ; fc+length(v(:,1))];
vn = [v ; v2];
TO = triangulation(fn,vn(:,1),vn(:,2),vn(:,3));
trisurf(TO,'FaceColor','g','FaceAlpha',1,'EdgeAlpha',1,'EdgeColor','none')
view(3)
light;
lighting gouraud
camlight
title('Gyroid');
stlwrite(TO,'Gyroid.stl');
I have added isocaps as above to close the wall between the 2 distinct volumes. I now want to add another isocap to the 4 sides of the gyroid so that it can be mesh'able for further pde numeric analysis. Please guide me.
0 comentarios
Respuestas (1)
Milan Bansal
el 11 de Sept. de 2024
Hi Kabo
To add isocaps to all the remaining voids in your gyroid structure for better meshing, you can adjust your MATLAB code by refining the way isocaps are applied, ensuring they encapsulate all sides of the gyroid. The function isocaps provides caps at boundaries where the surface intersects with the grid, so you'll need to apply this to each side or volume.
Here is a sample code snippet on how to add isocaps to the sides of the gyroid:
clc
clear
close all
Nx = 10;
Ny = 10;
Nz = 10;
% Generate meshgrid for the entire structure
x = linspace(0,2,Nx*10);
y = linspace(0,2,Ny*10);
z = linspace(0,2,Nz*10);
[X,Y,Z] = meshgrid(x,y,z);
ri = -0.35;
ra = -ri;
F = cos(2.*pi.*X).*sin(2.*pi.*Y)+cos(2.*pi.*Y).*sin(2.*pi.*Z)+cos(2.*pi.*Z).*sin(2.*pi.*X);
F = -(F+ri).*(F+ra);
% Extract isosurface and isocaps
[fs,v] = isosurface(x,y,z,F,0); % Isosurface of gyroid
[fc,v2,c] = isocaps(x,y,z,F,0); % Isocaps at the boundary
% Combine surface and caps for rendering
fn = [fs; fc+length(v(:,1))];
vn = [v; v2];
% Plot the gyroid with isocaps
TO = triangulation(fn, vn(:,1),vn(:,2),vn(:,3));
trisurf(TO, 'FaceColor', 'g', 'FaceAlpha', 1, 'EdgeAlpha', 1, 'EdgeColor', 'none')
view(3)
light;
lighting gouraud
camlight
title('Gyroid with Isocaps on All Sides');
%%%% MODIFICATIONS %%%%%%
% Add isocaps for xmin, xmax, ymin, ymax, zmin, and zmax planes
hold on;
[fc_xmin, v2_xmin, c_xmin] = isocaps(x, y, z, F, 'xmin'); % Isocaps at xmin
trisurf(triangulation(fc_xmin, v2_xmin(:,1), v2_xmin(:,2), v2_xmin(:,3)), 'FaceColor', 'r', 'FaceAlpha', 0.3, 'EdgeAlpha', 0.1);
[fc_xmax, v2_xmax, c_xmax] = isocaps(x, y, z, F, 'xmax'); % Isocaps at xmax
trisurf(triangulation(fc_xmax, v2_xmax(:,1), v2_xmax(:,2), v2_xmax(:,3)), 'FaceColor', 'r', 'FaceAlpha', 0.3, 'EdgeAlpha', 0.1);
[fc_ymin, v2_ymin, c_ymin] = isocaps(x, y, z, F, 'ymin'); % Isocaps at ymin
trisurf(triangulation(fc_ymin, v2_ymin(:,1), v2_ymin(:,2), v2_ymin(:,3)), 'FaceColor', 'b', 'FaceAlpha', 0.3, 'EdgeAlpha', 0.1);
[fc_ymax, v2_ymax, c_ymax] = isocaps(x, y, z, F, 'ymax'); % Isocaps at ymax
trisurf(triangulation(fc_ymax, v2_ymax(:,1), v2_ymax(:,2), v2_ymax(:,3)), 'FaceColor', 'b', 'FaceAlpha', 0.3, 'EdgeAlpha', 0.1);
[fc_zmin, v2_zmin, c_zmin] = isocaps(x, y, z, F, 'zmin'); % Isocaps at zmin
trisurf(triangulation(fc_zmin, v2_zmin(:,1), v2_zmin(:,2), v2_zmin(:,3)), 'FaceColor', 'y', 'FaceAlpha', 0.3, 'EdgeAlpha', 0.1);
[fc_zmax, v2_zmax, c_zmax] = isocaps(x, y, z, F, 'zmax'); % Isocaps at zmax
trisurf(triangulation(fc_zmax, v2_zmax(:,1), v2_zmax(:,2), v2_zmax(:,3)), 'FaceColor', 'y', 'FaceAlpha', 0.3, 'EdgeAlpha', 0.1);
Please refer to the following documentation link to learn more about isocaps.
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Volume Visualization en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!