IgANet
IgANets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
igabase.hpp
Go to the documentation of this file.
1
15#pragma once
16
17#include <filesystem>
18
19namespace iganet {
20
22enum class collPts : short_t {
23 greville = 0,
25 greville_ref1 = 2,
27 3,
28 greville_ref2 = 4,
30 5,
31};
32
37template <typename GeometryMap, typename Variable> class IgABaseNoRefData {
38public:
40 using value_type =
41 typename std::common_type<typename GeometryMap::value_type,
42 typename Variable::value_type>::type;
43
46
49
52 std::pair<typename GeometryMap::eval_type,
53 typename GeometryMap::boundary_eval_type>;
54
57 std::pair<typename Variable::eval_type,
58 typename Variable::boundary_eval_type>;
59
61 bool static constexpr has_GeometryMap = true;
62
64 bool static constexpr has_RefData = false;
65
67 bool static constexpr has_Solution = true;
68
69protected:
72
75
76private:
79 template <std::size_t... GeometryMapNumCoeffs, size_t... Is,
80 std::size_t... VariableNumCoeffs, size_t... Js>
82 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
84 std::index_sequence<Is...>,
85 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
86 std::index_sequence<Js...>,
88 : // Construct the different spline objects individually
89 G_(std::get<Is>(geometryMapNumCoeffs)..., init::greville, options),
90 u_(std::get<Js>(variableNumCoeffs)..., init::random, options) {}
91
92public:
97
101 template <std::size_t NumCoeffs>
103 std::array<int64_t, NumCoeffs> ncoeffs,
105 : IgABaseNoRefData(std::tuple{ncoeffs}, std::tuple{ncoeffs}, options) {}
106
107 template <std::size_t... NumCoeffs>
109 std::tuple<std::array<int64_t, NumCoeffs>...> ncoeffs,
111 : IgABaseNoRefData(ncoeffs, ncoeffs, options) {}
113
117 template <std::size_t GeometryMapNumCoeffs, std::size_t VariableNumCoeffs>
119 std::array<int64_t, GeometryMapNumCoeffs> geometryMapNumCoeffs,
120 std::array<int64_t, VariableNumCoeffs> variableNumCoeffs,
123 std::tuple{variableNumCoeffs}, options) {}
124
125 template <std::size_t... GeometryMapNumCoeffs,
126 std::size_t... VariableNumCoeffs>
128 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
130 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
136 std::make_index_sequence<sizeof...(VariableNumCoeffs)>{}, options) {
137 }
139
142 inline const GeometryMap &G() const { return G_; }
143
146 inline GeometryMap &G() { return G_; }
147
150 inline const Variable &u() const { return u_; }
151
154 inline Variable &u() { return u_; }
155
156private:
163 template <size_t... Is>
165 geometryMap_collPts(enum collPts collPts, std::index_sequence<Is...>) const {
167
168 switch (collPts) {
169
171 // Get Greville abscissae inside the domain and at the boundary
172 ((std::get<Is>(collPts_.first) =
173 G_.template space<Is>().greville(/* interior */ false)),
174 ...);
175
176 // Get Greville abscissae at the domain
177 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>().greville()),
178 ...);
179 break;
180
182 // Get Greville abscissae inside the domain
183 ((std::get<Is>(collPts_.first) =
184 G_.template space<Is>().greville(/* interior */ true)),
185 ...);
186
187 // Get Greville abscissae at the domain
188 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>().greville()),
189 ...);
190 break;
191
193 // Get Greville abscissae inside the domain and at the boundary
194 ((std::get<Is>(collPts_.first) =
195 G_.template space<Is>().clone().uniform_refine().greville(
196 /* interior */ false)),
197 ...);
198
199 // Get Greville abscissae at the domain
200 ((std::get<Is>(collPts_.second) =
201 G_.template boundary<Is>().clone().uniform_refine().greville()),
202 ...);
203 break;
204
206 // Get Greville abscissae inside the domain
207 ((std::get<Is>(collPts_.first) =
208 G_.template space<Is>().clone().uniform_refine().greville(
209 /* interior */ true)),
210 ...);
211
212 // Get Greville abscissae at the domain
213 ((std::get<Is>(collPts_.second) =
214 G_.template boundary<Is>().clone().uniform_refine().greville()),
215 ...);
216 break;
217
219 // Get Greville abscissae inside the domain and at the boundary
220 ((std::get<Is>(collPts_.first) =
221 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
222 /* interior */ false)),
223 ...);
224
225 // Get Greville abscissae at the domain
226 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>()
227 .clone()
228 .uniform_refine(2, -1)
229 .greville()),
230 ...);
231 break;
232
234 // Get Greville abscissae inside the domain
235 ((std::get<Is>(collPts_.first) =
236 G_.template space<Is>().clone().uniform_refine(2, -1).greville(
237 /* interior */ true)),
238 ...);
239
240 // Get Greville abscissae at the domain
241 ((std::get<Is>(collPts_.second) = G_.template boundary<Is>()
242 .clone()
243 .uniform_refine(2, -1)
244 .greville()),
245 ...);
246 break;
247
248 default:
249 throw std::runtime_error("Invalid collocation point specifier");
250 }
251
252 return collPts_;
253 }
254
261 template <size_t... Is>
263 std::index_sequence<Is...>) const {
264 variable_collPts_type collPts_;
265
266 switch (collPts) {
267
269 // Get Greville abscissae inside the domain and at the boundary
270 ((std::get<Is>(collPts_.first) =
271 u_.template space<Is>().greville(/* interior */ false)),
272 ...);
273
274 // Get Greville abscissae at the domain
275 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>().greville()),
276 ...);
277 break;
278
280 // Get Greville abscissae inside the domain and at the boundary
281 ((std::get<Is>(collPts_.first) =
282 u_.template space<Is>().greville(/* interior */ true)),
283 ...);
284
285 // Get Greville abscissae at the domain
286 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>().greville()),
287 ...);
288 break;
289
291 // Get Greville abscissae inside the domain and at the boundary
292 ((std::get<Is>(collPts_.first) =
293 u_.template space<Is>().clone().uniform_refine().greville(
294 /* interior */ false)),
295 ...);
296
297 // Get Greville abscissae at the domain
298 ((std::get<Is>(collPts_.second) =
299 u_.template boundary<Is>().clone().uniform_refine().greville()),
300 ...);
301 break;
302
304 // Get Greville abscissae inside the domain and at the boundary
305 ((std::get<Is>(collPts_.first) =
306 u_.template space<Is>().clone().uniform_refine().greville(
307 /* interior */ true)),
308 ...);
309
310 // Get Greville abscissae at the domain
311 ((std::get<Is>(collPts_.second) =
312 u_.template boundary<Is>().clone().uniform_refine().greville()),
313 ...);
314 break;
315
317 // Get Greville abscissae inside the domain and at the boundary
318 ((std::get<Is>(collPts_.first) =
319 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
320 /* interior */ false)),
321 ...);
322
323 // Get Greville abscissae at the domain
324 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>()
325 .clone()
326 .uniform_refine(2, -1)
327 .greville()),
328 ...);
329 break;
330
332 // Get Greville abscissae inside the domain and at the boundary
333 ((std::get<Is>(collPts_.first) =
334 u_.template space<Is>().clone().uniform_refine(2, -1).greville(
335 /* interior */ true)),
336 ...);
337
338 // Get Greville abscissae at the domain
339 ((std::get<Is>(collPts_.second) = u_.template boundary<Is>()
340 .clone()
341 .uniform_refine(2, -1)
342 .greville()),
343 ...);
344 break;
345
346 default:
347 throw std::runtime_error("Invalid collocation point specifier");
348 }
349
350 return collPts_;
351 }
352
353public:
362 if constexpr (GeometryMap::nspaces() == 1)
363
364 switch (collPts) {
365
367 return {G_.space().greville(/* interior */ false),
368 G_.boundary().greville()};
369
371 return {G_.space().greville(/* interior */ true),
372 G_.boundary().greville()};
373
375 return {
376 G_.space().clone().uniform_refine().greville(/* interior */ false),
377 G_.boundary().clone().uniform_refine().greville()};
378
380 return {
381 G_.space().clone().uniform_refine().greville(/* interior */ true),
382 G_.boundary().clone().uniform_refine().greville()};
383
385 return {G_.space().clone().uniform_refine(2, -1).greville(
386 /* interior */ false),
387 G_.boundary().clone().uniform_refine(2, -1).greville()};
388
390 return {G_.space().clone().uniform_refine(2, -1).greville(
391 /* interior */ true),
392 G_.boundary().clone().uniform_refine(2, -1).greville()};
393
394 default:
395 throw std::runtime_error("Invalid collocation point specifier");
396 }
397
398 else
399 return geometryMap_collPts(
400 collPts, std::make_index_sequence<GeometryMap::nspaces()>{});
401 }
402
410 if constexpr (Variable::nspaces() == 1)
411
412 switch (collPts) {
413
415 return {u_.space().greville(/* interior */ false),
416 u_.boundary().greville()};
417
419 return {u_.space().greville(/* interior */ true),
420 u_.boundary().greville()};
421
423 return {
424 u_.space().clone().uniform_refine().greville(/* interior */ false),
425 u_.boundary().clone().uniform_refine().greville()};
426
428 return {
429 u_.space().clone().uniform_refine().greville(/* interior */ true),
430 u_.boundary().clone().uniform_refine().greville()};
431
433 return {u_.space().clone().uniform_refine(2, -1).greville(
434 /* interior */ false),
435 u_.boundary().clone().uniform_refine(2, -1).greville()};
436
438 return {u_.space().clone().uniform_refine(2, -1).greville(
439 /* interior */ true),
440 u_.boundary().clone().uniform_refine(2, -1).greville()};
441
442 default:
443 throw std::runtime_error("Invalid collocation point specifier");
444 }
445
446 else
448 std::make_index_sequence<Variable::nspaces()>{});
449 }
450};
451
455template <typename GeometryMap, typename Variable>
456class IgABase : public IgABaseNoRefData<GeometryMap, Variable> {
457public:
460
462 using value_type = typename Base::value_type;
463
466
469
472
475
477 bool static constexpr has_GeometryMap = true;
478
480 bool static constexpr has_RefData = true;
481
483 bool static constexpr has_Solution = true;
484
485protected:
488
489private:
492 template <std::size_t... GeometryMapNumCoeffs, size_t... Is,
493 std::size_t... VariableNumCoeffs, size_t... Js>
495 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
497 std::index_sequence<Is...>,
498 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
499 std::index_sequence<Js...>,
501 : // Construct the different spline objects individually
503 f_(std::get<Js>(variableNumCoeffs)..., init::zeros, options) {}
504
505public:
507 explicit IgABase(
509 : Base::G_(), f_(), Base::u_() {}
510
514 template <size_t NumCoeffs>
515 IgABase(std::array<int64_t, NumCoeffs> ncoeffs,
517 : IgABase(std::tuple{ncoeffs}, std::tuple{ncoeffs}, options) {}
518
519 template <size_t... NumCoeffs>
520 IgABase(std::tuple<std::array<int64_t, NumCoeffs>...> ncoeffs,
522 : IgABase(ncoeffs, ncoeffs, options) {}
524
528 template <std::size_t GeometryMapNumCoeffs, std::size_t VariableNumCoeffs>
529 IgABase(std::array<int64_t, GeometryMapNumCoeffs> geometryMapNumCoeffs,
530 std::array<int64_t, VariableNumCoeffs> variableNumCoeffs,
533 options) {}
534
535 template <std::size_t... GeometryMapNumCoeffs,
536 std::size_t... VariableNumCoeffs>
538 std::tuple<std::array<int64_t, GeometryMapNumCoeffs>...>
540 std::tuple<std::array<int64_t, VariableNumCoeffs>...> variableNumCoeffs,
545 std::make_index_sequence<sizeof...(VariableNumCoeffs)>{},
546 options) {}
548
551 inline const Variable &f() const { return f_; }
552
555 inline Variable &f() { return f_; }
556};
557
563protected:
565 template <typename T>
566 inline void read_from_xml(std::string location, T &obj,
567 std::vector<torch::Tensor> &v) {
568
569 std::filesystem::path path(location);
570
571 if (std::filesystem::exists(path)) {
572 if (std::filesystem::is_regular_file(path)) {
573 try {
574 pugi::xml_document doc;
575 doc.load_file(path.c_str());
576 v.emplace_back(obj.from_xml(doc).as_tensor());
577 } catch (...) {
578 }
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") {
582 try {
583 pugi::xml_document doc;
584 doc.load_file(file.path().c_str());
585 v.emplace_back(obj.from_xml(doc).as_tensor());
586 } catch (...) {
587 }
588 }
589 }
590 } else
591 throw std::runtime_error(
592 "The path refers to neither a file nor a directory");
593 } else
594 throw std::runtime_error("The path does not exist");
595 }
596};
597
603template <bool solution = false> class IgADataset;
604
605template <>
607 : public IgADatasetBase,
608 public torch::data::Dataset<
609 IgADataset<false>,
610 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>> {
611private:
613 std::vector<torch::Tensor> G_;
614
616 std::vector<torch::Tensor> f_;
617
618public:
621 torch::data::Example<torch::Tensor, torch::data::example::NoTarget>;
622
625 template <typename T> void add_geometryMap(T &obj, std::string location) {
626 read_from_xml(location, obj, G_);
627 }
628
629 template <typename T> void add_geometryMap(T &&obj, std::string location) {
630 read_from_xml(location, obj, G_);
631 }
633
636 template <typename T>
637 void add_geometryMap(T &obj, const pugi::xml_document &doc, int id = 0,
638 std::string label = "") {
639 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
640 }
641
642 template <typename T>
643 void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id = 0,
644 std::string label = "") {
645 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
646 }
648
651 template <typename T>
652 void add_geometryMap(T &obj, const pugi::xml_node &root, int id = 0,
653 std::string label = "") {
654 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
655 }
656
657 template <typename T>
658 void add_geometryMap(T &&obj, const pugi::xml_node &root, int id = 0,
659 std::string label = "") {
660 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
661 }
663
666 template <typename T> void add_referenceData(T &obj, std::string location) {
667 read_from_xml(location, obj, f_);
668 }
669
670 template <typename T> void add_referenceData(T &&obj, std::string location) {
671 read_from_xml(location, obj, f_);
672 }
674
677 template <typename T>
678 void add_referenceData(T &obj, const pugi::xml_document &doc, int id = 0,
679 std::string label = "") {
680 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
681 }
682
683 template <typename T>
684 void add_referenceData(T &&obj, const pugi::xml_document &doc, int id = 0,
685 std::string label = "") {
686 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
687 }
689
692 template <typename T>
693 void add_referenceData(T &obj, const pugi::xml_node &root, int id = 0,
694 std::string label = "") {
695 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
696 }
697
698 template <typename T>
699 void add_referenceData(T &&obj, const pugi::xml_node &root, int id = 0,
700 std::string label = "") {
701 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
702 }
704
707 template <typename T, typename Func>
709 f_.emplace_back(obj.transform(func).as_tensor());
710 }
711
712 template <typename T, typename Func>
714 f_.emplace_back(obj.transform(func).as_tensor());
715 }
717
719 inline example_type get(std::size_t index) override {
720
721 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
722 std::size_t ref_index = index - geo_index * f_.size();
723
724 if (!G_.empty()) {
725 if (!f_.empty())
726 return torch::cat({G_.at(geo_index), f_.at(ref_index)});
727 else
728 return G_.at(geo_index);
729 } else {
730 if (!f_.empty())
731 return f_.at(ref_index);
732 else
733 throw std::runtime_error("No geometry maps and reference data");
734 }
735 };
736
737 // @brief Return the total size of the data set
738 inline torch::optional<std::size_t> size() const override {
739 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
740 }
741};
742
743template <>
745 : public IgADatasetBase,
746 public torch::data::Dataset<IgADataset<true>, torch::data::Example<>> {
747private:
749 std::vector<torch::Tensor> G_;
750
752 std::vector<torch::Tensor> f_;
753
755 std::vector<torch::Tensor> u_;
756
757public:
760 template <typename T> void add_geometryMap(T &obj, std::string location) {
761 read_from_xml(location, obj, G_);
762 }
763
764 template <typename T> void add_geometryMap(T &&obj, std::string location) {
765 read_from_xml(location, obj, G_);
766 }
768
771 template <typename T>
772 void add_geometryMap(T &obj, const pugi::xml_document &doc, int id = 0,
773 std::string label = "") {
774 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
775 }
776
777 template <typename T>
778 void add_geometryMap(T &&obj, const pugi::xml_document &doc, int id = 0,
779 std::string label = "") {
780 G_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
781 }
783
786 template <typename T>
787 void add_geometryMap(T &obj, const pugi::xml_node &root, int id = 0,
788 std::string label = "") {
789 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
790 }
791
792 template <typename T>
793 void add_geometryMap(T &&obj, const pugi::xml_node &root, int id = 0,
794 std::string label = "") {
795 G_.emplace_back(obj.from_xml(root, id, label).as_tensor());
796 }
798
801 template <typename T> void add_referenceData(T &obj, std::string location) {
802 read_from_xml(location, obj, f_);
803 }
804
805 template <typename T> void add_referenceData(T &&obj, std::string location) {
806 read_from_xml(location, obj, f_);
807 }
809
812 template <typename T>
813 void add_referenceData(T &obj, const pugi::xml_document &doc, int id = 0,
814 std::string label = "") {
815 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
816 }
817
818 template <typename T>
819 void add_referenceData(T &&obj, const pugi::xml_document &doc, int id = 0,
820 std::string label = "") {
821 f_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
822 }
824
827 template <typename T>
828 void add_referenceData(T &obj, const pugi::xml_node &root, int id = 0,
829 std::string label = "") {
830 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
831 }
832
833 template <typename T>
834 void add_referenceData(T &&obj, const pugi::xml_node &root, int id = 0,
835 std::string label = "") {
836 f_.emplace_back(obj.from_xml(root, id, label).as_tensor());
837 }
839
842 template <typename T, typename Func>
844 f_.emplace_back(obj.transform(func).as_tensor());
845 }
846
847 template <typename T, typename Func>
849 f_.emplace_back(obj.transform(func).as_tensor());
850 }
852
855 template <typename T> void add_solution(T &obj, std::string location) {
856 read_from_xml(location, obj, u_);
857 }
858
859 template <typename T> void add_solution(T &&obj, std::string location) {
860 read_from_xml(location, obj, u_);
861 }
863
866 template <typename T>
867 void add_solution(T &obj, const pugi::xml_document &doc, int id = 0,
868 std::string label = "") {
869 u_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
870 }
871
872 template <typename T>
873 void add_solution(T &&obj, const pugi::xml_document &doc, int id = 0,
874 std::string label = "") {
875 u_.emplace_back(obj.from_xml(doc.child("xml"), id, label).as_tensor());
876 }
878
881 template <typename T>
882 void add_solution(T &obj, const pugi::xml_node &root, int id = 0,
883 std::string label = "") {
884 u_.emplace_back(obj.from_xml(root, id, label).as_tensor());
885 }
886
887 template <typename T>
888 void add_solution(T &&obj, const pugi::xml_node &root, int id = 0,
889 std::string label = "") {
890 u_.emplace_back(obj.from_xml(root, id, label).as_tensor());
891 }
893
895 inline torch::data::Example<> get(std::size_t index) override {
896
897 std::size_t geo_index = index / (f_.empty() ? 1 : f_.size());
898 std::size_t ref_index = index - geo_index * f_.size();
899
900 if (!G_.empty()) {
901 if (!f_.empty())
902 return {torch::cat({G_.at(geo_index), f_.at(ref_index)}), u_.at(index)};
903 else
904 return {G_.at(geo_index), u_.at(index)};
905 } else {
906 if (!f_.empty())
907 return {f_.at(ref_index), u_.at(index)};
908 else
909 throw std::runtime_error("No geometry maps and reference data");
910 }
911 };
912
913 // @brief Return the total size of the data set
914 inline torch::optional<std::size_t> size() const override {
915 return (G_.empty() ? 1 : G_.size()) * (f_.empty() ? 1 : f_.size());
916 }
917};
919
920} // namespace iganet
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
STL namespace.