IgANet
IgANets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees > Class Template Reference

Tensor-product non-uniform B-spline (core functionality) More...

#include </home/runner/work/iganet/iganet/include/bspline.hpp>

Inheritance diagram for iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >:
iganet::UniformBSplineCore< real_t, GeoDim, Degrees... > iganet::utils::Serializable iganet::BSplinePatch< real_t, GeoDim, sizeof...(Degrees)>

Public Types

template<typename other_t , short_t GeoDim_, short_t... Degrees_>
using derived_self_type = NonUniformBSplineCore< other_t, GeoDim_, Degrees_... >
 Deduces the derived self-type when exposed to different class template parameters real_t and GeoDim, and the Degrees parameter pack.
 
template<template< typename, short_t, short_t... > class BSpline, std::make_signed< short_t >::type degree_elevate = 0>
using derived_type = BSpline< real_t, GeoDim,(Degrees+degree_elevate)... >
 Deduces the type of the template template parameter BSpline when exposed to the class template parameters real_t and GeoDim, and the Degrees parameter pack. The optional template parameter degree_elevate can be used to (de-)elevate the degrees by an additive constant.
 
template<typename other_t >
using real_derived_self_type = NonUniformBSplineCore< other_t, GeoDim, Degrees... >
 Deduces the derived self-type when exposed to a different class template parameter real_t
 
template<std::make_signed< short_t >::type degree_elevate = 0>
using self_type = typename Base::template derived_type< NonUniformBSplineCore, degree_elevate >
 Deduces the self-type possibly degrees (de-)elevated by the additive constant degree_elevate
 
using value_type = real_t
 Value type.
 
- Public Types inherited from iganet::UniformBSplineCore< real_t, GeoDim, Degrees... >
using derived_self_type = UniformBSplineCore< other_t, GeoDim_, Degrees_... >
 Deduces the derived self-type when exposed to different class template parameters real_t and GeoDim, and the Degrees parameter pack.
 
using derived_type = BSpline< real_t, GeoDim,(Degrees+degree_elevate)... >
 Deduces the type of the template template parameter BSpline when exposed to the class template parameters real_t and GeoDim, and the Degrees parameter pack. The optional template parameter degree_elevate can be used to (de-)elevate the degrees by an additive constant.
 
using real_derived_self_type = UniformBSplineCore< other_t, GeoDim, Degrees... >
 Deduces the derived self-type when exposed to a different class template parameter real_t
 
using self_type = derived_type< UniformBSplineCore, degree_elevate >
 Deduces the self-type possibly degrees (de-)elevated by the additive constant degree_elevate
 
using value_type = real_t
 Value type.
 

Public Member Functions

 NonUniformBSplineCore (const std::array< std::vector< typename Base::value_type >, Base::parDim_ > &kv, const utils::TensorArray< Base::geoDim_ > &coeffs, bool clone=false, Options< real_t > options=Options< real_t >{})
 Constructor for non-equidistant knot vectors.
 
 NonUniformBSplineCore (const std::array< std::vector< typename Base::value_type >, Base::parDim_ > &kv, enum init init=init::greville, Options< real_t > options=Options< real_t >{})
 Constructor for non-equidistant knot vectors.
 
template<typename BSpline >
autofrom_gismo (BSpline &bspline, bool, bool)
 
NonUniformBSplineCoreinsert_knots (const utils::TensorArray< Base::parDim_ > &knots)
 Returns the B-spline object with refined knot and coefficient vectors.
 
NonUniformBSplineCorereduce_continuity (int numReduce=1, int dim=-1)
 Returns the B-spline object with updated knot and coefficient vectors with reduced continuity.
 
NonUniformBSplineCoreuniform_refine (int numRefine=1, int dim=-1)
 Returns the B-spline object with uniformly refined knot and coefficient vectors.
 
- Public Member Functions inherited from iganet::UniformBSplineCore< real_t, GeoDim, Degrees... >
 UniformBSplineCore (const std::array< int64_t, parDim_ > &ncoeffs, const utils::TensorArray< geoDim_ > &coeffs, bool clone=false, Options< real_t > options=Options< real_t >{})
 Constructor for equidistant knot vectors.
 
 UniformBSplineCore (const std::array< int64_t, parDim_ > &ncoeffs, enum init init=init::greville, Options< real_t > options=Options< real_t >{})
 Constructor for equidistant knot vectors.
 
 UniformBSplineCore (const std::array< int64_t, parDim_ > &ncoeffs, utils::TensorArray< geoDim_ > &&coeffs, Options< real_t > options=Options< real_t >{})
 Constructor for equidistant knot vectors.
 
 UniformBSplineCore (const UniformBSplineCore< other_t, GeoDim, Degrees... > &other, Options< real_t > options=Options< real_t >{})
 Copy constructor.
 
 UniformBSplineCore (Options< real_t > options=Options< real_t >{})
 Default constructor.
 
torch::Tensor as_tensor () const noexcept override
 Returns all coefficients as a single tensor.
 
int64_t as_tensor_size () const noexcept override
 Returns the size of the single tensor representation of all coefficients.
 
const utils::TensorArray< geoDim_ > & coeffs () const noexcept
 Returns a constant reference to the array of coefficient vectors.
 
utils::TensorArray< geoDim_ > & coeffs () noexcept
 Returns a non-constant reference to the array of coefficient vectors.
 
const torch::Tensor & coeffs (short_t i) const noexcept
 Returns a constant reference to the coefficient vector in the \(i\)-th dimension.
 
torch::Tensor & coeffs (short_t i) noexcept
 Returns a non-constant reference to the coefficient vector in the \(i\)-th dimension.
 
nlohmann::json coeffs_to_json () const
 Returns the B-spline object's coefficients as JSON object.
 
utils::TensorArray< geoDim_ > coeffs_view () const noexcept
 Returns an array of views to the coefficient vectors.
 
const auto coeffs_view (short_t i) const noexcept
 Returns a view to the coefficient vector in the \(i\)-th dimension.
 
torch::Device device () const noexcept override
 Returns the device property.
 
int32_t device_index () const noexcept override
 Returns the device_index property.
 
torch::Dtype dtype () const noexcept override
 Returns the dtype property.
 
auto eval (const utils::TensorArray< parDim_ > &xi, const utils::TensorArray< parDim_ > &knot_indices) const
 Returns the value of the univariate B-spline object in the points xi
 
auto eval (const utils::TensorArray< parDim_ > &xi, const utils::TensorArray< parDim_ > &knot_indices, const torch::Tensor &coeff_indices) const
 Returns the value of the univariate B-spline object in the points xi
 
auto & from_gismo (BSpline &bspline, bool, bool)
 
UniformBSplineCorefrom_json (const nlohmann::json &json)
 Updates the B-spline object from JSON object.
 
UniformBSplineCorefrom_tensor (const torch::Tensor &tensor) noexcept override
 Sets all coefficients from a single tensor.
 
UniformBSplineCorefrom_xml (const pugi::xml_document &doc, int id=0, std::string label="", int index=-1)
 Updates the B-spline object from XML object.
 
UniformBSplineCorefrom_xml (const pugi::xml_node &root, int id=0, std::string label="", int index=-1)
 Updates the B-spline object from XML node.
 
auto greville (bool interior=false) const
 Returns the Greville abscissae.
 
void init_coeffs (enum init init)
 Initializes the B-spline coefficients.
 
void init_knots ()
 Initializes the B-spline knots.
 
bool is_sparse () const noexcept override
 Returns true if the layout is sparse.
 
bool isclose (const UniformBSplineCore< other_t, GeoDim_, Degrees_... > &other, real_t rtol=real_t{1e-5}, real_t atol=real_t{1e-8}) const
 Returns true if both B-spline objects are close up to the given tolerances.
 
const utils::TensorArray< parDim_ > & knots () const noexcept
 Returns a constant reference to the array of knot vectors.
 
utils::TensorArray< parDim_ > & knots () noexcept
 Returns a non-constant reference to the array of knot vectors.
 
const torch::Tensor & knots (short_t i) const noexcept
 Returns a constant reference to the knot vector in the \(i\)-th dimension.
 
torch::Tensor & knots (short_t i) noexcept
 Returns a non-constant reference to the knot vector in the \(i\)-th dimension.
 
nlohmann::json knots_to_json () const
 Returns the B-spline object's knots as JSON object.
 
torch::Layout layout () const noexcept override
 Returns the layout property.
 
void load (const std::string &filename, const std::string &key="bspline")
 Loads the B-spline from file.
 
const std::array< int64_t, parDim_ > & ncoeffs () const noexcept
 Returns a constant reference to the array of coefficient vector dimensions.
 
int64_t ncoeffs (short_t i) const noexcept
 Returns the total number of coefficients in the \(i\)-th direction.
 
int64_t ncumcoeffs () const noexcept
 Returns the total number of coefficients.
 
const std::array< int64_t, parDim_ > & nknots () const noexcept
 Returns a constant reference to the array of knot vector dimensions.
 
int64_t nknots (short_t i) const noexcept
 Returns the dimension of the knot vector in the \(i\)-th dimension.
 
bool operator!= (const UniformBSplineCore< other_t, GeoDim_, Degrees_... > &other) const
 Returns true if both B-spline objects are different.
 
bool operator== (const UniformBSplineCore< other_t, GeoDim_, Degrees_... > &other) const
 Returns true if both B-spline objects are the same.
 
const Options< real_t > & options () const noexcept
 Returns a constant reference to the B-spline object's options.
 
bool pinned_memory () const noexcept override
 Returns the pinned_memory property.
 
torch::serialize::InputArchive & read (torch::serialize::InputArchive &archive, const std::string &key="bspline")
 Reads the B-spline from a torch::serialize::InputArchive object.
 
bool requires_grad () const noexcept override
 Returns the requires_grad property.
 
void save (const std::string &filename, const std::string &key="bspline") const
 Saves the B-spline to file.
 
UniformBSplineCoreset_requires_grad (bool requires_grad) noexcept override
 Sets the B-spline object's requires_grad property.
 
auto to_gismo () const
 Converts the B-spline object into a gsBSpline object of the parametric dimension is one and a gsTensorBSpline object otherwise.
 
BSpline & to_gismo (BSpline &bspline, bool, bool) const
 
nlohmann::json to_json () const override
 Returns the B-spline object as JSON object.
 
pugi::xml_document to_xml (int id=0, std::string label="", int index=-1) const
 Returns the B-spline object as XML object.
 
pugi::xml_node & to_xml (pugi::xml_node &root, int id=0, std::string label="", int index=-1) const
 Returns the B-spline object as XML node.
 
UniformBSplineCoretransform (const std::function< std::array< real_t, geoDim_ >(const std::array< real_t, parDim_ > &)> transformation)
 Transforms the coefficients based on the given mapping.
 
UniformBSplineCoretransform (const std::function< std::array< real_t, N >(const std::array< real_t, parDim_ > &)> transformation, std::array< short_t, N > dims)
 Transforms the coefficients based on the given mapping.
 
UniformBSplineCoreuniform_refine (int numRefine=1, int dim=-1)
 Returns the B-spline object with uniformly refined knot and coefficient vectors.
 
torch::serialize::OutputArchive & write (torch::serialize::OutputArchive &archive, const std::string &key="bspline") const
 Writes the B-spline into a torch::serialize::OutputArchive object.
 
- Public Member Functions inherited from iganet::utils::Serializable
virtual void pretty_print (std::ostream &os=Log(log::info)) const =0
 Returns a string representation of the object.
 
- Public Member Functions inherited from iganet::BSplinePatch< real_t, GeoDim, sizeof...(Degrees)>
virtual void pretty_print (std::ostream &os=Log(log::info)) const noexcept=0
 Returns a string representation.
 

Static Public Member Functions

static constexpr bool is_nonuniform ()
 Returns true if the B-spline is non-uniform.
 
static constexpr bool is_uniform ()
 Returns true if the B-spline is uniform.
 
- Static Public Member Functions inherited from iganet::UniformBSplineCore< real_t, GeoDim, Degrees... >
static constexpr const short_tdegree (short_t i) noexcept
 Returns a constant reference to the degree in the \(i\)-th dimension.
 
static constexpr const std::array< short_t, parDim_ > & degrees () noexcept
 Returns a constant reference to the array of degrees.
 
static constexpr short_t geoDim () noexcept
 Returns the geometric dimension.
 
static constexpr bool is_nonuniform () noexcept
 Returns true if the B-spline is non-uniform.
 
static constexpr bool is_uniform () noexcept
 Returns true if the B-spline is uniform.
 
static constexpr short_t parDim () noexcept
 Returns the parametric dimension.
 

Private Types

using Base = UniformBSplineCore< real_t, GeoDim, Degrees... >
 Base type.
 

Private Member Functions

void init_knots (const std::array< std::vector< typename Base::value_type >, Base::parDim_ > &kv)
 Initializes the B-spline knots.
 

Additional Inherited Members

- Protected Member Functions inherited from iganet::UniformBSplineCore< real_t, GeoDim, Degrees... >
auto eval_basfunc_univariate (const torch::Tensor &xi, const torch::Tensor &knot_indices) const
 Returns the vector of univariate B-spline basis functions (or their derivatives) evaluated in the point xi
 
void update_coeffs (const utils::TensorArray< parDim_ > &knots, const utils::TensorArray< parDim_ > &knot_indices)
 Updates the B-spline coefficients after knot insertion.
 
auto update_coeffs_univariate (const torch::Tensor &knots, const torch::Tensor &knot_indices) const
 Returns the knot insertion matrix.
 
- Protected Attributes inherited from iganet::UniformBSplineCore< real_t, GeoDim, Degrees... >
utils::TensorArray< geoDim_ > coeffs_
 Array storing the coefficients of the control net \(\left(\mathbf{c}_{i_d}\right)_{i_d=1}^{n_d}\), \(\mathbf{c}_{i_d}\in\mathbb{R}^{d_\text{geo}}\).
 
utils::TensorArray< parDim_ > knots_
 Array storing the knot vectors \(\left(\left(t_{i_d}\right)_{i_d=1}^{n_d+p_d+1}\right)_{d=1}^{d_\text{par}}\).
 
std::array< int64_t, parDim_ > ncoeffs_
 Array storing the sizes of the coefficients of the control net \(\left(n_d\right)_{d=1}^{d_\text{par}}\).
 
std::array< int64_t, parDim_ > ncoeffs_reverse_
 Array storing the sizes of the coefficients of the control net \(\left(n_d\right)_{d=1}^{d_\text{par}}\) in reverse order (needed for coeffs_view)
 
std::array< int64_t, parDim_ > nknots_
 Array storing the sizes of the knot vectors \(\left(n_d+p_d+1\right)_{d=1}^{d_\text{par}}\).
 
Options< real_t > options_
 Options.
 
- Static Protected Attributes inherited from iganet::UniformBSplineCore< real_t, GeoDim, Degrees... >
static constexpr const std::array< short_t, parDim_ > degrees_
 Array storing the degrees \(\left(p_d\right)_{d=1}^{d_\text{par}}\).
 
static constexpr const short_t geoDim_
 Dimension of the geometric space \(\Omega\subset\mathbb{R}^{d_\text{geo}}\).
 
static constexpr const short_t parDim_
 Dimension of the parametric space \(\hat\Omega=[0,1]^{d_\text{par}}\).
 

Detailed Description

template<typename real_t, short_t GeoDim, short_t... Degrees>
class iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >

Tensor-product non-uniform B-spline (core functionality)

This class extends the base class UniformBSplineCore to non-uniform B-splines. Like its base class it only implements the core functionality of non-uniform B-splines

Member Typedef Documentation

◆ Base

template<typename real_t , short_t GeoDim, short_t... Degrees>
using iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::Base = UniformBSplineCore<real_t, GeoDim, Degrees...>
private

Base type.

◆ derived_self_type

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<typename other_t , short_t GeoDim_, short_t... Degrees_>
using iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::derived_self_type = NonUniformBSplineCore<other_t, GeoDim_, Degrees_...>

Deduces the derived self-type when exposed to different class template parameters real_t and GeoDim, and the Degrees parameter pack.

◆ derived_type

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<template< typename, short_t, short_t... > class BSpline, std::make_signed< short_t >::type degree_elevate = 0>
using iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::derived_type = BSpline<real_t, GeoDim, (Degrees + degree_elevate)...>

Deduces the type of the template template parameter BSpline when exposed to the class template parameters real_t and GeoDim, and the Degrees parameter pack. The optional template parameter degree_elevate can be used to (de-)elevate the degrees by an additive constant.

◆ real_derived_self_type

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<typename other_t >
using iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::real_derived_self_type = NonUniformBSplineCore<other_t, GeoDim, Degrees...>

Deduces the derived self-type when exposed to a different class template parameter real_t

◆ self_type

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<std::make_signed< short_t >::type degree_elevate = 0>
using iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::self_type = typename Base::template derived_type<NonUniformBSplineCore, degree_elevate>

Deduces the self-type possibly degrees (de-)elevated by the additive constant degree_elevate

◆ value_type

template<typename real_t , short_t GeoDim, short_t... Degrees>
using iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::value_type = real_t

Value type.

Constructor & Destructor Documentation

◆ NonUniformBSplineCore() [1/2]

template<typename real_t , short_t GeoDim, short_t... Degrees>
iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::NonUniformBSplineCore ( const std::array< std::vector< typename Base::value_type >, Base::parDim_ > &  kv,
enum init  init = init::greville,
Options< real_t >  options = Options<real_t>{} 
)
inline

Constructor for non-equidistant knot vectors.

Parameters
[in]kvKnot vectors
[in]initType of initialization
[in]optionsOptions configuration

◆ NonUniformBSplineCore() [2/2]

template<typename real_t , short_t GeoDim, short_t... Degrees>
iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::NonUniformBSplineCore ( const std::array< std::vector< typename Base::value_type >, Base::parDim_ > &  kv,
const utils::TensorArray< Base::geoDim_ > &  coeffs,
bool  clone = false,
Options< real_t >  options = Options<real_t>{} 
)
inline

Constructor for non-equidistant knot vectors.

Parameters
[in]kvKnot vectors
[in]coeffsVectors of coefficients per parametric dimension
[in]cloneIf true, coefficients will be cloned. Otherwise, coefficients will be aliased
[in]optionsOptions configuration
Note
It is not checked whether vectors of coefficients are compatible with the given Options object if clone is false.

Member Function Documentation

◆ eval() [1/4]

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<deriv deriv = deriv::func, bool memory_optimized = false>
auto iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::eval ( const torch::Tensor &  xi) const
inline

Returns the value of the multivariate B-spline object in the point xi

◆ eval() [2/4]

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<deriv deriv = deriv::func, bool memory_optimized = false>
auto iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::eval ( const utils::TensorArray< Base::parDim_ > &  xi) const
inline

Returns the value of the multivariate B-spline object in the point xi

◆ eval() [3/4]

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<deriv deriv = deriv::func, bool memory_optimized = false>
auto iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::eval ( const utils::TensorArray< Base::parDim_ > &  xi,
const utils::TensorArray< Base::parDim_ > &  knot_indices 
) const
inline

Returns the value of the multivariate B-spline object in the point xi

◆ eval() [4/4]

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<deriv deriv = deriv::func, bool memory_optimized = false>
auto iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::eval ( const utils::TensorArray< Base::parDim_ > &  xi,
const utils::TensorArray< Base::parDim_ > &  knot_indices,
const torch::Tensor &  coeff_indices 
) const
inline

Returns the value of the multivariate B-spline object in the point xi

◆ find_knot_indices() [1/2]

template<typename real_t , short_t GeoDim, short_t... Degrees>
auto iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::find_knot_indices ( const torch::Tensor &  xi) const
inline

Returns the indices of knot spans containing xi

This function returns the indices \((i_d)_{d=1}^{d_\text{par}}\) of the knot spans such that

\[ \boldsymbol{\xi} \in [t_{i_1}, t_{i_1+1}) \times [t_{i_2}, t_{i_2+1}) \times \dots \times [t_{i_{d_\text{par}}}, t_{i_{d_\text{par}}+1}). \]

The indices are returned as utils::TensorArray<parDim_> in the same order as provided in xi

◆ find_knot_indices() [2/2]

template<typename real_t , short_t GeoDim, short_t... Degrees>
auto iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::find_knot_indices ( const utils::TensorArray< Base::parDim_ > &  xi) const
inline

Returns the indices of knot spans containing xi

This function returns the indices \((i_d)_{d=1}^{d_\text{par}}\) of the knot spans such that

\[ \boldsymbol{\xi} \in [t_{i_1}, t_{i_1+1}) \times [t_{i_2}, t_{i_2+1}) \times \dots \times [t_{i_{d_\text{par}}}, t_{i_{d_\text{par}}+1}). \]

The indices are returned as utils::TensorArray<parDim_> in the same order as provided in xi

◆ from_gismo()

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<typename BSpline >
auto & iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::from_gismo ( BSpline bspline,
bool  ,
bool   
)
inline

◆ init_knots()

template<typename real_t , short_t GeoDim, short_t... Degrees>
void iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::init_knots ( const std::array< std::vector< typename Base::value_type >, Base::parDim_ > &  kv)
inlineprivate

Initializes the B-spline knots.

◆ insert_knots()

template<typename real_t , short_t GeoDim, short_t... Degrees>
NonUniformBSplineCore & iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::insert_knots ( const utils::TensorArray< Base::parDim_ > &  knots)
inline

Returns the B-spline object with refined knot and coefficient vectors.

◆ is_nonuniform()

template<typename real_t , short_t GeoDim, short_t... Degrees>
static constexpr bool iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::is_nonuniform ( )
inlinestaticconstexpr

Returns true if the B-spline is non-uniform.

◆ is_uniform()

template<typename real_t , short_t GeoDim, short_t... Degrees>
static constexpr bool iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::is_uniform ( )
inlinestaticconstexpr

Returns true if the B-spline is uniform.

◆ reduce_continuity()

template<typename real_t , short_t GeoDim, short_t... Degrees>
NonUniformBSplineCore & iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::reduce_continuity ( int  numReduce = 1,
int  dim = -1 
)
inline

Returns the B-spline object with updated knot and coefficient vectors with reduced continuity.

◆ uniform_refine()

template<typename real_t , short_t GeoDim, short_t... Degrees>
NonUniformBSplineCore & iganet::NonUniformBSplineCore< real_t, GeoDim, Degrees >::uniform_refine ( int  numRefine = 1,
int  dim = -1 
)
inline

Returns the B-spline object with uniformly refined knot and coefficient vectors.

If dim = -1, new knot values are inserted uniformly in each knot span in all spatial dimensions. Otherwise, i.e., dim != -1 new knots are only inserted in the specified dimension.


The documentation for this class was generated from the following file: