How to acess the values of a Table

From KratosWiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "Tables are stored in the ModelPart. If you want to acces the data of a table, you must know the Id of this table. Then, if you want to acces table 2 from C++ you can do: ModelP...")
 
Line 6: Line 6:
  
 
  table_2 = modelpart.GetTable(2)
 
  table_2 = modelpart.GetTable(2)
 +
 +
  
 
If you have a table written in the input file (mdpa file) like this one:
 
If you have a table written in the input file (mdpa file) like this one:
Line 21: Line 23:
  
 
  temperature_at_time_0_5 = table_2.GetValue(0.5)
 
  temperature_at_time_0_5 = table_2.GetValue(0.5)
 +
 +
  
 
The result will be ''temperature_at_time_0_5 = 1.25'', because it's interpolated automatically.
 
The result will be ''temperature_at_time_0_5 = 1.25'', because it's interpolated automatically.

Revision as of 13:44, 23 March 2016

Tables are stored in the ModelPart. If you want to acces the data of a table, you must know the Id of this table. Then, if you want to acces table 2 from C++ you can do:

ModelPart::Table<double,double>& table_2 = modelpart.GetTable(2);

You can do the same in Python:

table_2 = modelpart.GetTable(2)


If you have a table written in the input file (mdpa file) like this one:

Begin Table 2 TIME TEMPERATURE
0.0  1.0
1.0  1.5
End Table

accessing its values is simple. Do this in C++:

double temperature_at_time_0_5 = table_2.GetValue(0.5)

or in Python:

temperature_at_time_0_5 = table_2.GetValue(0.5)


The result will be temperature_at_time_0_5 = 1.25, because it's interpolated automatically.

Of course, you can do it all in a single line by doing in C++:

double temperature_at_time_0_5 = modelpart.GetTable(2).GetValue(0.5)

or in Python:

temperature_at_time_0_5 = modelpart.GetTable(2).GetValue(0.5)
Personal tools
Categories