22#include <nlohmann/json.hpp>
40 { a.as_tensor_size() };
53template <
typename real_t,
short_t GeoDim,
short_t ParDim>
class BSplinePatch {
71 virtual torch::Device
device() const noexcept = 0;
125 virtual utils::BlockTensor<
torch::Tensor, 1, GeoDim>
127 const
torch::Tensor &coeff_indices, int64_t numeval,
128 torch::IntArrayRef sizes) const = 0;
136 virtual utils::BlockTensor<
torch::Tensor, 1, GeoDim>
138 const
torch::Tensor &coeff_indices, int64_t numeval,
139 torch::IntArrayRef sizes) const = 0;
144 [[nodiscard]] virtual nlohmann::json
to_json() const = 0;
156 [[nodiscard]] virtual pugi::xml_document
157 to_xml(
int id = 0, const
std::
string &label = "",
int index = -1) const = 0;
165 virtual pugi::xml_node &
to_xml(pugi::xml_node &root,
int id = 0,
166 const
std::
string &label = "",
167 int index = -1) const = 0;
176 const
std::
string &label = "",
186 const
std::
string &label = "",
198operator<<(
std::ostream &os, const
BSplinePatch<real_t, GeoDim, ParDim> &obj) {
199 obj.pretty_print(os);
Compile-time block tensor.
Abstract patch function base class.
Definition patch.hpp:53
virtual torch::Layout layout() const noexcept=0
Returns the layout property.
virtual bool pinned_memory() const noexcept=0
Returns the pinned_memory property.
virtual torch::Tensor as_tensor() const noexcept=0
Provides the as_tensor operation.
static constexpr short_t geoDim() noexcept
Dimension of the physical space.
Definition patch.hpp:60
virtual int32_t device_index() const noexcept=0
Returns the device_index property.
virtual nlohmann::json to_json() const =0
Returns the B-spline patch as a JSON object.
virtual bool requires_grad() const noexcept=0
Returns the requires_grad property.
virtual torch::Dtype dtype() const noexcept=0
Returns the dtype property.
virtual BSplinePatch & set_requires_grad(bool requires_grad) noexcept=0
Sets the B-spline object's requires_grad property.
virtual BSplinePatch & from_tensor(const torch::Tensor &tensor) noexcept=0
Sets all coefficients from a single tensor.
virtual BSplinePatch & from_json(const nlohmann::json &json)=0
Updates the B-spline patch from a JSON object.
virtual bool is_sparse() const noexcept=0
Returns if the layout is sparse.
virtual ~BSplinePatch()=default
Destructor.
virtual pugi::xml_document to_xml(int id=0, const std::string &label="", int index=-1) const =0
Returns the B-spline patch as an XML document.
static constexpr short_t parDim() noexcept
Dimension of the parametric space.
Definition patch.hpp:64
real_t value_type
Scalar type.
Definition patch.hpp:56
virtual BSplinePatch & from_xml(const pugi::xml_document &doc, int id=0, const std::string &label="", int index=-1)=0
Updates the B-spline patch from an XML document.
virtual int64_t as_tensor_size() const noexcept=0
Returns the size of the single tensor representation of all coefficients.
virtual void pretty_print(std::ostream &os=Log(log::info)) const noexcept=0
Returns a string representation.
virtual utils::BlockTensor< torch::Tensor, 1, GeoDim > eval_from_precomputed(const torch::Tensor &basfunc, const torch::Tensor &coeff_indices, int64_t numeval, torch::IntArrayRef sizes) const =0
Returns the value of the spline function from precomputed basis function.
virtual torch::Device device() const noexcept=0
Returns the device property.
struct iganet::@0 Log
Logger.
log
Enumerator for specifying the logging level.
Definition core.hpp:102
short int short_t
Signed short integer type used by IgANet's compact enumerations.
Definition core.hpp:76
Definition optimizer.hpp:61
TensorArray utility functions.