Issues with meshrefine

110 views
Skip to first unread message

Alistair Newcombe

unread,
Jul 26, 2018, 2:08:00 PM7/26/18
to iso2mesh-users
Hi Dr Fang,

I'm attempting to model the light propagation through a block of attenuating medium that I'm exporting from Abaqus. Because of this I'm limited to the number of nodes I can have in my model (both because of computation and teaching Abaqus licence). This is causing my simulation using your MMC equation to have a number of "mesh artifacts" in it that are not desirable. 


(This is the light propagation with a homogeneous cylinder. I would not expect the "waviness" in the main light path. This medium is currently defined with relatively low scattering and absorption.)

I have attempted to refine my mesh using the meshrefine function in the iso2mesh library but havent been able to get it running. No matter the parameter I use it fails to refine the mesh and simply gives me a larger mesh size. (see the examples below):

 
Attempting to define each element volume using the already existing element volume provides mesh with 989 nodes and 599 elements. Down from 64999 nodes and 44807 elements in the original mesh.

vol=elemvolume(no,el,'vol');   
[newno,newel]=meshrefine(no,el,vol);


I then attempted to define the new element size using the minimum element size of the existing mesh. This gives me the same mesh. Dividing the min element size by 2, also gives me the same mesh

vol=elemvolume(no,el,'vol');   
[newno,newel]=meshrefine(no,el,struct('maxvol',min(vol))); 


This is the mesh the meshrefine function provides me.

This is my original mesh.






In an attempt to get around this problem I have tried to first convert the mesh to a volume using mesh2vol.m and the used vol2mesh to convert it back to a more refined mesh. But I'm unsure as to what to define for [Nx,Ny,Nz] as this mesh wasnt originally an image, or for (xi,yi,zi).

For this problem I would like to avoid any hard coding as for my PhD I need to determine the light propagation properties of many different materials/designs under different loads - hence deformations -- so different shapes.

Would appreciate any help you can provide.

Cheers.

Qianqian Fang

unread,
Jul 26, 2018, 2:48:12 PM7/26/18
to iso2mes...@googlegroups.com, Alistair Newcombe
On 07/26/2018 03:05 AM, Alistair Newcombe wrote:
Hi Dr Fang,

I'm attempting to model the light propagation through a block of attenuating medium that I'm exporting from Abaqus. Because of this I'm limited to the number of nodes I can have in my model (both because of computation and teaching Abaqus licence). This is causing my simulation using your MMC equation to have a number of "mesh artifacts" in it that are not desirable. 


hi Alistair

try the below sample script

[node,face,elem]=meshacylinder([0 0 0],[0 0 3],1,0.05,0.001,64);
c0=meshcentroid(node,elem(:,1:4));
rad=sqrt(sum(c0(:,1:2).*c0(:,1:2),2));
[no2,el2]=meshrefine(node,elem(:,1:5),rad.^2/1000);
plotmesh(no2,el2,'y>0')

the generated mesh crosssection is attached.

here I use the iso2mesh builtin function meshacylinder to generate the
coarse mesh, and then use the element size to refine.

you can adjust the power to the rad array to adjust the radial
density contrast, and use the denominator (1000) to adjust
the overall density.

Qianqian



(This is the light propagation with a homogeneous cylinder. I would not expect the "waviness" in the main light path. This medium is currently defined with relatively low scattering and absorption.)

I have attempted to refine my mesh using the meshrefine function in the iso2mesh library but havent been able to get it running. No matter the parameter I use it fails to refine the mesh and simply gives me a larger mesh size. (see the examples below):

 
Attempting to define each element volume using the already existing element volume provides mesh with 989 nodes and 599 elements. Down from 64999 nodes and 44807 elements in the original mesh.

vol=elemvolume(no,el,'vol');   
[newno,newel]=meshrefine(no,el,vol);


I then attempted to define the new element size using the minimum element size of the existing mesh. This gives me the same mesh. Dividing the min element size by 2, also gives me the same mesh

vol=elemvolume(no,el,'vol');   
[newno,newel]=meshrefine(no,el,struct('maxvol',min(vol))); 



This is the mesh the meshrefine function provides me.


This is my original mesh.






In an attempt to get around this problem I have tried to first convert the mesh to a volume using mesh2vol.m and the used vol2mesh to convert it back to a more refined mesh. But I'm unsure as to what to define for [Nx,Ny,Nz] as this mesh wasnt originally an image, or for (xi,yi,zi).

For this problem I would like to avoid any hard coding as for my PhD I need to determine the light propagation properties of many different materials/designs under different loads - hence deformations -- so different shapes.

Would appreciate any help you can provide.

Cheers.
--
You received this message because you are subscribed to the Google Groups "iso2mesh-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to iso2mesh-user...@googlegroups.com.
To post to this group, send email to iso2mes...@googlegroups.com.
Visit this group at https://groups.google.com/group/iso2mesh-users.
For more options, visit https://groups.google.com/d/optout.


refined_cylinder.png

Alistair Newcombe

unread,
Jul 26, 2018, 6:46:32 PM7/26/18
to iso2mesh-users
Hi Dr Fang

I have attempted to run the sample script you have provided on a fresh download of iso2mesh and I'm getting practically the same mesh as I was with the meshrefinement of my nodes from Abaqus.



This mesh has the same number of nodes and elements as I was getting previously. And the mesh has the same pattern at the top edge as previously. If I plot the mesh before running meshrefine I get something similar to the mesh you provide:




I'm wondering if this has to do with this error message I'm receiving. I've had a quick look in this forum for any similar error surrounding readtetgen but have failed to find any.





I was receiving the same error message previously, so I would assume this issue im having is coming from the readtetgen or mwpath function.


Thanks for you help,


Alistair Newcombe

Alistair Newcombe

unread,
Jul 26, 2018, 7:08:17 PM7/26/18
to iso2mesh-users
Ok, a small update. There seems to something in meshrefine that is storing my original mesh data. From the script you post previously I changed the second axis end point to [0 0 5] and it still produced the 3 unit high cylinder. Have you experienced this problem before?

Cheers

Qianqian Fang

unread,
Jul 26, 2018, 7:19:42 PM7/26/18
to iso2mes...@googlegroups.com, Alistair Newcombe
On 07/26/2018 07:08 PM, Alistair Newcombe wrote:
Ok, a small update. There seems to something in meshrefine that is storing my original mesh data. From the script you post previously I changed the second axis end point to [0 0 5] and it still produced the 3 unit high cylinder. Have you experienced this problem before?

then you have to look at the printed messages carefully. this typically happens when the command failed, and
unable to generate new data (but the old data were cached, so it read out the old output from the cached
folder  - use mwpath to find out where these files are stored).

if you see an error in your log, please post it here.
Message has been deleted

Alistair Newcombe

unread,
Aug 1, 2018, 7:30:49 PM8/1/18
to iso2mesh-users

then you have to look at the printed messages carefully. this typically happens when the command failed, and

unable to generate new data (but the old data were cached, so it read out the old output from the cached

folder  - use mwpath to find out where these files are stored).


if you see an error in your log, please post it here.

 

Hi Dr Fang,

 

If I delete all the files within my ....\AppData\Local\Temp\iso2mesh-anew809 folder then I am able to remesh the object. But this doesn't seem like an elegant/longterm fix. If I was to get an error where would this occur?

 

A similar thing is also occuring when I attempt to add an external source to my the source that is from running the first example within the example is added to my mesh.

 


Obviously I can run the example to add an external source to a sphere. But adding a small 1x1 source at (0,0,-0.1) fails and gives me these errors:

 

 

In other post in the mmc-users google group the issue appears to be with the Matlab version used, I'm using MATLAB R2015B (MATLAB 8.6). So this shouldn't be issue, unless I need to get the most up-to-date version. I have added a screenshot of the script that I'm running to attempt to generate this source, but its a direct copy from the example so this might not be helpful.

Apologies for asking a mmc related question on the iso2mesh group. I just seemed relevant to the issue I was previously having.

An additional question about the sources is there any documentation that defines all the available sources in mmc, and what the source parameters are defined as, specifically what the focus is defined as (angle from normal??). If there Isn't any documentation I'll take a dive into the code and see what I can work out.

Cheers

Capture.PNG

Qianqian Fang

unread,
Aug 2, 2018, 12:38:30 PM8/2/18
to iso2mes...@googlegroups.com, Alistair Newcombe
hi Alistair

the "Error: Invalid PLC"  error thrown by tetgen was the source of the problem.

would be helpful if you can send me your meshing script, so I can see if there is
another workaround.

Qianqian


On 08/01/2018 07:10 PM, Alistair Newcombe wrote:
then you have to look at the printed messages carefully. this typically happens when the command failed, and
unable to generate new data (but the old data were cached, so it read out the old output from the cached
folder  - use mwpath to find out where these files are stored).

if you see an error in your log, please post it here.

Hi Dr Fang,

If I delete all the files within my ....\AppData\Local\Temp\iso2mesh-anew809 folder then I am able to remesh the object. But this doesn't seem like an elegant/longterm fix. If I was to get an error where would this occur?

A similar thing is also occuring when I attempt to add an external source to my the source that is from running the first example within the example is added to my mesh.


Obviously I can run the example to add an external source to a sphere. But adding a small 1x1 source at (0,0,-0.1) fails and gives me these errors:



In other post in the mmc-users google group the issue appears to be with the Matlab version used, I'm using MATLAB



Alistair Newcombe

unread,
Aug 2, 2018, 7:14:59 PM8/2/18
to iso2mesh-users
Hi Dr Fang

I have attached the scripts involved with loading in my abaqus node values from a '.vtk' file format and the script for meshing my part and generating the output files. Hopefully each section of my meshing script has a title that will allow for easy distinguishing of their function.

My aim with this script is to allow me to input any arbitrary meshed part (and the mechanical deformed parts), that is why i have avoided using any hard coded parts. 

I really appreciate the help you have provided. 

Cheers.
Alistair Newcombe
Alistair_Newcombe_Monte_Carlo_Files.zip

Alistair Newcombe

unread,
Aug 5, 2018, 10:02:21 PM8/5/18
to iso2mesh-users
Hi,

I have update my iso2mesh from version 1.5 to version 1.9. This has unfortunately made no difference.

Additionally I have run meshcheckrepair and it appears that I have multiple open surfaces. Im going to attempt to generate an isosurface using the matlab function 'isosurface' and then see if i can mesh that to solve my issues.

Cheers

Qianqian Fang

unread,
Aug 6, 2018, 2:29:43 PM8/6/18
to iso2mes...@googlegroups.com, Alistair Newcombe
hi Alistair

I tried your script, and saw the same error (it had Open_File.m missing, but I managed
to convert the vtk file to something I can import).

is it important to use the vtk mesh? from looking at it, it is basically a uniform cylinder,
which you can easily recreate using iso2mesh's meshacylinder.m function.

I managed to get the below script to work

[no,fc,el]=meshacylinder([0 0 0],[0 0 3],1,0.1,0.001,128);
fixednodes=[0.0, 0.0, -1.0; 0.0, 0.0, 4.0; ...
    -4.0, 0.0, 1.5; 4.0, 0.0, 1.5; ...
    0.0, -4.0, 1.5; 0.0, 4.0, 1.5];
source=double([-1 -1;-1 1;1 1;1 -1]);
source(:,3)=-1;
[newnode,newelem]=mmcaddsrc(no,el,[fixednodes; source],'extcmdopt','-Y -a1','extlabel',0);

newelem(newelem(:,end)<0,end)=0;

srcnode=find(newnode(:,3)==-1)  % find the nodes on the source plane
eid=ismember(newelem(:,1:4),srcnode); % find the elements that containing souce nodes
srceid=find(sum(eid,2)>=3)   % elements on the src aperture;
newelem(srceid,end)=-1;

plotmesh(newnode,[],newelem,'y>0')

I replaced your cylinder with a new one, and merged fixednodes with source nodes,
and then I manually identify the source elements.

let me know if this script works for you.

Qianqian


Cheers

Alistair Newcombe

unread,
Aug 8, 2018, 4:39:44 AM8/8/18
to iso2mesh-users
I replied to your email, which I'm adding here to ensure you get.

Hi Qianqian,

I'm simply using the basic uniform cylinder to test the MC sim and get it up and working. I want to be able to import any arbitrary deformed object, refine the mesh with iso2mesh and then run that in your MMC model. This is why I have been avoiding "hard-coding" the shape of the mesh.

Could I be running into issues due to my Abaqus model using a 10-node tetrahedron, and iso2mesh using a 4-node tetrahedron. But even then I should be able to simple remove the unneeded nodes from my node array. Doing so does not change the result.

Thanks for your help.

I've continued to work on attempting to fix this issue. To attempt to solve this I've taken my nodes as a point cloud describing the object of interest. Then using the Matlab function boundary I have produced a complete surface which describes the top, bottom, and sides of the object. This has allowed me to use surf2mesh to produce a mesh of the shape. I was hoping that this would remove any issues with the mesh that was present in the exported mesh from Abaqus.

But this appears to only work when I set the keepratio really low, which of course results in a deformed shape. But I am able to add an external source to it (although even this results in weird mesh.)

But at least this is progress!!! Although again meshrefine is not work.


I'm really not understanding why this is not working. What I'm to mesh is trivial compared to some of the examples that you have provided. So this should be an extremely simple thing to mesh. I'm going to spend one or two more days trying to trouble-shoot this problem, and if I cant get it in that time i might have to give up this approach. And simply model the geometry using a number of primitive shapes (so cylinders, rectangles etc), that should approximate the light path.


Thank you very much for all your help Dr Fang.


Alistair Newcombe


Reply all
Reply to author
Forward
0 new messages