|
|
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.
|
|
|
|
|
|
`Table.geo`
|
|
|
|
|
|
```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};
|
|
|
Line Loop(5) = {4, 1, 2, 3};
|
|
|
Plane Surface(6) = {5};
|
|
|
Physical Surface(7) = {6};
|
|
|
```
|
|
|
|
|
|
`Table.pro`
|
|
|
|
|
|
```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 = {
|
|
|
0,0,
|
|
|
0.1,1,
|
|
|
0.2,4,
|
|
|
0.3,9,
|
|
|
0.4,16,
|
|
|
0.5,25,
|
|
|
0.6,36,
|
|
|
0.7,49,
|
|
|
0.8,64,
|
|
|
0.9,81,
|
|
|
1,100
|
|
|
};
|
|
|
|
|
|
// Lists can also be loaded from a file. The structure is the same but the values are separated by spaces!
|
|
|
MyListB = ListFromFile["C:\Users\AsamMich\Stromis_Daten_auf_C\Gmsh_GetDP\Wiki_GetDP\Miscellaneous\UsageOfTables\Table_1D.txt"];
|
|
|
|
|
|
|
|
|
// 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
|
|
|
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)
|
|
|
|
|
|
// 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(Nv)) g(u(2),v(Nv)) g(u(3),v(Nv)) ... g(u(Nu),v(Nv))
|
|
|
|
|
|
MyList2D = ListFromFile["C:\Users\AsamMich\Stromis_Daten_auf_C\Gmsh_GetDP\Wiki_GetDP\Miscellaneous\UsageOfTables\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
|
|
|
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
|
|
|
Galerkin { [ Dof{H}, {H} ]; In Surf; Integration I1; Jacobian JVol; }
|
|
|
Galerkin { [ -g_List[X[],Y[]], {H} ]; In Surf; Integration I1; Jacobian JVol; }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
Resolution {
|
|
|
{ Name EvalList;
|
|
|
System {
|
|
|
{ Name SetH; NameOfFormulation SetH; }
|
|
|
}
|
|
|
Operation {
|
|
|
InitSolution[SetH];
|
|
|
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{ Local{ [ f_A[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fB; Value{ Local{ [ f_B[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fC; Value{ Local{ [ f_C[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fD; Value{ Local{ [ f_D[ X[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name fAnalytic; Value{ Local{ [ 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{ Local{ [ g_List[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name gAnalytic; Value{ Local{ [ g_Analytic[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
|
|
|
// The function "dInterpolationBilinear" is implemented since version 2.3.1
|
|
|
{ Name gDerivativeList; Value{ Local{ [ g_Derivative_List[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
{ Name gDerivativeAnalytic; Value{ Local{ [ g_Derivative_Analytic[ X[], Y[] ] ]; In Surf; Jacobian JVol;} } }
|
|
|
|
|
|
{ Name H; Value{ Local{ [ {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`
|
|
|
|
|
|
```
|
|
|
0 0
|
|
|
0.1 1
|
|
|
0.2 4
|
|
|
0.3 9
|
|
|
0.4 16
|
|
|
0.5 25
|
|
|
0.6 36
|
|
|
0.7 49
|
|
|
0.8 64
|
|
|
0.9 81
|
|
|
1 100
|
|
|
```
|
|
|
|
|
|
`Table_2D.txt`
|
|
|
|
|
|
```
|
|
|
6 11
|
|
|
0 0.2 0.4 0.6 0.8 1
|
|
|
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
|
|
|
0 10 20 30 40 50
|
|
|
1 11 21 31 41 51
|
|
|
4 14 24 34 44 54
|
|
|
9 19 29 39 49 59
|
|
|
16 26 36 46 56 66
|
|
|
25 35 45 55 65 75
|
|
|
36 46 56 66 76 86
|
|
|
49 59 69 79 89 99
|
|
|
64 74 84 94 104 114
|
|
|
81 91 101 111 121 131
|
|
|
100 110 120 130 140 150
|
|
|
```
|
|
|
|
|
|
----
|
|
|
*Initially written by @AsamMich.*
|
|
|
|