https://mooseframework.inl.gov
Loading...
Searching...
No Matches
DataIO.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "DenseMatrix.h"
11#include "DataIO.h"
12#include "MooseMesh.h"
13#include "FEProblemBase.h"
14#include "NonlinearSystemBase.h"
15
16#include "libmesh/vector_value.h"
17#include "libmesh/tensor_value.h"
18#include "libmesh/fe_type.h"
19
20#include "libmesh/elem.h"
21#include "libmesh/petsc_vector.h"
22#include "libmesh/enum_solver_package.h"
23#include "libmesh/petsc_solver_exception.h"
24#include "libmesh/bounding_box.h"
25
26#include "mtwist.h"
27
28template <>
29void
30dataStore<mt_state>(std::ostream & stream, mt_state & foo, void * ctx)
31{
32 dataStore(stream, foo.statevec, ctx);
33 dataStore(stream, foo.stateptr, ctx);
34 dataStore(stream, foo.initialized, ctx);
35}
36
37template <>
38void
39dataStore(std::ostream & stream, std::string & v, void * /*context*/)
40{
41 // Write the size of the string
42 unsigned int size = v.size();
43 stream.write((char *)&size, sizeof(size));
44
45 // Write the string (Do not store the null byte)
46 stream.write(v.c_str(), sizeof(char) * size);
47}
48
49template <>
50void
51dataStore(std::ostream & stream, VariableName & v, void * context)
52{
53 auto & name = cast_ref<std::string &>(v);
54 dataStore(stream, name, context);
55}
56
57template <>
58void
59dataStore(std::ostream & stream, UserObjectName & v, void * context)
60{
61 auto & name = cast_ref<std::string &>(v);
62 dataStore(stream, name, context);
63}
64
65template <>
66void
67dataStore(std::ostream & stream, FEType & v, void * context)
68{
69 auto order = v.order.get_order();
70 dataStore(stream, order, context);
71
72 auto family = v.family;
73 dataStore(stream, family, context);
74
75#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
76 auto radial_order = v.radial_order.get_order();
77 dataStore(stream, radial_order, context);
78
79 auto radial_family = v.radial_family;
80 dataStore(stream, radial_family, context);
81
82 auto inf_map = v.inf_map;
83 dataStore(stream, inf_map, context);
84#endif
85
86 auto p_refinement = v.p_refinement;
87 dataStore(stream, p_refinement, context);
88}
89
90template <>
91void
92dataStore(std::ostream & stream, std::vector<bool> & v, void * context)
93{
94 std::size_t size = v.size();
95 dataStore(stream, size, nullptr);
96 for (bool b : v)
97 dataStore(stream, b, context);
98}
99
100template <>
101void
102dataStore(std::ostream & stream, RankTwoTensor & rtt, void * context)
103{
104 dataStore(stream, rtt._coords, context);
105}
106
107template <>
108void
109dataStore(std::ostream & stream, RankThreeTensor & rtht, void * context)
110{
111 dataStore(stream, rtht._vals, context);
112}
113
114template <>
115void
116dataStore(std::ostream & stream, RankFourTensor & rft, void * context)
117{
118 dataStore(stream, rft._vals, context);
119}
120
121template <>
122void
123dataStore(std::ostream & stream, ADReal & dn, void * context)
124{
125 dataStore(stream, dn.value(), context);
126
127 if (ADReal::do_derivatives)
128 {
129 auto & derivatives = dn.derivatives();
130 std::size_t size = derivatives.size();
131 dataStore(stream, size, context);
132 for (MooseIndex(size) i = 0; i < size; ++i)
133 {
134 dataStore(stream, derivatives.raw_index(i), context);
135 dataStore(stream, derivatives.raw_at(i), context);
136 }
137 }
138}
139
140template <>
141void
142dataStore(std::ostream & stream, const Elem *& e, void * context)
143{
144 // TODO: Write out the unique ID of this elem
145 dof_id_type id = libMesh::DofObject::invalid_id;
146
147 if (e)
148 {
149 id = e->id();
151 mooseError("Can't output Elems with invalid ids!");
152 }
153
154 dataStore(stream, id, context);
155}
156
157template <>
158void
159dataStore(std::ostream & stream, const Node *& n, void * context)
160{
161 // TODO: Write out the unique ID of this node
162 dof_id_type id = libMesh::DofObject::invalid_id;
163
164 if (n)
165 {
166 id = n->id();
168 mooseError("Can't output Nodes with invalid ids!");
169 }
170
171 dataStore(stream, id, context);
172}
173
174template <>
175void
176dataStore(std::ostream & stream, Elem *& e, void * context)
177{
178 // TODO: Write out the unique ID of this elem
179 dof_id_type id = libMesh::DofObject::invalid_id;
180
181 if (e)
182 {
183 id = e->id();
185 mooseError("Can't output Elems with invalid ids!");
186 }
187
188 dataStore(stream, id, context);
189}
190
191template <>
192void
193dataStore(std::ostream & stream, Node *& n, void * context)
194{
195 // TODO: Write out the unique ID of this node
196 dof_id_type id = libMesh::DofObject::invalid_id;
197
198 if (n)
199 {
200 id = n->id();
202 mooseError("Can't output Nodes with invalid ids!");
203 }
204
205 dataStore(stream, id, context);
206}
207
208template <>
209void
210dataStore(std::ostream & stream, std::stringstream & s, void * /* context */)
211{
212 const std::string & s_str = s.str();
213
214 size_t s_size = s_str.size();
215 stream.write((char *)&s_size, sizeof(s_size));
216
217 stream.write(s_str.c_str(), sizeof(char) * (s_str.size()));
218}
219
220#ifdef MOOSE_LIBTORCH_ENABLED
221template <>
222void
223dataStore(std::ostream & stream, torch::Tensor & t, void * context)
224{
225 const bool defined = t.defined();
226 dataStore(stream, defined, nullptr);
227
228 if (!defined)
229 return;
230
231 const auto tensor = LibtorchUtils::toCPUContiguous(t);
232 mooseAssert(tensor.scalar_type() == at::kDouble,
233 "Restart storage currently supports only double tensors.");
234
235 auto rank = cast_int<unsigned int>(tensor.dim());
236 dataStore(stream, rank, nullptr);
237 for (unsigned int dim = 0; dim < rank; ++dim)
238 {
239 auto size = cast_int<unsigned int>(tensor.sizes()[dim]);
240 dataStore(stream, size, nullptr);
241 }
242
243 const auto flattened = tensor.reshape({tensor.numel()});
244 const auto t_accessor = flattened.accessor<Real, 1>();
245 for (int64_t i = 0; i < flattened.numel(); ++i)
246 {
247 Real r = t_accessor[i];
248 dataStore(stream, r, context);
249 }
250}
251#endif
252
253template <typename T>
254void
255dataStore(std::ostream & stream, TensorValue<T> & v, void * context)
256{
257 for (const auto i : make_range(Moose::dim))
258 for (const auto j : make_range(Moose::dim))
259 {
260 T r = v(i, j);
261 dataStore(stream, r, context);
262 }
263}
264
265template void dataStore(std::ostream & stream, TensorValue<Real> & v, void * context);
266template void dataStore(std::ostream & stream, TensorValue<ADReal> & v, void * context);
267
268template <typename T>
269void
270dataStore(std::ostream & stream, DenseMatrix<T> & v, void * context)
271{
272 unsigned int m = v.m();
273 unsigned int n = v.n();
274 stream.write((char *)&m, sizeof(m));
275 stream.write((char *)&n, sizeof(n));
276 for (unsigned int i = 0; i < m; i++)
277 for (unsigned int j = 0; j < n; j++)
278 {
279 T r = v(i, j);
280 dataStore(stream, r, context);
281 }
282}
283
284template void dataStore(std::ostream & stream, DenseMatrix<Real> & v, void * context);
285template void dataStore(std::ostream & stream, DenseMatrix<ADReal> & v, void * context);
286
287template <typename T>
288void
289dataStore(std::ostream & stream, VectorValue<T> & v, void * context)
290{
291 // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
292 // won't work.
293 for (const auto i : make_range(Moose::dim))
294 {
295 T r = v(i);
296 dataStore(stream, r, context);
297 }
298}
299
300template void dataStore(std::ostream & stream, VectorValue<Real> & v, void * context);
301template void dataStore(std::ostream & stream, VectorValue<ADReal> & v, void * context);
302
303template <>
304void
305dataStore(std::ostream & stream, const Point & p, void * context)
306{
307 for (const auto i : make_range(Moose::dim))
308 dataStore(stream, p(i), context);
309}
310
311void
312dataStore(std::ostream & stream, libMesh::BoundingBox & bbox, void * context)
313{
314 dataStore(stream, cast_ref<std::pair<Point, Point> &>(bbox), context);
315}
316
317template <>
318void
319dataStore(std::ostream & stream, Point & p, void * context)
320{
321 dataStore(stream, const_cast<const Point &>(p), context);
322}
323
324template <>
325void
326dataStore(std::ostream & stream, libMesh::Parameters & p, void * context)
327{
328 // First store the size of the map
329 unsigned int size = p.n_parameters();
330 stream.write((char *)&size, sizeof(size));
331
332 auto it = p.begin();
333 auto end = p.end();
334
335 for (; it != end; ++it)
336 {
337 auto & key = const_cast<std::string &>(it->first);
338 auto type = it->second->type();
339
340 dataStore(stream, key, context);
341 dataStore(stream, type, context);
342
343#define storescalar(ptype) \
344 else if (it->second->type() == demangle(typeid(ptype).name())) dataStore( \
345 stream, \
346 (dynamic_cast<libMesh::Parameters::Parameter<ptype> *>(MooseUtils::get(it->second)))->get(), \
347 context)
348
349 if (false)
350 ;
351 storescalar(Real);
352 storescalar(short);
353 storescalar(int);
354 storescalar(long);
355 storescalar(unsigned short);
356 storescalar(unsigned int);
357 storescalar(unsigned long);
358
359#undef storescalar
360 }
361}
362
363template <>
364void
365dataStore(std::ostream & stream,
366 std::unique_ptr<libMesh::NumericVector<Number>> & v,
367 void * context)
368{
369 // Classes may declare unique pointers to vectors as restartable data and never actually create
370 // vector instances. This happens for example in the `TimeIntegrator` class where subvector
371 // instances are only created if multiple time integrators are present
372 bool have_vector = v.get();
373 dataStore(stream, have_vector, context);
374 if (!have_vector)
375 return;
376
377 mooseAssert(context, "Needs a context of the communicator");
378 const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
379 mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
380
381 if (v->type() == GHOSTED)
382 mooseError("Cannot store ghosted numeric vectors");
383
384 // Store the communicator size for sanity checking later
385 unsigned int comm_size = comm.size();
386 dataStore(stream, comm_size, nullptr);
387
388 // Store the solver package so that we know what vector type to construct
389 libMesh::SolverPackage solver_package;
390 if (dynamic_cast<libMesh::PetscVector<Number> *>(v.get()))
391 solver_package = libMesh::PETSC_SOLVERS;
392 else
393 mooseError("Can only store unique_ptrs of PetscVectors");
394 int solver_package_int = solver_package;
395 dataStore(stream, solver_package_int, nullptr);
396
397 // Store the sizes
398 dof_id_type size = v->size();
399 dataStore(stream, size, nullptr);
400 dof_id_type local_size = v->local_size();
401 dataStore(stream, local_size, nullptr);
402
403 // Store the vector itself
404 dataStore(stream, *v, nullptr);
405}
406
407// global load functions
408
409template <>
410void
411dataLoad<mt_state>(std::istream & stream, mt_state & foo, void * ctx)
412{
413 dataLoad(stream, foo.statevec, ctx);
414 dataLoad(stream, foo.stateptr, ctx);
415 dataLoad(stream, foo.initialized, ctx);
416}
417
418template <>
419void
420dataLoad(std::istream & stream, std::string & v, void * /*context*/)
421{
422 // Read the size of the string
423 unsigned int size = 0;
424 stream.read((char *)&size, sizeof(size));
425
426 // Resize the string data
427 v.resize(size);
428
429 // Read the string
430 stream.read(&v[0], sizeof(char) * size);
431}
432
433template <>
434void
435dataLoad(std::istream & stream, VariableName & v, void * context)
436{
437 auto & name = cast_ref<std::string &>(v);
438 dataLoad(stream, name, context);
439}
440
441template <>
442void
443dataLoad(std::istream & stream, UserObjectName & v, void * context)
444{
445 auto & name = cast_ref<std::string &>(v);
446 dataLoad(stream, name, context);
447}
448
449template <>
450void
451dataLoad(std::istream & stream, FEType & v, void * context)
452{
453 int order = 0;
454 dataLoad(stream, order, context);
455 v.order = order;
456
457 dataLoad(stream, v.family, context);
458
459#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
460 int radial_order = 0;
461 dataLoad(stream, radial_order, context);
462 v.radial_order = radial_order;
463
464 dataLoad(stream, v.radial_family, context);
465 dataLoad(stream, v.inf_map, context);
466#endif
467
468 dataLoad(stream, v.p_refinement, context);
469}
470
471template <>
472void
473dataLoad(std::istream & stream, std::vector<bool> & v, void * context)
474{
475 std::size_t size = 0;
476 dataLoad(stream, size, nullptr);
477 v.resize(size);
478 for (std::size_t i = 0; i < size; i++)
479 {
480 bool b;
481 dataLoad(stream, b, context);
482 v[i] = b;
483 }
484}
485
486template <>
487void
488dataLoad(std::istream & stream, ADReal & dn, void * context)
489{
490 dataLoad(stream, dn.value(), context);
491
492 if (ADReal::do_derivatives)
493 {
494 auto & derivatives = dn.derivatives();
495 std::size_t size = 0;
496 stream.read((char *)&size, sizeof(size));
497 derivatives.resize(size);
498
499 for (MooseIndex(derivatives) i = 0; i < derivatives.size(); ++i)
500 {
501 dataLoad(stream, derivatives.raw_index(i), context);
502 dataLoad(stream, derivatives.raw_at(i), context);
503 }
504 }
505}
506
507template <>
508void
509dataLoad(std::istream & stream, const Elem *& e, void * context)
510{
511 if (!context)
512 mooseError("Can only load Elem objects using a MooseMesh context!");
513
514 MooseMesh * mesh = static_cast<MooseMesh *>(context);
515
516 // TODO: Write out the unique ID of this element
517 dof_id_type id = libMesh::DofObject::invalid_id;
518
519 dataLoad(stream, id, context);
520
522 e = mesh->elemPtr(id);
523 else
524 e = NULL;
525}
526
527template <>
528void
529dataLoad(std::istream & stream, const Node *& n, void * context)
530{
531 if (!context)
532 mooseError("Can only load Node objects using a MooseMesh context!");
533
534 MooseMesh * mesh = static_cast<MooseMesh *>(context);
535
536 // TODO: Write out the unique ID of this nodeent
537 dof_id_type id = libMesh::DofObject::invalid_id;
538
539 dataLoad(stream, id, context);
540
542 n = mesh->nodePtr(id);
543 else
544 n = NULL;
545}
546
547template <>
548void
549dataLoad(std::istream & stream, Elem *& e, void * context)
550{
551 if (!context)
552 mooseError("Can only load Elem objects using a MooseMesh context!");
553
554 MooseMesh * mesh = static_cast<MooseMesh *>(context);
555
556 // TODO: Write out the unique ID of this element
557 dof_id_type id = libMesh::DofObject::invalid_id;
558
559 dataLoad(stream, id, context);
560
562 e = mesh->elemPtr(id);
563 else
564 e = NULL;
565}
566
567template <>
568void
569dataLoad(std::istream & stream, Node *& n, void * context)
570{
571 if (!context)
572 mooseError("Can only load Node objects using a MooseMesh context!");
573
574 MooseMesh * mesh = static_cast<MooseMesh *>(context);
575
576 // TODO: Write out the unique ID of this nodeent
577 dof_id_type id = libMesh::DofObject::invalid_id;
578
579 dataLoad(stream, id, context);
580
582 n = mesh->nodePtr(id);
583 else
584 n = NULL;
585}
586
587template <>
588void
589dataLoad(std::istream & stream, std::stringstream & s, void * /* context */)
590{
591 size_t s_size = 0;
592 stream.read((char *)&s_size, sizeof(s_size));
593
594 std::unique_ptr<char[]> s_s = std::make_unique<char[]>(s_size);
595 stream.read(s_s.get(), s_size);
596
597 // Clear the stringstream before loading new data into it.
598 s.str(std::string());
599 s.write(s_s.get(), s_size);
600}
601
602#ifdef MOOSE_LIBTORCH_ENABLED
603template <>
604void
605dataLoad(std::istream & stream, torch::Tensor & t, void * context)
606{
607 bool defined = false;
608 dataLoad(stream, defined, nullptr);
609 if (!defined)
610 {
611 t = torch::Tensor(); // undefined tensor
612 return;
613 }
614
615 unsigned int rank = 0;
616 dataLoad(stream, rank, nullptr);
617
618 std::vector<int64_t> sizes(rank);
619 for (unsigned int dim = 0; dim < rank; ++dim)
620 {
621 unsigned int size = 0;
622 dataLoad(stream, size, nullptr);
623 sizes[dim] = size;
624 }
625
626 t = torch::empty(sizes, at::kDouble);
627 auto flattened = t.reshape({t.numel()});
628 auto t_accessor = flattened.accessor<Real, 1>();
629 for (int64_t i = 0; i < flattened.numel(); ++i)
630 {
631 Real r = 0;
632 dataLoad(stream, r, context);
633 t_accessor[i] = r;
634 }
635}
636#endif
637
638template <typename T>
639void
640dataLoad(std::istream & stream, TensorValue<T> & v, void * context)
641{
642 // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
643 // won't work.
644 for (const auto i : make_range(Moose::dim))
645 for (const auto j : make_range(Moose::dim))
646 {
647 T r = 0;
648 dataLoad(stream, r, context);
649 v(i, j) = r;
650 }
651}
652
653template void dataLoad(std::istream & stream, TensorValue<Real> & v, void * context);
654template void dataLoad(std::istream & stream, TensorValue<ADReal> & v, void * context);
655
656template <typename T>
657void
658dataLoad(std::istream & stream, DenseMatrix<T> & v, void * context)
659{
660 unsigned int m = 0, n = 0;
661 stream.read((char *)&m, sizeof(m));
662 stream.read((char *)&n, sizeof(n));
663 v.resize(m, n);
664 for (unsigned int i = 0; i < m; i++)
665 for (unsigned int j = 0; j < n; j++)
666 {
667 T r = 0;
668 dataLoad(stream, r, context);
669 v(i, j) = r;
670 }
671}
672
673template void dataLoad(std::istream & stream, DenseMatrix<Real> & v, void * context);
674template void dataLoad(std::istream & stream, DenseMatrix<ADReal> & v, void * context);
675
676template <typename T>
677void
678dataLoad(std::istream & stream, VectorValue<T> & v, void * context)
679{
680 // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
681 // won't work.
682 for (const auto i : make_range(Moose::dim))
683 {
684 T r = 0;
685 dataLoad(stream, r, context);
686 v(i) = r;
687 }
688}
689
690template void dataLoad(std::istream & stream, VectorValue<Real> & v, void * context);
691template void dataLoad(std::istream & stream, VectorValue<ADReal> & v, void * context);
692
693template <>
694void
695dataLoad(std::istream & stream, Point & p, void * context)
696{
697 for (const auto i : make_range(Moose::dim))
698 dataLoad(stream, p(i), context);
699}
700
701void
702dataLoad(std::istream & stream, libMesh::BoundingBox & bbox, void * context)
703{
704 dataLoad(stream, cast_ref<std::pair<Point, Point> &>(bbox), context);
705}
706
707template <>
708void
709dataLoad(std::istream & stream, libMesh::Parameters & p, void * context)
710{
711 p.clear();
712
713 // First read the size of the map
714 unsigned int size = 0;
715 stream.read((char *)&size, sizeof(size));
716
717 for (unsigned int i = 0; i < size; i++)
718 {
719 std::string key, type;
720 dataLoad(stream, key, context);
721 dataLoad(stream, type, context);
722
723#define loadscalar(ptype) \
724 else if (type == demangle(typeid(ptype).name())) do \
725 { \
726 ptype & value = p.set<ptype>(key); \
727 dataLoad(stream, value, context); \
728 } \
729 while (0)
730
731 if (false)
732 ;
733 loadscalar(Real);
734 loadscalar(short);
735 loadscalar(int);
736 loadscalar(long);
737 loadscalar(unsigned short);
738 loadscalar(unsigned int);
739 loadscalar(unsigned long);
740
741#undef loadscalar
742 }
743}
744
745template <>
746void
747dataLoad(std::istream & stream, std::unique_ptr<libMesh::NumericVector<Number>> & v, void * context)
748{
749 bool have_vector;
750 dataLoad(stream, have_vector, context);
751
752 if (!have_vector)
753 return;
754
755 mooseAssert(context, "Needs a context of the communicator");
756 const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
757 if (v)
758 mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
759
760 // Load the communicator size for consistency checks
761 unsigned int comm_size;
762 dataLoad(stream, comm_size, nullptr);
763 mooseAssert(comm.size() == comm_size, "Inconsistent communicator size");
764
765 // Load the solver package to build the vector
766 int solver_package_int;
767 dataLoad(stream, solver_package_int, nullptr);
768 libMesh::SolverPackage solver_package = static_cast<libMesh::SolverPackage>(solver_package_int);
769
770 // Load the sizes
771 dof_id_type size, local_size;
772 dataLoad(stream, size, nullptr);
773 dataLoad(stream, local_size, nullptr);
774
775 // Construct the vector given the type, only if we need to. v could be non-null here
776 // if we're advancing back and loading a backup
777 if (!v)
778 {
779 v = NumericVector<Number>::build(comm, solver_package);
780 v->init(size, local_size);
781 }
782 else
783 mooseAssert(v->type() != GHOSTED, "Cannot be ghosted");
784
785 // Make sure that the sizes are consistent; this will happen if we're calling this
786 // on a vector that has already been loaded previously
787 mooseAssert(v->size() == size, "Inconsistent size");
788 mooseAssert(v->local_size() == local_size, "Inconsistent local size");
789
790 // Now that we have an initialized vector, fill the entries
791 dataLoad(stream, *v, nullptr);
792}
793
794template <>
795void
796dataLoad(std::istream & stream, Vec & v, void * context)
797{
798 PetscInt local_size;
799 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
800 PetscScalar * array;
801 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
802 for (PetscInt i = 0; i < local_size; i++)
803 dataLoad(stream, array[i], context);
804
805 LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
806}
807
808template <>
809void
810dataStore(std::ostream & stream, Vec & v, void * context)
811{
812 PetscInt local_size;
813 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
814 PetscScalar * array;
815 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
816 for (PetscInt i = 0; i < local_size; i++)
817 dataStore(stream, array[i], context);
818
819 LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
820}
DualNumber< Real, DNDerivativeType, true > ADReal
void dataLoad< mt_state >(std::istream &stream, mt_state &foo, void *ctx)
Definition DataIO.C:411
void dataStore< mt_state >(std::ostream &stream, mt_state &foo, void *ctx)
Definition DataIO.C:30
void dataStore(std::ostream &stream, std::string &v, void *)
Definition DataIO.C:39
void dataLoad(std::istream &stream, std::string &v, void *)
Definition DataIO.C:420
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int dim
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
RankFourTensorTempl is designed to handle any N-dimensional fourth order tensor, C.
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
RankThreeTensor is designed to handle any N-dimensional third order tensor, r.
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k)
static constexpr dof_id_type invalid_id
std::size_t n_parameters() const
virtual void clear()
T _coords[LIBMESH_DIM *LIBMESH_DIM]
MeshBase & mesh
torch::Tensor toCPUContiguous(const torch::Tensor &tensor)
Return a detached contiguous CPU copy of a tensor.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:175