Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Iso surface mesh export using LiveLink for MATLAB

Please login with a confirmed email address before reporting spam

Hello Comsol Comunity,

In our team, we use Comsol to make simulation of electric fields propagation, that we display using a fixed threshold:

  • simulation domain 100x100x100mm, heterogenious conductivity
  • source: cylinder at the center of the domain
  • gound: sides of the simulation domain

Once we have displayed the isosurface, we export this as vtu file using the "Export plot" function in the context menu. Our issues:

  • first the mesh is pretty broken, even in Comsol some triangles are missing. Setting a finer mesh (physics controlled) reduces it but does not suppress the issue.
  • we automated the simulations with livelink, modifying the position of the source, and the amplitude of the stimulation. However, we haven't found how to mimic the vtu export. For now we used mphplot, and extracted the mesh displayed in the figure (very hacky, the mesh is even more broken).

Best, DV


4 Replies Last Post 18.06.2019, 04:37 GMT-4
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 14.06.2019, 04:26 GMT-4
Updated: 5 years ago 14.06.2019, 04:26 GMT-4

Comsol and its LiveLink for Matlab can only export the isosurfaces that are actually in the model. What do you mean by broken? Do you require the exported mesh to be water tight?

If you send an example model to support we may be able to help you with your work flow.

-------------------
Lars Gregersen
Comsol Denmark
Comsol and its LiveLink for Matlab can only export the isosurfaces that are actually in the model. What do you mean by broken? Do you require the exported mesh to be water tight? If you send an example model to support we may be able to help you with your work flow.

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 17.06.2019, 10:05 GMT-4
Updated: 5 years ago 17.06.2019, 10:05 GMT-4

Hey Lars, Thank you for you answer. I don't really understand what you mean by "isosurfaces that are actually in the model", the isosurfaces that we are looking for are in the results, extracted with an isosurface plot. We would need an equivalent to: Right click on the isosurface plot > Add plot to export > in the export node, select VTK as export format.

The broken mesh aspect is actually secondary issue for us, since we manipulate the mesh in post-processing anyways. But we were a bit surprised that some triangles are missing from the surface. Such as shown in broken_mesh.png.

You can find attached a simple model illustrating that.

Hey Lars, Thank you for you answer. I don't really understand what you mean by "isosurfaces that are actually in the model", the isosurfaces that we are looking for are in the results, extracted with an isosurface plot. We would need an equivalent to: Right click on the isosurface plot > Add plot to export > in the export node, select VTK as export format. The broken mesh aspect is actually secondary issue for us, since we manipulate the mesh in post-processing anyways. But we were a bit surprised that some triangles are missing from the surface. Such as shown in `broken_mesh.png`. You can find attached a simple model illustrating that.


Gunnar Andersson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 17.06.2019, 11:10 GMT-4

In 5.4 and earlier COMSOL versions, isosurfaces can have small holes if the isosurface curves sharply (compared to the local element size). This will be fixed in the next major release, tentatively schedules for this fall.

In 5.4 and earlier COMSOL versions, isosurfaces can have small holes if the isosurface curves sharply (compared to the local element size). This will be fixed in the next major release, tentatively schedules for this fall.

Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 18.06.2019, 04:37 GMT-4
Updated: 5 years ago 18.06.2019, 04:37 GMT-4

Hi Dorian

I simply meant that both LiveLink for Matlab and the VTK export uses the data that is in the model (results). Exporting to VTK gives the same data as using pd = mphplot(model, 'pg3') The variable pd then contains the data you need in pd{2}{1}.

You can of course export your data to a VTK file using the API if you want. Just make an export from Comsol and save the model as an M-file to learn the syntax.

-------------------
Lars Gregersen
Comsol Denmark
Hi Dorian I simply meant that both LiveLink for Matlab *and* the VTK export uses the data that is in the model (results). Exporting to VTK gives the same data as using pd = mphplot(model, 'pg3') The variable pd then contains the data you need in pd{2}{1}. You can of course export your data to a VTK file using the API if you want. Just make an export from Comsol and save the model as an M-file to learn the syntax.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.