IgANet
IgANets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
BSplineModel.hpp
Go to the documentation of this file.
1
15#include <iganet.h>
16#include <model.hpp>
17
18namespace iganet {
19
20namespace webapp {
21
23enum class degree {
24 constant = 0,
25 linear = 1,
26 quadratic = 2,
27 cubic = 3,
28 quartic = 4,
29 quintic = 5
30};
31
33template <class Spline>
34class BSplineModel : public Model<typename Spline::value_type>,
35 public ModelEval,
37 public ModelRefine,
38 public ModelSerialize,
39 public ModelXML,
40 public Spline {
41
42 static_assert(is_SplineType_v<Spline>, "Spline must be a valid SplineType");
43
44private:
47
49 Spline solution_;
50
51public:
54
56 BSplineModel(const std::array<int64_t, Spline::parDim()> ncoeffs,
58 : Spline(ncoeffs, init), solution_(ncoeffs, init) {
59 if constexpr (Spline::parDim() == 1)
60 solution_.transform(
61 [](const std::array<typename Spline::value_type, 1> xi) {
62 return std::array<typename Spline::value_type, Spline::geoDim()>{
63 static_cast<iganet::real_t>(std::sin(M_PI * xi[0])), 0.0, 0.0};
64 });
65
66 else if constexpr (Spline::parDim() == 2)
67 solution_.transform(
68 [](const std::array<typename Spline::value_type, 2> xi) {
69 return std::array<typename Spline::value_type, Spline::geoDim()>{
70 static_cast<iganet::real_t>(std::sin(M_PI * xi[0]) *
71 std::sin(M_PI * xi[1])),
72 0.0, 0.0};
73 });
74
75 else if constexpr (Spline::parDim() == 3)
76 solution_.transform(
77 [](const std::array<typename Spline::value_type, 3> xi) {
78 return std::array<typename Spline::value_type, Spline::geoDim()>{
79 static_cast<iganet::real_t>(std::sin(M_PI * xi[0]) *
80 std::sin(M_PI * xi[1]) *
81 std::sin(M_PI * xi[2])),
82 0.0, 0.0};
83 });
84 }
85
88
90 std::string getName() const override {
91 if constexpr (Spline::parDim() == 1)
92 return "BSplineCurve";
93 else if constexpr (Spline::parDim() == 2)
94 return "BSplineSurface";
95 else if constexpr (Spline::parDim() == 3)
96 return "BSplineVolume";
97 else if constexpr (Spline::parDim() == 4)
98 return "BSplineHyperVolume";
99 else
100 return "invalidName";
101 }
102
104 std::string getDescription() const override {
105 if constexpr (Spline::parDim() == 1)
106 return "B-spline curve";
107 else if constexpr (Spline::parDim() == 2)
108 return "B-spline surface";
109 else if constexpr (Spline::parDim() == 3)
110 return "B-spline volume";
111 else if constexpr (Spline::parDim() == 4)
112 return "B-spline hypervolume";
113 else
114 return "invalidDescription";
115 }
116
118 nlohmann::json getOptions() const override {
119 if constexpr (Spline::parDim() == 1)
120 return R"([{
121 "name" : "degree",
122 "label" : "Spline degree",
123 "description" : "Spline degree",
124 "type" : "select",
125 "value" : ["constant", "linear", "quadratic", "cubic", "quartic", "quintic"],
126 "default" : 2,
127 "uiid" : 0},{
128 "name" : "ncoeffs",
129 "label" : "Number of coefficients",
130 "description" : "Number of coefficients",
131 "type" : ["int"],
132 "value" : [3],
133 "default" : [3],
134 "uiid" : 1},{
135 "name" : "init",
136 "label" : "Initialization of the coefficients",
137 "description" : "Initialization of the coefficients",
138 "type" : "select",
139 "value" : ["zeros", "ones", "linear", "random", "greville"],
140 "default" : 4,
141 "uiid" : 2},{
142 "name" : "nonuniform",
143 "label" : "Create non-uniform knot vector",
144 "description" : "Create non-uniform knot vector",
145 "type" : "select",
146 "value" : ["false", "true"],
147 "default" : 0,
148 "uiid" : 3}])"_json;
149
150 else if constexpr (Spline::parDim() == 2)
151 return R"([{
152 "name" : "degree",
153 "label" : "Spline degrees",
154 "description" : "Spline degrees per parametric dimension",
155 "type" : "select",
156 "value" : ["constant", "linear", "quadratic", "cubic", "quartic", "quintic"],
157 "default" : 2,
158 "uiid" : 0},{
159 "name" : "ncoeffs",
160 "label" : "Number of coefficients",
161 "description" : "Number of coefficients per parametric dimension",
162 "type" : ["int","int"],
163 "value" : [3,3],
164 "default" : [3,3],
165 "uiid" : 1},{
166 "name" : "init",
167 "label" : "Initialization of the coefficients",
168 "description" : "Initialization of the coefficients",
169 "type" : "select",
170 "value" : ["zeros", "ones", "linear", "random", "greville"],
171 "default" : 4,
172 "uiid" : 2},{
173 "name" : "nonuniform",
174 "label" : "Create non-uniform knot vectors",
175 "description" : "Create non-uniform knot vectors",
176 "type" : "select",
177 "value" : ["false", "true"],
178 "default" : 0,
179 "uiid" : 3}])"_json;
180
181 else if constexpr (Spline::parDim() == 3)
182 return R"([{
183 "name" : "degree",
184 "label" : "Spline degrees",
185 "description" : "Spline degrees per parametric dimension",
186 "type" : "select",
187 "value" : ["constant", "linear", "quadratic", "cubic", "quartic", "quintic"],
188 "default" : 2,
189 "uiid" : 0},{
190 "name" : "ncoeffs",
191 "label" : "Number of coefficients",
192 "description" : "Number of coefficients per parametric dimension",
193 "type" : ["int","int","int"],
194 "value" : [3,3,3],
195 "default" : [3,3,3],
196 "uiid" : 1},{
197 "name" : "init",
198 "label" : "Initialization of the coefficients",
199 "description" : "Initialization of the coefficients",
200 "type" : "select",
201 "value" : ["zeros", "ones", "linear", "random", "greville"],
202 "default" : 4,
203 "uiid" : 2},{
204 "name" : "nonuniform",
205 "label" : "Create non-uniform knot vectors",
206 "description" : "Create non-uniform knot vectors",
207 "type" : "select",
208 "value" : ["false", "true"],
209 "default" : 0,
210 "uiid" : 3}])"_json;
211
212 else if constexpr (Spline::parDim() == 4)
213 return R"([{
214 "name" : "degree",
215 "label" : "Spline degrees",
216 "description" : "Spline degrees per parametric dimension",
217 "type" : "select",
218 "value" : ["constant", "linear", "quadratic", "cubic", "quartic", "quintic"],
219 "default" : 2,
220 "uiid" : 0},{
221 "name" : "ncoeffs",
222 "label" : "Number of coefficients",
223 "description" : "Number of coefficients per parametric dimension",
224 "type" : [int,int,int,int],
225 "value" : [3,3,3,3],
226 "default" : [3,3,3,3],
227 "uiid" : 1},{
228 "name" : "init",
229 "label" : "Initialization of the coefficients",
230 "description" : "Initialization of the coefficients",
231 "type" : "select",
232 "value" : ["zeros", "ones", "linear", "random", "greville"],
233 "default" : 4,
234 "uiid" : 2},{
235 "name" : "nonuniform",
236 "label" : "Create non-uniform knot vectors",
237 "description" : "Create non-uniform knot vectors",
238 "type" : "select",
239 "value" : ["false", "true"],
240 "default" : 0,
241 "uiid" : 3}])"_json;
242
243 else
244 return R"({ INVALID REQUEST })"_json;
245 }
246
248 nlohmann::json getInputs() const override {
249 return R"([{
250 "name" : "geometry",
251 "description" : "Geometry",
252 "type" : 2}])"_json;
253 }
254
256 nlohmann::json getOutputs() const override {
257 if constexpr (Spline::geoDim() == 1)
258 return R"([{
259 "name" : "ValueFieldMagnitude",
260 "description" : "Magnitude of the B-spline values",
261 "type" : 1}])"_json;
262 else
263 return R"([{
264 "name" : "ValueFieldMagnitude",
265 "description" : "Magnitude of the B-spline values",
266 "type" : 1},{
267 "name" : "ValueField",
268 "description" : "B-spline values",
269 "type" : 2}])"_json;
270 }
271
273 nlohmann::json getParameters() const override { return R"([])"_json; }
274
276 nlohmann::json to_json(const std::string &patch, const std::string &component,
277 const std::string &attribute) const override {
278
279 // At the moment the "patch" flag is ignored
280
281 if (component == "geometry") {
282 if (attribute != "") {
283 nlohmann::json json;
284 if (attribute == "degrees")
285 json["degrees"] = this->degrees();
286 else if (attribute == "geoDim")
287 json["geoDim"] = this->geoDim();
288 else if (attribute == "parDim")
289 json["parDim"] = this->parDim();
290 else if (attribute == "ncoeffs")
291 json["ncoeffs"] = this->ncoeffs();
292 else if (attribute == "nknots")
293 json["nknots"] = this->nknots();
294 else if (attribute == "coeffs")
295 json["coeffs"] = this->coeffs_to_json();
296 else if (attribute == "knots")
297 json["knots"] = this->knots_to_json();
298
299 return json;
300
301 } else {
302
303 return Spline::to_json();
304 }
305 }
306
307 else if (component == "solution") {
308 if (attribute != "") {
309 nlohmann::json json;
310 if (attribute == "degrees")
311 json["degrees"] = solution_.degrees();
312 else if (attribute == "geoDim")
313 json["geoDim"] = solution_.geoDim();
314 else if (attribute == "parDim")
315 json["parDim"] = solution_.parDim();
316 else if (attribute == "ncoeffs")
317 json["ncoeffs"] = solution_.ncoeffs();
318 else if (attribute == "nknots")
319 json["nknots"] = solution_.nknots();
320 else if (attribute == "coeffs")
321 json["coeffs"] = solution_.coeffs_to_json();
322 else if (attribute == "knots")
323 json["knots"] = solution_.knots_to_json();
324
325 return json;
326 } else
327
328 return solution_.to_json();
329 }
330
331 else
332 return Base::to_json(patch, component, attribute);
333 }
334
336 nlohmann::json updateAttribute(const std::string &patch,
337 const std::string &component,
338 const std::string &attribute,
339 const nlohmann::json &json) override {
340
341 // At the moment the "patch" and "component" flags are ignored
342
343 if (attribute == "coeffs") {
344 if (!json.contains("data"))
346 if (!json["data"].contains("indices") || !json["data"].contains("coeffs"))
348
349 auto indices = json["data"]["indices"].get<std::vector<int64_t>>();
350 auto coeffs_cpu =
351 utils::to_tensorAccessor<typename Spline::value_type, 1>(
352 Spline::coeffs(), torch::kCPU);
353
354 switch (Spline::geoDim()) {
355 case (1): {
356 auto coords =
357 json["data"]["coeffs"]
358 .get<std::vector<std::tuple<typename Spline::value_type>>>();
359 auto xAccessor = std::get<1>(coeffs_cpu)[0];
360
361 for (const auto &[index, coord] : iganet::utils::zip(indices, coords)) {
362 if (index < 0 || index >= Spline::ncumcoeffs())
364 xAccessor[index] = std::get<0>(coord);
365 }
366 break;
367 }
368 case (2): {
369 auto coords =
370 json["data"]["coeffs"]
371 .get<std::vector<std::tuple<typename Spline::value_type,
372 typename Spline::value_type>>>();
373 auto xAccessor = std::get<1>(coeffs_cpu)[0];
374 auto yAccessor = std::get<1>(coeffs_cpu)[1];
375
376 for (const auto &[index, coord] : iganet::utils::zip(indices, coords)) {
377 if (index < 0 || index >= Spline::ncumcoeffs())
379
380 xAccessor[index] = std::get<0>(coord);
381 yAccessor[index] = std::get<1>(coord);
382 }
383 break;
384 }
385 case (3): {
386 auto coords =
387 json["data"]["coeffs"]
388 .get<std::vector<std::tuple<typename Spline::value_type,
389 typename Spline::value_type,
390 typename Spline::value_type>>>();
391 auto xAccessor = std::get<1>(coeffs_cpu)[0];
392 auto yAccessor = std::get<1>(coeffs_cpu)[1];
393 auto zAccessor = std::get<1>(coeffs_cpu)[2];
394
395 for (const auto &[index, coord] : iganet::utils::zip(indices, coords)) {
396 if (index < 0 || index >= Spline::ncumcoeffs())
398
399 xAccessor[index] = std::get<0>(coord);
400 yAccessor[index] = std::get<1>(coord);
401 zAccessor[index] = std::get<2>(coord);
402 }
403 break;
404 }
405 case (4): {
406 auto coords =
407 json["data"]["coeffs"]
408 .get<std::vector<std::tuple<typename Spline::value_type,
409 typename Spline::value_type,
410 typename Spline::value_type,
411 typename Spline::value_type>>>();
412 auto xAccessor = std::get<1>(coeffs_cpu)[0];
413 auto yAccessor = std::get<1>(coeffs_cpu)[1];
414 auto zAccessor = std::get<1>(coeffs_cpu)[2];
415 auto tAccessor = std::get<1>(coeffs_cpu)[3];
416
417 for (const auto &[index, coord] : iganet::utils::zip(indices, coords)) {
418 if (index < 0 || index >= Spline::ncumcoeffs())
420
421 xAccessor[index] = std::get<0>(coord);
422 yAccessor[index] = std::get<1>(coord);
423 zAccessor[index] = std::get<2>(coord);
424 tAccessor[index] = std::get<3>(coord);
425 }
426 break;
427 }
428 default:
430 }
431 return "{}";
432 } else
434 }
435
437 nlohmann::json eval(const std::string &patch, const std::string &component,
438 const nlohmann::json &json) const override {
439
440 // At the moment the "patch" flags is ignored
441
442 if constexpr (Spline::parDim() == 1) {
443
444 std::array<int64_t, 1> res({25});
445 if (json.contains("data"))
446 if (json["data"].contains("resolution"))
447 res = json["data"]["resolution"].get<std::array<int64_t, 1>>();
448
449 utils::TensorArray1 xi = {torch::linspace(0, 1, res[0])};
450
451 if (component == "ValueFieldMagnitude") {
452 return nlohmann::json::array().emplace_back(
453 utils::to_json<iganet::real_t, 1>(*(solution_.eval(xi)[0])));
454 } else if (component == "ValueField") {
455 auto values = Spline::eval(xi);
456 auto result = nlohmann::json::array();
457 for (short_t dim = 0; dim < Spline::geoDim(); ++dim)
458 result.emplace_back(
459 utils::to_json<iganet::real_t, 1>(*(values[dim])));
460 return result;
461 } else
462 return R"({ INVALID REQUEST })"_json;
463 }
464
465 else if constexpr (Spline::parDim() == 2) {
466
467 std::array<int64_t, 2> res({25, 25});
468 if (json.contains("data"))
469 if (json["data"].contains("resolution"))
470 res = json["data"]["resolution"].get<std::array<int64_t, 2>>();
471
472 utils::TensorArray2 xi = utils::to_array<2>(torch::meshgrid(
473 {torch::linspace(0, 1, res[0],
475 torch::linspace(0, 1, res[1],
477 "xy"));
478
479 if (component == "ValueFieldMagnitude") {
480 return nlohmann::json::array().emplace_back(
481 utils::to_json<iganet::real_t, 2>(*(solution_.eval(xi)[0])));
482 } else if (component == "ValueField") {
483 auto values = Spline::eval(xi);
484 auto result = nlohmann::json::array();
485 for (short_t dim = 0; dim < Spline::geoDim(); ++dim)
486 result.emplace_back(
487 utils::to_json<iganet::real_t, 2>(*(values[dim])));
488 return result;
489 } else
490 return R"({ INVALID REQUEST })"_json;
491 }
492
493 else if constexpr (Spline::parDim() == 3) {
494
495 std::array<int64_t, 3> res({25, 25, 25});
496 if (json.contains("data"))
497 if (json["data"].contains("resolution"))
498 res = json["data"]["resolution"].get<std::array<int64_t, 3>>();
499
500 utils::TensorArray3 xi = utils::to_array<3>(torch::meshgrid(
501 {torch::linspace(0, 1, res[0],
503 torch::linspace(0, 1, res[1],
505 torch::linspace(0, 1, res[2],
507 "xy"));
508
509 if (component == "ValueFieldMagnitude") {
510 return nlohmann::json::array().emplace_back(
511 utils::to_json<iganet::real_t, 3>(*(solution_.eval(xi)[0])));
512 } else if (component == "ValueField") {
513 auto values = Spline::eval(xi);
514 auto result = nlohmann::json::array();
515 for (short_t dim = 0; dim < Spline::geoDim(); ++dim)
516 result.emplace_back(
517 utils::to_json<iganet::real_t, 3>(*(values[dim])));
518 return result;
519 } else
520 return R"({ INVALID REQUEST })"_json;
521 }
522
523 else if constexpr (Spline::parDim() == 4) {
524
525 std::array<int64_t, 4> res({25, 25, 25, 25});
526 if (json.contains("data"))
527 if (json["data"].contains("resolution"))
528 res = json["data"]["resolution"].get<std::array<int64_t, 4>>();
529
530 utils::TensorArray4 xi = utils::to_array<4>(torch::meshgrid(
531 {torch::linspace(0, 1, res[0],
533 torch::linspace(0, 1, res[1],
535 torch::linspace(0, 1, res[2],
537 torch::linspace(0, 1, res[3],
539 "xy"));
540
541 if (component == "ValueFieldMagnitude") {
542 return nlohmann::json::array().emplace_back(
543 utils::to_json<iganet::real_t, 4>(*(solution_.eval(xi)[0])));
544 } else if (component == "ValueField") {
545 auto values = Spline::eval(xi);
546 auto result = nlohmann::json::array();
547 for (short_t dim = 0; dim < Spline::geoDim(); ++dim)
548 result.emplace_back(
549 utils::to_json<iganet::real_t, 4>(*(values[dim])));
550 return result;
551 } else
552 return R"({ INVALID REQUEST })"_json;
553 }
554 }
555
557 void refine(const nlohmann::json &json = NULL) override {
558 int num = 1, dim = -1;
559
560 if (json.contains("data")) {
561 if (json["data"].contains("num"))
562 num = json["data"]["num"].get<int>();
563
564 if (json["data"].contains("dim"))
565 dim = json["data"]["dim"].get<int>();
566 }
567
568 Spline::uniform_refine(num, dim);
569
570 solution_.uniform_refine(num, dim);
571 if constexpr (Spline::parDim() == 1)
572 solution_.transform(
573 [](const std::array<typename Spline::value_type, 1> xi) {
574 return std::array<typename Spline::value_type, Spline::geoDim()>{
575 static_cast<iganet::real_t>(std::sin(M_PI * xi[0])), 0.0, 0.0};
576 });
577
578 else if constexpr (Spline::parDim() == 2)
579 solution_.transform(
580 [](const std::array<typename Spline::value_type, 2> xi) {
581 return std::array<typename Spline::value_type, Spline::geoDim()>{
582 static_cast<iganet::real_t>(std::sin(M_PI * xi[0]) *
583 std::sin(M_PI * xi[1])),
584 0.0, 0.0};
585 });
586
587 else if constexpr (Spline::parDim() == 3)
588 solution_.transform(
589 [](const std::array<typename Spline::value_type, 3> xi) {
590 return std::array<typename Spline::value_type, Spline::geoDim()>{
591 static_cast<iganet::real_t>(std::sin(M_PI * xi[0]) *
592 std::sin(M_PI * xi[1]) *
593 std::sin(M_PI * xi[2])),
594 0.0, 0.0};
595 });
596 }
597
599 void reparameterize(const std::string &patch, const nlohmann::json &json = NULL) override {
600
601 // gismo::gsBarrierPatch<d, T> opt(geo_, false);
602 // opt.options().setInt("ParamMethod", 1);
603 // opt.compute();
604
605 // geo_ = opt.result();
606 }
607
609 void load(const nlohmann::json &json) override {
610
611 if (json.contains("data")) {
612 if (json["data"].contains("binary")) {
613
614 // get binary vector from JSON object
615 std::vector<std::uint8_t> binary = json["data"]["binary"];
616
617 // recover input archive from binary vector
618 torch::serialize::InputArchive archive;
619 archive.load_from(reinterpret_cast<const char *>(binary.data()),
620 binary.size());
621
622 Spline::read(archive, "geometry");
623 solution_.read(archive, "solution");
624
625 return;
626 }
627 }
628
629 throw InvalidModelException();
630 }
631
633 nlohmann::json save() const override {
634
635 // serialize model to output archive
636 torch::serialize::OutputArchive archive;
637 archive.write("model",
638 static_cast<int64_t>(std::hash<std::string>{}(getName())));
639 archive.write("nonuniform", static_cast<bool>(Spline::is_nonuniform()));
640
641 Spline::write(archive, "geometry");
642 solution_.write(archive, "solution");
643
644 // store output archive in binary vector
645 std::vector<std::uint8_t> binary;
646
647 archive.save_to(
648 [&binary](const void *data, size_t size) mutable -> std::size_t {
649 auto data_ = reinterpret_cast<const std::uint8_t *>(data);
650
651 for (std::size_t i = 0; i < size; ++i)
652 binary.push_back(data_[i]);
653
654 return size;
655 });
656
657 // attach binary vector to JSON object
658 nlohmann::json json;
659 json["binary"] = binary;
660
661 return json;
662 }
663
665 void importXML(const std::string &patch,
666 const std::string& component,
667 const nlohmann::json &json,
668 int id = 0) override {
669
670 if (json.contains("data")) {
671 if (json["data"].contains("xml")) {
672
673 std::string xml = json["data"]["xml"].get<std::string>();
674
675 pugi::xml_document doc;
676 pugi::xml_parse_result result =
677 doc.load_buffer(xml.c_str(), xml.size());
678
679 if (pugi::xml_node root = doc.child("xml"))
680 importXML(patch, component, root, id);
681 else
682 throw std::runtime_error("No \"xml\" node in XML object");
683
684 return;
685 }
686 }
687
688 throw std::runtime_error("No XML node in JSON object");
689 }
690
692 void importXML(const std::string &patch,
693 const std::string& component,
694 const pugi::xml_node &xml,
695 int id = 0) override {
696
697 if (component.empty()) {
698 Spline::from_xml(xml, id, "geometry");
699 solution_.from_xml(xml, id, "solution");
700 } else {
701 if (component == "geometry") {
702 Spline::from_xml(xml, id, "geometry");
703 } else if (component == "solution")
704 solution_.from_xml(xml, id, "solution");
705 else
706 throw std::runtime_error("Unsupported component");
707 }
708 }
709
711 nlohmann::json exportXML(const std::string &patch,
712 const std::string& component,
713 int id = 0) override {
714
715 // serialize to XML
716 pugi::xml_document doc;
717 pugi::xml_node xml = doc.append_child("xml");
718 xml = exportXML(patch, component, xml, id);
719
720 // serialize to JSON
721 std::ostringstream oss;
722 doc.save(oss);
723
724 return oss.str();
725 }
726
728 pugi::xml_node &exportXML(const std::string &patch,
729 const std::string& component,
730 pugi::xml_node &xml,
731 int id = 0) override {
732
733 if (component.empty()) {
734 Spline::to_xml(xml, id, "geometry");
735 solution_.to_xml(xml, id, "solution");
736 } else {
737 if (component == "geometry") {
738 Spline::to_xml(xml, id, "geometry");
739 } else if (component == "solution")
740 solution_.to_xml(xml, id, "solution");
741 else
742 throw std::runtime_error("Unsupported component");
743 }
744 return xml;
745 }
746};
747
748} // namespace webapp
749} // namespace iganet
Model evaluator.
Definition model.hpp:98
Model interface.
Definition model.hpp:195
virtual nlohmann::json to_json(const std::string &patch, const std::string &component, const std::string &attribute) const
Serializes the model to JSON.
Definition model.hpp:289
virtual nlohmann::json updateAttribute(const std::string &patch, const std::string &component, const std::string &attribute, const nlohmann::json &json)
Updates the attributes of the model.
Definition model.hpp:297
Model refinement.
Definition model.hpp:124
Model reparameterization.
Definition model.hpp:136
Model serialization.
Definition model.hpp:148
Model XML serialization.
Definition model.hpp:163
The Options class handles the automated determination of dtype from the template argument and the sel...
Definition options.hpp:90
B-spline model.
Definition BSplineModel.hpp:40
nlohmann::json getOptions() const override
Returns the model's options.
Definition BSplineModel.hpp:118
void importXML(const std::string &patch, const std::string &component, const nlohmann::json &json, int id=0) override
Imports the model from XML (as JSON object)
Definition BSplineModel.hpp:665
nlohmann::json eval(const std::string &patch, const std::string &component, const nlohmann::json &json) const override
Evaluates the model.
Definition BSplineModel.hpp:437
BSplineModel()
Default constructor.
Definition BSplineModel.hpp:53
void load(const nlohmann::json &json) override
Loads model from LibTorch file.
Definition BSplineModel.hpp:609
std::string getDescription() const override
Returns the model's description.
Definition BSplineModel.hpp:104
nlohmann::json updateAttribute(const std::string &patch, const std::string &component, const std::string &attribute, const nlohmann::json &json) override
Updates the attributes of the model.
Definition BSplineModel.hpp:336
nlohmann::json getOutputs() const override
Returns the model's outputs.
Definition BSplineModel.hpp:256
nlohmann::json getInputs() const override
Returns the model's inputs.
Definition BSplineModel.hpp:248
void importXML(const std::string &patch, const std::string &component, const pugi::xml_node &xml, int id=0) override
Imports the model from XML (as XML object)
Definition BSplineModel.hpp:692
nlohmann::json to_json(const std::string &patch, const std::string &component, const std::string &attribute) const override
Serializes the model to JSON.
Definition BSplineModel.hpp:276
Spline solution_
"fake" solution vector
Definition BSplineModel.hpp:49
std::string getName() const override
Returns the model's name.
Definition BSplineModel.hpp:90
pugi::xml_node & exportXML(const std::string &patch, const std::string &component, pugi::xml_node &xml, int id=0) override
Exports the model to XML (as XML object)
Definition BSplineModel.hpp:728
nlohmann::json exportXML(const std::string &patch, const std::string &component, int id=0) override
Exports the model to XML (as JSON object)
Definition BSplineModel.hpp:711
void reparameterize(const std::string &patch, const nlohmann::json &json=NULL) override
Reparameterize the model.
Definition BSplineModel.hpp:599
nlohmann::json save() const override
Saves model to LibTorch file.
Definition BSplineModel.hpp:633
void refine(const nlohmann::json &json=NULL) override
Refines the model.
Definition BSplineModel.hpp:557
~BSplineModel()
Destructor.
Definition BSplineModel.hpp:87
nlohmann::json getParameters() const override
Returns the model's parameters.
Definition BSplineModel.hpp:273
BSplineModel(const std::array< int64_t, Spline::parDim()> ncoeffs, enum iganet::init init=iganet::init::zeros)
Constructor for equidistant knot vectors.
Definition BSplineModel.hpp:56
Isogeometric analysis network main header file.
Model capabilities.
TensorArray< 4 > TensorArray4
Definition tensorarray.hpp:34
auto zip(T &&...seqs)
Definition zip.hpp:97
TensorArray< 3 > TensorArray3
Definition tensorarray.hpp:33
TensorArray< 1 > TensorArray1
Definition tensorarray.hpp:31
TensorArray< 2 > TensorArray2
Definition tensorarray.hpp:32
degree
Enumerator for specifying the degree of B-splines.
Definition BSplineModel.hpp:23
Definition boundary.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
IndexOutOfBounds exception.
Definition model.hpp:32
InvalidModelAttribute exception.
Definition model.hpp:42
InvalidModel exception.
Definition model.hpp:37