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

Tensor-product non-uniform rational B-spline with uniform knot vector (core functionality) More...

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

Inheritance diagram for iganet::UniformNurbsCore< real_t, GeoDim, Degrees >:
iganet::UniformBSplineCore< real_t, GeoDim+1, 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 = UniformNurbsCore< 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+1,(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 = UniformNurbsCore< 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< UniformNurbsCore, 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+1, 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

 UniformNurbsCore (const std::array< int64_t, Base::parDim_ > &ncoeffs, const utils::TensorArray< Base::geoDim_ > &coeffs, bool clone=false, Options< real_t > options=Options< real_t >{})
 Constructor for equidistant knot vectors.
 
 UniformNurbsCore (const std::array< int64_t, Base::parDim_ > &ncoeffs, enum init init=init::greville, Options< real_t > options=Options< real_t >{})
 Constructor for equidistant knot vectors.
 
 UniformNurbsCore (const std::array< int64_t, Base::parDim_ > &ncoeffs, utils::TensorArray< Base::geoDim_ > &&coeffs, Options< real_t > options=Options< real_t >{})
 Constructor for equidistant knot vectors.
 
template<typename other_t >
 UniformNurbsCore (const UniformNurbsCore< other_t, GeoDim+1, Degrees... > &other, Options< real_t > options=Options< real_t >{})
 Copy constructor.
 
 UniformNurbsCore (Options< real_t > options=Options< real_t >{})
 Default constructor.
 
const torch::Tensor & weights () const noexcept
 Returns a constant reference to the weights.
 
torch::Tensor & weights () noexcept
 Returns a non-constant reference to the weights.
 
- Public Member Functions inherited from iganet::UniformBSplineCore< real_t, GeoDim+1, 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 short_t geoDim () noexcept
 
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+1, 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+1, Degrees... >
 Base type.
 

Additional Inherited Members

- Protected Member Functions inherited from iganet::UniformBSplineCore< real_t, GeoDim+1, 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+1, 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+1, 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::UniformNurbsCore< real_t, GeoDim, Degrees >

Tensor-product non-uniform rational B-spline with uniform knot vector (core functionality)

This class extends the base class UniformBSplineCore to non-uniform rational B-splines (NURBS) with uniform knot vectors. Like its base class it only implements the core functionality of non-uniform rational B-splines.

This implementation exploits the fact that NURBS in \(d\) space dimensions can be realized through perspective projection from B-splines in \(d+1\) space dimensions. That is, a NURBS object with control points

\[ \mathbf{c}_i = \left(x_i, y_i, z_i\right) \]

is extended to a B-spline object with homogeneous coordinates

\[ \mathbf{c}_i = \left(w_i x_i, w_i y_i, w_i z_i, w_i\right) \]

with non-negative weights \(w_i\). All operations are performed on the B-spline object which is afterwards converted to a NURBS object through perspective projection onto the coordinates \(\left(x/w, y/w, z/w\right)\).

Member Typedef Documentation

◆ Base

template<typename real_t , short_t GeoDim, short_t... Degrees>
using iganet::UniformNurbsCore< real_t, GeoDim, Degrees >::Base = UniformBSplineCore<real_t, GeoDim + 1, 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::UniformNurbsCore< real_t, GeoDim, Degrees >::derived_self_type = UniformNurbsCore<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::UniformNurbsCore< real_t, GeoDim, Degrees >::derived_type = BSpline<real_t, GeoDim + 1, (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::UniformNurbsCore< real_t, GeoDim, Degrees >::real_derived_self_type = UniformNurbsCore<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::UniformNurbsCore< real_t, GeoDim, Degrees >::self_type = typename Base::template derived_type<UniformNurbsCore, 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::UniformNurbsCore< real_t, GeoDim, Degrees >::value_type = real_t

Value type.

Constructor & Destructor Documentation

◆ UniformNurbsCore() [1/5]

template<typename real_t , short_t GeoDim, short_t... Degrees>
iganet::UniformNurbsCore< real_t, GeoDim, Degrees >::UniformNurbsCore ( Options< real_t >  options = Options<real_t>{})
inline

Default constructor.

Parameters
[in]optionsOptions configuration

◆ UniformNurbsCore() [2/5]

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

Constructor for equidistant knot vectors.

Parameters
[in]ncoeffsNumber of coefficients per parametric dimension
[in]initType of initialization
[in]optionsOptions configuration

◆ UniformNurbsCore() [3/5]

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

Constructor for equidistant knot vectors.

Parameters
[in]ncoeffsNumber of coefficients per parametric dimension
[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.

◆ UniformNurbsCore() [4/5]

template<typename real_t , short_t GeoDim, short_t... Degrees>
iganet::UniformNurbsCore< real_t, GeoDim, Degrees >::UniformNurbsCore ( const std::array< int64_t, Base::parDim_ > &  ncoeffs,
utils::TensorArray< Base::geoDim_ > &&  coeffs,
Options< real_t >  options = Options<real_t>{} 
)
inline

Constructor for equidistant knot vectors.

Parameters
[in]ncoeffsNumber of coefficients per parametric dimension
[in]coeffsVectors of coefficients per parametric dimension
[in]optionsOptions configuration
Note
It is not checked whether vectors of coefficients are compatible with the given Options object if clone is false.

◆ UniformNurbsCore() [5/5]

template<typename real_t , short_t GeoDim, short_t... Degrees>
template<typename other_t >
iganet::UniformNurbsCore< real_t, GeoDim, Degrees >::UniformNurbsCore ( const UniformNurbsCore< other_t, GeoDim+1, Degrees... > &  other,
Options< real_t >  options = Options<real_t>{} 
)
inline

Copy constructor.

Parameters
[in]otherUniform Nurbs object to copy
[in]optionsOptions configuration

Member Function Documentation

◆ geoDim()

template<typename real_t , short_t GeoDim, short_t... Degrees>
static constexpr short_t iganet::UniformNurbsCore< real_t, GeoDim, Degrees >::geoDim ( )
inlinestaticconstexprnoexcept
Returns
Number of geometric dimensions
Note
This override of the geoDim() function makes sure that the geometric dimension is reported correctly with respect to the NURBS object

◆ is_nonuniform()

template<typename real_t , short_t GeoDim, short_t... Degrees>
static constexpr bool iganet::UniformNurbsCore< 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::UniformNurbsCore< real_t, GeoDim, Degrees >::is_uniform ( )
inlinestaticconstexpr

Returns true if the B-spline is uniform.

◆ weights() [1/2]

template<typename real_t , short_t GeoDim, short_t... Degrees>
const torch::Tensor & iganet::UniformNurbsCore< real_t, GeoDim, Degrees >::weights ( ) const
inlinenoexcept

Returns a constant reference to the weights.

Note
Since the weights are the entry of the homogeneous coordinates which are stored in coeff one can likewise retrieve them using coeffs(GeoDim)

◆ weights() [2/2]

template<typename real_t , short_t GeoDim, short_t... Degrees>
torch::Tensor & iganet::UniformNurbsCore< real_t, GeoDim, Degrees >::weights ( )
inlinenoexcept

Returns a non-constant reference to the weights.

Note
Since the weights are the entry of the homogeneous coordinates which are stored in coeff one can likewise retrieve them using coeffs(GeoDim)

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