Export mesh to Comsol using iso2mesh
10 views (last 30 days)
Show older comments
Hello,
I am trying to transfer a geometry I created in Matlab into a FE program. For this application I found the toolbox ISO2MESH. I'm able to export the provided examples and import them into Comsol. Since there were some issues with my application, I tried it with a smaller but similar example (provided by https://de.mathworks.com/help/matlab/ref/tetramesh.html) and encountered difficulties:
d = [-1 1];
[x,y,z] = meshgrid(d,d,d); % a cube
x = [x(:);0];
y = [y(:);0];
z = [z(:);0];
DT = delaunayTriangulation(x,y,z);
tetramesh(DT);
camorbit(20,0)
M=meshgrid(x,y,z);% change to volumetric binary image
%%iso2mesh
[node,elem,face]=vol2mesh(M,1:size(M,1),1:size(M,2),1:size(M,3),0.1,2,1);
savemphtxt(node,face,elem,'test_mesh_export_comsol.mphtxt');
This code compiles with the warning "You are meshing the surface with sub-pixel size. If this is not your intent, please check if you set "opt.radbound" correctly for the default meshing method. "
I get a result readable by Comsol, but it does not share the dimensions of the original and is too finely meshed (see below).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/378836/image.png)
I change the parameters in the line
[node,elem,face]=vol2mesh(M,1:size(M,1),1:size(M,2),1:size(M,3),2,2,1);
so I don't get a warning anymore, the imported result is very bad (see below).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/378841/image.jpeg)
I would be happy if someone has an idea what I am doing wrong and how I can export the net cleanly.
1 Comment
Roya
on 6 Jan 2023
Edited: Roya
on 6 Jan 2023
Hi Kim
in comsol you can import your mesh from component > mesh > import, after that from mesh tab click on create geometry from mesh , it makes new geometry in new component ,then you could remesh it from mesh tab > build >mesh2 >settings > element size and choose appropriate mesh size from extremely fine to extremely coarse.
Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!