function
- class nutils.function.LowerArg(space, transforms, index, coordinates)
Bases:
objectArgument for
Lowerable.lower().- transforms
- index
- Type:
- coordinates
- Type:
nutils.evaluable.Array, optional
- replace(obj, /, **changes)
Return a new object replacing specified fields with new values.
This is especially useful for frozen classes. Example usage:
@dataclass(frozen=True) class C: x: int y: int c = C(1, 2) c1 = replace(c, x=3) assert c1.x == 3 and c1.y == 2
- property without_points: LowerArg
A copy of the
LowerArgwithcoordinatesset to None.
- map_coordinates(self, map)
Return a copy of the
LowerArgwithcoordinatesmapped usingmap.
- rename_spaces(self, map)
Return a copy of the
LowerArgwithspacerenamed usingmap.If the old space is not found in
map, theLowerArgis returned unchanged.
- __weakref__
list of weak references to the object
- class nutils.function.LowerArgs(points_shape, args)
Bases:
objectAn ordered sequence of
LowerArgs with commonpoints_shape.- points_shape
The shape of the leading points axes that are to be added to the lowered
nutils.evaluable.Array.- Type:
tupleof scalar, integernutils.evaluable.Array
- classmethod empty(points_shape=())
Returns an empty instance of
LowerArgs, optionally with the providedpoints_shape.
- property without_points: LowerArgs
A copy of the
LowerArgswithout points (emptypoints_shapeandLowerArg.coordinates).
- map_coordinates(self, points_shape, map)
Return a copy of the
LowerArgswith the givenpoints_shapeandLowerArg.coordinatesmapped usingmap.
- rename_spaces(self, map)
Return a copy of the
LowerArgswith spaces renamed usingmap.Spaces that are not found in
mapare unchanged. The order of theargsremains the same.It is allowed to map different old spaces to the same new space. Note that
LowerArgs.__getitem__()only returns the last entry ofargsthat matches the given space.
- __mul__(self, other)
Return the outer product of two
LowerArgs.The
points_shapeof the product is the concatenation of thepoints_shapes of the factors; likewise for theargs. If both factors containLowerArgs for a certain space, theLowerArgof the right factor will beexposed.
- __add__(self, other)
Join two
LowerArgswith the samepoints_shape.The
argsis the concatenation of theargsof the terms. If both terms containLowerArgs for a certain space, theLowerArgof the right term will beexposed.
- __getitem__(self, space)
Return the
exposedLowerArgwith the givenspace.- Raises:
KeyError – If the
spaceis unknown.
- property exposed
Subset of
argsthat are exposed.An item a of
argsis exposed if there exists no item b inargsto the right of a with the sameLowerArg.spaceas a.
- __weakref__
list of weak references to the object
- class nutils.function.Lowerable
Bases:
objectProtocol for lowering to
nutils.evaluable.Array.- lower(self, args)
Lower this object to a
nutils.evaluable.Array.- Parameters:
args (
LowerArgs)
- __weakref__
list of weak references to the object
- class nutils.function.Array(shape, dtype, spaces, arguments)
Bases:
NDArrayOperatorsMixinBase class for array valued functions.
- Parameters:
- arguments
The mapping of argument names to their shapes and dtypes for all arguments of this array function.
- Type:
mapping of
str
- classmethod cast(_Array__value, dtype=None, ndim=None)
Cast a value to an
Array.- Parameters:
value (
Array, or anumpy.ndarrayor similar) – The value to cast.
- __len__(self)
Length of the first axis.
- __iter__(self)
Iterator over the first axis.
- sum(self, axis=None)
Return the sum of array elements over the given axes.
Warning
This method will change in future to match Numpy’s equivalent method, which sums over all axes by default. During transition, use of this method without an axis argument will raise an error if the input array is of ndim >= 2.
- prod(self, _Array__axis)
Return the product of array elements over the given axes.
- dot(self, _Array__other, axes=None)
Return the inner product of the arguments over the given axes, elementwise over the remanining axes.
Warning
This method will change in future to match Numpy’s equivalent method, which does not support an axis argument and has different behaviour in case of higher dimensional input. During transition, use of this method for any situation other than the contraction of two vectors will raise a warning, and later an error. For continuity, use numpy.dot, numpy.matmul, or the @ operator instead.
- Parameters:
axis (
int, a sequence ofint, orNone) – The axis or axes along which the inner product is performed. If the second argument has one dimension and axes isNone, the default, the inner product of the second argument with the first axis of the first argument is computed. Otherwiseaxes=Noneis not allowed.
- Return type:
- normalized(self, _Array__axis=-1)
See
normalized().
- curvature(self, ndims=-1, *, spaces=None)
See
curvature().
- nsymgrad(self, geom, /, ndims=0, *, spaces=None)
See
nsymgrad().
- eval(self, /, arguments=None, *, legacy=None, **kwargs)
Evaluate this function.
- derivative(self, _Array__var)
See
derivative().
- replace(self, _Array__arguments)
Return a copy with arguments applied.
- contains(self, _Array__name)
Test if target occurs in this function.
- conjugate(self)
Return the complex conjugate, elementwise.
- Returns:
The complex conjugate.
- Return type:
- conj(self)
Return the complex conjugate, elementwise.
- Returns:
The complex conjugate.
- Return type:
- property real
Return the real part of the complex argument.
- Returns:
The real part of the complex argument.
- Return type:
- property imag
Return the imaginary part of the complex argument.
- Returns:
The imaginary part of the complex argument.
- Return type:
- __weakref__
list of weak references to the object
- class nutils.function.Custom(args, shape, dtype, npointwise=0)
Bases:
ArrayCombined
nutils.functionandnutils.evaluablearray base class.Ordinary
Arraysubclasses should define theArray.lowermethod, which returns the correspondingnutils.evaluable.Arraywith the proper amount of points axes. In many cases theArraysubclass is trivial and the correspondingnutils.evaluable.Arraycontains all the specifics. For those situations theCustombase class exists. Rather than defining theArray.lowermethod, this base class allows you to define aCustom.evalf()and optionally aCustom.partial_derivative(), which are used to instantiate a genericnutils.evaluable.Arrayautomatically during lowering.By default the
Arrayarguments passed to the constructor are unmodified. Broadcasting and singleton expansion, if required, should be applied before passing the arguments to the constructor ofCustom. It is possible to declarenpointwiseleading axes as being pointwise. In that caseCustomapplies singleton expansion to the leading pointwise axes and the shape of the result passed toCustomshould not include the pointwise axes.For internal reasons, both
evalfandpartial_derivativemust be static methods, meaning that they will not receive a reference toselfwhen called. Instead, all relevant data should be passed toevalfvia the constructor argumentargs. The constructor will automatically distinguish between Array and non-Array arguments, and pass the latter on toevalfunchanged. Thepartial_derivativewill not be called for those arguments. Furthermore,evalfandpartial_derivativemust be hashable. Thenutils.types.hashable_function()decorator both defines a hash for the decorated function and makes the decorated function static.- Parameters:
args (iterable of
Arrayobjects or immutable and hashable objects) – The arguments of this array function.shape (
tupleofintorArray) – The shape of the array function without leading pointwise axes.dtype (
bool,int,floatorcomplex) – The dtype of the array elements.npointwise (
int) – The number of leading pointwise axis.
Example
The following class implements multiplication using
Customwithout broadcasting and forfloatarrays only.>>> from nutils.types import hashable_function >>> class Multiply(Custom): ... ... def __init__(self, left: IntoArray, right: IntoArray) -> None: ... # Broadcast the arrays. `broadcast_arrays` automatically casts the ... # arguments to `Array`. ... left, right = broadcast_arrays(left, right) ... # Dtype coercion is beyond the scope of this example. ... if left.dtype != float or right.dtype != float: ... raise ValueError('left and right arguments should have dtype float') ... # We treat all axes as pointwise, hence parameter `shape`, the shape ... # of the remainder, is empty and `npointwise` is the dimension of the ... # arrays. ... super().__init__(args=(left, right), shape=(), dtype=float, npointwise=left.ndim) ... ... @hashable_function ... def evalf(left: numpy.ndarray, right: numpy.ndarray) -> numpy.ndarray: ... # Because all axes are pointwise, the evaluated `left` and `right` ... # arrays are 1d. ... return left * right ... ... @hashable_function ... def partial_derivative(iarg: int, left: Array, right: Array) -> IntoArray: ... # The arguments passed to this function are of type `Array` and the ... # pointwise axes are omitted, hence `left` and `right` are 0d. ... if iarg == 0: ... return right ... elif iarg == 1: ... return left ... else: ... raise NotImplementedError ... >>> Multiply([1., 2.], [3., 4.]).eval() array([ 3., 8.]) >>> a = Argument('a', (2,)) >>> Multiply(a, [3., 4.]).derivative(a).eval(a=numpy.array([1., 2.])).export('dense') array([[ 3., 0.], [ 0., 4.]])
The following class wraps
numpy.roll(), applied to the last axis of the array argument, with constant shift.>>> class Roll(Custom): ... ... def __init__(self, array: IntoArray, shift: int) -> None: ... array = asarray(array) ... # We are being nit-picky here and cast `exponent` to an `int` without ... # truncation. ... shift = shift.__index__() ... # We treat all but the last axis of `array` as pointwise. ... super().__init__(args=(array, shift), shape=array.shape[-1:], dtype=array.dtype, npointwise=array.ndim-1) ... ... @hashable_function ... def evalf(array: numpy.ndarray, shift: int) -> numpy.ndarray: ... # `array` is evaluated to a `numpy.ndarray` because we passed `array` ... # as an `Array` to the constructor. `shift`, however, is untouched ... # because it is not an `Array`. The `array` has two axes: a points ... # axis and the axis to be rolled. ... return numpy.roll(array, shift, 1) ... ... @hashable_function ... def partial_derivative(iarg, array: Array, shift: int) -> IntoArray: ... if iarg == 0: ... return Roll(eye(array.shape[0]), shift).T ... else: ... # We don't implement the derivative to `shift`, because this is ... # a constant `int`. ... raise NotImplementedError ... >>> Roll([1, 2, 3], 1).eval() array([3, 1, 2]) >>> b = Argument('b', (3,)) >>> Roll(b, 1).derivative(b).eval().export('dense') array([[ 0., 0., 1.], [ 1., 0., 0.], [ 0., 1., 0.]])
- evalf(*args)
Evaluate this function for the given evaluated arguments.
This function is called with arguments that correspond to the arguments that are passed to the constructor of
Custom: every instance ofArrayis evaluated to anumpy.ndarraywith one leading axis compared to theArrayand all other instances are passed as is. The return value of this method should also include a leading axis with the same length as the other array arguments have, or length one if there are no array arguments. If constructor argumentnpointwiseis nonzero, the pointwise axes of theArrayarguments are raveled and included in the single leading axis of the evaluated array arguments as well.If possible this method should not use
self, e.g. by decorating this method withstaticmethod(). The result of this function must only depend on the arguments and must not mutate the arguments.This method is equivalent to
nutils.evaluable.Array.evalfup to the treatment of the leading axis.- Parameters:
*args – The evaluated arguments corresponding to the
argsparameter of theCustomconstructor.- Returns:
The result of this function with one leading points axis.
- Return type:
- partial_derivative(iarg, *args)
Return the partial derivative of this function to
Customconstructor argument numberiarg.This method is only called for those arguments that are instances of
Arraywith dtypefloatand have the derivative target as a dependency. It is therefor allowed to omit an implementation for some or all arguments if the above conditions are not met.Axes that are declared pointwise via the
npointwiseconstructor argument are omitted.
- class nutils.function.Argument(name, shape, dtype=<class 'float'>)
Bases:
ArrayArray valued function argument.
- Parameters:
- nutils.function.asarray(__arg)
Cast a value to an
Array.- Parameters:
value (
Array, or anumpy.ndarrayor similar) – The value to cast.- Return type:
- nutils.function.zeros(shape, dtype=<class 'float'>)
Create a new
Arrayof given shape and dtype, filled with zeros.
- nutils.function.ones(shape, dtype=<class 'float'>)
Create a new
Arrayof given shape and dtype, filled with ones.
- nutils.function.eye(__n, dtype=<class 'float'>)
Create a 2-D
Arraywith ones on the diagonal and zeros elsewhere.
- nutils.function.levicivita(__n, dtype=<class 'float'>)
Create an n-D Levi-Civita symbol.
- nutils.function.swap_spaces(arg, space0, space1, /)
Swap the two
spacesofarg.If
argis invariant to the spacesswap_spaces()does nothing. Also, swappingargtwice with the same set of spaces results in the originalarg.
- nutils.function.opposite(__arg)
Evaluate this function at the opposite side.
When evaluating a function
argat an interface, the function will be evaluated at one side of the interface.opposite()selects the opposite side.Example
We create a one dimensional topology with two elements and a discontinuous function
fthat is 1 on the first element and 2 on the second:>>> from nutils import mesh, function >>> topo, geom = mesh.rectilinear([2]) >>> f = topo.basis('discont', 0).dot([1, 2])
Evaluating this function at the interface gives (for this particular topology) the value at the side of the first element:
>>> topo.interfaces.sample('bezier', 1).eval(f) array([ 1.])
Using
opposite()we obtain the value at the side of second element:>>> topo.interfaces.sample('bezier', 1).eval(function.opposite(f)) array([ 2.])
It is allowed to nest opposites:
>>> topo.interfaces.sample('bezier', 1).eval(function.opposite(function.opposite(f))) array([ 1.])
- nutils.function.mean(__arg)
Return the mean of the argument at an interface.
Example
We create a one dimensional topology with two elements and a discontinuous function
fthat is 1 on the first element and 2 on the second:>>> from nutils import mesh, function >>> topo, geom = mesh.rectilinear([2]) >>> f = topo.basis('discont', 0).dot([1, 2])
Evaluating the mean of this function at the interface gives:
>>> topo.interfaces.sample('bezier', 1).eval(function.mean(f)) array([ 1.5])
- nutils.function.jump(__arg)
Return the jump of the argument at an interface.
The sign of the jump depends on the orientation of the interfaces in a
Topology. Usually the jump is used as part of an inner product with thenormal()of the geometry is used, which is independent of the orientation of the interfaces.Example
We create a one dimensional topology with two elements and a discontinuous function
fthat is 1 on the first element and 2 on the second:>>> from nutils import mesh, function >>> topo, geom = mesh.rectilinear([2]) >>> f = topo.basis('discont', 0).dot([1, 2])
Evaluating the jump of this function at the interface gives (for this particular topology):
>>> topo.interfaces.sample('bezier', 1).eval(function.jump(f)) array([ 1.])
- nutils.function.normalized(__arg, axis=-1)
Return the argument normalized over the given axis, elementwise over the remanining axes.
- nutils.function.matmat(__arg0, *args)
helper function, contracts last axis of arg0 with first axis of arg1, etc
- nutils.function.diagonalize(__arg, __axis=-1, __newaxis=-1)
Return argument with
newaxissuch thataxisand newaxis` is diagonal.
- nutils.function.outer(arg1, arg2=None, axis=0)
outer product
- nutils.function.insertaxis(__array, axis, length)
Insert an axis with given length.
- nutils.function.expand_dims(__array, axis)
Insert a singleton axis.
- nutils.function.unravel(__array, axis, shape)
Unravel an axis to the given shape.
- nutils.function.get(__array, __axis, __index)
Get one element from an array along an axis.
- Parameters:
- Return type:
See also
kronecker()The complement operation.
- nutils.function.scatter(__array, length, indices)
Distribute the last dimensions of an array over a new axis.
- Parameters:
- Return type:
Notes
Scatter strictly reorganizes array entries, it cannot assign multiple entries to the same position. In other words, the provided indices must be unique.
- nutils.function.kronecker(__array, axis, length, pos)
Position an element in an axis of given length.
- Parameters:
- Return type:
See also
get()The complement operation.
- nutils.function.linearize(__array, __arguments)
Linearize functional.
Similar to
derivative(), linearize takes the derivative of an array to one or more arguments, but with the derivative directions represented by arguments rather than array axes. The result is by definition linear in the new arguments.- Parameters:
Example
The following example demonstrates the use of linearize with four equivalent argument specifications:
>>> u, v, p, q = [Argument(s, (), float) for s in 'uvpq'] >>> f = u**2 + p >>> lin1 = linearize(f, 'u:v,p:q') >>> lin2 = linearize(f, dict(u='v', p='q')) >>> lin3 = linearize(f, ('u:v', 'p:q')) >>> lin4 = linearize(f, (('u', 'v'), ('p', 'q'))) >>> # lin1 = lin2 == lin3 == lin4 == 2 * u * v + q
- nutils.function.broadcast_arrays(*arrays)
Broadcast the given arrays.
- nutils.function.typecast_arrays(*arrays, min_dtype=<class 'bool'>)
Cast the given arrays to the same dtype.
- nutils.function.broadcast_shapes(*shapes)
Broadcast the given shapes into a single shape.
- nutils.function.derivative(__arg, __var)
Differentiate arg to var.
- nutils.function.grad(arg, geom, /, ndims=0, *, spaces=None)
Return the gradient of the argument to the given geometry.
- Parameters:
- Return type:
- nutils.function.curl(arg, geom, /, *, spaces=None)
Return the curl of the argument w.r.t. the given geometry.
- nutils.function.normal(geom, /, refgeom=None, *, spaces=None)
Return the normal of the geometry.
- Parameters:
refgeom (
Array, optional`) – The reference geometry. IfNone, the reference geometry is the tip coordinate system of the spaces on whichgeomis defined. The dimension of the reference geometry must be exactly one smaller than the dimension of the geometry.spaces (iterable of
str, optional) – Compute the normal inspaces. If absent all spaces ofgeomare used.
- Return type:
- nutils.function.dotnorm(arg, geom, /, axis=-1, *, spaces=None)
Return the inner product of an array with the normal of the given geometry.
- Parameters:
arg (
Arrayor something that can becast()into one) – The array.geom (
Arrayor something that can becast()into one) – The geometry. This must be a 1-D array.axis (
int) – The axis ofargalong which the inner product should be performed. Defaults to the last axis.spaces (iterable of
str, optional) – Compute the inner product with the normal inspaces. If absent all spaces ofgeomare used.
- Return type:
- nutils.function.tangent(geom, vec, /, *, spaces=None)
Return the tangent.
- nutils.function.jacobian(geom, ndims=None, /, *, spaces=None)
Return the absolute value of the determinant of the Jacobian matrix of the given geometry.
- nutils.function.J(geom, ndims=None, /, *, spaces=None)
Return the absolute value of the determinant of the Jacobian matrix of the given geometry.
Alias of
jacobian().
- nutils.function.surfgrad(arg, /, geom, *, spaces=None)
Return the surface gradient of the argument to the given geometry.
- nutils.function.curvature(geom, /, ndims=-1, *, spaces=None)
Return the curvature of the given geometry.
- nutils.function.div(arg, geom, /, ndims=0, spaces=None)
Return the divergence of
argw.r.t. the given geometry.
- nutils.function.laplace(arg, geom, /, ndims=0, spaces=None)
Return the Laplacian of
argw.r.t. the given geometry.
- nutils.function.symgrad(arg, geom, /, ndims=0, *, spaces=None)
Return the symmetric gradient of
argw.r.t. the given geometry.
- nutils.function.ngrad(arg, geom, /, ndims=0, *, spaces=None)
Return the inner product of the gradient of
argwith the normal of the given geometry.
- nutils.function.nsymgrad(arg, geom, /, ndims=0, *, spaces=None)
Return the inner product of the symmetric gradient of
argwith the normal of the given geometry.- Parameters:
- Return type:
- nutils.function.eval(funcs, /, arguments=None, **kwargs)
Evaluate one or several Array objects.
- nutils.function.as_coo(array)
Convert any array to an evaluable tuple of sparse COO data.
The tuple consists of the array values, followed by the corresponding indices in all axes. Indices are lexicographically ordered and unique, but values are not guaranteed to be nonzero.
- nutils.function.as_csr(array)
Convert a 2D array to an evaluable tuple of sparse CSR data.
The tuple consists of the array values, row pointers, and column indices.
- nutils.function.integral(func, sample)
Integrate a function over a sample.
- Parameters:
func (
nutils.function.Array) – Integrand.sample – The integration sample.
- nutils.function.sample(func, sample)
Evaluate a function in all sample points.
- Parameters:
func (
nutils.function.Array) – Integrand.sample – The integration sample.
- nutils.function.rootcoords(space, __dim)
Return the root coordinates.
- nutils.function.piecewise(level, intervals, *funcs)
- nutils.function.partition(f, *levels)
Create a partition of unity for a scalar function f.
When
nlevels are specified,n+1indicator functions are formed that evaluate to one if and only if the following condition holds:indicator 0: f < levels[0] indicator 1: levels[0] < f < levels[1] ... indicator n-1: levels[n-2] < f < levels[n-1] indicator n: f > levels[n-1]
At the interval boundaries the indicators evaluate to one half, in the remainder of the domain they evaluate to zero such that the whole forms a partition of unity. The partitions can be used to create a piecewise continuous function by means of multiplication and addition.
The following example creates a topology consiting of three elements, and a function
fthat is zero in the first element, parabolic in the second, and zero again in the third element.>>> from nutils import mesh >>> domain, x = mesh.rectilinear([3]) >>> left, center, right = partition(x[0], 1, 2) >>> f = (1 - (2*x[0]-3)**2) * center
- nutils.function.heaviside(f)
Create a heaviside step-function based on a scalar function f.
\[ \begin{align}\begin{aligned}H(f) &= 0 && f < 0\\H(f) &= 0.5 && f = 0\\H(f) &= 1 && f > 0\end{aligned}\end{align} \]See also
partition()generalized version of
heaviside()
- nutils.function.chain(_funcs)
- nutils.function.vectorize(args)
Combine scalar-valued bases into a vector-valued basis.
- Parameters:
args (iterable of 1-dimensional
nutils.function.Arrayobjects)- Return type:
- nutils.function.add_T(__arg, axes=(-2, -1))
add transposed
- nutils.function.field(name, /, *arrays, shape=(), dtype=<class 'float'>)
Return the inner product of the first axes of the given arrays with an argument with the given name.
An argument with shape
(arrays[0].shape[0], ..., arrays[-1].shape[0]) + shapewill be created. Repeatedly the inner product of the result, starting with the argument, with every array fromarraysis taken, where all but the first axis are treated as an outer product.- Parameters:
- Returns:
The inner product with shape
shape + arrays[0].shape[1:] + ... + arrays[-1].shape[1:].- Return type:
- nutils.function.arguments_for(*arrays)
Get all arguments that array(s) depend on.
Given any number of arrays, return a dictionary of all arguments involved, mapping the name to the
Argumentobject. Raise aValueErrorif arrays have conflicting arguments, i.e. sharing a name but differing in shape and/or dtype.
- class nutils.function.Basis(ndofs, nelems, index, coords)
Bases:
ArrayAbstract base class for bases.
A basis is a sequence of elementwise polynomial functions.
- Parameters:
Notes
Subclasses must implement
get_dofs()andget_coefficients()and if possible should redefineget_support().- get_support(self, dof)
Return the support of basis function
dof.If
dofis anint, return the indices of elements that form the support ofdof. Ifdofis an array, return the union of supports of the selected dofs as a unique array. The returned array is always unique, i.e. strict monotonic increasing.- Parameters:
dof (
intor array ofintorbool) – Index or indices of basis function or a mask.- Returns:
support – The elements (as indices) where function
dofhas support.- Return type:
sorted and unique
numpy.ndarray
- get_dofs(self, ielem)
Return an array of indices of basis functions with support on element
ielem.If
ielemis anint, return the dofs on elementielemmatching the coefficients array as returned byget_coefficients(). Ifielemis an array, return the union of dofs on the selected elements as a unique array, i.e. a strict monotonic increasing array.
- get_ndofs(self, ielem)
Return the number of basis functions with support on element
ielem.
- get_coefficients(self, ielem)
Return an array of coefficients for all basis functions with support on element
ielem.- Parameters:
ielem (
int) – Element number.- Returns:
coefficients – Array of coefficients with shape
(nlocaldofs,)+(degree,)*ndims, where the first axis corresponds to the dofs returned byget_dofs().- Return type:
- discontinuous_at_partition_interfaces(self, part_indices)
Returns a basis that is discontinuous at element partition interfaces.
Given a partition of elements, this basis is made discontinuous at the partition interfaces. All elements that have the same part index belong to the same part.
The returned basis is formed by clipping each function of the basis to each part individually and stacking all nonzero clipped functions. As a consequence, if a basis function has support on three topologically adjacent elements of which the first and the last element belong to one part and the middle to another, this function will not be clipped to each of the three elements individually, but to the first and the last element and to the middle element.
- Parameters:
part_indices (sequence or
numpy.ndarrayofint) – For each element the index of the part the element belongs to.
- class nutils.function.PlainBasis(coefficients, dofs, ndofs, index, coords)
Bases:
BasisA general purpose implementation of a
Basis.Use this class only if there exists no specific implementation of
Basisfor the basis at hand.- Parameters:
coefficients (
tupleofnumpy.ndarrayobjects) – The coefficients of the basis functions per transform. The order should match thetransformsargument.dofs (
tupleofnumpy.ndarrayobjects) – The dofs corresponding to thecoefficientsargument.ndofs (
int) – The number of basis functions.index (
Array) – The element index.coords (
Array) – The element local coordinates.
- class nutils.function.DiscontBasis(coefficients, index, coords)
Bases:
BasisA discontinuous basis with monotonic increasing dofs.
- Parameters:
coefficients (
tupleofnumpy.ndarrayobjects) – The coefficients of the basis functions per transform. The order should match thetransformsargument.index (
Array) – The element index.coords (
Array) – The element local coordinates.
- class nutils.function.LegendreBasis(degree, nelems, index, coords)
Bases:
BasisA discontinuous Legendre basis.
- class nutils.function.MaskedBasis(parent, indices)
Bases:
BasisAn order preserving subset of another
Basis.
- class nutils.function.StructuredBasis(coeffs, start_dofs, stop_dofs, dofs_shape, transforms_shape, index, coords)
Bases:
BasisA basis for class:nutils.transformseq.StructuredTransforms.
- Parameters:
coeffs (
tupleoftuples of arrays) – Per dimension the coefficients of the basis functions per transform.start_dofs (
tupleof arrays ofints) – Per dimension the dof of the first entry incoeffsper transform.stop_dofs (
tupleof arrays ofints) – Per dimension one plus the dof of the last entry incoeffsper transform.transforms_shape (
tupleofints) – The tensor shape of the transforms.index (
Array) – The element index.coords (
Array) – The element local coordinates.