Tables of the approximation functions kept per shell across calls (panels.basis_tables) ==================================================================

The numerically integrated kernels of panels.models evaluate the approximation functions of Bardell, and their derivatives, once per integration point and term, in tables such as ftab along \(x\) and gtab along \(y\). The integration points of a shell do not change from one call to the next, nor do the numbers of terms or the boundary flags, such that these tables are also the same from one call to the next. The kernels therefore keep them on the shell, one table per kernel, filled at the first call and only read afterwards, for every point of the integration domain: a table along \(x\) has the shape (nx, rows, m) and one along \(y\) the shape (ny, rows, n).

Each table is stored with the key of all the values it depends on: the numbers of terms and of integration points, the Gauss-Legendre abscissae, the limits of the integration domain in natural coordinates, the boundary flags of the fields of its rows and the dimensions entering its rows, e.g. 2/a of a derivative. A kernel whose key differs from the stored one, e.g. after a change of m, of a boundary flag or of Shell.integration_limits(), fills a new table and replaces the stored one, such that a shell keeps at most one table per kernel and table name.

The kernels call lookup_table() and store_table(), inserted by panels.dev.tabulate.tabulate_basis(); clear_tables() empties the tables of a shell, e.g. to release their memory.

Notes#

The values in a stored table are computed by the same code of the kernel, at the same coordinates, as in a kernel that fills its tables at every call: the matrices and vectors are the same, bit for bit.

The tables are created and stored while the kernel holds the GIL, before and after its nogil block. A table is filled only while it is new and not yet stored, and a stored table is never modified, only replaced: a kernel running in another thread keeps reading the table it started with.

panels.basis_tables.clear_tables(shell)#

Remove the tables of the approximation functions of a shell

The kernels fill them again at their next call, with the same values.

Parameters:
shellShell

The shell.

panels.basis_tables.lookup_table(shell, module, function, table, key, shape)#

Table of approximation functions of a kernel, stored or new

The table stored on the shell under the names module, function and table is returned when its shape is shape and its key equals key, every value compared to the bit. Otherwise, and for an object without stored tables, a new array is returned; nothing is stored by this function.

Parameters:
shellShell

The shell whose tables are looked up.

module, function, tablestr

Names of the module of the kernel, of the kernel and of the table, e.g. 'panels.models.plate_clpt_donnell_num', 'fkC_num' and 'ftab', which identify the code that fills the table.

keytuple

The values the table depends on, numbers or arrays, see the module docstring.

shapetuple of int

Shape of the table, (points, rows, terms).

Returns:
tabnumpy.ndarray

The stored table when it has the same key, otherwise a new, uninitialized array of shape shape and dtype DOUBLE, which the kernel fills and stores with store_table().

newint

1 when tab is new and must be filled, 0 when it is the stored table.

panels.basis_tables.store_table(shell, module, function, table, key, tab)#

Store a table filled by a kernel, replacing the stored one

The table is kept in the attribute _basis_tables of the shell, a dictionary created at the first call, under the names module, function and table, together with its key. A table already stored under the same names is replaced, not modified.

Parameters:
shellShell

The shell that keeps the table. Nothing is stored for an object without the attribute _basis_tables.

module, function, tablestr

As in lookup_table().

keytuple

As in lookup_table().

tabnumpy.ndarray

The filled table, which is not modified afterwards.