Bardell’s Hierarchical Functions

Introduction

Bardell (1991) [bardell1991] proposed a very convinient set of approximation functions based on hierarchical polynomials. The convenience comes from the fast convergence and from the easiness to simulate practically any type of boundary conditions.

The boundary condition is controlled by the first 4 terms of the approximation function, herein defined as:

  • t1: the translation at extremity 1 (\xi = -1)

  • r1: the rotation at extremity 1

  • t2: the translation at extremity 2 (\xi = +1)

  • r2: the rotation at extremity 2

Generating Bardell’s functions

The following code can be used to generate the Bardell functions for a given number of terms nmax. The substitution replace('**', '^') aims to create an input to Mathematica.

../../../../theory/func/bardell/bardell.py
from __future__ import division
import numpy as np
from sympy import var, factorial, factorial2, sympify

nmax = 40

xi = var('xi')
var('t1, r1, t2, r2')

u = list(map(sympify, ['1/2 - 3/4*xi + 1/4*xi**3',
                  '1/8 - 1/8*xi - 1/8*xi**2 + 1/8*xi**3',
                  '1/2 + 3/4*xi - 1/4*xi**3',
                  '-1/8 - 1/8*xi + 1/8*xi**2 + 1/8*xi**3']))

for r in range(5, nmax+1):
    utmp = []
    for n in range(0, r//2+1):
        den = 2**n*factorial(n)*factorial(r-2*n-1)
        utmp.append((-1)**n*factorial2(2*r - 2*n - 7)/den * xi**(r-2*n-1))
    u.append(sum(utmp))

u[0] = t1*u[0]
u[1] = r1*u[1]
u[2] = t2*u[2]
u[3] = r2*u[3]

with open('bardell.txt', 'w') as f:
    f.write("Bardell's hierarchical functions\n\n")
    f.write('Number of terms: {0}\n\n'.format(len(u)))
    f.write(',\n'.join(list(map(str, u))).replace('**', '^') + '\n\n')

The output of the code above is:

../../../../theory/func/bardell/bardell.txt
Bardell's hierarchical functions

Number of terms: 40

t1*(xi^3/4 - 3*xi/4 + 1/2),
r1*(xi^3/8 - xi^2/8 - xi/8 + 1/8),
t2*(-xi^3/4 + 3*xi/4 + 1/2),
r2*(xi^3/8 + xi^2/8 - xi/8 - 1/8),
xi^4/8 - xi^2/4 + 1/8,
xi^5/8 - xi^3/4 + xi/8,
7*xi^6/48 - 5*xi^4/16 + 3*xi^2/16 - 1/48,
3*xi^7/16 - 7*xi^5/16 + 5*xi^3/16 - xi/16,
33*xi^8/128 - 21*xi^6/32 + 35*xi^4/64 - 5*xi^2/32 + 1/128,
143*xi^9/384 - 33*xi^7/32 + 63*xi^5/64 - 35*xi^3/96 + 5*xi/128,
143*xi^10/256 - 429*xi^8/256 + 231*xi^6/128 - 105*xi^4/128 + 35*xi^2/256 - 1/256,
221*xi^11/256 - 715*xi^9/256 + 429*xi^7/128 - 231*xi^5/128 + 105*xi^3/256 - 7*xi/256,
4199*xi^12/3072 - 2431*xi^10/512 + 6435*xi^8/1024 - 1001*xi^6/256 + 1155*xi^4/1024 - 63*xi^2/512 + 7/3072,
2261*xi^13/1024 - 4199*xi^11/512 + 12155*xi^9/1024 - 2145*xi^7/256 + 3003*xi^5/1024 - 231*xi^3/512 + 21*xi/1024,
7429*xi^14/2048 - 29393*xi^12/2048 + 46189*xi^10/2048 - 36465*xi^8/2048 + 15015*xi^6/2048 - 3003*xi^4/2048 + 231*xi^2/2048 - 3/2048,
37145*xi^15/6144 - 52003*xi^13/2048 + 88179*xi^11/2048 - 230945*xi^9/6144 + 36465*xi^7/2048 - 9009*xi^5/2048 + 1001*xi^3/2048 - 33*xi/2048,
334305*xi^16/32768 - 185725*xi^14/4096 + 676039*xi^12/8192 - 323323*xi^10/4096 + 692835*xi^8/16384 - 51051*xi^6/4096 + 15015*xi^4/8192 - 429*xi^2/4096 + 33/32768,
570285*xi^17/32768 - 334305*xi^15/4096 + 1300075*xi^13/8192 - 676039*xi^11/4096 + 1616615*xi^9/16384 - 138567*xi^7/4096 + 51051*xi^5/8192 - 2145*xi^3/4096 + 429*xi/32768,
1964315*xi^18/65536 - 9694845*xi^16/65536 + 5014575*xi^14/16384 - 16900975*xi^12/49152 + 7436429*xi^10/32768 - 2909907*xi^8/32768 + 323323*xi^6/16384 - 36465*xi^4/16384 + 6435*xi^2/65536 - 143/196608,
3411705*xi^19/65536 - 17678835*xi^17/65536 + 9694845*xi^15/16384 - 11700675*xi^13/16384 + 16900975*xi^11/32768 - 7436429*xi^9/32768 + 969969*xi^7/16384 - 138567*xi^5/16384 + 36465*xi^3/65536 - 715*xi/65536,
23881935*xi^20/262144 - 64822395*xi^18/131072 + 300540195*xi^16/262144 - 48474225*xi^14/32768 + 152108775*xi^12/131072 - 37182145*xi^10/65536 + 22309287*xi^8/131072 - 969969*xi^6/32768 + 692835*xi^4/262144 - 12155*xi^2/131072 + 143/262144,
42077695*xi^21/262144 - 119409675*xi^19/131072 + 583401555*xi^17/262144 - 100180065*xi^15/32768 + 339319575*xi^13/131072 - 91265265*xi^11/65536 + 185910725*xi^9/393216 - 3187041*xi^7/32768 + 2909907*xi^5/262144 - 230945*xi^3/393216 + 2431*xi/262144,
149184555*xi^22/524288 - 883631595*xi^20/524288 + 2268783825*xi^18/524288 - 3305942145*xi^16/524288 + 1502700975*xi^14/262144 - 882230895*xi^12/262144 + 334639305*xi^10/262144 - 79676025*xi^8/262144 + 22309287*xi^6/524288 - 1616615*xi^4/524288 + 46189*xi^2/524288 - 221/524288,
265937685*xi^23/524288 - 1641030105*xi^21/524288 + 4418157975*xi^19/524288 - 6806351475*xi^17/524288 + 3305942145*xi^15/262144 - 2103781365*xi^13/262144 + 882230895*xi^11/262144 - 239028075*xi^9/262144 + 79676025*xi^7/524288 - 7436429*xi^5/524288 + 323323*xi^3/524288 - 4199*xi/524288,
3811773485*xi^24/4194304 - 6116566755*xi^22/1048576 + 34461632205*xi^20/2097152 - 27981667175*xi^18/1048576 + 115707975075*xi^16/4194304 - 9917826435*xi^14/524288 + 9116385915*xi^12/1048576 - 1386362835*xi^10/524288 + 2151252675*xi^8/4194304 - 185910725*xi^6/3145728 + 7436429*xi^4/2097152 - 88179*xi^2/1048576 + 4199/12582912,
6861192273*xi^25/4194304 - 11435320455*xi^23/1048576 + 67282234305*xi^21/2097152 - 57436053675*xi^19/1048576 + 251835004575*xi^17/4194304 - 23141595015*xi^15/524288 + 23141595015*xi^13/1048576 - 3907022535*xi^11/524288 + 6931814175*xi^9/4194304 - 239028075*xi^7/1048576 + 37182145*xi^5/2097152 - 676039*xi^3/1048576 + 29393*xi/4194304,
24805848987*xi^26/8388608 - 171529806825*xi^24/8388608 + 263012370465*xi^22/4194304 - 470975640135*xi^20/4194304 + 1091285019825*xi^18/8388608 - 856239015555*xi^16/8388608 + 115707975075*xi^14/2097152 - 42977247885*xi^12/2097152 + 42977247885*xi^10/8388608 - 6931814175*xi^8/8388608 + 334639305*xi^6/4194304 - 16900975*xi^4/4194304 + 676039*xi^2/8388608 - 2261/8388608,
135054066707*xi^27/25165824 - 322476036831*xi^25/8388608 + 514589420475*xi^23/4194304 - 964378691705*xi^21/4194304 + 2354878200675*xi^19/8388608 - 1964313035685*xi^17/8388608 + 285413005185*xi^15/2097152 - 115707975075*xi^13/2097152 + 128931743655*xi^11/8388608 - 23876248825*xi^9/8388608 + 1386362835*xi^7/4194304 - 91265265*xi^5/4194304 + 16900975*xi^3/25165824 - 52003*xi/8388608,
327988447717*xi^28/33554432 - 1215486600363*xi^26/16777216 + 8061900920775*xi^24/33554432 - 3945185556975*xi^22/8388608 + 20251952525805*xi^20/33554432 - 8948537162565*xi^18/16777216 + 11131107202215*xi^16/33554432 - 611599296825*xi^14/4194304 + 1504203675975*xi^12/33554432 - 157583242245*xi^10/16777216 + 42977247885*xi^8/33554432 - 882230895*xi^6/8388608 + 152108775*xi^4/33554432 - 1300075*xi^2/16777216 + 7429/33554432,
599427163069*xi^29/33554432 - 2295919134019*xi^27/16777216 + 15801325804719*xi^25/33554432 - 8061900920775*xi^23/8388608 + 43397041126725*xi^21/33554432 - 20251952525805*xi^19/16777216 + 26845611487695*xi^17/33554432 - 1590158171745*xi^15/4194304 + 4281195077775*xi^13/33554432 - 501401225325*xi^11/16777216 + 157583242245*xi^9/33554432 - 3907022535*xi^7/8388608 + 882230895*xi^5/33554432 - 11700675*xi^3/16777216 + 185725*xi/33554432,
6593698793759*xi^30/201326592 - 17383387729001*xi^28/67108864 + 61989816618513*xi^26/67108864 - 131677715039325*xi^24/67108864 + 185423721177825*xi^22/67108864 - 182267572732245*xi^20/67108864 + 128262365996765*xi^18/67108864 - 65196485041545*xi^16/67108864 + 23852372576175*xi^14/67108864 - 6183948445675*xi^12/67108864 + 1103082695715*xi^10/67108864 - 128931743655*xi^8/67108864 + 9116385915*xi^6/67108864 - 339319575*xi^4/67108864 + 5014575*xi^2/67108864 - 37145/201326592,
4041299260691*xi^31/67108864 - 32968493968795*xi^29/67108864 + 121683714103007*xi^27/67108864 - 268622538680223*xi^25/67108864 + 395033145117975*xi^23/67108864 - 407932186591215*xi^21/67108864 + 303779287887075*xi^19/67108864 - 164908756281555*xi^17/67108864 + 65196485041545*xi^15/67108864 - 18551845337025*xi^13/67108864 + 3710369067405*xi^11/67108864 - 501401225325*xi^9/67108864 + 42977247885*xi^7/67108864 - 2103781365*xi^5/67108864 + 48474225*xi^3/67108864 - 334305*xi/67108864,
238436656380769*xi^32/2147483648 - 125280277081421*xi^30/134217728 + 956086325095055*xi^28/268435456 - 1095153426927063*xi^26/134217728 + 6715563467005575*xi^24/536870912 - 1817152467542685*xi^22/134217728 + 2855525306138505*xi^20/268435456 - 824543781407775*xi^18/134217728 + 2803448856786435*xi^16/1073741824 - 108660808402575*xi^14/134217728 + 48234797876265*xi^12/268435456 - 3710369067405*xi^10/134217728 + 1504203675975*xi^8/536870912 - 23141595015*xi^6/134217728 + 1502700975*xi^4/268435456 - 9694845*xi^2/134217728 + 334305/2147483648,
1322239639929719*xi^33/6442450944 - 238436656380769*xi^31/134217728 + 1879204156221315*xi^29/268435456 - 6692604275665385*xi^27/402653184 + 14236994550051819*xi^25/536870912 - 4029338080203345*xi^23/134217728 + 6662892380989845*xi^21/268435456 - 2039660932956075*xi^19/134217728 + 7420894032669975*xi^17/1073741824 - 311494317420715*xi^15/134217728 + 152125131763605*xi^13/268435456 - 13154944875345*xi^11/134217728 + 6183948445675*xi^9/536870912 - 115707975075*xi^7/134217728 + 9917826435*xi^5/268435456 - 100180065*xi^3/134217728 + 9694845*xi/2147483648,
1633354849324947*xi^34/4294967296 - 14544636039226909*xi^32/4294967296 + 7391536347803839*xi^30/536870912 - 18165640176806045*xi^28/536870912 + 60233438480988465*xi^26/1073741824 - 71184972750259095*xi^24/1073741824 + 30891591948225645*xi^22/536870912 - 19988677142969535*xi^20/536870912 + 38753557726165425*xi^18/2147483648 - 14017244283932175*xi^16/2147483648 + 934482952262145*xi^14/536870912 - 179784246629715*xi^12/536870912 + 48234797876265*xi^10/1073741824 - 4281195077775*xi^8/1073741824 + 115707975075*xi^6/536870912 - 3305942145*xi^4/536870912 + 300540195*xi^2/4294967296 - 570285/4294967296,
3033373291603473*xi^35/4294967296 - 27767032438524099*xi^33/4294967296 + 14544636039226909*xi^31/536870912 - 36957681739019195*xi^29/536870912 + 127159481237642315*xi^27/1073741824 - 156606940050570009*xi^25/1073741824 + 71184972750259095*xi^23/536870912 - 48543930204354585*xi^21/536870912 + 99943385714847675*xi^19/2147483648 - 38753557726165425*xi^17/2147483648 + 2803448856786435*xi^15/536870912 - 594670969621365*xi^13/536870912 + 179784246629715*xi^11/1073741824 - 18551845337025*xi^9/1073741824 + 611599296825*xi^7/536870912 - 23141595015*xi^5/536870912 + 3305942145*xi^3/4294967296 - 17678835*xi/4294967296,
67745336845810897*xi^36/51539607552 - 106168065206121555*xi^34/8589934592 + 916312070471295267*xi^32/17179869184 - 450883717216034179*xi^30/3221225472 + 1071772770431556655*xi^28/4294967296 - 686661198683268501*xi^26/2147483648 + 1305057833754750075*xi^24/4294967296 - 233893481893708455*xi^22/1073741824 + 1019422534291446285*xi^20/8589934592 - 210991592064678425*xi^18/4294967296 + 131762096268962445*xi^16/8589934592 - 3822884804708775*xi^14/1073741824 + 2576907535025915*xi^12/4294967296 - 152125131763605*xi^10/2147483648 + 23852372576175*xi^8/4294967296 - 285413005185*xi^6/1073741824 + 115707975075*xi^4/17179869184 - 583401555*xi^2/8589934592 + 1964315/17179869184,
42111966147395963*xi^37/17179869184 - 203236010537432691*xi^35/8589934592 + 1804857108504066435*xi^33/17179869184 - 305437356823765089*xi^31/1073741824 + 2254418586080170895*xi^29/4294967296 - 1500481878604179317*xi^27/2147483648 + 2975531860960830171*xi^25/4294967296 - 559310500180607175*xi^23/1073741824 + 2572828300830793005*xi^21/8589934592 - 566345852384136825*xi^19/4294967296 + 379784865716421165*xi^17/8589934592 - 11978372388087495*xi^15/1073741824 + 8920064544320475*xi^13/4294967296 - 594670969621365*xi^11/2147483648 + 108660808402575*xi^9/4294967296 - 1590158171745*xi^7/1073741824 + 856239015555*xi^5/17179869184 - 6806351475*xi^3/8589934592 + 64822395*xi/17179869184,
157365768235005967*xi^38/34359738368 - 1558142747453650631*xi^36/34359738368 + 7113260368810144185*xi^34/34359738368 - 19853428193544730785*xi^32/34359738368 + 9468558061536717759*xi^30/8589934592 - 13075627799264991191*xi^28/8589934592 + 13504336907437613853*xi^26/8589934592 - 10626899503431536325*xi^24/8589934592 + 12864141504153965025*xi^22/17179869184 - 6003266035271850345*xi^20/17179869184 + 2152114239059719935*xi^18/17179869184 - 586940247016287255*xi^16/17179869184 + 59891861940437475*xi^14/8589934592 - 8920064544320475*xi^12/8589934592 + 934482952262145*xi^10/8589934592 - 65196485041545*xi^8/8589934592 + 11131107202215*xi^6/34359738368 - 251835004575*xi^4/34359738368 + 2268783825*xi^2/34359738368 - 3411705/34359738368,
883669313935033507*xi^39/103079215104 - 2989949596465113373*xi^37/34359738368 + 14023284727082855679*xi^35/34359738368 - 40308475423257483715*xi^33/34359738368 + 19853428193544730785*xi^31/8589934592 - 28405674184610153277*xi^29/8589934592 + 91529394594854938337*xi^27/25769803776 - 25079482828098425727*xi^25/8589934592 + 31880698510294608975*xi^23/17179869184 - 15722839616188179475*xi^21/17179869184 + 6003266035271850345*xi^19/17179869184 - 1760820741048861765*xi^17/17179869184 + 195646749005429085*xi^15/8589934592 - 32249464121774025*xi^13/8589934592 + 3822884804708775*xi^11/8589934592 - 311494317420715*xi^9/8589934592 + 65196485041545*xi^7/34359738368 - 1964313035685*xi^5/34359738368 + 27981667175*xi^3/34359738368 - 119409675*xi/34359738368

In order to calculate the displacement, strain of stress fields using Cython, the above output is not adequate due to very long integer numbers that will cause precision overflows. The code below should be used to create an input to Cython:

../../../../theory/func/bardell/bardell_floating_point.py
from __future__ import division
import numpy as np
from sympy import var, factorial, factorial2, sympify, diff

nmax = 30

xi = var('xi')

u = map(sympify, ['1./2. - 3./4.*xi + 1./4.*xi**3',
                  '1./8. - 1./8.*xi - 1./8.*xi**2 + 1./8.*xi**3',
                  '1./2. + 3./4.*xi - 1./4.*xi**3',
                  '-1./8. - 1./8.*xi + 1./8.*xi**2 + 1./8.*xi**3'])

for r in range(5, nmax+1):
    utmp = []
    for n in range(0, r//2+1):
        den = 2**n*factorial(n)*factorial(r-2*n-1)
        utmp.append((-1)**n*factorial2(2*r - 2*n - 7)/den * xi**(r-2*n-1)/1.)
    u.append(sum(utmp))

with open('bardell_floating_point.txt', 'w') as f:
    f.write("Bardell's hierarchical functions\n\n")
    f.write('Number of terms: {0}\n\n'.format(len(u)))
    f.write('cdef void calc_vec_f(double *f, double xi, double xi1t=1., double xi1r=1.,\n' +
            '                 double xi2t=1., double xi2r=1.) nogil:\n')
    consts = {0:'xi1t', 1:'xi1r', 2:'xi2t', 3:'xi2r'}
    for i in range(len(u)):
        const = consts.get(i)
        if const is None:
            f.write('    f[%d] = %s\n' % (i, str(u[i])))
        else:
            f.write('    f[%d] = %s*(%s)\n' % (i, const, str(u[i])))

    f.write('\n\n')
    f.write('cdef void calc_vec_fxi(double *fxi, double xi, double xi1t=1., double xi1r=1.,\n' +
            '                       double xi2t=1., double xi2r=1.) nogil:\n')
    for i in range(len(u)):
        const = consts.get(i)
        if const is None:
            f.write('    fxi[%d] = %s\n' % (i, str(diff(u[i], xi))))
        else:
            f.write('    fxi[%d] = %s*(%s)\n' % (i, const, str(diff(u[i], xi))))

    f.write('\n\n')
    f.write('cdef double calc_f(int i, double xi, double xi1t, double xi1r,\n' +
            '                   double xi2t, double xi2r) nogil:\n')
    for i in range(len(u)):
        const = consts.get(i)
        f.write('    if i == %d:\n' % i)
        if const is None:
            f.write('        return %s\n' % str(u[i]))
        else:
            f.write('        return %s*(%s)\n' % (const, str(u[i])))

    f.write('\n\n')
    f.write('cdef double calc_fxi(int i, double xi, double xi1t, double xi1r,\n' +
            '                     double xi2t, double xi2r) nogil:\n')
    for i in range(len(u)):
        const = consts.get(i)
        f.write('    if i == %d:\n' % i)
        if const is None:
            f.write('        return %s\n' % str(diff(u[i], xi)))
        else:
            f.write('        return %s*(%s)\n' % (const, str(diff(u[i], xi))))



Generating the following output:

Implemented modules

Three modules were created and they are called in compmech shared library. These libraries are available in compmech/lib after installation.

Three modules are currently available:

  • bardell: for the integration along the full domain

\int_{\xi=-1}^{\xi=+1} {f(\xi) g(\xi)}

  • bardell_12: for the integration in any interval

\int_{\xi=\xi_1}^{\xi=\xi_2} {f(\xi) g(\xi)}

  • bardell_c0c1: for the integration of two linearly dependent field variables \xi and \xi'

\int_{\xi=-1}^{\xi=+1} {f(\xi) g(\xi')}

such that:

\xi' = c_0 + c_1 \xi

with c_0 and c_1 being constant values.