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.

Importing external line segments for 2D geometry, 4.0a

Please login with a confirmed email address before reporting spam

Dear comsol users,
I was wandering if someone could help me with this problem:
In 2D, I would like to draw a line, which follows a given expression (for instance, y(x)=sin(2*pi*x)) sampled, let's say, every deltaX space intervals.
I know I can create a table with the pairs of points (x1,y1) (x2,y2) (x3,y3), etc. in excel, matlab or any other software, the problem is that typing all those points as "line segments" will take ages if using the GUI for more than, let' say, 20 points.

Is there any way of importing points from file? this would avoid typing massive data in the GUI. I have seen that one could do so with user-defined functions.
Thanks a lot for your help
john

11 Replies Last Post Dec 18, 2010, 4:09 a.m. EST
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 28, 2010, 2:42 p.m. EDT
Hi

if we believe www.comsol.eu/products/formats/ there should be txt file format at least as possible,

But if you study the splines of COMSOL (check the doc) I believe you should be able to make a small matlab routine to generate a curve even smoother than segmeted straight lines

--
Good luck
Ivar
Hi if we believe http://www.comsol.eu/products/formats/ there should be txt file format at least as possible, But if you study the splines of COMSOL (check the doc) I believe you should be able to make a small matlab routine to generate a curve even smoother than segmeted straight lines -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 28, 2010, 4:05 p.m. EDT
Hi Ivar,
Thanks for your kind replay. I know I can do much better than linear interpolation, but the problem is still the same:

Let's us suppose I have a bunch of spline points, (as described somewhere in the user guide) I cannot read this file from the GUI.
I don't have livelink to Matlab, so I was wandering whether there was an easy way of importing this type of data from file or not (so I don't have to type in the GUI).

The link you refer doesn't include the possibility to open point-cloud files, even though it isn't more complicated than opening a "colortable" or an "interpolation function".

Perhaps someone has investigated how to do this via modifying comsol's java file?

Thanks
john
Hi Ivar, Thanks for your kind replay. I know I can do much better than linear interpolation, but the problem is still the same: Let's us suppose I have a bunch of spline points, (as described somewhere in the user guide) I cannot read this file from the GUI. I don't have livelink to Matlab, so I was wandering whether there was an easy way of importing this type of data from file or not (so I don't have to type in the GUI). The link you refer doesn't include the possibility to open point-cloud files, even though it isn't more complicated than opening a "colortable" or an "interpolation function". Perhaps someone has investigated how to do this via modifying comsol's java file? Thanks john

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 29, 2010, 4:28 a.m. EDT
Hi

have you tried to study :

"Definitions Functions Interpolation" there you have a txt file Load/import option

--
Good luck
Ivar
Hi have you tried to study : "Definitions Functions Interpolation" there you have a txt file Load/import option -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 29, 2010, 6:46 a.m. EDT
Hi Ivar,
Yes, indeed that is a very handy feature of comsol (one could even use multivariate data import), the problem is that when defining such a function from txt file, you can use it everywhere in comsol (such us material data, boundary condition, plotting, etc), but not inside the Geometry Node. That is, it cannot be used for drawing.

That is why I'm asking other comsolers if they have been able to do something like "draw from file".

thanks
John
Hi Ivar, Yes, indeed that is a very handy feature of comsol (one could even use multivariate data import), the problem is that when defining such a function from txt file, you can use it everywhere in comsol (such us material data, boundary condition, plotting, etc), but not inside the Geometry Node. That is, it cannot be used for drawing. That is why I'm asking other comsolers if they have been able to do something like "draw from file". thanks John

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 29, 2010, 7:24 a.m. EDT
Hi

I missed that point ;)
Then I see only importing in a CAD tool (thats my way).

I can live without matlab (at least I'm trying in V4 as I must re-learn about everything) but NOT without an external CAD tool (mine is SW, but the others are probably as good), even if COMSOL CAD has strongly improved.
And often I receive the CAD from my colleague or clients and before running FEm on it, I need to defeature and split to help the meshing

--
Good luck
Ivar
Hi I missed that point ;) Then I see only importing in a CAD tool (thats my way). I can live without matlab (at least I'm trying in V4 as I must re-learn about everything) but NOT without an external CAD tool (mine is SW, but the others are probably as good), even if COMSOL CAD has strongly improved. And often I receive the CAD from my colleague or clients and before running FEm on it, I need to defeature and split to help the meshing -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 29, 2010, 6:09 p.m. EDT
Hi Ivar,
Sure you are right, for more advanced geometries one cannot rely on comsol CAD, and one must go via an external CAD software.

My point was, and still is, that it is a pity that such a wonderful software, that can do almost as much I could ever dream, is not able to import a simple txt file with x,y coordinates. It is so annoying to know that I can type all those points in the GUI, but it will take ages to do it for more than 15 points.

Imagine all kind of problems in CFD, heat transfer or electromagnetics we could solve without going into complicate CAD software. We could draw parabolic, hyperbolic curves (beside the built-in primitives), or import points for drawing the NACA airfoils, etc.

Anyway, it seems that none in this forum could through some light, beside comsol developers. Any hints?

cheers
john



Hi Ivar, Sure you are right, for more advanced geometries one cannot rely on comsol CAD, and one must go via an external CAD software. My point was, and still is, that it is a pity that such a wonderful software, that can do almost as much I could ever dream, is not able to import a simple txt file with x,y coordinates. It is so annoying to know that I can type all those points in the GUI, but it will take ages to do it for more than 15 points. Imagine all kind of problems in CFD, heat transfer or electromagnetics we could solve without going into complicate CAD software. We could draw parabolic, hyperbolic curves (beside the built-in primitives), or import points for drawing the NACA airfoils, etc. Anyway, it seems that none in this forum could through some light, beside comsol developers. Any hints? cheers john

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 29, 2010, 10:00 p.m. EDT
Good day John,
This procedure worked for 3.5a but I'm not sure the new spline GUI will permit it in 4.0. If not then one could create the spline in 3.5 and export the mphbin file, and then bring it into 4.0.

In a nutshell X,Y coordinate pairs are formed in a spread sheet with X and Y in separate columns. In COMSOL then a shift/click would open the spline GUI and two fields would be available.....one each for x and y values. I could then simply cut and paste the entire columns of values from the spreadsheet into the respective fields.

Maybe this will help.
Marty
Good day John, This procedure worked for 3.5a but I'm not sure the new spline GUI will permit it in 4.0. If not then one could create the spline in 3.5 and export the mphbin file, and then bring it into 4.0. In a nutshell X,Y coordinate pairs are formed in a spread sheet with X and Y in separate columns. In COMSOL then a shift/click would open the spline GUI and two fields would be available.....one each for x and y values. I could then simply cut and paste the entire columns of values from the spreadsheet into the respective fields. Maybe this will help. Marty

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 30, 2010, 12:54 p.m. EDT
Hi Marty,
Many thanks, you are right. In 3.5a, I could copy-paste a bunch of x,y coordinate in the drawing part of the GUI (line segments or just a bunch of points), that specific feature was removed from 4.0a.

I'm planning a more insdustrialized application, so I could use java model files to handle line segments in txt files, so avoiding user interaction. Let's hope this feature is back in comsol 4.1

thanks
john

Hi Marty, Many thanks, you are right. In 3.5a, I could copy-paste a bunch of x,y coordinate in the drawing part of the GUI (line segments or just a bunch of points), that specific feature was removed from 4.0a. I'm planning a more insdustrialized application, so I could use java model files to handle line segments in txt files, so avoiding user interaction. Let's hope this feature is back in comsol 4.1 thanks john

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 31, 2010, 3:42 a.m. EDT
Hi

Have you sent this as a suggestion to support ?
I find it perfetly justified too

--
Good luck
Ivar
Hi Have you sent this as a suggestion to support ? I find it perfetly justified too -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 17, 2010, 4:41 p.m. EST
I am looking to do the same thing as described above: import a geometry that consists of line segmets or splines or bezier curves or some collection of 1D entities. Also noted this seems to be impossible in Comsol 4.

I have tried to import a SolidWorks file, but because such a line is not a "solid" comsol gives error of empty file (or something to that effect).

Saw this suggestion,

In a nutshell X,Y coordinate pairs are formed in a spread sheet with X and Y in separate columns. In COMSOL then a shift/click would open the spline GUI and two fields would be available.....one each for x and y values. I could then simply cut and paste the entire columns of values from the spreadsheet into the respective fields.


I'm not sure what you mean by shift click, but the dialog box for "line" in 3D mode in Comsol 3.5a has an input box for X, Y and Z, and options of Segments, Polyline or Closed Polyline.

Presently I'm trying to decipher this passage in the help file: "
In the Style list you specify the style of the generated solid object. Select Polyline to generate a solid object with vertices in the specified coordinates. If you select Segments, the specified coordinates must have the structure start1 end1 start2 end2 and so on. This generates a solid object with segments according to the specified start and end coordinate values."

But it looks promising, and I hope to take this .MPH file into Comsol 4.0

(My particular geometry is to draw a solenoid coil, which I have found very difficult to mesh using an actual solid [with volume])
I am looking to do the same thing as described above: import a geometry that consists of line segmets or splines or bezier curves or some collection of 1D entities. Also noted this seems to be impossible in Comsol 4. I have tried to import a SolidWorks file, but because such a line is not a "solid" comsol gives error of empty file (or something to that effect). Saw this suggestion, [QUOTE] In a nutshell X,Y coordinate pairs are formed in a spread sheet with X and Y in separate columns. In COMSOL then a shift/click would open the spline GUI and two fields would be available.....one each for x and y values. I could then simply cut and paste the entire columns of values from the spreadsheet into the respective fields. [/QUOTE] I'm not sure what you mean by shift click, but the dialog box for "line" in 3D mode in Comsol 3.5a has an input box for X, Y and Z, and options of Segments, Polyline or Closed Polyline. Presently I'm trying to decipher this passage in the help file: " In the Style list you specify the style of the generated solid object. Select Polyline to generate a solid object with vertices in the specified coordinates. If you select Segments, the specified coordinates must have the structure start1 end1 start2 end2 and so on. This generates a solid object with segments according to the specified start and end coordinate values." But it looks promising, and I hope to take this .MPH file into Comsol 4.0 (My particular geometry is to draw a solenoid coil, which I have found very difficult to mesh using an actual solid [with volume])

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 18, 2010, 4:09 a.m. EST
Hi

have you shecked the new helice sweep functionalities of V4.1 ? (latest patch check on COMSOL main web site)

I believe the sentence is linked to the way you may define a polyline (open or closed), by a set of coordinates, implicitely foining a line from one to the other and then back (or not) to the first point. And some representations of closed segments by a set of coordinates and then a list of lines linking two by two points.

Transferring surfaces (hence lines and points) from SolidWorks to COMSOL does work but you must play with both the options of SW and COMSOL (export sketch and line geoemtry and test out the different formats (x-T, step, iges, dxf ...) most of these goes into COMSOL in 3D mode, I have only managed to get DXF into COMSOL in 2D mode, lickily now COMSOL accepts 3D DXF (by ignoring Z) what it did not accept at all in v3.5a

--
Good luck
Ivar
Hi have you shecked the new helice sweep functionalities of V4.1 ? (latest patch check on COMSOL main web site) I believe the sentence is linked to the way you may define a polyline (open or closed), by a set of coordinates, implicitely foining a line from one to the other and then back (or not) to the first point. And some representations of closed segments by a set of coordinates and then a list of lines linking two by two points. Transferring surfaces (hence lines and points) from SolidWorks to COMSOL does work but you must play with both the options of SW and COMSOL (export sketch and line geoemtry and test out the different formats (x-T, step, iges, dxf ...) most of these goes into COMSOL in 3D mode, I have only managed to get DXF into COMSOL in 2D mode, lickily now COMSOL accepts 3D DXF (by ignoring Z) what it did not accept at all in v3.5a -- Good luck Ivar

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.