IgANet
IGAnets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
nurbs.hpp
Go to the documentation of this file.
1
15#pragma once
16
18
19namespace iganet {
20
33//
39//
48template <typename real_t, short_t GeoDim, short_t... Degrees>
50 : public UniformBSplineCore<real_t, GeoDim + 1, Degrees...> {
51private:
53 using Base = UniformBSplineCore<real_t, GeoDim + 1, Degrees...>;
54
55public:
57 using value_type = real_t;
58
64 template <template <typename, short_t, short_t...> class BSpline,
65 std::make_signed_t<short_t> degree_elevate = 0>
67 BSpline<real_t, GeoDim + 1, (Degrees + degree_elevate)...>;
68
71 template <std::make_signed_t<short_t> degree_elevate = 0>
72 using self_type =
74
78 template <typename other_t, short_t GeoDim_, short_t... Degrees_>
79 using derived_self_type = UniformNurbsCore<other_t, GeoDim_, Degrees_...>;
80
83 template <typename other_t>
84 using real_derived_self_type = UniformNurbsCore<other_t, GeoDim, Degrees...>;
85
89 static constexpr bool is_uniform() { return true; }
90
93 static constexpr bool is_nonuniform() { return false; }
94
100
108 explicit UniformNurbsCore(const std::array<int64_t, Base::parDim_> &ncoeffs,
109 enum init init = init::greville,
111 : Base(ncoeffs, init, options) {
112 if (Base::coeffs_[GeoDim].defined())
113 Base::coeffs_[GeoDim] = torch::ones_like(Base::coeffs_[GeoDim]);
114 }
115
129 UniformNurbsCore(const std::array<int64_t, Base::parDim_> &ncoeffs,
131 bool clone = false,
133 : Base(ncoeffs, coeffs, clone, options) {}
134
149
155 template <typename other_t>
159 : Base(static_cast<UniformBSplineCore<other_t, GeoDim + 1, Degrees...>>(
160 other)) {}
161
167 inline static constexpr short_t geoDim() noexcept { return GeoDim; }
168
175 [[nodiscard]] inline const torch::Tensor &weights() const noexcept {
176 return Base::coeffs_[GeoDim];
177 }
178
185 inline torch::Tensor &weights() noexcept { return Base::coeffs_[GeoDim]; }
186};
187
194template <typename real_t, short_t GeoDim, short_t... Degrees>
196 : public NonUniformBSplineCore<real_t, GeoDim, Degrees...> {
197private:
199 using Base = NonUniformBSplineCore<real_t, GeoDim, Degrees...>;
200
201protected:
203 torch::Tensor weights_;
204
205public:
207 using value_type = real_t;
208
214 template <template <typename, short_t, short_t...> class BSpline,
215 std::make_signed_t<short_t> degree_elevate = 0>
216 using derived_type = BSpline<real_t, GeoDim, (Degrees + degree_elevate)...>;
217
220 template <std::make_signed_t<short_t> degree_elevate = 0>
221 using self_type =
223
227 template <typename other_t, short_t GeoDim_, short_t... Degrees_>
228 using derived_self_type = NonUniformNurbsCore<other_t, GeoDim_, Degrees_...>;
229
232 template <typename other_t>
234 NonUniformNurbsCore<other_t, GeoDim, Degrees...>;
235
239 static constexpr bool is_uniform() { return false; }
240
243 static constexpr bool is_nonuniform() { return true; }
244};
245
247template <typename real_t, short_t GeoDim, short_t... Degrees>
249 BSplineCommon<UniformNurbsCore<real_t, GeoDim, Degrees...>>;
250
261template <typename real_t, short_t GeoDim, short_t... Degrees>
262inline std::ostream &
263operator<<(std::ostream &os,
265 obj.pretty_print(os);
266 return os;
267}
268
270template <typename real_t, short_t GeoDim, short_t... Degrees>
272 BSplineCommon<NonUniformNurbsCore<real_t, GeoDim, Degrees...>>;
273
284template <typename real_t, short_t GeoDim, short_t... Degrees>
285inline std::ostream &
286operator<<(std::ostream &os,
288 obj.pretty_print(os);
289 return os;
290}
291} // namespace iganet
Multivariate B-splines.
B-spline (common high-level functionality).
Definition bspline.hpp:3890
void pretty_print(std::ostream &os) const noexcept override
Returns a string representation of the BSplineCommon object.
Definition bspline.hpp:7462
Tensor-product non-uniform B-spline (core functionality).
Definition bspline.hpp:3287
Tensor-product non-uniform rational B-spline with non-uniform knot vectors (core functionality).
Definition nurbs.hpp:196
static constexpr bool is_nonuniform()
Returns true if the B-spline is non-uniform.
Definition nurbs.hpp:243
torch::Tensor weights_
Tensor storing the weights.
Definition nurbs.hpp:203
BSpline< real_t, GeoDim,(Degrees+degree_elevate)... > derived_type
Deduces the type of the template parameter BSpline when exposed to the class template parameters real...
Definition nurbs.hpp:216
real_t value_type
Value type.
Definition nurbs.hpp:207
Base::template derived_type< NonUniformNurbsCore, degree_elevate > self_type
Deduces the self-type possibly degrees (de-)elevated by the additive constant degree_elevate.
Definition nurbs.hpp:222
static constexpr bool is_uniform()
Returns true if the B-spline is uniform.
Definition nurbs.hpp:239
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:47
Tensor-product uniform B-spline (core functionality).
Definition bspline.hpp:229
const Options< real_t > & options() const noexcept
Returns a constant reference to the B-spline object's options.
Definition bspline.hpp:383
utils::TensorArray< geoDim_ > coeffs_
Array storing the coefficients of the control net. , .
Definition bspline.hpp:268
const utils::TensorArray< geoDim_ > & coeffs() const noexcept
Returns a constant reference to the array of coefficient vectors.
Definition bspline.hpp:613
const std::array< int64_t, parDim_ > & ncoeffs() const noexcept
Returns a constant reference to the array of coefficient vector dimensions.
Definition bspline.hpp:688
Tensor-product non-uniform rational B-spline with uniform knot vector (core functionality).
Definition nurbs.hpp:50
const torch::Tensor & weights() const noexcept
Returns a constant reference to the weights.
Definition nurbs.hpp:175
UniformBSplineCore< real_t, GeoDim+1, Degrees... > Base
Base type.
Definition nurbs.hpp:53
static constexpr short_t geoDim() noexcept
Definition nurbs.hpp:167
UniformNurbsCore(Options< real_t > options=Options< real_t >{})
Default constructor.
Definition nurbs.hpp:98
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.
Definition nurbs.hpp:129
static constexpr bool is_uniform()
Returns true if the B-spline is uniform.
Definition nurbs.hpp:89
UniformNurbsCore(const UniformNurbsCore< other_t, GeoDim+1, Degrees... > &other, Options< real_t > options=Options< real_t >{})
Copy constructor.
Definition nurbs.hpp:156
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.
Definition nurbs.hpp:145
BSpline< real_t, GeoDim+1,(Degrees+degree_elevate)... > derived_type
Deduces the type of the template parameter BSpline when exposed to the class template parameters real...
Definition nurbs.hpp:67
static constexpr bool is_nonuniform()
Returns true if the B-spline is non-uniform.
Definition nurbs.hpp:93
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.
Definition nurbs.hpp:108
real_t value_type
Value type.
Definition nurbs.hpp:57
Base::template derived_type< UniformNurbsCore, degree_elevate > self_type
Deduces the self-type possibly degrees (de-)elevated by the additive constant degree_elevate.
Definition nurbs.hpp:73
torch::Tensor & weights() noexcept
Returns a non-constant reference to the weights.
Definition nurbs.hpp:185
std::array< torch::Tensor, N > TensorArray
Definition tensorarray.hpp:26
Definition core.hpp:73
std::ostream & operator<<(std::ostream &os, const MemoryDebugger< id > &obj)
Prints a memory debugger object.
Definition memory.hpp:145
init
Enumerator for specifying the initialization of B-spline coefficients.
Definition bspline.hpp:58
short int short_t
Signed short integer type used by IgANet's compact enumerations.
Definition core.hpp:76