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