Development tools (panels.dev)#

Tabulation of the approximation functions (panels.dev.tabulate)#

Tabulation of the approximation functions in the numerical kernels

The numerically integrated kernels, e.g. fkC_num of panels/models/<model>_num.pyx or fkCSB11_dmg of panels/multidomain/connections/kCSB_dmg.pyx, evaluate the approximation functions inside their loops over the terms, e.g. fBu = f(k, xi, x1u, x1ur, x2u, x2ur) in the innermost loop over the pairs of terms of a stiffness matrix. tabulate_basis() rewrites a kernel such that each function is evaluated once per integration point and term, in tables such as ftab[k, i] along \(x\) and gtab[k, j] along \(y\), filled at the start of the loop over the integration points and read in the loops over the terms. The arithmetic of the integrands is unchanged, so are the results, bit for bit.

A call NAME = f(IDX, COORD, x1F, x1Fr, x2F, x2Fr), with f, fp or fpp, the boundary flags x1F... along \(x\) or y1F... along \(y\) of the field F and an optional suffix of the panel, e.g. x1u1, x1ur1, x2u1, x2ur1, becomes NAME = ftab1[k, IDX], with one table per direction, suffix and coordinate COORD, whose number of columns is that of the loop for IDX in range(...) of the kernel, and which is filled with IDX as loop variable. Without a loop over the integration points enclosing the calls, e.g. along a line of constant \(\xi\) of the connections, the tables are filled once, before the outermost loop over the terms. A kernel is left unchanged when it has no such call, or when it is already tabulated. A call in another form raises a ValueError.

The integration points, the numbers of terms and the boundary flags of a shell do not change from one call of a kernel to the next, nor do the tables. keep_tables(), applied last by tabulate_basis(), rewrites the kernels with a shell argument such that they keep their tables on the shell across calls, one row per integration point, with the key of all the values the tables depend on, see panels.basis_tables: the tables are filled at the first call, or after a change of the key, and only read afterwards.

The scripts that generate the kernel modules from the symbolic integrands apply tabulate_basis() or keep_tables() to their output; python -m panels.dev.tabulate <file.pyx> ... applies both to the modules written by hand.

Notes#

An entry of a numerically integrated stiffness matrix between the terms \((i, j)\) and \((k, l)\) of the Ritz series is a sum over the Gauss-Legendre points of products of the approximation functions \(P_i(\xi)\), \(P_k(\xi)\), \(P_j(\eta)\) and \(P_l(\eta)\), and of their derivatives, see panels.bardell. In the innermost loop over the pairs of terms each function is evaluated \(m^2 n^2\) times per integration point, although it depends on one index and one coordinate only. Tabulated, it is evaluated \(m\) (or \(n\)) times per point, and the cost of the functions becomes negligible against the \(m^2 n^2\) products of the assembly. Since only where the values are computed changes, and not the operations on them, the results are identical.

panels.dev.tabulate.keep_tables(source)#

Keep the tables of approximation functions of the kernels of the module source across calls, on the shell

Each table TAB of shape (rows, terms) filled by a loop for IDX in range(SIZE): of rows TAB[ROW, IDX] = EXPR in the loops over the integration points of a nogil block becomes a table of shape (points, rows, terms), with one entry per point of the loop over the integration points that its coordinate depends on, looked up with panels.basis_tables.lookup_table() before the nogil block, filled only when it is new, stored with panels.basis_tables.store_table() after the block and read as TAB[PT, ROW, IDX]. The key of the table gathers the names that EXPR depends on, through the assignments in the loops over the points, e.g. xis, xi1, xi2 of the coordinate xi, the boundary flags and the dimensions, together with SIZE and the number of points; a ValueError is raised when this dependence cannot be established, e.g. for a name assigned conditionally, or modified in the nogil block. The functions already rewritten are left unchanged, and so are the tables filled outside the loops over the integration points, e.g. at a single point given as argument.

Parameters:
sourcestr

The text of a .pyx module, with tabulated kernels, or of a part of a module.

Returns:
sourcestr

The rewritten text, with the import of the functions of panels.basis_tables after the line from panels import ..., when there is one and the import is missing.

panels.dev.tabulate.tabulate_basis(source)#

Tabulate the approximation functions of every kernel of the module source, see the module docstring, and keep the tables across calls, see keep_tables()

The source is split before each line starting with def, cdef or cpdef; only the parts that are def functions are rewritten, the others are kept as they are. A ValueError is raised for a kernel whose calls are not in the expected form.

Parameters:
sourcestr

The text of a .pyx module.

Returns:
sourcestr

The rewritten text, equal to source when no kernel is changed.

Generator of Bardell’s functions#

The C++ evaluation of Bardell’s functions, panels/core/src/bardell_functions.cpp, is written by the SymPy script theory/func/bardell/bardell_functions_C.py, which expands the exact polynomials of the definition and their derivatives and writes each one by Horner’s rule, see Bardell’s hierarchical functions:

python theory/func/bardell/bardell_functions_C.py

followed by a new build of the extensions. The script is not part of the package.