|
|
Here is an example showing how to use tables and how to interpolate the table based data depending on one or two variables.
|
|
|
|
|
|
Some of the tables are within the GetDP input file (`Table.pro`) and some are in separate files.
|
|
|
All tables are handled by GetDP as simple lists, which can be defined either directly in the `.pro` files, or in separate ASCII text files.
|
|
|
|
|
|
`Table.geo`
|
|
|
The following files show how to import tabular data and interpolate 1D and 2D data:
|
|
|
|
|
|
```cpp
|
|
|
Point(1) = {0, 0, 0, 0.01};
|
|
|
Point(2) = {1, 0, 0, 0.01};
|
|
|
Point(3) = {1, 1, 0, 0.01};
|
|
|
Point(4) = {0, 1, 0, 0.01};
|
|
|
Line(1) = {1, 2};
|
|
|
Line(2) = {2, 3};
|
|
|
Line(3) = {3, 4};
|
|
|
Line(4) = {4, 1};
|
|
|
Curve Loop(5) = {4, 1, 2, 3};
|
|
|
Plane Surface(6) = {5};
|
|
|
Physical Surface(7) = {6};
|
|
|
```
|
|
|
* Geometry: [Table.geo](Table.geo)
|
|
|
* Problem definition: [Table.pro](Table.pro)
|
|
|
* 1D and 2D datasets: [Table_1D.txt](Table_1D.txt) and [Table_2D.txt](Table_2D.txt)
|
|
|
|
|
|
`Table.pro`
|
|
|
Here is an excerpt from `Table.pro` highlighting the important parts:
|
|
|
|
|
|
```cpp
|
|
|
Group {
|
|
|
|
|
|
// Surfaces
|
|
|
Surf = Region[7];
|
|
|
|
|
|
}
|
|
|
|
|
|
Function {
|
|
|
|
|
|
// 1D Tables: Value depends only on just one variable -> f(u) = (10 * u)^2
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
// The list here consists of pairs of u and f. The u values have to be in
|
|
|
// in an ascending order. To make the list better readable the table here
|
|
|
// is written in that way that the values for u are in the first column
|
|
|
// and the values of f are in the second one.
|
|
|
// All values are separated by commas.
|
|
|
MyListA = {
|
|
|
|
|
|
// The list here consists of pairs of u and f. The u values have to be in in
|
|
|
// an ascending order. To make the list better readable the table here is
|
|
|
// written in that way that the values for u are in the first column and the
|
|
|
// values of f are in the second one. All values are separated by commas.
|
|
|
MyListA() = {
|
|
|
0,0,
|
|
|
0.1,1,
|
|
|
0.2,4,
|
... | ... | @@ -51,207 +33,58 @@ Function { |
|
|
0.9,81,
|
|
|
1,100
|
|
|
};
|
|
|
|
|
|
// Lists can also be loaded from a file. The structure is the same but the
|
|
|
|
|
|
// Lists can also be loaded from a file. The structure is the same but the
|
|
|
// values are separated by spaces!
|
|
|
MyListB = ListFromFile["Table_1D.txt"];
|
|
|
MyListB() = ListFromFile["Table_1D.txt"];
|
|
|
|
|
|
|
|
|
// The values for u and f can be in separate lists which then must be combined
|
|
|
// The values for u and f can be in separate lists which then must be combined
|
|
|
// to one list before doing the interpolation.
|
|
|
uList = { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 };
|
|
|
fList = { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 };
|
|
|
MyListC = ListAlt[uList(), fList()];
|
|
|
|
|
|
// Now let's do the interpolation
|
|
|
f_A[] = InterpolationLinear[$1]{MyListA()}; // Linear interpolation between the table values
|
|
|
f_B[] = dInterpolationLinear[$1]{MyListB()}; // 1st derivative of the linearly interpolated table values
|
|
|
f_C[] = InterpolationAkima[$1]{MyListC()}; // Akima interpolation (3rd order spline interpolation, continuously differentiable)
|
|
|
// See also: http://www.iue.tuwien.ac.at/phd/rottinger/node60.html
|
|
|
f_D[] = dInterpolationAkima[$1]{MyListC()}; // 1st derivative of Akima interpolated values
|
|
|
uList() = { 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1 };
|
|
|
fList() = { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 };
|
|
|
MyListC() = ListAlt[uList(), fList()];
|
|
|
|
|
|
// Now let's do the interpolation:
|
|
|
// - Linear interpolation between the table values
|
|
|
f_A[] = InterpolationLinear[$1]{MyListA()};
|
|
|
// - 1st derivative of the linearly interpolated table values
|
|
|
f_B[] = dInterpolationLinear[$1]{MyListB()};
|
|
|
// - Akima interpolation (3rd order spline interpolation, continuously differentiable)
|
|
|
// See also: http://www.iue.tuwien.ac.at/phd/rottinger/node60.html
|
|
|
f_C[] = InterpolationAkima[$1]{MyListC()};
|
|
|
// - 1st derivative of Akima interpolated values
|
|
|
f_D[] = dInterpolationAkima[$1]{MyListC()};
|
|
|
f_Analytic[] = ($1 * 10.0)^2;
|
|
|
|
|
|
|
|
|
// 2D Tables: Value depends on two variables -> g(u, v) = 50 * u + (10 * v)^2
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
// The 2D table has the following elements (note that they are separated with space, no comma):
|
|
|
// (Nu = Number of u values; Nv = Number of v values)
|
|
|
|
|
|
// The 2D table has the following elements (Nu = Number of u values; Nv =
|
|
|
// Number of v values)
|
|
|
|
|
|
// Nu Nv
|
|
|
// u(1) u(2) u(3) ... u(Nu)
|
|
|
// v(1) v(2) v(3) ... v(Nv)
|
|
|
// g(u(1),v(1)) g(u(2),v(1)) g(u(3),v(1)) ... g(u(Nu),v(1))
|
|
|
// g(u(1),v(2)) g(u(2),v(2)) g(u(3),v(2)) ... g(u(Nu),v(2))
|
|
|
// g(u(1),v(3)) g(u(2),v(3)) g(u(3),v(3)) ... g(u(Nu),v(3))
|
|
|
// g(u(1),v(1)) g(u(2),v(1)) g(u(3),v(1)) ... g(u(Nu),v(1))
|
|
|
// g(u(1),v(2)) g(u(2),v(2)) g(u(3),v(2)) ... g(u(Nu),v(2))
|
|
|
// g(u(1),v(3)) g(u(2),v(3)) g(u(3),v(3)) ... g(u(Nu),v(3))
|
|
|
// ...
|
|
|
// g(u(1),v(Nv)) g(u(2),v(Nv)) g(u(3),v(Nv)) ... g(u(Nu),v(Nv))
|
|
|
|
|
|
MyList2D = ListFromFile["Table_2D.txt"];
|
|
|
// g(u(1),v(Nv)) g(u(2),v(Nv)) g(u(3),v(Nv)) ... g(u(Nu),v(Nv))
|
|
|
|
|
|
MyList2D() = ListFromFile["Table_2D.txt"];
|
|
|
|
|
|
g_List[] = InterpolationBilinear[$1,$2]{MyList2D()};
|
|
|
g_Analytic[] = 50.0 * $1 + ($2 * 10.0)^2;
|
|
|
|
|
|
// The function "dInterpolationBilinear" is implemented since version 2.3.1
|
|
|
|
|
|
// The function "dInterpolationBilinear" is implemented since version 2.3.1
|
|
|
g_Derivative_List[] = dInterpolationBilinear[$1,$2]{MyList2D()};
|
|
|
g_Derivative_Analytic[] = Vector[ 50.0, $2 * 200.0, 0 ];
|
|
|
}
|
|
|
|
|
|
Constraint {
|
|
|
{ Name HConstr;
|
|
|
Case {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Jacobian {
|
|
|
{ Name JVol;
|
|
|
Case {
|
|
|
{ Region Region[{Surf}]; Jacobian Sur; }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Integration {
|
|
|
{ Name I1 ;
|
|
|
Case {
|
|
|
{ Type Gauss ;
|
|
|
Case {
|
|
|
{ GeoElement Point ; NumberOfPoints 1 ; }
|
|
|
{ GeoElement Line ; NumberOfPoints 5 ; }
|
|
|
{ GeoElement Triangle ; NumberOfPoints 6 ; }
|
|
|
{ GeoElement Quadrangle ; NumberOfPoints 7 ; }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
FunctionSpace {
|
|
|
{ Name FS_H; Type Form0;
|
|
|
BasisFunction {
|
|
|
{ Name sn; NameOfCoef Hn; Function BF_Node; Support Surf; Entity NodesOf[All]; }
|
|
|
}
|
|
|
Constraint {
|
|
|
{ NameOfCoef Hn; EntityType NodesOf ; NameOfConstraint HConstr; }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Formulation {
|
|
|
{ Name SetH; Type FemEquation;
|
|
|
Quantity {
|
|
|
{ Name H; Type Local; NameOfSpace FS_H; }
|
|
|
}
|
|
|
Equation {
|
|
|
// Here we simply set the values of H according the values from the function g_List
|
|
|
Integral { [ Dof{H}, {H} ]; In Surf; Integration I1; Jacobian JVol; }
|
|
|
Integral { [ -g_List[X[],Y[]], {H} ]; In Surf; Integration I1; Jacobian JVol; }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Resolution {
|
|
|
{ Name EvalList;
|
|
|
System {
|
|
|
{ Name SetH; NameOfFormulation SetH; }
|
|
|
}
|
|
|
Operation {
|
|
|
Generate[SetH];
|
|
|
Solve[SetH];
|
|
|
SaveSolution[SetH];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
PostProcessing {
|
|
|
{ Name Postpro; NameOfFormulation SetH;
|
|
|
Quantity {
|
|
|
// Values derived from the 1D tables with the x-position as function argument -> f(x)
|
|
|
{ Name fA; Value{ Term{ [ f_A[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fB; Value{ Term{ [ f_B[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fC; Value{ Term{ [ f_C[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fD; Value{ Term{ [ f_D[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fAnalytic; Value{ Term{ [ f_Analytic[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
|
|
|
// Values derived from the 2D table with the x- and y-position as function arguments -> g(x,y)
|
|
|
{ Name gList; Value{ Term{ [ g_List[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name gAnalytic; Value{ Term{ [ g_Analytic[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
|
|
|
// The function "dInterpolationBilinear" is implemented since version 2.3.1
|
|
|
{ Name gDerivativeList; Value{ Term{ [ g_Derivative_List[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name gDerivativeAnalytic; Value{ Term{ [ g_Derivative_Analytic[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name H; Value{ Term{ [ {H} ]; In Surf; Jacobian JVol;} } }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
PostOperation {
|
|
|
{ Name fA; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ fA, OnElementsOf Surf, File "Result_fA.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{ Name fB; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ fB, OnElementsOf Surf, File "Result_fB.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{ Name fC; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ fC, OnElementsOf Surf, File "Result_fC.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{ Name fD; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ fD, OnElementsOf Surf, File "Result_fD.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{ Name fAnalytic; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ fAnalytic, OnElementsOf Surf, File "Result_fAnalytic.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{ Name gList; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ gList, OnElementsOf Surf, File "Result_gList.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{ Name gAnalytic; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ gAnalytic, OnElementsOf Surf, File "Result_gAnalytic.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// The function "dInterpolationBilinear" is implemented since version 2.3.1
|
|
|
{ Name gDerivative; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ gDerivativeList, OnElementsOf Surf, File "Result_gDerivativeList.pos"];
|
|
|
Print[ gDerivativeAnalytic, OnElementsOf Surf, File "Result_gDerivativeAnalytic.pos"];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
{ Name H; NameOfPostProcessing Postpro;
|
|
|
Operation {
|
|
|
Print[ H, OnElementsOf Surf, File "Result_H.pos"];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
`Table_1D.txt`
|
|
|
There is no special format for tabular data imported from separate files:
|
|
|
numbers should simply be separacted by white space (spaces, newlines, tabs are
|
|
|
all accepted). For example `Table_1D.txt` contains:
|
|
|
|
|
|
```
|
|
|
0 0
|
... | ... | @@ -267,7 +100,7 @@ PostOperation { |
|
|
1 100
|
|
|
```
|
|
|
|
|
|
`Table_2D.txt`
|
|
|
and `Table_2D.txt` contains:
|
|
|
|
|
|
```
|
|
|
6 11
|
... | ... | |