https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SystemBase.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 "MooseApp.h"
11#include "SystemBase.h"
12#include "Factory.h"
13#include "SubProblem.h"
14#include "MooseVariableFE.h"
15#include "MooseVariableFV.h"
16#include "MooseVariableScalar.h"
18#include "Conversion.h"
19#include "Parser.h"
21#include "MooseTypes.h"
22#include "InitialCondition.h"
24#include "Assembly.h"
25#include "MooseMesh.h"
26#include "MooseUtils.h"
27#include "FVBoundaryCondition.h"
28#include "FEProblemBase.h"
29#include "TimeIntegrator.h"
30#include "GradientLimiterType.h"
31#include "libmesh/dof_map.h"
32#include "libmesh/string_to_enum.h"
33#include "libmesh/fe_interface.h"
34#include "libmesh/static_condensation.h"
35
37void
38extraSendList(std::vector<dof_id_type> & send_list, void * context)
39{
40 SystemBase * sys = static_cast<SystemBase *>(context);
41 sys->augmentSendList(send_list);
42}
43
45void
47 std::vector<dof_id_type> & n_nz,
48 std::vector<dof_id_type> & n_oz,
49 void * context)
50{
51 SystemBase * sys = static_cast<SystemBase *>(context);
52 sys->augmentSparsity(sparsity, n_nz, n_oz);
53}
54
56 FEProblemBase & fe_problem,
57 const std::string & name,
58 Moose::VarKindType var_kind)
59 : libMesh::ParallelObject(subproblem),
60 ConsoleStreamInterface(subproblem.getMooseApp()),
61 _subproblem(subproblem),
62 _fe_problem(fe_problem),
63 _app(subproblem.getMooseApp()),
64 _factory(_app.getFactory()),
65 _mesh(subproblem.mesh()),
66 _name(name),
67 _vars(libMesh::n_threads()),
68 _var_map(),
69 _max_var_number(0),
70 _u_dot(nullptr),
71 _u_dotdot(nullptr),
72 _u_dot_old(nullptr),
73 _u_dotdot_old(nullptr),
74 _saved_old(nullptr),
75 _saved_older(nullptr),
76 _saved_dot_old(nullptr),
77 _saved_dotdot_old(nullptr),
78 _var_kind(var_kind),
79 _max_var_n_dofs_per_elem(0),
80 _max_var_n_dofs_per_node(0),
81 _automatic_scaling(false),
82 _verbose(false),
83 _solution_states_initialized(false),
84 _skip_next_solution_to_old_copy(false)
85{
86}
87
89SystemBase::getVariable(THREAD_ID tid, const std::string & var_name) const
90{
92 dynamic_cast<MooseVariableFieldBase *>(_vars[tid].getVariable(var_name));
93 if (!var)
94 mooseError("Variable '", var_name, "' does not exist in this system");
95 return *var;
96}
97
99SystemBase::getVariable(THREAD_ID tid, unsigned int var_number) const
100{
101 if (var_number < _numbered_vars[tid].size())
102 if (_numbered_vars[tid][var_number])
103 return *_numbered_vars[tid][var_number];
104
105 mooseError("Variable #", Moose::stringify(var_number), " does not exist in this system");
106}
107
108template <typename T>
110SystemBase::getFieldVariable(THREAD_ID tid, const std::string & var_name)
111{
112 return *_vars[tid].getFieldVariable<T>(var_name);
113}
114
115template <typename T>
117SystemBase::getActualFieldVariable(THREAD_ID tid, const std::string & var_name)
118{
119 return *_vars[tid].getActualFieldVariable<T>(var_name);
120}
121
122template <typename T>
124SystemBase::getFVVariable(THREAD_ID tid, const std::string & var_name)
125{
126 return *_vars[tid].getFVVariable<T>(var_name);
127}
128
129template <typename T>
131SystemBase::getFieldVariable(THREAD_ID tid, unsigned int var_number)
132{
133 return *_vars[tid].getFieldVariable<T>(var_number);
134}
135
136template <typename T>
139{
140 return *_vars[tid].getActualFieldVariable<T>(var_number);
141}
142
144SystemBase::getScalarVariable(THREAD_ID tid, const std::string & var_name) const
145{
146 MooseVariableScalar * var = dynamic_cast<MooseVariableScalar *>(_vars[tid].getVariable(var_name));
147 if (!var)
148 mooseError("Scalar variable '" + var_name + "' does not exist in this system");
149 return *var;
150}
151
153SystemBase::getScalarVariable(THREAD_ID tid, unsigned int var_number) const
154{
155 MooseVariableScalar * var =
156 dynamic_cast<MooseVariableScalar *>(_vars[tid].getVariable(var_number));
157 if (!var)
158 mooseError("variable #" + Moose::stringify(var_number) + " does not exist in this system");
159 return *var;
160}
161
162const std::set<SubdomainID> *
163SystemBase::getVariableBlocks(unsigned int var_number)
164{
165 mooseAssert(_var_map.find(var_number) != _var_map.end(), "Variable does not exist.");
166 if (_var_map[var_number].empty())
167 return nullptr;
168 else
169 return &_var_map[var_number];
170}
171
172void
174{
175 _vars_to_be_zeroed_on_residual.push_back(var_name);
176}
177
178void
180{
181 _vars_to_be_zeroed_on_jacobian.push_back(var_name);
182}
183
184void
185SystemBase::setVariableGlobalDoFs(const std::string & var_name)
186{
187 AllLocalDofIndicesThread aldit(_subproblem, {var_name});
188 const ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
189 Threads::parallel_reduce(elem_range, aldit);
190
191 // Gather the dof indices across procs to get all the dof indices for var_name
192 aldit.dofIndicesSetUnion();
193
194 const auto & all_dof_indices = aldit.getDofIndices();
195 _var_all_dof_indices.assign(all_dof_indices.begin(), all_dof_indices.end());
196}
197
198void
199SystemBase::zeroVariables(std::vector<std::string> & vars_to_be_zeroed)
200{
201 if (vars_to_be_zeroed.size() > 0)
202 {
203 NumericVector<Number> & solution = this->solution();
204
205 auto problem = dynamic_cast<FEProblemBase *>(&_subproblem);
206 if (!problem)
207 mooseError("System needs to be registered in FEProblemBase for using zeroVariables.");
208
209 AllLocalDofIndicesThread aldit(*problem, vars_to_be_zeroed, true);
210 const ConstElemRange & elem_range = *_mesh.getActiveLocalElementRange();
211 Threads::parallel_reduce(elem_range, aldit);
212
213 const auto & dof_indices_to_zero = aldit.getDofIndices();
214
215 solution.close();
216
217 for (const auto & dof : dof_indices_to_zero)
218 solution.set(dof, 0);
219
220 solution.close();
221
222 // Call update to update the current_local_solution for this system
223 system().update();
224 }
225}
226
227void
232
233void
238
239Order
241{
242 Order order = CONSTANT;
243 const std::vector<MooseVariableFieldBase *> & vars = _vars[0].fieldVariables();
244 for (const auto & var : vars)
245 {
246 FEType fe_type = var->feType();
247 if (fe_type.default_quadrature_order() > order)
248 order = fe_type.default_quadrature_order();
249 }
250
251 return order;
252}
253
254void
256{
258 {
259 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
261 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
262 for (const auto & var : vars)
263 var->clearDofIndices();
264
265 for (const auto & var : active_elemental_moose_variables)
266 if (&(var->sys()) == this)
267 var->prepare();
268 }
269 else
270 {
271 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
272 for (const auto & var : vars)
273 var->prepare();
274 }
275}
276
277void
278SystemBase::prepareFace(THREAD_ID tid, bool resize_data)
279{
280 // We only need to do something if the element prepare was restricted
282 {
283 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
285
286 std::vector<MooseVariableFieldBase *> newly_prepared_vars;
287
288 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
289 for (const auto & var : vars)
290 {
291 mooseAssert(&var->sys() == this,
292 "I will cry if we store variables in our warehouse that don't belong to us");
293
294 // If it wasn't in the active list, we need to prepare it. This has the potential to duplicate
295 // prepare if we have these conditions:
296 //
297 // 1. We have a displaced problem
298 // 2. We are using AD
299 // 3. We are not using global AD indexing
300 //
301 // But I think I would rather risk duplicate prepare than introduce an additional member set
302 // variable for tracking prepared variables. Set insertion is slow and some simulations have a
303 // ton of variables
304 if (!active_elemental_moose_variables.count(var))
305 {
306 var->prepare();
307 newly_prepared_vars.push_back(var);
308 }
309 }
310
311 // Make sure to resize the residual and jacobian datastructures for all the new variables
312 if (resize_data)
313 for (const auto var_ptr : newly_prepared_vars)
314 {
315 _subproblem.assembly(tid, number()).prepareVariable(var_ptr);
317 _subproblem.assembly(tid, number()).prepareVariableNonlocal(var_ptr);
318 }
319 }
320}
321
322void
324{
325 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
326 for (const auto & var : vars)
327 var->prepareNeighbor();
328}
329
330void
332{
333 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
334 for (const auto & var : vars)
335 var->prepareLowerD();
336}
337
338void
339SystemBase::reinitElem(const Elem * const elem, THREAD_ID tid)
340{
342 {
343 const std::set<MooseVariableFieldBase *> & active_elemental_moose_variables =
345 for (const auto & var : active_elemental_moose_variables)
346 if (&(var->sys()) == this)
347 var->computeElemValues();
348 }
349 else
350 {
351 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
352 for (const auto & var : vars)
353 var->computeElemValues();
354 }
355
357 for (auto & [tag, matrix] : _active_tagged_matrices)
358 {
359 libmesh_ignore(tag);
360 cast_ptr<libMesh::StaticCondensation *>(matrix)->set_current_elem(*elem);
361 }
362}
363
364void
365SystemBase::reinitElemFace(const Elem * /*elem*/, unsigned int /*side*/, THREAD_ID tid)
366{
367 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
368 for (const auto & var : vars)
369 var->computeElemValuesFace();
370}
371
372void
373SystemBase::reinitNeighborFace(const Elem * /*elem*/, unsigned int /*side*/, THREAD_ID tid)
374{
375 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
376 for (const auto & var : vars)
377 var->computeNeighborValuesFace();
378}
379
380void
381SystemBase::reinitNeighbor(const Elem * /*elem*/, THREAD_ID tid)
382{
383 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
384 for (const auto & var : vars)
385 var->computeNeighborValues();
386}
387
388void
390{
391 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
392 for (const auto & var : vars)
393 var->computeLowerDValues();
394}
395
396void
397SystemBase::reinitNode(const Node * /*node*/, THREAD_ID tid)
398{
399 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
400 for (const auto & var : vars)
401 {
402 var->reinitNode();
403 if (var->isNodalDefined())
404 var->computeNodalValues();
405 }
406}
407
408void
409SystemBase::reinitNodeFace(const Node * /*node*/, BoundaryID /*bnd_id*/, THREAD_ID tid)
410{
411 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
412 for (const auto & var : vars)
413 {
414 var->reinitNode();
415 if (var->isNodalDefined())
416 var->computeNodalValues();
417 }
418}
419
420void
421SystemBase::reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid)
422{
423 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
424 for (const auto & var : vars)
425 {
426 var->reinitNodes(nodes);
427 var->computeNodalValues();
428 }
429}
430
431void
432SystemBase::reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid)
433{
434 const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
435 for (const auto & var : vars)
436 {
437 var->reinitNodesNeighbor(nodes);
438 var->computeNodalNeighborValues();
439 }
440}
441
442void
443SystemBase::reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering /*=false*/)
444{
445 const std::vector<MooseVariableScalar *> & vars = _vars[tid].scalars();
446 for (const auto & var : vars)
447 var->reinit(reinit_for_derivative_reordering);
448}
449
450void
451SystemBase::augmentSendList(std::vector<dof_id_type> & send_list)
452{
453 std::set<dof_id_type> & ghosted_elems = _subproblem.ghostedElems();
454
455 DofMap & dof_map = dofMap();
456
457 std::vector<dof_id_type> dof_indices;
458
459 System & sys = system();
460
461 unsigned int sys_num = sys.number();
462
463 unsigned int n_vars = sys.n_vars();
464
465 for (const auto & elem_id : ghosted_elems)
466 {
467 Elem * elem = _mesh.elemPtr(elem_id);
468
469 if (elem->active())
470 {
471 dof_map.dof_indices(elem, dof_indices);
472
473 // Only need to ghost it if it's actually not on this processor
474 for (const auto & dof : dof_indices)
475 if (dof < dof_map.first_dof() || dof >= dof_map.end_dof())
476 send_list.push_back(dof);
477
478 // Now add the DoFs from all of the nodes. This is necessary because of block
479 // restricted variables. A variable might not live _on_ this element but it
480 // might live on nodes connected to this element.
481 for (unsigned int n = 0; n < elem->n_nodes(); n++)
482 {
483 Node * node = elem->node_ptr(n);
484
485 // Have to get each variable's dofs
486 for (unsigned int v = 0; v < n_vars; v++)
487 {
488 const libMesh::Variable & var = sys.variable(v);
489 unsigned int var_num = var.number();
490 unsigned int n_comp = var.n_components();
491
492 // See if this variable has any dofs at this node
493 if (node->n_dofs(sys_num, var_num) > 0)
494 {
495 // Loop over components of the variable
496 for (unsigned int c = 0; c < n_comp; c++)
497 send_list.push_back(node->dof_number(sys_num, var_num, c));
498 }
499 }
500 }
501 }
502 }
503}
504
508void
510{
512 if (num_states > 1)
513 {
514 _saved_solution_states.resize(num_states);
515 for (unsigned int i = 1; i <= num_states - 1; ++i)
518 &addVector("save_solution_state_" + std::to_string(i), false, PARALLEL);
519
520 for (unsigned int i = 1; i <= num_states - 1; ++i)
522 }
523
525 _saved_dot_old = &addVector("save_solution_dot_old", false, PARALLEL);
527 _saved_dotdot_old = &addVector("save_solution_dotdot_old", false, PARALLEL);
528
529 if (solutionUDotOld())
531
532 if (solutionUDotDotOld())
534}
535
539void
541{
543 if (num_states > 1)
544 for (unsigned int i = 1; i <= num_states - 1; ++i)
546 {
548 removeVector("save_solution_state_" + std::to_string(i));
549 _saved_solution_states[i] = nullptr;
550 }
551
553 {
555 removeVector("save_solution_dot_old");
556 _saved_dot_old = nullptr;
557 }
559 {
561 removeVector("save_solution_dotdot_old");
562 _saved_dotdot_old = nullptr;
563 }
564}
565
566SparseMatrix<Number> &
568{
570 mooseError("Cannot add tagged matrix with TagID ",
571 tag,
572 " in system '",
573 name(),
574 "' because the tag does not exist in the problem");
575
576 if (hasMatrix(tag))
577 return getMatrix(tag);
578
579 const auto matrix_name = _subproblem.matrixTagName(tag);
580 SparseMatrix<Number> & mat = system().add_matrix(matrix_name);
581 associateMatrixToTag(mat, tag);
582
583 return mat;
584}
585
586void
588{
589 if (!_subproblem.matrixTagExists(tag_id))
590 mooseError("Cannot remove the matrix with TagID ",
591 tag_id,
592 "\nin system '",
593 name(),
594 "', because that tag does not exist in the problem");
595
596 if (hasMatrix(tag_id))
597 {
598 const auto matrix_name = _subproblem.matrixTagName(tag_id);
599 system().remove_matrix(matrix_name);
600 _tagged_matrices[tag_id] = nullptr;
601 }
602}
603
604NumericVector<Number> &
605SystemBase::addVector(const std::string & vector_name,
606 const bool project,
607 const libMesh::ParallelType type)
608{
609 if (hasVector(vector_name))
610 return getVector(vector_name);
611
612 NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
613 return vec;
614}
615
616NumericVector<Number> &
617SystemBase::addVector(TagID tag, const bool project, const libMesh::ParallelType type)
618{
620 mooseError("Cannot add tagged vector with TagID ",
621 tag,
622 " in system '",
623 name(),
624 "' because the tag does not exist in the problem");
625
626 if (hasVector(tag))
627 {
628 auto & vec = getVector(tag);
629
630 if (type != AUTOMATIC && vec.type() != type)
631 mooseError("Cannot add tagged vector '",
633 "', in system '",
634 name(),
635 "' because a vector with the same name was found with a different parallel type");
636
637 return vec;
638 }
639
640 const auto vector_name = _subproblem.vectorTagName(tag);
641 NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
642 associateVectorToTag(vec, tag);
643
644 return vec;
645}
646
647void
649{
651 mooseError("Cannot close vector with TagID ",
652 tag,
653 " in system '",
654 name(),
655 "' because that tag does not exist in the problem");
656 else if (!hasVector(tag))
657 mooseError("Cannot close vector tag with name '",
659 "' in system '",
660 name(),
661 "' because there is no vector associated with that tag");
662 getVector(tag).close();
663}
664
665void
666SystemBase::closeTaggedVectors(const std::set<TagID> & tags)
667{
668 for (const auto tag : tags)
670}
671
672void
674{
676 mooseError("Cannot zero vector with TagID ",
677 tag,
678 " in system '",
679 name(),
680 "' because that tag does not exist in the problem");
681 else if (!hasVector(tag))
682 mooseError("Cannot zero vector tag with name '",
684 "' in system '",
685 name(),
686 "' because there is no vector associated with that tag");
688 getVector(tag).zero();
689}
690
691void
692SystemBase::zeroTaggedVectors(const std::set<TagID> & tags)
693{
694 for (const auto tag : tags)
695 zeroTaggedVector(tag);
696}
697
698void
700{
701 if (!_subproblem.vectorTagExists(tag_id))
702 mooseError("Cannot remove the vector with TagID ",
703 tag_id,
704 "\nin system '",
705 name(),
706 "', because that tag does not exist in the problem");
707
708 if (hasVector(tag_id))
709 {
710 auto vector_name = _subproblem.vectorTagName(tag_id);
711 system().remove_vector(vector_name);
712 _tagged_vectors[tag_id] = nullptr;
713 }
714}
715
716void
717SystemBase::addVariable(const std::string & var_type,
718 const std::string & name,
719 InputParameters & parameters)
720{
722
723 const auto components = parameters.get<unsigned int>("components");
724
725 // Convert the std::vector parameter provided by the user into a std::set for use by libMesh's
726 // System::add_variable method
727 std::set<SubdomainID> blocks;
728 const auto & block_param = parameters.get<std::vector<SubdomainName>>("block");
729 for (const auto & subdomain_name : block_param)
730 {
731 SubdomainID blk_id = _mesh.getSubdomainID(subdomain_name);
732 blocks.insert(blk_id);
733 }
734
735 const auto fe_type =
736 FEType(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")),
737 Utility::string_to_enum<FEFamily>(parameters.get<MooseEnum>("family")));
738 const auto fe_field_type = FEInterface::field_type(fe_type);
739
740 unsigned int var_num;
741
742 if (var_type == "ArrayMooseVariable")
743 {
744 if (fe_field_type == libMesh::TYPE_VECTOR)
745 mooseError("Vector family type cannot be used in an array variable");
746
747 std::vector<std::string> array_var_component_names;
748 const bool has_array_names = parameters.isParamValid("array_var_component_names");
749 if (has_array_names)
750 {
751 array_var_component_names =
752 parameters.get<std::vector<std::string>>("array_var_component_names");
753 if (array_var_component_names.size() != components)
754 parameters.paramError("array_var_component_names",
755 "Must be the same size as 'components' (size ",
756 components,
757 ") for array variable '",
758 name,
759 "'");
760 }
761
762 // Build up the variable names
763 std::vector<std::string> var_names;
764 for (unsigned int i = 0; i < components; i++)
765 {
766 if (!has_array_names)
767 array_var_component_names.push_back(std::to_string(i));
768 var_names.push_back(name + "_" + array_var_component_names[i]);
769 }
770
771 // makes sure there is always a name, either the provided one or '1 2 3 ...'
772 parameters.set<std::vector<std::string>>("array_var_component_names") =
773 array_var_component_names;
774
775 // The number returned by libMesh is the _last_ variable number... we want to hold onto the
776 // _first_
777 var_num = system().add_variable_array(var_names, fe_type, &blocks) - (components - 1);
778
779 // Set as array variable
780 if (parameters.isParamSetByUser("array") && !parameters.get<bool>("array"))
781 parameters.paramError("array",
782 "Must be set to true for variable '",
783 name,
784 "' because 'components' > 1 (is an array variable)");
785 parameters.set<bool>("array") = true;
786 }
787 else
788 {
789 if (parameters.isParamSetByUser("array_var_component_names"))
790 parameters.paramError("array_var_component_names",
791 "Should not be set because this variable (",
792 name,
793 ") is a non-array variable");
794 var_num = system().add_variable(name, fe_type, &blocks);
795 }
796
797 parameters.set<unsigned int>("_var_num") = var_num;
798 parameters.set<SystemBase *>("_system_base") = this;
799
800 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
801 {
802 parameters.set<THREAD_ID>("tid") = tid;
803 std::shared_ptr<MooseVariableBase> var =
804 _factory.create<MooseVariableBase>(var_type, name, parameters, tid);
805
806 _vars[tid].add(name, var);
807
808 if (auto fe_var = dynamic_cast<MooseVariableFieldBase *>(var.get()))
809 {
810 auto required_size = var_num + components;
811 if (required_size > _numbered_vars[tid].size())
812 _numbered_vars[tid].resize(required_size);
813 for (MooseIndex(components) component = 0; component < components; ++component)
814 _numbered_vars[tid][var_num + component] = fe_var;
815
816 if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADReal> *>(fe_var))
817 _subproblem.addFunctor(name, *functor, tid);
818 else if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADRealVectorValue> *>(fe_var))
819 _subproblem.addFunctor(name, *functor, tid);
820 else if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADRealEigenVector> *>(fe_var))
821 _subproblem.addFunctor(name, *functor, tid);
822 else
823 mooseError("This should be a functor");
824 }
825
826 if (auto scalar_var = dynamic_cast<MooseVariableScalar *>(var.get()))
827 {
828 if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADReal> *>(scalar_var))
829 _subproblem.addFunctor(name, *functor, tid);
830 else
831 mooseError("Scalar variables should be functors");
832 }
833
834 if (var->blockRestricted())
835 for (const SubdomainID & id : var->blockIDs())
836 for (MooseIndex(components) component = 0; component < components; ++component)
837 _var_map[var_num + component].insert(id);
838 else
839 for (MooseIndex(components) component = 0; component < components; ++component)
840 _var_map[var_num + component] = std::set<SubdomainID>();
841 }
842
843 // getMaxVariableNumber is an API method used in Rattlesnake
844 if (var_num > _max_var_number)
845 _max_var_number = var_num;
846 _du_dot_du.resize(var_num + 1);
847}
848
849bool
850SystemBase::hasVariable(const std::string & var_name) const
851{
852 auto & names = getVariableNames();
853 if (system().has_variable(var_name))
854 return system().variable_type(var_name).family != SCALAR;
855 if (std::find(names.begin(), names.end(), var_name) != names.end())
856 // array variable
857 return true;
858 else
859 return false;
860}
861
862bool
863SystemBase::isArrayVariable(const std::string & var_name) const
864{
865 auto & names = getVariableNames();
866 if (!system().has_variable(var_name) &&
867 std::find(names.begin(), names.end(), var_name) != names.end())
868 // array variable
869 return true;
870 else
871 return false;
872}
873
874bool
875SystemBase::hasScalarVariable(const std::string & var_name) const
876{
877 if (system().has_variable(var_name))
878 return system().variable_type(var_name).family == SCALAR;
879 else
880 return false;
881}
882
883bool
884SystemBase::isScalarVariable(unsigned int var_num) const
885{
886 return (system().variable(var_num).type().family == SCALAR);
887}
888
889unsigned int
891{
892 unsigned int n = nFieldVariables();
893 n += _vars[0].scalars().size();
894
895 return n;
896}
897
898unsigned int
900{
901 unsigned int n = 0;
902 for (auto & var : _vars[0].fieldVariables())
903 n += var->count();
904
905 return n;
906}
907
908unsigned int
910{
911 unsigned int n = 0;
912 for (auto & var : _vars[0].fieldVariables())
913 if (var->isFV())
914 n += var->count();
915
916 return n;
917}
918
922bool
923SystemBase::hasVector(const std::string & name) const
924{
925 return system().have_vector(name);
926}
927
931NumericVector<Number> &
932SystemBase::getVector(const std::string & name)
933{
934 return system().get_vector(name);
935}
936
937const NumericVector<Number> &
938SystemBase::getVector(const std::string & name) const
939{
940 return system().get_vector(name);
941}
942
943NumericVector<Number> &
945{
946 if (!hasVector(tag))
947 {
949 mooseError("Cannot retrieve vector with tag ", tag, " because that tag does not exist");
950 else
951 mooseError("Cannot retrieve vector with tag ",
952 tag,
953 " in system '",
954 name(),
955 "'\nbecause a vector has not been associated with that tag.");
956 }
957
958 return *_tagged_vectors[tag];
959}
960
961const NumericVector<Number> &
963{
964 if (!hasVector(tag))
965 {
967 mooseError("Cannot retrieve vector with tag ", tag, " because that tag does not exist");
968 else
969 mooseError("Cannot retrieve vector with tag ",
970 tag,
971 " in system '",
972 name(),
973 "'\nbecause a vector has not been associated with that tag.");
974 }
975
976 return *_tagged_vectors[tag];
977}
978
979void
980SystemBase::associateVectorToTag(NumericVector<Number> & vec, TagID tag)
981{
983 mooseError("Cannot associate vector to tag ", tag, " because that tag does not exist");
984
985 if (_tagged_vectors.size() < tag + 1)
986 _tagged_vectors.resize(tag + 1);
987
988 _tagged_vectors[tag] = &vec;
989}
990
991void
992SystemBase::disassociateVectorFromTag(NumericVector<Number> & vec, TagID tag)
993{
995 mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
996 if (hasVector(tag) && &getVector(tag) != &vec)
997 mooseError("You can not disassociate a vector from a tag which it was not associated to");
998
1000}
1001
1002void
1004{
1005 if (!_subproblem.vectorTagExists(tag))
1006 mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
1007
1008 if (_tagged_vectors.size() < tag + 1)
1009 _tagged_vectors.resize(tag + 1);
1010 _tagged_vectors[tag] = nullptr;
1011}
1012
1013void
1015{
1016 const auto tags = defaultVectorTags();
1017 for (const auto tag : tags)
1020}
1021
1022SparseMatrix<Number> &
1024{
1025 if (!hasMatrix(tag))
1026 {
1027 if (!_subproblem.matrixTagExists(tag))
1028 mooseError("Cannot retrieve matrix with tag ", tag, " because that tag does not exist");
1029 else
1030 mooseError("Cannot retrieve matrix with tag ",
1031 tag,
1032 " in system '",
1033 name(),
1034 "'\nbecause a matrix has not been associated with that tag.");
1035 }
1036
1037 return *_tagged_matrices[tag];
1038}
1039
1040const SparseMatrix<Number> &
1042{
1043 if (!hasMatrix(tag))
1044 {
1045 if (!_subproblem.matrixTagExists(tag))
1046 mooseError("Cannot retrieve matrix with tag ", tag, " because that tag does not exist");
1047 else
1048 mooseError("Cannot retrieve matrix with tag ",
1049 tag,
1050 " in system '",
1051 name(),
1052 "'\nbecause a matrix has not been associated with that tag.");
1053 }
1054
1055 return *_tagged_matrices[tag];
1056}
1057
1058void
1059SystemBase::closeTaggedMatrices(const std::set<TagID> & tags)
1060{
1061 for (auto tag : tags)
1062 if (hasMatrix(tag))
1063 getMatrix(tag).close();
1064}
1065
1066void
1067SystemBase::flushTaggedMatrices(const std::set<TagID> & tags)
1068{
1069 for (auto tag : tags)
1070 if (hasMatrix(tag))
1071 getMatrix(tag).flush();
1072}
1073
1074void
1075SystemBase::associateMatrixToTag(SparseMatrix<Number> & matrix, TagID tag)
1076{
1077 if (!_subproblem.matrixTagExists(tag))
1078 mooseError("Cannot associate matrix to tag ", tag, " because that tag does not exist");
1079
1080 if (_tagged_matrices.size() < tag + 1)
1081 _tagged_matrices.resize(tag + 1);
1082
1083 _tagged_matrices[tag] = &matrix;
1084}
1085
1086void
1087SystemBase::disassociateMatrixFromTag(SparseMatrix<Number> & matrix, TagID tag)
1088{
1089 if (!_subproblem.matrixTagExists(tag))
1090 mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1091 if (hasMatrix(tag) && &getMatrix(tag) != &matrix)
1092 mooseError("You can not disassociate a matrix from a tag which it was not associated to");
1093
1095}
1096
1097void
1099{
1100 if (!_subproblem.matrixTagExists(tag))
1101 mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1102
1103 if (_tagged_matrices.size() < tag + 1)
1104 _tagged_matrices.resize(tag + 1);
1105 _tagged_matrices[tag] = nullptr;
1106}
1107
1108void
1110{
1111 const auto tags = defaultMatrixTags();
1112 for (const auto tag : tags)
1115}
1116
1117void
1119{
1120 auto num_matrix_tags = _subproblem.numMatrixTags();
1121
1122 _matrix_tag_active_flags.resize(num_matrix_tags);
1123
1124 for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1125 _matrix_tag_active_flags[tag] = false;
1127}
1128
1129void
1131{
1132 auto num_matrix_tags = _subproblem.numMatrixTags();
1133
1134 _matrix_tag_active_flags.resize(num_matrix_tags);
1136
1137 for (const auto tag : make_range(num_matrix_tags))
1138 if (hasMatrix(tag))
1139 {
1140 _matrix_tag_active_flags[tag] = true;
1141 _active_tagged_matrices.emplace(tag, &getMatrix(tag));
1142 }
1143 else
1144 _matrix_tag_active_flags[tag] = false;
1145}
1146
1147bool
1149{
1150 mooseAssert(_subproblem.matrixTagExists(tag), "Matrix tag " << tag << " does not exist");
1151
1152 return tag < _matrix_tag_active_flags.size() && _matrix_tag_active_flags[tag];
1153}
1154
1155unsigned int
1157{
1158 return system().number();
1159}
1160
1161DofMap &
1163{
1164 return system().get_dof_map();
1165}
1166
1167const DofMap &
1169{
1170 return system().get_dof_map();
1171}
1172
1173void
1174SystemBase::addVariableToCopy(const std::string & dest_name,
1175 const std::string & source_name,
1176 const std::string & timestep)
1177{
1178 _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
1179}
1180
1181void
1182SystemBase::copyVars(ExodusII_IO & io)
1183{
1184 int n_steps = io.get_num_time_steps();
1185
1186 bool did_copy = false;
1187 for (const auto & vci : _var_to_copy)
1188 {
1189 int timestep = -1;
1190
1191 if (vci._timestep == "LATEST")
1192 // Use the last time step in the file from which to retrieve the solution
1193 timestep = n_steps;
1194 else
1195 {
1196 timestep = MooseUtils::convert<int>(vci._timestep);
1197 if (timestep > n_steps)
1198 mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
1199 "a valid integer between 1 and ",
1200 n_steps,
1201 " inclusive, received ",
1202 vci._timestep);
1203 }
1204
1205 did_copy = true;
1206
1207 if (hasVariable(vci._dest_name))
1208 {
1209 const auto & var = getVariable(0, vci._dest_name);
1210 if (var.isArray())
1211 {
1212 const auto & array_var = getFieldVariable<RealEigenVector>(0, vci._dest_name);
1213 for (MooseIndex(var.count()) i = 0; i < var.count(); ++i)
1214 {
1215 const auto & exodus_var = var.arrayVariableComponent(i);
1216 const auto & system_var = array_var.componentName(i);
1217 if (var.isNodal())
1218 io.copy_nodal_solution(system(), exodus_var, system_var, timestep);
1219 else
1220 io.copy_elemental_solution(system(), exodus_var, system_var, timestep);
1221 }
1222 }
1223 else
1224 {
1225 if (var.isNodal())
1226 io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
1227 else
1228 io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
1229 }
1230 }
1231 else if (hasScalarVariable(vci._dest_name))
1232 io.copy_scalar_solution(system(), {vci._dest_name}, {vci._source_name}, timestep);
1233 else
1234 mooseError("Unrecognized variable ", vci._dest_name, " in variables to copy.");
1235 }
1236
1237 if (did_copy)
1238 solution().close();
1239}
1240
1241void
1243{
1244 system().update();
1245}
1246
1247void
1249{
1250 system().solve();
1251}
1252
1256void
1263
1264void
1271
1272void
1274{
1275 // Normally copy through old (index 1). For Time, optionally stop at older
1276 // and leave old unchanged.
1277 const bool skip_old =
1279
1280 const auto num_states = getNumSolutionStates(iteration_type);
1281 if (num_states > 1)
1282 {
1283 const std::size_t stop = skip_old ? 1 : 0;
1284 for (std::size_t i = num_states - 1; i > stop; --i)
1285 solutionState(i, iteration_type) = solutionState(i - 1, iteration_type);
1286 }
1287
1288 // Custom logic for changing state based on iteration type
1289 switch (iteration_type)
1290 {
1293 if (solutionUDotOld())
1295 if (solutionUDotDotOld())
1297 break;
1301 break;
1305 break;
1306 }
1307}
1308
1309void
1311{
1312 const bool skip_current_to_old =
1314 copyPreviousSolutions(iteration_type);
1315 copyAdditionalStateBackwards(iteration_type, skip_current_to_old);
1316}
1317
1321void
1326
1330void
1332{
1333 if (!hasSolutionState(1))
1334 mooseError("Cannot restore solutions without old solution");
1335
1336 *(const_cast<NumericVector<Number> *&>(currentSolution())) = solutionOld();
1337 solution() = solutionOld();
1338 if (solutionUDotOld())
1340 if (solutionUDotDotOld())
1344 system().update();
1345}
1346
1347void
1353
1354void
1355SystemBase::removeVector(const std::string & name)
1356{
1358}
1359
1360const std::string &
1362{
1363 return system().name();
1364}
1365
1366NumericVector<Number> *
1374
1375const NumericVector<Number> *
1377{
1380 else
1381 return nullptr;
1382}
1383
1384void
1386{
1387 // Default is the current solution
1388 unsigned int state = 0;
1389
1390 // Add additional states as required by the variable states requested
1391 for (const auto & var : getVariables(/* tid = */ 0))
1392 state = std::max(state, var->oldestSolutionStateRequested());
1393 for (const auto & var : getScalarVariables(/* tid = */ 0))
1394 state = std::max(state, var->oldestSolutionStateRequested());
1395
1397
1399}
1400
1401TagName
1403 const Moose::SolutionIterationType iteration_type) const
1404{
1405 mooseAssert(state != 0, "Not an old state");
1406 mooseAssert(static_cast<unsigned short>(iteration_type) <
1407 static_cast<unsigned short>(Moose::SolutionIterationType::Count),
1408 "Invalid iteration_type");
1409
1410 switch (iteration_type)
1411 {
1413 if (state == 1)
1415 else if (state == 2)
1417 break;
1419 if (state == 1)
1421 break;
1423 if (state == 1)
1425 break;
1427 if (state == 1)
1429 break;
1431 break;
1432 }
1433
1434 return "solution_state_" + std::to_string(state) + "_" + Moose::stringify(iteration_type);
1435}
1436
1437const NumericVector<Number> &
1438SystemBase::solutionState(const unsigned int state,
1439 const Moose::SolutionIterationType iteration_type) const
1440{
1441 if (!hasSolutionState(state, iteration_type))
1442 {
1443 const auto num_states = getNumSolutionStates(iteration_type);
1444 mooseError("For iteration type '",
1445 Moose::stringify(iteration_type),
1446 "': solution state ",
1447 state,
1448 " was requested in ",
1449 name(),
1450 " but only up to state ",
1451 (num_states == 0) ? 0 : num_states - 1,
1452 " is available.");
1453 }
1454
1455 const auto & solution_states = getSolutionStates(iteration_type);
1456
1457 if (state == 0)
1458 mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1459 else
1460 mooseAssert(solution_states[state] ==
1461 &getVector(oldSolutionStateVectorName(state, iteration_type)),
1462 "Inconsistent solution state");
1463
1464 return *solution_states[state];
1465}
1466
1467NumericVector<Number> &
1468SystemBase::solutionState(const unsigned int state,
1469 const Moose::SolutionIterationType iteration_type)
1470{
1471 if (!hasSolutionState(state, iteration_type))
1472 needSolutionState(state, iteration_type);
1473 return *getSolutionStates(iteration_type)[state];
1474}
1475
1478 const Moose::SolutionIterationType iteration_type) const
1479{
1480 if (!hasSolutionState(state, iteration_type))
1481 mooseError("solutionStateParallelType() may only be called if the solution state exists.");
1482 return getSolutionStates(iteration_type)[state]->type();
1483}
1484
1485void
1486SystemBase::needSolutionState(const unsigned int state,
1487 const Moose::SolutionIterationType iteration_type,
1488 const libMesh::ParallelType parallel_type)
1489{
1490 libmesh_parallel_only(this->comm());
1491 mooseAssert(!Threads::in_threads,
1492 "This routine is not thread-safe. Request the solution state before using it in "
1493 "a threaded region.");
1494
1495 if (hasSolutionState(state, iteration_type))
1496 return;
1497
1498 auto & solution_states = getSolutionStates(iteration_type);
1499 solution_states.resize(state + 1);
1500
1501 // The 0-th (current) solution state is owned by libMesh
1502 if (!solution_states[0])
1503 solution_states[0] = &solutionInternal();
1504 else
1505 mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1506
1507 // We will manually add all states past current
1508 for (unsigned int i = 1; i <= state; ++i)
1509 if (!solution_states[i])
1510 {
1511 auto tag = _subproblem.addVectorTag(oldSolutionStateVectorName(i, iteration_type),
1513 solution_states[i] = &addVector(tag, true, parallel_type);
1514 }
1515 else
1516 {
1517 // If the existing parallel type is PARALLEL and GHOSTED is now requested,
1518 // this would require an upgrade, which is risky if anybody has already
1519 // stored a pointer to the existing vector, since the upgrade would create
1520 // a new vector and make that pointer null. If the existing parallel type
1521 // is GHOSTED and PARALLEL is now requested, we don't need to do anything.
1522 if (parallel_type == GHOSTED && solutionStateParallelType(i, iteration_type) == PARALLEL)
1523 mooseError("The solution state has already been declared as PARALLEL");
1524
1525 mooseAssert(solution_states[i] == &getVector(oldSolutionStateVectorName(i, iteration_type)),
1526 "Inconsistent solution state");
1527 }
1528}
1529
1530void
1531SystemBase::applyScalingFactors(const std::vector<Real> & inverse_scaling_factors)
1532{
1533 for (MooseIndex(_vars) thread = 0; thread < _vars.size(); ++thread)
1534 {
1535 auto & field_variables = _vars[thread].fieldVariables();
1536 for (MooseIndex(field_variables) i = 0, p = 0; i < field_variables.size(); ++i)
1537 {
1538 auto factors = field_variables[i]->arrayScalingFactor();
1539 for (unsigned int j = 0; j < field_variables[i]->count(); ++j, ++p)
1540 factors[j] /= inverse_scaling_factors[p];
1541
1542 field_variables[i]->scalingFactor(factors);
1543 }
1544
1545 auto offset = field_variables.size();
1546
1547 auto & scalar_variables = _vars[thread].scalars();
1548 for (MooseIndex(scalar_variables) i = 0; i < scalar_variables.size(); ++i)
1549 scalar_variables[i]->scalingFactor(
1550 {1. / inverse_scaling_factors[offset + i] * scalar_variables[i]->scalingFactor()});
1551
1552 if (thread == 0 && _verbose)
1553 {
1554 _console << "Automatic scaling factors:\n";
1555 auto original_flags = _console.flags();
1556 auto original_precision = _console.precision();
1557 _console.unsetf(std::ios_base::floatfield);
1559
1560 for (const auto & field_variable : field_variables)
1561 {
1562 const auto & factors = field_variable->arrayScalingFactor();
1563 _console << " " << field_variable->name() << ":";
1564 for (const auto i : make_range(field_variable->count()))
1565 _console << " " << factors[i];
1566 _console << "\n";
1567 }
1568 for (const auto & scalar_variable : scalar_variables)
1569 _console << " " << scalar_variable->name() << ": " << scalar_variable->scalingFactor()
1570 << "\n";
1571 _console << "\n" << std::endl;
1572
1573 // restore state
1574 _console.flags(original_flags);
1575 _console.precision(original_precision);
1576 }
1577 }
1578}
1579
1580void
1582{
1583 addVector("scaling_factors", /*project=*/false, GHOSTED);
1585}
1586
1587bool
1592
1593void
1595{
1596 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1597 _vars[tid].initialSetup();
1598}
1599
1600void
1602{
1603 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1604 _vars[tid].timestepSetup();
1605}
1606
1607void
1609{
1610 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1611 _vars[tid].customSetup(exec_type);
1612}
1613
1614void
1616{
1617 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1618 _vars[tid].subdomainSetup();
1619}
1620
1621void
1623{
1624 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1625 _vars[tid].residualSetup();
1626}
1627
1628void
1630{
1631 for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1632 _vars[tid].jacobianSetup();
1633}
1634
1635void
1637{
1638 for (auto & var_warehouse : _vars)
1639 var_warehouse.clearAllDofIndices();
1640}
1641
1642void
1644{
1645 _vars[tid].setActiveVariableCoupleableVectorTags(vtags);
1646}
1647
1648void
1650 THREAD_ID tid)
1651{
1652 _vars[tid].setActiveScalarVariableCoupleableVectorTags(vtags);
1653}
1654
1655void
1657{
1659 _u_dot = &addVector("u_dot", true, GHOSTED);
1661 _u_dot_old = &addVector("u_dot_old", true, GHOSTED);
1663 _u_dotdot = &addVector("u_dotdot", true, GHOSTED);
1665 _u_dotdot_old = &addVector("u_dotdot_old", true, GHOSTED);
1666}
1667
1668NumericVector<Number> &
1670{
1671 if (!_serialized_solution.get())
1672 {
1673 _serialized_solution = NumericVector<Number>::build(_communicator);
1674 _serialized_solution->init(system().n_dofs(), false, SERIAL);
1675 }
1676
1677 return *_serialized_solution;
1678}
1679
1680void
1681SystemBase::addTimeIntegrator(const std::string & type,
1682 const std::string & name,
1683 InputParameters & parameters)
1684{
1685 parameters.set<SystemBase *>("_sys") = this;
1686 _time_integrators.push_back(_factory.create<TimeIntegrator>(type, name, parameters));
1687}
1688
1689void
1694
1695const TimeIntegrator *
1696SystemBase::queryTimeIntegrator(const unsigned int var_num) const
1697{
1698 for (auto & ti : _time_integrators)
1699 if (ti->integratesVar(var_num))
1700 return ti.get();
1701
1702 return nullptr;
1703}
1704
1705const TimeIntegrator &
1706SystemBase::getTimeIntegrator(const unsigned int var_num) const
1707{
1708 const auto * const ti = queryTimeIntegrator(var_num);
1709
1710 if (ti)
1711 return *ti;
1712 else
1713 mooseError("No time integrator found that integrates variable number ",
1714 std::to_string(var_num));
1715}
1716
1717const std::vector<std::shared_ptr<TimeIntegrator>> &
1722
1723const Number &
1724SystemBase::duDotDu(const unsigned int var_num) const
1725{
1726 return _du_dot_du[var_num];
1727}
1728
1729const std::set<SubdomainID> &
1730SystemBase::getSubdomainsForVar(const std::string & var_name) const
1731{
1732 return getSubdomainsForVar(getVariable(0, var_name).number());
1733}
1734
1735std::string
1737{
1738 return system().prefix_with_name() ? system().prefix() : "";
1739}
1740
1741void
1743{
1744 for (const auto & warehouse : _vars)
1745 for (const auto & [var_num, var_ptr] : warehouse.numberToVariableMap())
1746 var_ptr->sizeMatrixTagData();
1747}
1748
1749template MooseVariableFE<Real> & SystemBase::getFieldVariable<Real>(THREAD_ID tid,
1750 const std::string & var_name);
1751
1753SystemBase::getFieldVariable<RealVectorValue>(THREAD_ID tid, const std::string & var_name);
1754
1756SystemBase::getFieldVariable<RealEigenVector>(THREAD_ID tid, const std::string & var_name);
1757
1758template MooseVariableFE<Real> & SystemBase::getFieldVariable<Real>(THREAD_ID tid,
1759 unsigned int var_number);
1760
1762SystemBase::getFieldVariable<RealVectorValue>(THREAD_ID tid, unsigned int var_number);
1763
1765SystemBase::getFieldVariable<RealEigenVector>(THREAD_ID tid, unsigned int var_number);
1766
1767template MooseVariableField<Real> &
1768SystemBase::getActualFieldVariable<Real>(THREAD_ID tid, const std::string & var_name);
1769
1771SystemBase::getActualFieldVariable<RealVectorValue>(THREAD_ID tid, const std::string & var_name);
1772
1774SystemBase::getActualFieldVariable<RealEigenVector>(THREAD_ID tid, const std::string & var_name);
1775
1776template MooseVariableField<Real> &
1777SystemBase::getActualFieldVariable<Real>(THREAD_ID tid, unsigned int var_number);
1778
1780SystemBase::getActualFieldVariable<RealVectorValue>(THREAD_ID tid, unsigned int var_number);
1781
1783SystemBase::getActualFieldVariable<RealEigenVector>(THREAD_ID tid, unsigned int var_number);
1784
1785template MooseVariableFV<Real> & SystemBase::getFVVariable<Real>(THREAD_ID tid,
1786 const std::string & var_name);
boundary_id_type BoundaryID
subdomain_id_type SubdomainID
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int TagID
Definition MooseTypes.h:238
unsigned int THREAD_ID
Definition MooseTypes.h:237
for(PetscInt i=0;i< nvars;++i)
char ** vars
char ** blocks
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
Free function used for a libMesh callback.
Definition SystemBase.C:38
void extraSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context)
Free function used for a libMesh callback.
Definition SystemBase.C:46
unsigned int n_vars
Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in.
const std::set< dof_id_type > & getDofIndices() const
void prepareNeighbor()
Definition Assembly.C:2810
An inteface for the _console for outputting to the Console object.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
std::ios_base::fmtflags flags() const
Return the current flags.
std::streamsize precision() const
Return the current precision.
void unsetf(std::ios_base::fmtflags mask) const
Unset format flags.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual bool uDotRequested()
Get boolean flag to check whether solution time derivative needs to be stored.
virtual bool uDotOldRequested()
Get boolean flag to check whether old solution time derivative needs to be stored.
virtual bool uDotDotRequested()
Get boolean flag to check whether solution second time derivative needs to be stored.
virtual bool uDotDotOldRequested()
Get boolean flag to check whether old solution second time derivative needs to be stored.
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters &parameters, THREAD_ID tid=0, bool print_deprecated=true)
Definition Factory.C:142
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
void paramError(const std::string &param, Args... args) const
Emits a parameter error prefixed with the parameter location and object information if available.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another,...
Class for containing MooseEnum item information.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
virtual Elem * elemPtr(const dof_id_type i)
Definition MooseMesh.C:3222
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
Definition MooseMesh.C:1723
const libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems,...
Definition MooseMesh.C:1245
Base variable class.
Class for stuff related to variables.
This class provides variable solution values for other classes/objects to bind to when looping over f...
This class provides an interface for common operations on field variables of both FE and FV types wit...
Class for stuff related to variables.
Class for scalar variables (they are different).
Base class template for functor objects.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition SubProblem.C:220
virtual bool computingScalingJacobian() const =0
Getter for whether we're computing the scaling jacobian.
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition SubProblem.C:453
void hasScalingVector(const unsigned int nl_sys_num)
Tells this problem that the assembly associated with the given nonlinear system number involves a sca...
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition SubProblem.h:680
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition SubProblem.h:248
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition SubProblem.C:356
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
virtual bool hasActiveElementalMooseVariables(const THREAD_ID tid) const
Whether or not a list of active elemental moose variables has been set.
Definition SubProblem.C:459
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition SubProblem.C:91
virtual bool checkNonlocalCouplingRequirement() const =0
bool vectorTagNotZeroed(const TagID tag) const
Checks if a vector tag is in the list of vectors that will not be zeroed when other tagged vectors ar...
Definition SubProblem.C:154
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition SubProblem.C:327
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition SubProblem.h:201
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
add a functor to the problem functor container
Base class for a system (of equations)
Definition SystemBase.h:87
std::unique_ptr< NumericVector< Number > > _serialized_solution
Serialized version of the solution vector, or nullptr if a serialized solution is not needed.
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition SystemBase.C:692
virtual void addVariableToZeroOnJacobian(std::string var_name)
Adds this variable to the list of variables to be zeroed during each Jacobian evaluation.
Definition SystemBase.C:179
void zeroTaggedVector(const TagID tag)
Zero vector with the given tag.
Definition SystemBase.C:673
virtual void zeroVariables(std::vector< std::string > &vars_to_be_zeroed)
Zero out the solution for the list of variables passed in.
Definition SystemBase.C:199
NumericVector< Number > * _u_dot
solution vector for u^dot
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:323
virtual const NumericVector< Number > *const & currentSolution() const =0
The solution vector that is currently being operated on.
virtual void reinitNode(const Node *node, THREAD_ID tid)
Reinit nodal assembly info.
Definition SystemBase.C:397
virtual void addVariableToZeroOnResidual(std::string var_name)
Adds this variable to the list of variables to be zeroed during each residual evaluation.
Definition SystemBase.C:173
virtual void copySolutionsBackwards()
Copy current solution into old and older.
virtual void zeroVariablesForJacobian()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
Definition SystemBase.C:234
virtual void augmentSparsity(libMesh::SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz)=0
Will modify the sparsity pattern to add logical geometric connections.
bool _solution_states_initialized
Whether or not the solution states have been initialized.
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition SystemBase.h:347
virtual void deactivateAllMatrixTags()
Make matrices inactive.
virtual NumericVector< Number > & solutionInternal() const =0
Internal getter for solution owned by libMesh.
virtual void reinitElem(const Elem *elem, THREAD_ID tid)
Reinit an element assembly info.
Definition SystemBase.C:339
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
Definition SystemBase.C:421
bool _verbose
True if printing out additional information.
void copyOldSolutions()
Copy the solution back in time (older -> old, etc).
FEProblemBase & _fe_problem
the governing finite element/volume problem
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition SystemBase.C:381
TagName oldSolutionStateVectorName(const unsigned int, Moose::SolutionIterationType iteration_type) const
Gets the vector name used for an old (not current) solution state.
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition SystemBase.h:791
virtual void subdomainSetup()
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition SystemBase.C:373
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
void addTimeIntegrator(const std::string &type, const std::string &name, InputParameters &parameters)
std::string prefix() const
std::vector< std::string > _vars_to_be_zeroed_on_residual
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition SystemBase.C:923
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition SystemBase.C:890
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
Gets a reference to a variable of with specified name.
Definition SystemBase.C:110
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition SystemBase.C:89
virtual NumericVector< Number > * solutionUDot()
Definition SystemBase.h:289
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
Definition SystemBase.C:863
virtual void augmentSendList(std::vector< dof_id_type > &send_list)
Will modify the send_list to add all of the extra ghosted dofs for this system.
Definition SystemBase.C:451
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
Definition SystemBase.C:443
unsigned int number() const
Gets the number of this system.
virtual void saveOldSolutions()
Save the old and older solutions.
Definition SystemBase.C:509
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
Definition SystemBase.C:540
virtual bool isScalarVariable(unsigned int var_name) const
Definition SystemBase.C:884
Factory & _factory
std::vector< libMesh::SparseMatrix< Number > * > _tagged_matrices
Tagged matrices (pointer)
void restoreStateHistory()
Restore solution vectors and additional system-owned state together.
virtual void activateAllMatrixTags()
Make all existing matrices active.
unsigned int nFieldVariables() const
Get the number of field variables in this system.
Definition SystemBase.C:899
void advanceStateHistory(Moose::SolutionIterationType iteration_type)
Advance solution vectors and additional system-owned state together.
virtual void addVariableToCopy(const std::string &dest_name, const std::string &source_name, const std::string &timestep)
Add info about variable that will be copied.
const std::vector< VariableName > & getVariableNames() const
Definition SystemBase.h:890
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
virtual void zeroVariablesForResidual()
Zero out the solution for the variables that were registered as needing to have their solutions zeroe...
Definition SystemBase.C:228
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &parameters)
Canonical method for adding a variable.
Definition SystemBase.C:717
MooseVariableFV< T > & getFVVariable(THREAD_ID tid, const std::string &var_name)
Return a finite volume variable.
Definition SystemBase.C:124
std::unordered_map< TagID, libMesh::SparseMatrix< Number > * > _active_tagged_matrices
Active tagged matrices. A matrix is active if its tag-matrix pair is present in the map....
virtual void addDotVectors()
Add u_dot, u_dotdot, u_dot_old and u_dotdot_old vectors if requested by the time integrator.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
Definition SystemBase.C:932
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time, libMesh::ParallelType parallel_type=GHOSTED)
Registers that the solution state state is needed.
const std::vector< MooseVariableFieldBase * > & getVariables(THREAD_ID tid)
Definition SystemBase.h:779
virtual bool matrixTagActive(TagID tag) const
If or not a matrix tag is active.
virtual void customSetup(const ExecFlagType &exec_type)
NumericVector< Number > & solutionOld()
Definition SystemBase.h:213
const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
unsigned int nFVVariables() const
Get the number of finite volume variables in this system.
Definition SystemBase.C:909
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
NumericVector< Real > * _saved_dotdot_old
void copyStateHistoryBackwards()
Copy solution vectors and additional system-owned state into older states.
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
Definition SystemBase.C:185
virtual void initialSetup()
Setup Functions.
virtual void initSolutionState()
Initializes the solution state.
virtual void timestepSetup()
virtual void associateVectorToTag(NumericVector< Number > &vec, TagID tag)
Associate a vector for a given tag.
Definition SystemBase.C:980
virtual void jacobianSetup()
virtual void residualSetup()
MooseVariableField< T > & getActualFieldVariable(THREAD_ID tid, const std::string &var_name)
Returns a field variable pointer - this includes finite volume variables.
Definition SystemBase.C:117
bool computingScalingJacobian() const
Whether we are computing an initial Jacobian for automatic variable scaling.
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of neighbor nodes.
Definition SystemBase.C:432
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
virtual void disassociateDefaultVectorTags()
Disassociate the vectors associated with the default vector tags of this system.
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
libMesh::ParallelType solutionStateParallelType(const unsigned int state, const Moose::SolutionIterationType iteration_type) const
Returns the parallel type of the given solution state.
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
Definition SystemBase.C:389
virtual NumericVector< Number > * solutionUDotOld()
Definition SystemBase.h:291
virtual void disassociateVectorFromTag(NumericVector< Number > &vec, TagID tag)
Disassociate a given vector from a given tag.
Definition SystemBase.C:992
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition SystemBase.C:255
SystemBase(SubProblem &subproblem, FEProblemBase &fe_problem, const std::string &name, Moose::VarKindType var_kind)
Definition SystemBase.C:55
void closeTaggedVectors(const std::set< TagID > &tags)
Close all vectors for given tags.
Definition SystemBase.C:666
std::size_t getNumSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get the number of solution states (0 = current, 1 = current + old, ...) for the given iteration type.
virtual const std::set< SubdomainID > * getVariableBlocks(unsigned int var_number)
Get the block where a variable of this system is defined.
Definition SystemBase.C:163
virtual MooseVariableScalar & getScalarVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a scalar variable with specified number.
Definition SystemBase.C:144
virtual bool hasScalarVariable(const std::string &var_name) const
Definition SystemBase.C:875
virtual void reinitElemFace(const Elem *elem, unsigned int side, THREAD_ID tid)
Reinit assembly info for a side of an element.
Definition SystemBase.C:365
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition SystemBase.C:409
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
void copyPreviousSolutions(const Moose::SolutionIterationType iteration_type)
Copy a specific type of solution back in time (current -> old -> older, etc).
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition SystemBase.C:850
void closeTaggedMatrices(const std::set< TagID > &tags)
Close all matrices associated the tags.
virtual const NumericVector< Number > * solutionPreviousNewton() const
const std::vector< std::shared_ptr< TimeIntegrator > > & getTimeIntegrators()
const std::vector< NumericVector< Number > * > & getSolutionStates(const Moose::SolutionIterationType iteration_type) const
Get all of the solution states (current, old, ...) for the given iteration type.
virtual const Number & duDotDu(unsigned int var_num=0) const
void flushTaggedMatrices(const std::set< TagID > &tags)
flushes all matrices associated to tags.
SubProblem & _subproblem
The subproblem for whom this class holds variable data, etc; this can either be the governing finite ...
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system's variables.
NumericVector< Real > * _saved_dot_old
virtual void restoreAdditionalStates()
Restore system-owned state not represented by solution vectors.
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
libMesh::SparseMatrix< Number > & addMatrix(TagID tag)
Adds a matrix with a given tag.
Definition SystemBase.C:567
void clearAllDofIndices()
Clear all dof indices from moose variables.
NumericVector< Number > * _u_dotdot_old
old solution vector for u^dotdot
virtual const std::string & name() const
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition SystemBase.h:388
void addScalingVector()
Add the scaling factor vector to the system.
void copyTimeIntegrators(const SystemBase &other_sys)
Copy time integrators from another system.
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
unsigned int _max_var_number
Maximum variable number.
virtual void disassociateDefaultMatrixTags()
Disassociate the matrices associated with the default matrix tags of this system.
void copyVars(libMesh::ExodusII_IO &io)
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
Definition SystemBase.C:587
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
bool _skip_next_solution_to_old_copy
Whether to skip the next copy from the solution to the old vector.
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
std::map< unsigned int, std::set< SubdomainID > > _var_map
Map of variables (variable id -> array of subdomains where it lives)
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older,...
std::vector< VarCopyInfo > _var_to_copy
NumericVector< Number > & solution()
Definition SystemBase.h:212
NumericVector< Number > * _u_dot_old
old solution vector for u^dot
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
virtual NumericVector< Number > * solutionUDotDotOld()
Definition SystemBase.h:292
void sizeVariableMatrixData()
size the matrix data for each variable for the number of matrix tags we have
virtual void copyAdditionalStateBackwards(Moose::SolutionIterationType, bool)
Copy system-owned state not represented by solution vectors.
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition SystemBase.h:786
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable's equation.
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
Definition SystemBase.C:605
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
Definition SystemBase.C:240
void update()
Update the system (doing libMesh magic)
virtual void prepareFace(THREAD_ID tid, bool resize_data)
Prepare the system for use on sides.
Definition SystemBase.C:278
virtual std::set< TagID > defaultVectorTags() const
Get the default vector tags associated with this system.
Definition SystemBase.h:340
void closeTaggedVector(const TagID tag)
Close vector with the given tag.
Definition SystemBase.C:648
virtual void solve()
Solve the system (using libMesh magic)
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
virtual NumericVector< Number > * solutionUDotDot()
Definition SystemBase.h:290
MooseMesh & _mesh
virtual NumericVector< Number > & serializedSolution()
Returns a reference to a serialized version of the solution vector for this subproblem.
std::vector< std::vector< MooseVariableFieldBase * > > _numbered_vars
Map variable number to its pointer.
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Definition SystemBase.C:331
Base class for time integrators.
virtual void set(const numeric_index_type i, const T value)=0
virtual void close()=0
virtual void zero()=0
const Parallel::Communicator & _communicator
const Parallel::Communicator & comm() const
virtual void close()=0
virtual void flush()
SparseMatrix< Number > & add_matrix(std::string_view mat_name, ParallelType type=PARALLEL, MatrixBuildType mat_build_type=MatrixBuildType::AUTOMATIC)
const std::string & name() const
void remove_matrix(std::string_view mat_name)
void remove_vector(std::string_view vec_name)
const FEType & variable_type(const unsigned int i) const
void prefix_with_name(bool value)
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
unsigned int add_variable_array(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
virtual void solve()
virtual void update()
bool has_static_condensation() const
std::string prefix() const
const DofMap & get_dof_map() const
unsigned int number() const
const NumericVector< Number > & get_vector(std::string_view vec_name) const
bool have_vector(std::string_view vec_name) const
unsigned int n_components() const
unsigned int number() const
MeshBase & mesh
const TagName PREVIOUS_MULTISYSTEM_FP_SOLUTION_TAG
Definition MooseTypes.C:30
const TagName OLDER_SOLUTION_TAG
Definition MooseTypes.C:27
@ VECTOR_TAG_SOLUTION
const TagName PREVIOUS_NL_SOLUTION_TAG
Definition MooseTypes.C:28
const TagName PREVIOUS_MULTIAPP_FP_SOLUTION_TAG
Definition MooseTypes.C:29
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:64
const TagName OLD_SOLUTION_TAG
Definition MooseTypes.C:26
SolutionIterationType
Definition MooseTypes.h:270
VarKindType
Framework-wide stuff.
Definition MooseTypes.h:769
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
unsigned int n_threads()
Information about variables that will be copied.
Definition SystemBase.h:68