Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

problem by loading mesh from text data

Please login with a confirmed email address before reporting spam

Hi,

I want to load a mesh generated by an external program using the following code (as explained in the comsol multiphysics scripting guide):

load coord.txt
load vertices.txt
el = cell(1,0);
vertices = vertices+1;
el{1} = struct('type','vertices','elem',vertices');
m = femmesh(coord',el);
m = meshenrich(m);
meshplot(m);

where 'vertices.txt' contains the indices of the nodes and 'coord.txt' contains the coordinates of the mesh vertices.
For a 2D squared geometry of length 1, the file 'vertices.txt' contains:
1 7 0 4
2 8 1 7
3 9 2 8
4 7 5 10
6 5 11 10
8 12 7 10
13 12 9 8
12 14 10 11
14 12 15 13
and the file 'coord.txt' contains:
0 1
0 0.66666666666666641
0 0.3333333333333332
0 0
0.3333333333333332 1
0.66666666666666641 1
1 1
0.33333333333333326 0.66666666666666652
0.33333333333333326 0.33333333333333326
0.3333333333333332 0
0.66666666666666663 0.66666666666666663
1 0.66666666666666641
0.66666666666666652 0.33333333333333326
0.66666666666666641 0
1 0.3333333333333332
1 0

But I get the following error from Comsol:
An error occurred when opening the m-file. Loaded data will be incomplete. Index out of bounds in exchange processing.

Does Anyone know where this error is coming from?

Actually I only want to use easily shaped geometries (rectangular) in 2D or in 3D with some singularities (point sources) and I want to mesh these geometries with a structured rectangular grid whose nodes are located on the singularities.

Thanks a lot for your help




3 Replies Last Post Mar 15, 2011, 1:08 p.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 28, 2009, 9:32 a.m. EDT
Hi,
try with:
....
....
el{1} = struct('type','quad','elem',vertices');
m = femmesh(coord',el);
m = meshenrich(m);

In this way you translate the imported quad mesh into a quad-based mesh in comsol. Note that te last row is needed because it create the mesh/geometry structure (vertices, edge, faces,...) which can be used into a simulation.

I hope this can help you!

Regards

Pasquale
Hi, try with: .... .... el{1} = struct('type','quad','elem',vertices'); m = femmesh(coord',el); m = meshenrich(m); In this way you translate the imported quad mesh into a quad-based mesh in comsol. Note that te last row is needed because it create the mesh/geometry structure (vertices, edge, faces,...) which can be used into a simulation. I hope this can help you! Regards Pasquale

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 28, 2009, 3:04 p.m. EDT
Hi,

Thanks a lot! That was the point.

Regards

Magalie


Hi, Thanks a lot! That was the point. Regards Magalie

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 15, 2011, 1:08 p.m. EDT
hello,
I was trying to run the same sample square, the code and data points of which you have mentioned and I am not able to load the geometry to COMSOL. I am able to do it in MATLAB, which I am assuming is a bit different from the model M file required for COMSOL to make the geometry. I have no idea how to shift from plain M file to a comsol model M file. Please help me.

Thanks

nikhil
hello, I was trying to run the same sample square, the code and data points of which you have mentioned and I am not able to load the geometry to COMSOL. I am able to do it in MATLAB, which I am assuming is a bit different from the model M file required for COMSOL to make the geometry. I have no idea how to shift from plain M file to a comsol model M file. Please help me. Thanks nikhil

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.