https://github.com/gridap/tensorpolynomialbases.jl
++REPO NOT MAINTAINED++ Gallery of tensor-valued multivariate polynomial bases for the julia language
https://github.com/gridap/tensorpolynomialbases.jl
Last synced: 7 months ago
JSON representation
++REPO NOT MAINTAINED++ Gallery of tensor-valued multivariate polynomial bases for the julia language
- Host: GitHub
- URL: https://github.com/gridap/tensorpolynomialbases.jl
- Owner: gridap
- License: mit
- Created: 2019-05-15T15:54:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-08-09T15:39:27.000Z (almost 3 years ago)
- Last Synced: 2025-01-20T22:51:10.658Z (over 1 year ago)
- Language: Julia
- Homepage:
- Size: 62.5 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TensorPolynomialBases
[](https://travis-ci.com/gridap/TensorPolynomialBases.jl)
[](https://codecov.io/gh/gridap/TensorPolynomialBases.jl)
[](https://gridap.github.io/TensorPolynomialBases.jl/stable)
[](https://gridap.github.io/TensorPolynomialBases.jl/latest)
The **TensorPolynomialBases** package provides a collection of different types representing tensor-valued multivariate polynomial bases. It provides a common interface, called `TensorPolynomialBasis`, and several concrete implementations. At the moment, only a concrete implementation, called `MonomialBasis` is available, which implements a tensor-valued multivariate monomial basis. For representing the tensor values arising in the evaluation of tensor-valued polynomails, the user can either use the [StaticArrays](https://github.com/JuliaArrays/StaticArrays.jl) or the [TensorValues](https://github.com/gridap/TensorValues.jl) packages.
## Quick start
### Create a vector-valued monomial basis of P-polynomials in 2 variables
```julia
using TensorPolynomialBases
using StaticArrays
# Define a filter to select the monomials in the P-space
filter(e,order) = sum(e) <= order
order= 4
P = SVector{2,Float64} # type of the evaluation point
V = SVector{3,Float64} # type of the value
basis = MonomialBasis{P,V}(filter,order)
# Create scratch data that can be reused between evaluations
cache = ScratchData(basis)
# Evaluation point
x = @SVector rand(3)
# Evaluation
v = zeros(V,length(basis))
evaluate!(v,basis,x,cache) # No memory allocation here
@show v
# Evaluation of the gradient
G = gradient_type(basis)
# G == SMatrix{2,3,T,6}
v = zeros(G,length(basis))
gradient!(v,basis,x,cache) # No memory allocation here
@show v
```
### Create a Tensor-valued monomial basis of the "serendipity" space in 3 variables (this time using the types of the TensorValues package)
```julia
using TensorValues
# Define the filter for the serendipity space
filter(e,order) = sum( ( i for i in e if i>1 ) ) <= order
order= 3
P = VectorValue{3,Float64} # type of the evaluation point
V = TensorValue{3,Float64,9} # type of the value (3x3 tensor)
basis = MonomialBasis{P,V}(filter,order)
# Create scratch data that can be reused between evaluations
cache = ScratchData(basis)
# Evaluation point
x = VectorValue(0.1,2.0,3.1)
# Evaluation
v = zeros(V,length(basis))
evaluate!(v,basis,x,cache) # No memory allocation here
@show v
```