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["Table_1D.dat"]; // 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: // - 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 (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["Table_2D.dat"]; 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 ]; } Jacobian { { Name JVol; Case { { Region Region[{Surf}]; Jacobian Vol; } } } } 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]; } } } } 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; } } } { 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"]; Print[ fB, OnElementsOf Surf, File "Result_fB.pos"]; Print[ fC, OnElementsOf Surf, File "Result_fC.pos"]; Print[ fD, OnElementsOf Surf, File "Result_fD.pos"]; Print[ fAnalytic, OnElementsOf Surf, File "Result_fAnalytic.pos"]; Print[ gList, OnElementsOf Surf, File "Result_gList.pos"]; Print[ gAnalytic, OnElementsOf Surf, File "Result_gAnalytic.pos"]; Print[ gDerivativeList, OnElementsOf Surf, File "Result_gDerivativeList.pos"]; Print[ gDerivativeAnalytic, OnElementsOf Surf, File "Result_gDerivativeAnalytic.pos"]; Print[ H, OnElementsOf Surf, File "Result_H.pos"]; } } }