41 typename std::common_type<
typename GeometryMap::value_type,
42 typename Variable::value_type>::type;
52 std::pair<
typename GeometryMap::eval_type,
53 typename GeometryMap::boundary_eval_type>;
57 std::pair<
typename Variable::eval_type,
58 typename Variable::boundary_eval_type>;
82 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
84 std::index_sequence<Is...>,
86 std::index_sequence<Js...>,
101 template <std::
size_t NumCoeffs>
103 std::array<int64_t, NumCoeffs> ncoeffs,
109 std::tuple<std::array<int64_t, NumCoeffs>...> ncoeffs,
117 template <std::
size_t GeometryMapNumCoeffs, std::
size_t VariableNumCoeffs>
128 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
136 std::make_index_sequence<
sizeof...(VariableNumCoeffs)>{}, options) {
163 template <
size_t...
Is>
172 ((std::get<Is>(collPts_.first) =
177 ((std::get<Is>(collPts_.second) =
G_.template
boundary<Is>().greville()),
183 ((std::get<Is>(collPts_.first) =
188 ((std::get<Is>(collPts_.second) =
G_.template
boundary<Is>().greville()),
194 ((std::get<Is>(collPts_.first) =
195 G_.template
space<Is>().clone().uniform_refine().greville(
200 ((std::get<Is>(collPts_.second) =
207 ((std::get<Is>(collPts_.first) =
208 G_.template
space<Is>().clone().uniform_refine().greville(
213 ((std::get<Is>(collPts_.second) =
220 ((std::get<Is>(collPts_.first) =
221 G_.template
space<Is>().clone().uniform_refine(2, -1).greville(
228 .uniform_refine(2, -1)
235 ((std::get<Is>(collPts_.first) =
236 G_.template
space<Is>().clone().uniform_refine(2, -1).greville(
243 .uniform_refine(2, -1)
249 throw std::runtime_error(
"Invalid collocation point specifier");
261 template <
size_t...
Is>
263 std::index_sequence<Is...>)
const {
270 ((std::get<Is>(collPts_.first) =
275 ((std::get<Is>(collPts_.second) =
u_.template
boundary<Is>().greville()),
281 ((std::get<Is>(collPts_.first) =
286 ((std::get<Is>(collPts_.second) =
u_.template
boundary<Is>().greville()),
292 ((std::get<Is>(collPts_.first) =
293 u_.template
space<Is>().clone().uniform_refine().greville(
298 ((std::get<Is>(collPts_.second) =
305 ((std::get<Is>(collPts_.first) =
306 u_.template
space<Is>().clone().uniform_refine().greville(
311 ((std::get<Is>(collPts_.second) =
318 ((std::get<Is>(collPts_.first) =
319 u_.template
space<Is>().clone().uniform_refine(2, -1).greville(
326 .uniform_refine(2, -1)
333 ((std::get<Is>(collPts_.first) =
334 u_.template
space<Is>().clone().uniform_refine(2, -1).greville(
341 .uniform_refine(2, -1)
347 throw std::runtime_error(
"Invalid collocation point specifier");
362 if constexpr (GeometryMap::nspaces() == 1)
367 return {
G_.space().greville(
false),
368 G_.boundary().greville()};
371 return {
G_.space().greville(
true),
372 G_.boundary().greville()};
376 G_.space().clone().uniform_refine().greville(
false),
377 G_.boundary().clone().uniform_refine().greville()};
381 G_.space().clone().uniform_refine().greville(
true),
382 G_.boundary().clone().uniform_refine().greville()};
385 return {
G_.space().clone().uniform_refine(2, -1).greville(
387 G_.boundary().clone().uniform_refine(2, -1).greville()};
390 return {
G_.space().clone().uniform_refine(2, -1).greville(
392 G_.boundary().clone().uniform_refine(2, -1).greville()};
395 throw std::runtime_error(
"Invalid collocation point specifier");
400 collPts, std::make_index_sequence<GeometryMap::nspaces()>{});
410 if constexpr (Variable::nspaces() == 1)
415 return {
u_.space().greville(
false),
416 u_.boundary().greville()};
419 return {
u_.space().greville(
true),
420 u_.boundary().greville()};
424 u_.space().clone().uniform_refine().greville(
false),
425 u_.boundary().clone().uniform_refine().greville()};
429 u_.space().clone().uniform_refine().greville(
true),
430 u_.boundary().clone().uniform_refine().greville()};
433 return {
u_.space().clone().uniform_refine(2, -1).greville(
435 u_.boundary().clone().uniform_refine(2, -1).greville()};
438 return {
u_.space().clone().uniform_refine(2, -1).greville(
440 u_.boundary().clone().uniform_refine(2, -1).greville()};
443 throw std::runtime_error(
"Invalid collocation point specifier");
448 std::make_index_sequence<Variable::nspaces()>{});
455template <
typename GeometryMap,
typename Variable>
495 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
497 std::index_sequence<Is...>,
499 std::index_sequence<Js...>,
514 template <
size_t NumCoeffs>
515 IgABase(std::array<int64_t, NumCoeffs> ncoeffs,
520 IgABase(std::tuple<std::array<int64_t, NumCoeffs>...> ncoeffs,
522 :
IgABase(ncoeffs, ncoeffs, options) {}
528 template <std::
size_t GeometryMapNumCoeffs, std::
size_t VariableNumCoeffs>
538 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
545 std::make_index_sequence<
sizeof...(VariableNumCoeffs)>{},
565 template <
typename T>
567 std::vector<torch::Tensor> &
v) {
571 if (std::filesystem::exists(
path)) {
572 if (std::filesystem::is_regular_file(
path)) {
574 pugi::xml_document
doc;
576 v.emplace_back(
obj.from_xml(
doc).as_tensor());
579 }
else if (std::filesystem::is_directory(
path)) {
580 for (
const auto &
file : std::filesystem::directory_iterator(
path)) {
581 if (
file.is_regular_file() &&
file.path().extension() ==
".xml") {
583 pugi::xml_document
doc;
584 doc.load_file(
file.path().c_str());
585 v.emplace_back(
obj.from_xml(
doc).as_tensor());
591 throw std::runtime_error(
592 "The path refers to neither a file nor a directory");
594 throw std::runtime_error(
"The path does not exist");
608 public torch::data::Dataset<
610 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>> {
613 std::vector<torch::Tensor>
G_;
616 std::vector<torch::Tensor>
f_;
621 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>;
636 template <
typename T>
638 std::string
label =
"") {
639 G_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
642 template <
typename T>
644 std::string
label =
"") {
645 G_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
651 template <
typename T>
653 std::string
label =
"") {
654 G_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
657 template <
typename T>
659 std::string
label =
"") {
660 G_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
677 template <
typename T>
679 std::string
label =
"") {
680 f_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
683 template <
typename T>
685 std::string
label =
"") {
686 f_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
692 template <
typename T>
694 std::string
label =
"") {
695 f_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
698 template <
typename T>
700 std::string
label =
"") {
701 f_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
707 template <
typename T,
typename Func>
709 f_.emplace_back(
obj.transform(
func).as_tensor());
712 template <
typename T,
typename Func>
714 f_.emplace_back(
obj.transform(
func).as_tensor());
721 std::size_t
geo_index = index / (f_.empty() ? 1 : f_.size());
733 throw std::runtime_error(
"No geometry maps and reference data");
738 inline torch::optional<std::size_t>
size()
const override {
739 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
746 public torch::data::Dataset<IgADataset<true>, torch::data::Example<>> {
749 std::vector<torch::Tensor>
G_;
752 std::vector<torch::Tensor>
f_;
755 std::vector<torch::Tensor>
u_;
771 template <
typename T>
773 std::string
label =
"") {
774 G_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
777 template <
typename T>
779 std::string
label =
"") {
780 G_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
786 template <
typename T>
788 std::string
label =
"") {
789 G_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
792 template <
typename T>
794 std::string
label =
"") {
795 G_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
812 template <
typename T>
814 std::string
label =
"") {
815 f_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
818 template <
typename T>
820 std::string
label =
"") {
821 f_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
827 template <
typename T>
829 std::string
label =
"") {
830 f_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
833 template <
typename T>
835 std::string
label =
"") {
836 f_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
842 template <
typename T,
typename Func>
844 f_.emplace_back(
obj.transform(
func).as_tensor());
847 template <
typename T,
typename Func>
849 f_.emplace_back(
obj.transform(
func).as_tensor());
866 template <
typename T>
868 std::string
label =
"") {
869 u_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
872 template <
typename T>
874 std::string
label =
"") {
875 u_.emplace_back(
obj.from_xml(
doc.child(
"xml"),
id,
label).as_tensor());
881 template <
typename T>
883 std::string
label =
"") {
884 u_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
887 template <
typename T>
889 std::string
label =
"") {
890 u_.emplace_back(
obj.from_xml(
root,
id,
label).as_tensor());
895 inline torch::data::Example<>
get(std::size_t index)
override {
897 std::size_t
geo_index = index / (f_.empty() ? 1 : f_.size());
909 throw std::runtime_error(
"No geometry maps and reference data");
914 inline torch::optional<std::size_t>
size()
const override {
915 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
IgA base class.
Definition igabase.hpp:456
Variable f_
Spline representation of the reference data.
Definition igabase.hpp:487
IgABase(std::array< int64_t, NumCoeffs > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:515
const Variable & f() const
Returns a constant reference to the spline representation of the reference data.
Definition igabase.hpp:551
IgABase(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:537
IgABase(std::array< int64_t, GeometryMapNumCoeffs > geometryMapNumCoeffs, std::array< int64_t, VariableNumCoeffs > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:529
IgABaseNoRefData< GeometryMap, Variable > Base
Base type.
Definition igabase.hpp:459
Variable & f()
Returns a non-constant reference to the spline representation of the reference data.
Definition igabase.hpp:555
Variable variable_type
Type of the variable function space(s)
Definition igabase.hpp:468
typename Base::value_type value_type
Value type.
Definition igabase.hpp:462
IgABase(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::index_sequence< Is... >, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, std::index_sequence< Js... >, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for Geometry and Variable types)
Definition igabase.hpp:494
typename Base::variable_collPts_type variable_collPts_type
Type of the variable collocation points.
Definition igabase.hpp:474
IgABase(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:507
IgABase(std::tuple< std::array< int64_t, NumCoeffs >... > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:520
GeometryMap geometryMap_type
Type of the geometry map function space(s)
Definition igabase.hpp:465
static bool constexpr has_GeometryMap
Indicates whether this class provides a geometry map.
Definition igabase.hpp:477
typename Base::geometryMap_collPts_type geometryMap_collPts_type
Type of the geometry map collocation points.
Definition igabase.hpp:471
static bool constexpr has_Solution
Indicates whether this class provides a solution.
Definition igabase.hpp:483
static bool constexpr has_RefData
Indicates whether this class provides a reference solution.
Definition igabase.hpp:480
IgA base class (no reference data)
Definition igabase.hpp:37
virtual variable_collPts_type variable_collPts(enum collPts collPts) const
Returns the variable collocation points.
Definition igabase.hpp:409
IgABaseNoRefData(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:127
virtual geometryMap_collPts_type geometryMap_collPts(enum collPts collPts) const
Returns the geometry map collocation points.
Definition igabase.hpp:361
GeometryMap geometryMap_type
Type of the geometry map function space(s)
Definition igabase.hpp:45
geometryMap_collPts_type geometryMap_collPts(enum collPts collPts, std::index_sequence< Is... >) const
Returns the geometry map collocation points.
Definition igabase.hpp:165
typename std::common_type< typename GeometryMap::value_type, typename Variable::value_type >::type value_type
Value type.
Definition igabase.hpp:42
IgABaseNoRefData(std::tuple< std::array< int64_t, NumCoeffs >... > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:108
std::pair< typename Variable::eval_type, typename Variable::boundary_eval_type > variable_collPts_type
Type of the variable collocation points.
Definition igabase.hpp:58
const Variable & u() const
Returns a constant reference to the spline representation of the solution.
Definition igabase.hpp:150
IgABaseNoRefData(std::array< int64_t, GeometryMapNumCoeffs > geometryMapNumCoeffs, std::array< int64_t, VariableNumCoeffs > variableNumCoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for geometry map and variables)
Definition igabase.hpp:118
Variable variable_type
Type of the variable function space(s)
Definition igabase.hpp:48
IgABaseNoRefData(iganet::Options< value_type > options=iganet::Options< value_type >{})
Default constructor.
Definition igabase.hpp:94
IgABaseNoRefData(std::array< int64_t, NumCoeffs > ncoeffs, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (same for geometry map and variables)
Definition igabase.hpp:102
static bool constexpr has_GeometryMap
Indicates whether this class provides a geometry map.
Definition igabase.hpp:61
static bool constexpr has_RefData
Indicates whether this class provides reference data.
Definition igabase.hpp:64
variable_collPts_type variable_collPts(enum collPts collPts, std::index_sequence< Is... >) const
Returns the variable collocation points.
Definition igabase.hpp:262
GeometryMap G_
Spline representation of the geometry map.
Definition igabase.hpp:71
IgABaseNoRefData(std::tuple< std::array< int64_t, GeometryMapNumCoeffs >... > geometryMapNumCoeffs, std::index_sequence< Is... >, std::tuple< std::array< int64_t, VariableNumCoeffs >... > variableNumCoeffs, std::index_sequence< Js... >, iganet::Options< value_type > options=iganet::Options< value_type >{})
Constructor: number of spline coefficients (different for Geometry and Variable types)
Definition igabase.hpp:81
Variable u_
Spline representation of the solution.
Definition igabase.hpp:74
static bool constexpr has_Solution
Indicates whether this class provides a solution.
Definition igabase.hpp:67
GeometryMap & G()
Returns a non-constant reference to the spline representation of the geometry map.
Definition igabase.hpp:146
Variable & u()
Returns a non-constant reference to the spline representation of the solution.
Definition igabase.hpp:154
std::pair< typename GeometryMap::eval_type, typename GeometryMap::boundary_eval_type > geometryMap_collPts_type
Type of the geometry map collocation points.
Definition igabase.hpp:53
const GeometryMap & G() const
Returns a constant reference to the spline representation of the geometry map.
Definition igabase.hpp:142
void add_referenceData(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:699
void add_referenceData(T &&obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:670
void add_referenceData(T &obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:708
void add_referenceData(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:693
std::vector< torch::Tensor > G_
Vector of tensors representing the geometry maps.
Definition igabase.hpp:613
std::vector< torch::Tensor > f_
Vector of tensors representing the reference data.
Definition igabase.hpp:616
void add_referenceData(T &obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:666
void add_geometryMap(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:658
void add_geometryMap(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:637
void add_geometryMap(T &&obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:629
void add_referenceData(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:684
void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:643
torch::data::Example< torch::Tensor, torch::data::example::NoTarget > example_type
Example type.
Definition igabase.hpp:621
void add_geometryMap(T &obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:625
void add_referenceData(T &&obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:713
example_type get(std::size_t index) override
Returns the data set at location index.
Definition igabase.hpp:719
torch::optional< std::size_t > size() const override
Definition igabase.hpp:738
void add_referenceData(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:678
void add_geometryMap(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:652
torch::optional< std::size_t > size() const override
Definition igabase.hpp:914
std::vector< torch::Tensor > G_
Vector of tensors representing the geometry maps.
Definition igabase.hpp:749
void add_geometryMap(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:793
void add_geometryMap(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:772
void add_referenceData(T &obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:843
void add_referenceData(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:819
void add_solution(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a solution from XML object.
Definition igabase.hpp:867
std::vector< torch::Tensor > f_
Vector of tensors representing the reference data.
Definition igabase.hpp:752
void add_referenceData(T &&obj, Func func)
Adds a reference data set from XML node.
Definition igabase.hpp:848
void add_geometryMap(T &&obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:764
void add_referenceData(T &&obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:805
void add_solution(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a solution from XML object.
Definition igabase.hpp:873
torch::data::Example get(std::size_t index) override
Returns the data set at location index.
Definition igabase.hpp:895
void add_referenceData(T &obj, std::string location)
Adds a reference data set from file.
Definition igabase.hpp:801
void add_referenceData(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:834
void add_solution(T &&obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a solution from XML node.
Definition igabase.hpp:888
void add_referenceData(T &obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a reference data set from XML object.
Definition igabase.hpp:813
void add_solution(T &obj, std::string location)
Adds a solution from file.
Definition igabase.hpp:855
void add_solution(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a solution from XML node.
Definition igabase.hpp:882
void add_solution(T &&obj, std::string location)
Adds a solution from file.
Definition igabase.hpp:859
std::vector< torch::Tensor > u_
Vector of tensors representing the solution data.
Definition igabase.hpp:755
void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id=0, std::string label="")
Adds a geometry map from XML object.
Definition igabase.hpp:778
void add_referenceData(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a reference data set from XML node.
Definition igabase.hpp:828
void add_geometryMap(T &obj, std::string location)
Adds a geometry map from file.
Definition igabase.hpp:760
void add_geometryMap(T &obj, const pugi::xml_node &root, int id=0, std::string label="")
Adds a geometry map from XML node.
Definition igabase.hpp:787
IgA dataset base class.
Definition igabase.hpp:562
void read_from_xml(std::string location, T &obj, std::vector< torch::Tensor > &v)
Reads a function space from file.
Definition igabase.hpp:566
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:90
Definition boundary.hpp:22
collPts
Enumerator for the collocation point specifier.
Definition igabase.hpp:22
constexpr bool is_SplineType_v
Alias to the value of is_SplineType.
Definition bspline.hpp:3243
init
Enumerator for specifying the initialization of B-spline coefficients.
Definition bspline.hpp:55
short int short_t
Definition core.hpp:74
IgA dataset class.
Definition igabase.hpp:603