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 .txt file via Interpolation function

Please login with a confirmed email address before reporting spam

Hi people

Well, I created a 3D block, and then I tried to import a .csv or .txt x,y,z coordinates file via Interpolation function, to plot geological layers in the block, but to no avail, and here are my questions:

1 - according to Dynamic Help -> Defining an Interpolation Function, I should be able to import a .csv or a .xls file, but obviously I can only choose .txt file under 'Data Source -> File'
2 - under 'Data Format', I choose 'Spreadsheet' because it seems to be the easiest way
3 - under 'Number of Arguments', I put '2' if I have only x,y,z and '3' if I have x,y,z,c (c has the same value as z)
4 - under 'Function', I tried out different function name, i.e. coorfun, cofun...
Question: how many function I should give if I only have x,y,z, only ONE or THREE?
Question: the 'Position in File' is kind of confusing, in my case, I always had the same x,y for all 7 geological layers, but z is different
5 - under 'Interpolation', I choose 'Linear'
6 - under 'Extrapolation', I choose 'Constant'

I always got the same error message 'The file does not contain a valid interpolation function', what is wrong? is there a standard function name? should I choose different 'Data Format'? should I amend all my coordinates files? etc? or I should not create a block beforehand?

Kindly advise. Many thanks for your time!!

regards
Liwah

8 Replies Last Post Jan 9, 2012, 3:48 a.m. EST

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 28, 2011, 12:25 p.m. EDT
Maybe I misunderstand you, do you want to import the interpolation to create a model geometry or?

To me, the interpolation function make it possible to assign material properties dependent on spatial coordinates, not aware that it's possible to use this to create model geometry.

Also, have you checked "Use space coordinates as arguments"? It's important to checked this option if you want the interpolation to be spatial coordinate dependent.

Hope this helps.
XLi
Maybe I misunderstand you, do you want to import the interpolation to create a model geometry or? To me, the interpolation function make it possible to assign material properties dependent on spatial coordinates, not aware that it's possible to use this to create model geometry. Also, have you checked "Use space coordinates as arguments"? It's important to checked this option if you want the interpolation to be spatial coordinate dependent. Hope this helps. XLi

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 28, 2011, 12:42 p.m. EDT
Hi Li

Since I have a few .txt or .xls or .csv files with field x,y,z data, I would like to import straight away into COMSOL to build a basic model, which consists of 7 geological layers. I was once advised to use a 'function' to do so, maybe I was wrong to use 'Interpolation', what do you think?

Thanks a lot for your ideas!

regards
Liwah

Hi Li Since I have a few .txt or .xls or .csv files with field x,y,z data, I would like to import straight away into COMSOL to build a basic model, which consists of 7 geological layers. I was once advised to use a 'function' to do so, maybe I was wrong to use 'Interpolation', what do you think? Thanks a lot for your ideas! regards Liwah

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 Mar 29, 2011, 12:43 a.m. EDT
Hi

search the forum, there is a tread giving an example for v4

--
Good luck
Ivar
Hi search the forum, there is a tread giving an example for v4 -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 29, 2011, 7:49 a.m. EDT
Hi Ivar

I have been looking through lotsa topics in the forum and couldnt find any, so I posted my question here (sorry if I duplicate the same issue), do you have an idea where is the relevant topic?

Appreciate a lot for your help!

regards
Liwah
Hi Ivar I have been looking through lotsa topics in the forum and couldnt find any, so I posted my question here (sorry if I duplicate the same issue), do you have an idea where is the relevant topic? Appreciate a lot for your help! regards Liwah

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 29, 2011, 8:15 a.m. EDT
Do you think you can import the data as mesh?

It's possible to use Nastran file format to import into Comsol as mesh.
Then you just need to change your txt data according to the nastran format.

XLi
Do you think you can import the data as mesh? It's possible to use Nastran file format to import into Comsol as mesh. Then you just need to change your txt data according to the nastran format. XLi

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 Mar 29, 2011, 3:46 p.m. EDT
Hi

as often I would say yes and now, you need to convert your imported mesh back to a geometry which is not always trivial

try a search for

geom_from_file_test_with_classeur1.txt.mph


--
Good luck
Ivar
Hi as often I would say yes and now, you need to convert your imported mesh back to a geometry which is not always trivial try a search for geom_from_file_test_with_classeur1.txt.mph -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 9, 2012, 3:37 a.m. EST
Hi Liwah,
have you solved this problem? Recently, I encountered the similar problem. through with the help of the example "geom_from_file_test_with_classeur1.txt.mph ", I have not solved the problem using the so-called Parametric Curve to build the geometry in the Geometry node. Could you do me a favor to give me some help and guidance? Thanks sincerely in advance.
Best wishes to you and your family.




Hi people

Well, I created a 3D block, and then I tried to import a .csv or .txt x,y,z coordinates file via Interpolation function, to plot geological layers in the block, but to no avail, and here are my questions:

1 - according to Dynamic Help -> Defining an Interpolation Function, I should be able to import a .csv or a .xls file, but obviously I can only choose .txt file under 'Data Source -> File'
2 - under 'Data Format', I choose 'Spreadsheet' because it seems to be the easiest way
3 - under 'Number of Arguments', I put '2' if I have only x,y,z and '3' if I have x,y,z,c (c has the same value as z)
4 - under 'Function', I tried out different function name, i.e. coorfun, cofun...
Question: how many function I should give if I only have x,y,z, only ONE or THREE?
Question: the 'Position in File' is kind of confusing, in my case, I always had the same x,y for all 7 geological layers, but z is different
5 - under 'Interpolation', I choose 'Linear'
6 - under 'Extrapolation', I choose 'Constant'

I always got the same error message 'The file does not contain a valid interpolation function', what is wrong? is there a standard function name? should I choose different 'Data Format'? should I amend all my coordinates files? etc? or I should not create a block beforehand?

Kindly advise. Many thanks for your time!!

regards
Liwah


Hi Liwah, have you solved this problem? Recently, I encountered the similar problem. through with the help of the example "geom_from_file_test_with_classeur1.txt.mph ", I have not solved the problem using the so-called Parametric Curve to build the geometry in the Geometry node. Could you do me a favor to give me some help and guidance? Thanks sincerely in advance. Best wishes to you and your family. [QUOTE] Hi people Well, I created a 3D block, and then I tried to import a .csv or .txt x,y,z coordinates file via Interpolation function, to plot geological layers in the block, but to no avail, and here are my questions: 1 - according to Dynamic Help -> Defining an Interpolation Function, I should be able to import a .csv or a .xls file, but obviously I can only choose .txt file under 'Data Source -> File' 2 - under 'Data Format', I choose 'Spreadsheet' because it seems to be the easiest way 3 - under 'Number of Arguments', I put '2' if I have only x,y,z and '3' if I have x,y,z,c (c has the same value as z) 4 - under 'Function', I tried out different function name, i.e. coorfun, cofun... Question: how many function I should give if I only have x,y,z, only ONE or THREE? Question: the 'Position in File' is kind of confusing, in my case, I always had the same x,y for all 7 geological layers, but z is different 5 - under 'Interpolation', I choose 'Linear' 6 - under 'Extrapolation', I choose 'Constant' I always got the same error message 'The file does not contain a valid interpolation function', what is wrong? is there a standard function name? should I choose different 'Data Format'? should I amend all my coordinates files? etc? or I should not create a block beforehand? Kindly advise. Many thanks for your time!! regards Liwah [/QUOTE]

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jan 9, 2012, 3:48 a.m. EST
Hi Simon

ended up I created the 3D geometry from scratch, for the reason: a direct import creates a complicated 3D geometry that COMSOL 4.0 couldnt handle i.e. incompatible relative repair tolerance (which leads to a failure of finalization).

up to now, my latest 3D geometry consists of 9 3D geological layers, 4 2D fractures and 2 1D wells, and only with some workarounds, it is postprocessed successfully, else it returns errors anyway.

I will upgrade my COMSOL to latest version sooner or later and see if things work better then. :) good luck!

best regards
Liwah
Hi Simon ended up I created the 3D geometry from scratch, for the reason: a direct import creates a complicated 3D geometry that COMSOL 4.0 couldnt handle i.e. incompatible relative repair tolerance (which leads to a failure of finalization). up to now, my latest 3D geometry consists of 9 3D geological layers, 4 2D fractures and 2 1D wells, and only with some workarounds, it is postprocessed successfully, else it returns errors anyway. I will upgrade my COMSOL to latest version sooner or later and see if things work better then. :) good luck! best regards Liwah

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.