basis Derived Type

type, public :: basis

Spline basis function class

Procedures assume basis with open knot vector


Contents

Source Code


Components

TypeVisibility AttributesNameInitial
integer, public :: p

Polynomial degree

integer, public :: nk

Number of the knots

integer, public :: m

The highest index of the knots ( nk-1 )

integer, public :: nb

Number of basis functions

integer, public :: n

The highest index of the basis functions ( nb-1 )

real(kind=wp), public, allocatable:: kv(:)

Open knot vector
kv(0:m)

real(kind=wp), public, allocatable:: unik(:)

Unique knot values

integer, public, allocatable:: mult(:)

Multiplicity of each unique knot value

integer, public :: minreg

Minimum reqularity of the basis functions,= me%p-max(me%mult(2:ubound(me%mult)-1)

integer, public :: maxreg

Maximum reqularity of the basis functions,= me%p-min(me%mult(2:ubound(me%mult)-1)

integer, public :: nbez

Number of elements with nonzero measure, i.e., number of Bezier segments


Constructor

public interface basis

Spline basis constructor

  • private pure function basisConstructor(nk, p, k) result(me)

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: nk

    Number of the knots

    integer, intent(in) :: p

    Polynomial degree

    real(kind=wp), intent(in) :: k(nk)

    Open knot vector
    kv(0:m)

    Return Value type(basis)

    Spline basis object


Type-Bound Procedures

procedure, public :: FindSpan

Knot span index search

  • private pure elemental function FindSpan(me, u) result(span)

    This procedure is an elemental function and does a binary search and return the integer :: span value, where lies on. Note that, indexing starts with zero. If , the index is , i.e., , where "nb " is number of control points of the univariate spline basis object.

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    real(kind=wp), intent(in) :: u

    Given value

    Return Value integer

    Knot span index of value

procedure, public :: FindMult

Knot multiplicity computation

  • private pure elemental function FindMult(me, i, u) result(mult)

    Computes the multiplicity of a knot

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    integer, intent(in) :: i

    Starting index for search

    real(kind=wp), intent(in) :: u

    Given value

    Return Value integer

    Multiplicity of value

procedure, public :: FindSpanMult

Knot span and multiplicity computation

  • private pure elemental subroutine FindSpanMult(me, u, k, s)

    Computes the span and multiplicity of a knot

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    real(kind=wp), intent(in) :: u

    Given value

    integer, intent(out) :: k

    Knot span index of value

    integer, intent(out) :: s

    Multiplicity of value

procedure, public :: BasisFuns

Computation of the non-vanishing basis functions

  • private pure subroutine BasisFuns(me, u, N, span)

    Computes the nonvanishing basis functions based on Algorithm A2.2 in the NURBS Book 1.

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    real(kind=wp), intent(in) :: u

    Given value

    real(kind=wp), intent(out) :: N(0:me%p)

    integer, intent(in), optional :: span

    Knot span where lies on

procedure, public :: OneBasisFun

Computation of a single basis function

  • private pure elemental function OneBasisFun(me, i, u) result(Nip)

    Computes a single basis function, .

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    integer, intent(in) :: i

    Basis function index

    real(kind=wp), intent(in) :: u

    Given value

    Return Value real(kind=wp)

procedure, public :: AllBasisFuns

Computation of a all non-zero basis function of all degrees from up to

  • private pure subroutine AllBasisFuns(me, u, N, span)

    Computes all non-zero basis function of all degrees from up to .

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    real(kind=wp), intent(in) :: u

    Given value

    real(kind=wp), intent(out) :: N(0:me%p,0:me%p)

    integer, intent(in), optional :: span

    Knot span where lies on

procedure, public :: DersBasisFuns

Computation of the derivatives of the non-vanishing basis functions

  • private pure subroutine DersBasisFuns(me, u, n, ders, span)

    Computes all nonzero basis functions and their derivatives based on Algorithm A2.3 in the NURBS Book [^1].

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    real(kind=wp), intent(in) :: u

    Given value

    integer, intent(in) :: n

    Number of derivatives ()

    real(kind=wp), intent(out) :: ders(0:me%p,0:n)

    integer, intent(in), optional :: span

    Knot span where lies on

procedure, public :: DersOneBasisFun

Computation of the the derivatives of a single basis function

  • private pure subroutine DersOneBasisFun(me, i, u, n, ders)

    Computes a single basis function and its derivatives based on Algorithm A2.5 in the NURBS Book [^1].

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    integer, intent(in) :: i

    Basis function index

    real(kind=wp), intent(in) :: u

    Given value

    integer, intent(in) :: n

    Number of derivatives ()

    real(kind=wp), intent(out) :: ders(0:n)

procedure, public :: InsertKnot

Knot insertion of a given knot into the knot vector

  • private pure subroutine InsertKnot(me, u, r, span)

    Insert knot into times.

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(inout) :: me
    real(kind=wp), intent(in) :: u

    knot value

    integer, intent(in) :: r

    multiplicity of new knot value

    integer, intent(in), optional :: span

    knot span

procedure, public :: UpdateBasis

Updating the basis (the same contents with constructor)

  • private pure subroutine UpdateBasis(me, nk, k, p)

    Updates all component of the basis according to input knot vector.

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(inout) :: me
    integer, intent(in) :: nk

    Number of the knots

    real(kind=wp), intent(in) :: k(nk)

    New knot vector

    integer, intent(in), optional :: p

    New basis degree

procedure, public :: BSegments

Computation of the segments' data of the basis

  • private pure subroutine BSegments(me, nb, knots)

    Returns the number of Bezier segments, integer :: nb, of the basis and the real(wp) :: knots(:) array containing the unique values of the knot vector.

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    integer, intent(out) :: nb

    Number of Bezier segments

    real(kind=wp), intent(out), optional allocatable:: knots(:)

    The unique knot values

procedure, public :: ParLen

Get the length of parameter space

  • private pure function ParLen(me) result(len)

    Return the length of the parameter space, i.e., , where is the highest index of the knot vector.

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me

    Return Value real(kind=wp)

    Length of the parameter space

procedure, public :: GrevilleAbscissae

Computation of the Greville abscissae

  • private pure function GrevilleAbscissae(me, dsc) result(pt)

    Return the Greville abscissae, , of the knot vector,

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    logical, intent(in), optional :: dsc

    If true, then the Greville abscissae are modified by shifting the boundary points into the domain

    Return Value real(kind=wp) (0:me%n)

    The array containing Greville abscissae

procedure, public :: Plot => PlotBasisFunc

Plot basis functions

  • private subroutine PlotBasisFunc(me, first, last, d, plotRes, title, work, fname, terminal, showPlot)

    This subroutine plots the basis functions or their th order derivatives having index from first to last by computing at interpolation points defined by plotRes, and print the image file into "|cwd|/data/work/fname.ext" if the workspace work is presented, "|cwd|/data/img/fname.ext" if else. Plotting requires GNUPlot installed on your computer. The input parameter terminal set the output terminal of GNUPlot.

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    integer, intent(in), optional :: first

    First index to be plotted

    integer, intent(in), optional :: last

    Last index to be plotted

    integer, intent(in), optional :: d

    Derivatives degree

    integer, intent(in), optional :: plotRes

    Resolution of the calculation, Default = 100

    character(len=*), intent(in), optional :: title

    Title of the graph, Default = "Basis functions"

    character(len=*), intent(in), optional :: work

    Current work name to create folder

    character(len=*), intent(in), optional :: fname

    Filename of the *.png output, if GNUPlot terminal is png. Default = "BasisFunctions"

    character(len=*), intent(in), optional :: terminal

    GNUPlot terminal, Default = wxt

    logical, intent(in), optional :: showPlot

    Key to open created png files

procedure, public :: get_nquad

Get the number of quadrature points

  • private pure elemental function get_nquad(me, key, reduced_int, pdeq) result(ngp)

    Return the number of quadrature points for a successive integration

    Arguments

    Type IntentOptional AttributesName
    class(basis), intent(in) :: me
    character(len=*), intent(in), optional :: key

    The key defining whether the quadrature is over the Bezier segments or over whole patch
    Valid inputs:
    - "elementwise"
    - "patchwise"

    logical, intent(in), optional :: reduced_int

    Reduced integration flag, if true, the routine will return
    the number of quadrature points for reduced integration

    character(len=*), intent(in), optional :: pdeq

    Internal name of the relevant partial differential equation
    Valid inputs:
    - "Timoshenko"
    - "Mindlin"
    - "Shell"

    Return Value integer

Source Code

    type :: basis
        !<  
        integer                 ::  p       !< Polynomial degree \(p\)
        integer                 ::  nk      !< Number of the knots
        integer                 ::  m       !< The highest index of the knots ` ( nk-1 ) `
        integer                 ::  nb      !< Number of basis functions
        integer                 ::  n       !< The highest index of the basis functions ` ( nb-1 ) `
        real(wp),   allocatable ::  kv(:)   !< [Open knot vector](../page/01.fooiga/eqns.html#openvec)  
                                            !< ` kv(0:m) ` \( = \left\{u_{0},..., u_{m}\right\} \)
        real(wp),   allocatable ::  unik(:) !< Unique knot values
        integer,    allocatable ::  mult(:) !< Multiplicity of each unique knot value
        integer                 ::  minreg  !< Minimum reqularity of the basis functions,` = me%p-max(me%mult(2:ubound(me%mult)-1)  `
        integer                 ::  maxreg  !< Maximum reqularity of the basis functions,` = me%p-min(me%mult(2:ubound(me%mult)-1)  `
        integer                 ::  nbez    !< Number of elements with nonzero measure, i.e., number of Bezier segments
    contains
        !< Procedures assume basis with **open knot vector**  
        procedure, public   :: FindSpan                 !< **Knot span index search                                                                     **
        procedure, public   :: FindMult                 !< **Knot multiplicity computation                                                              **
        procedure, public   :: FindSpanMult             !< **Knot span and multiplicity computation                                                     **
        procedure, public   :: BasisFuns                !< **Computation of the non-vanishing basis functions                                           **
        procedure, public   :: OneBasisFun              !< **Computation of a single basis function                                                     **
        procedure, public   :: AllBasisFuns             !< **Computation of a all non-zero basis function of all degrees from \(0\) up to \(p\)         **
        procedure, public   :: DersBasisFuns            !< **Computation of the derivatives of the non-vanishing basis functions                        **
        procedure, public   :: DersOneBasisFun          !< **Computation of the the derivatives of a single basis function                              **
        procedure, public   :: InsertKnot               !< **Knot insertion of a given knot into the knot vector                                        **
        procedure, public   :: UpdateBasis              !< **Updating the basis (the same contents with constructor)                                    **
        procedure, public   :: BSegments                !< **Computation of the segments' data of the basis                                             **
        procedure, public   :: ParLen                   !< **Get the length of parameter space                                                          **
        procedure, public   :: GrevilleAbscissae        !< **Computation of the Greville abscissae                                                      **  
        procedure, public   :: Plot => PlotBasisFunc    !< **Plot basis functions                                                                       **
        procedure, public   :: get_nquad                !< **Get the number of quadrature points                                                        **
    end type basis