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 
31 #include "libmesh/dof_map.h"
32 #include "libmesh/string_to_enum.h"
33 #include "libmesh/fe_interface.h"
34 
35 using namespace libMesh;
36 
38 void
39 extraSendList(std::vector<dof_id_type> & send_list, void * context)
40 {
41  SystemBase * sys = static_cast<SystemBase *>(context);
42  sys->augmentSendList(send_list);
43 }
44 
46 void
48  std::vector<dof_id_type> & n_nz,
49  std::vector<dof_id_type> & n_oz,
50  void * context)
51 {
52  SystemBase * sys = static_cast<SystemBase *>(context);
53  sys->augmentSparsity(sparsity, n_nz, n_oz);
54 }
55 
57  FEProblemBase & fe_problem,
58  const std::string & name,
59  Moose::VarKindType var_kind)
60  : libMesh::ParallelObject(subproblem),
61  ConsoleStreamInterface(subproblem.getMooseApp()),
62  _subproblem(subproblem),
63  _fe_problem(fe_problem),
64  _app(subproblem.getMooseApp()),
65  _factory(_app.getFactory()),
66  _mesh(subproblem.mesh()),
67  _name(name),
68  _vars(libMesh::n_threads()),
69  _var_map(),
70  _max_var_number(0),
71  _u_dot(nullptr),
72  _u_dotdot(nullptr),
73  _u_dot_old(nullptr),
74  _u_dotdot_old(nullptr),
75  _saved_old(nullptr),
76  _saved_older(nullptr),
77  _saved_dot_old(nullptr),
78  _saved_dotdot_old(nullptr),
79  _var_kind(var_kind),
80  _max_var_n_dofs_per_elem(0),
81  _max_var_n_dofs_per_node(0),
82  _automatic_scaling(false),
83  _verbose(false),
84  _solution_states_initialized(false)
85 {
86 }
87 
89 SystemBase::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 
99 SystemBase::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 
108 template <typename T>
110 SystemBase::getFieldVariable(THREAD_ID tid, const std::string & var_name)
111 {
112  return *_vars[tid].getFieldVariable<T>(var_name);
113 }
114 
115 template <typename T>
117 SystemBase::getActualFieldVariable(THREAD_ID tid, const std::string & var_name)
118 {
119  return *_vars[tid].getActualFieldVariable<T>(var_name);
120 }
121 
122 template <typename T>
124 SystemBase::getFVVariable(THREAD_ID tid, const std::string & var_name)
125 {
126  return *_vars[tid].getFVVariable<T>(var_name);
127 }
128 
129 template <typename T>
131 SystemBase::getFieldVariable(THREAD_ID tid, unsigned int var_number)
132 {
133  return *_vars[tid].getFieldVariable<T>(var_number);
134 }
135 
136 template <typename T>
138 SystemBase::getActualFieldVariable(THREAD_ID tid, unsigned int var_number)
139 {
140  return *_vars[tid].getActualFieldVariable<T>(var_number);
141 }
142 
144 SystemBase::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 
153 SystemBase::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 
162 const std::set<SubdomainID> *
163 SystemBase::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 
172 void
174 {
175  _vars_to_be_zeroed_on_residual.push_back(var_name);
176 }
177 
178 void
180 {
181  _vars_to_be_zeroed_on_jacobian.push_back(var_name);
182 }
183 
184 void
185 SystemBase::setVariableGlobalDoFs(const std::string & var_name)
186 {
187  AllLocalDofIndicesThread aldit(_subproblem, {var_name});
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 
198 void
199 SystemBase::zeroVariables(std::vector<std::string> & vars_to_be_zeroed)
200 {
201  if (vars_to_be_zeroed.size() > 0)
202  {
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);
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 
227 void
229 {
231 }
232 
233 void
235 {
237 }
238 
239 Order
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 
254 void
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 
277 void
278 SystemBase::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);
318  }
319  }
320 }
321 
322 void
324 {
325  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
326  for (const auto & var : vars)
327  var->prepareNeighbor();
328 }
329 
330 void
332 {
333  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
334  for (const auto & var : vars)
335  var->prepareLowerD();
336 }
337 
338 void
339 SystemBase::reinitElem(const Elem * /*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 }
356 
357 void
358 SystemBase::reinitElemFace(const Elem * /*elem*/, unsigned int /*side*/, THREAD_ID tid)
359 {
360  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
361  for (const auto & var : vars)
362  var->computeElemValuesFace();
363 }
364 
365 void
366 SystemBase::reinitNeighborFace(const Elem * /*elem*/, unsigned int /*side*/, THREAD_ID tid)
367 {
368  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
369  for (const auto & var : vars)
370  var->computeNeighborValuesFace();
371 }
372 
373 void
375 {
376  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
377  for (const auto & var : vars)
378  var->computeNeighborValues();
379 }
380 
381 void
383 {
384  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
385  for (const auto & var : vars)
386  var->computeLowerDValues();
387 }
388 
389 void
390 SystemBase::reinitNode(const Node * /*node*/, THREAD_ID tid)
391 {
392  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
393  for (const auto & var : vars)
394  {
395  var->reinitNode();
396  if (var->isNodalDefined())
397  var->computeNodalValues();
398  }
399 }
400 
401 void
402 SystemBase::reinitNodeFace(const Node * /*node*/, BoundaryID /*bnd_id*/, THREAD_ID tid)
403 {
404  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
405  for (const auto & var : vars)
406  {
407  var->reinitNode();
408  if (var->isNodalDefined())
409  var->computeNodalValues();
410  }
411 }
412 
413 void
414 SystemBase::reinitNodes(const std::vector<dof_id_type> & nodes, THREAD_ID tid)
415 {
416  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
417  for (const auto & var : vars)
418  {
419  var->reinitNodes(nodes);
420  var->computeNodalValues();
421  }
422 }
423 
424 void
425 SystemBase::reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, THREAD_ID tid)
426 {
427  const std::vector<MooseVariableFieldBase *> & vars = _vars[tid].fieldVariables();
428  for (const auto & var : vars)
429  {
430  var->reinitNodesNeighbor(nodes);
431  var->computeNodalNeighborValues();
432  }
433 }
434 
435 void
436 SystemBase::reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering /*=false*/)
437 {
438  const std::vector<MooseVariableScalar *> & vars = _vars[tid].scalars();
439  for (const auto & var : vars)
440  var->reinit(reinit_for_derivative_reordering);
441 }
442 
443 void
444 SystemBase::augmentSendList(std::vector<dof_id_type> & send_list)
445 {
446  std::set<dof_id_type> & ghosted_elems = _subproblem.ghostedElems();
447 
448  DofMap & dof_map = dofMap();
449 
450  std::vector<dof_id_type> dof_indices;
451 
452  System & sys = system();
453 
454  unsigned int sys_num = sys.number();
455 
456  unsigned int n_vars = sys.n_vars();
457 
458  for (const auto & elem_id : ghosted_elems)
459  {
460  Elem * elem = _mesh.elemPtr(elem_id);
461 
462  if (elem->active())
463  {
464  dof_map.dof_indices(elem, dof_indices);
465 
466  // Only need to ghost it if it's actually not on this processor
467  for (const auto & dof : dof_indices)
468  if (dof < dof_map.first_dof() || dof >= dof_map.end_dof())
469  send_list.push_back(dof);
470 
471  // Now add the DoFs from all of the nodes. This is necessary because of block
472  // restricted variables. A variable might not live _on_ this element but it
473  // might live on nodes connected to this element.
474  for (unsigned int n = 0; n < elem->n_nodes(); n++)
475  {
476  Node * node = elem->node_ptr(n);
477 
478  // Have to get each variable's dofs
479  for (unsigned int v = 0; v < n_vars; v++)
480  {
481  const Variable & var = sys.variable(v);
482  unsigned int var_num = var.number();
483  unsigned int n_comp = var.n_components();
484 
485  // See if this variable has any dofs at this node
486  if (node->n_dofs(sys_num, var_num) > 0)
487  {
488  // Loop over components of the variable
489  for (unsigned int c = 0; c < n_comp; c++)
490  send_list.push_back(node->dof_number(sys_num, var_num, c));
491  }
492  }
493  }
494  }
495  }
496 }
497 
501 void
503 {
504  const auto states =
505  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
506  if (states > 1)
507  {
508  _saved_solution_states.resize(states);
509  for (unsigned int i = 1; i <= states - 1; ++i)
510  if (!_saved_solution_states[i])
512  &addVector("save_solution_state_" + std::to_string(i), false, PARALLEL);
513 
514  for (unsigned int i = 1; i <= states - 1; ++i)
516  }
517 
519  _saved_dot_old = &addVector("save_solution_dot_old", false, PARALLEL);
521  _saved_dotdot_old = &addVector("save_solution_dotdot_old", false, PARALLEL);
522 
523  if (solutionUDotOld())
525 
526  if (solutionUDotDotOld())
528 }
529 
533 void
535 {
536  const auto states =
537  _solution_states[static_cast<unsigned short>(Moose::SolutionIterationType::Time)].size();
538  if (states > 1)
539  for (unsigned int i = 1; i <= states - 1; ++i)
540  if (_saved_solution_states[i])
541  {
543  removeVector("save_solution_state_" + std::to_string(i));
544  _saved_solution_states[i] = nullptr;
545  }
546 
548  {
550  removeVector("save_solution_dot_old");
551  _saved_dot_old = nullptr;
552  }
554  {
556  removeVector("save_solution_dotdot_old");
557  _saved_dotdot_old = nullptr;
558  }
559 }
560 
563 {
564  if (!_subproblem.matrixTagExists(tag))
565  mooseError("Cannot add tagged matrix with TagID ",
566  tag,
567  " in system '",
568  name(),
569  "' because the tag does not exist in the problem");
570 
571  if (hasMatrix(tag))
572  return getMatrix(tag);
573 
574  const auto matrix_name = _subproblem.matrixTagName(tag);
575  SparseMatrix<Number> & mat = system().add_matrix(matrix_name);
576  associateMatrixToTag(mat, tag);
577 
578  return mat;
579 }
580 
581 void
583 {
584  if (!_subproblem.matrixTagExists(tag_id))
585  mooseError("Cannot remove the matrix with TagID ",
586  tag_id,
587  "\nin system '",
588  name(),
589  "', because that tag does not exist in the problem");
590 
591  if (hasMatrix(tag_id))
592  {
593  const auto matrix_name = _subproblem.matrixTagName(tag_id);
594  system().remove_matrix(matrix_name);
595  _tagged_matrices[tag_id] = nullptr;
596  }
597 }
598 
600 SystemBase::addVector(const std::string & vector_name, const bool project, const ParallelType type)
601 {
602  if (hasVector(vector_name))
603  return getVector(vector_name);
604 
605  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
606  return vec;
607 }
608 
610 SystemBase::addVector(TagID tag, const bool project, const ParallelType type)
611 {
612  if (!_subproblem.vectorTagExists(tag))
613  mooseError("Cannot add tagged vector with TagID ",
614  tag,
615  " in system '",
616  name(),
617  "' because the tag does not exist in the problem");
618 
619  if (hasVector(tag))
620  {
621  auto & vec = getVector(tag);
622 
623  if (type != ParallelType::AUTOMATIC && vec.type() != type)
624  mooseError("Cannot add tagged vector '",
626  "', in system '",
627  name(),
628  "' because a vector with the same name was found with a different parallel type");
629 
630  return vec;
631  }
632 
633  const auto vector_name = _subproblem.vectorTagName(tag);
634  NumericVector<Number> & vec = system().add_vector(vector_name, project, type);
635  associateVectorToTag(vec, tag);
636 
637  return vec;
638 }
639 
640 void
642 {
643  if (!_subproblem.vectorTagExists(tag))
644  mooseError("Cannot close vector with TagID ",
645  tag,
646  " in system '",
647  name(),
648  "' because that tag does not exist in the problem");
649  else if (!hasVector(tag))
650  mooseError("Cannot close vector tag with name '",
652  "' in system '",
653  name(),
654  "' because there is no vector associated with that tag");
655  getVector(tag).close();
656 }
657 
658 void
659 SystemBase::closeTaggedVectors(const std::set<TagID> & tags)
660 {
661  for (const auto tag : tags)
662  closeTaggedVector(tag);
663 }
664 
665 void
667 {
668  if (!_subproblem.vectorTagExists(tag))
669  mooseError("Cannot zero vector with TagID ",
670  tag,
671  " in system '",
672  name(),
673  "' because that tag does not exist in the problem");
674  else if (!hasVector(tag))
675  mooseError("Cannot zero vector tag with name '",
677  "' in system '",
678  name(),
679  "' because there is no vector associated with that tag");
681  getVector(tag).zero();
682 }
683 
684 void
685 SystemBase::zeroTaggedVectors(const std::set<TagID> & tags)
686 {
687  for (const auto tag : tags)
688  zeroTaggedVector(tag);
689 }
690 
691 void
693 {
694  if (!_subproblem.vectorTagExists(tag_id))
695  mooseError("Cannot remove the vector with TagID ",
696  tag_id,
697  "\nin system '",
698  name(),
699  "', because that tag does not exist in the problem");
700 
701  if (hasVector(tag_id))
702  {
703  auto vector_name = _subproblem.vectorTagName(tag_id);
704  system().remove_vector(vector_name);
705  _tagged_vectors[tag_id] = nullptr;
706  }
707 }
708 
709 void
710 SystemBase::addVariable(const std::string & var_type,
711  const std::string & name,
712  InputParameters & parameters)
713 {
715 
716  auto components = parameters.get<unsigned int>("components");
717 
718  // Convert the std::vector parameter provided by the user into a std::set for use by libMesh's
719  // System::add_variable method
720  std::set<SubdomainID> blocks;
721  const auto & block_param = parameters.get<std::vector<SubdomainName>>("block");
722  for (const auto & subdomain_name : block_param)
723  {
724  SubdomainID blk_id = _mesh.getSubdomainID(subdomain_name);
725  blocks.insert(blk_id);
726  }
727 
728  const auto fe_type =
729  FEType(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")),
730  Utility::string_to_enum<FEFamily>(parameters.get<MooseEnum>("family")));
731  const auto fe_field_type = FEInterface::field_type(fe_type);
732 
733  unsigned int var_num;
734 
735  if (var_type == "ArrayMooseVariable")
736  {
737  if (fe_field_type == TYPE_VECTOR)
738  mooseError("Vector family type cannot be used in an array variable");
739 
740  std::vector<std::string> array_var_component_names;
741  const bool has_array_names = parameters.isParamValid("array_var_component_names");
742  if (has_array_names)
743  {
744  array_var_component_names =
745  parameters.get<std::vector<std::string>>("array_var_component_names");
746  if (array_var_component_names.size() != components)
747  mooseError("For variable ",
748  name,
749  ", parameter 'array_var_component_names' has ",
750  array_var_component_names.size(),
751  " name(s), but there are ",
752  components,
753  " array variable component(s).");
754  }
755 
756  // Build up the variable names
757  std::vector<std::string> var_names;
758  for (unsigned int i = 0; i < components; i++)
759  {
760  if (!has_array_names)
761  array_var_component_names.push_back(std::to_string(i));
762  var_names.push_back(name + "_" + array_var_component_names[i]);
763  }
764 
765  // makes sure there is always a name, either the provided one or '1 2 3 ...'
766  parameters.set<std::vector<std::string>>("array_var_component_names") =
767  array_var_component_names;
768 
769  // The number returned by libMesh is the _last_ variable number... we want to hold onto the
770  // _first_
771  var_num = system().add_variables(var_names, fe_type, &blocks) - (components - 1);
772 
773  // Set as array variable
774  if (parameters.isParamSetByUser("array") && !parameters.get<bool>("array"))
775  mooseError("Variable '",
776  name,
777  "' is an array variable ('components' > 1) but 'array' is set to false.");
778  parameters.set<bool>("array") = true;
779  }
780  else
781  {
782  if (parameters.isParamSetByUser("array_var_component_names"))
783  mooseError("Variable '",
784  name,
785  "' is a regular variable. 'array_var_component_names' should not be set.");
786  var_num = system().add_variable(name, fe_type, &blocks);
787  }
788 
789  parameters.set<unsigned int>("_var_num") = var_num;
790  parameters.set<SystemBase *>("_system_base") = this;
791 
792  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
793  {
794  parameters.set<THREAD_ID>("tid") = tid;
795  std::shared_ptr<MooseVariableBase> var =
796  _factory.create<MooseVariableBase>(var_type, name, parameters, tid);
797 
798  _vars[tid].add(name, var);
799 
800  if (auto fe_var = dynamic_cast<MooseVariableFieldBase *>(var.get()))
801  {
802  auto required_size = var_num + components;
803  if (required_size > _numbered_vars[tid].size())
804  _numbered_vars[tid].resize(required_size);
805  for (MooseIndex(components) component = 0; component < components; ++component)
806  _numbered_vars[tid][var_num + component] = fe_var;
807 
808  if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADReal> *>(fe_var))
809  _subproblem.addFunctor(name, *functor, tid);
810  else if (auto * const functor = dynamic_cast<Moose::FunctorBase<ADRealVectorValue> *>(fe_var))
811  _subproblem.addFunctor(name, *functor, tid);
812  else if (auto * const functor = dynamic_cast<Moose::FunctorBase<RealEigenVector> *>(fe_var))
813  _subproblem.addFunctor(name, *functor, tid);
814  else
815  mooseError("This should be a functor");
816  }
817 
818  if (var->blockRestricted())
819  for (const SubdomainID & id : var->blockIDs())
820  for (MooseIndex(components) component = 0; component < components; ++component)
821  _var_map[var_num + component].insert(id);
822  else
823  for (MooseIndex(components) component = 0; component < components; ++component)
824  _var_map[var_num + component] = std::set<SubdomainID>();
825  }
826 
827  // getMaxVariableNumber is an API method used in Rattlesnake
828  if (var_num > _max_var_number)
829  _max_var_number = var_num;
830  _du_dot_du.resize(var_num + 1);
831 }
832 
833 bool
834 SystemBase::hasVariable(const std::string & var_name) const
835 {
836  auto & names = getVariableNames();
837  if (system().has_variable(var_name))
838  return system().variable_type(var_name).family != SCALAR;
839  if (std::find(names.begin(), names.end(), var_name) != names.end())
840  // array variable
841  return true;
842  else
843  return false;
844 }
845 
846 bool
847 SystemBase::isArrayVariable(const std::string & var_name) const
848 {
849  auto & names = getVariableNames();
850  if (!system().has_variable(var_name) &&
851  std::find(names.begin(), names.end(), var_name) != names.end())
852  // array variable
853  return true;
854  else
855  return false;
856 }
857 
858 bool
859 SystemBase::hasScalarVariable(const std::string & var_name) const
860 {
861  if (system().has_variable(var_name))
862  return system().variable_type(var_name).family == SCALAR;
863  else
864  return false;
865 }
866 
867 bool
868 SystemBase::isScalarVariable(unsigned int var_num) const
869 {
870  return (system().variable(var_num).type().family == SCALAR);
871 }
872 
873 unsigned int
875 {
876  unsigned int n = nFieldVariables();
877  n += _vars[0].scalars().size();
878 
879  return n;
880 }
881 
882 unsigned int
884 {
885  unsigned int n = 0;
886  for (auto & var : _vars[0].fieldVariables())
887  n += var->count();
888 
889  return n;
890 }
891 
892 unsigned int
894 {
895  unsigned int n = 0;
896  for (auto & var : _vars[0].fieldVariables())
897  if (var->isFV())
898  n += var->count();
899 
900  return n;
901 }
902 
906 bool
907 SystemBase::hasVector(const std::string & name) const
908 {
909  return system().have_vector(name);
910 }
911 
916 SystemBase::getVector(const std::string & name)
917 {
918  return system().get_vector(name);
919 }
920 
921 const NumericVector<Number> &
922 SystemBase::getVector(const std::string & name) const
923 {
924  return system().get_vector(name);
925 }
926 
929 {
930  if (!hasVector(tag))
931  {
932  if (!_subproblem.vectorTagExists(tag))
933  mooseError("Cannot retreive vector with tag ", tag, " because that tag does not exist");
934  else
935  mooseError("Cannot retreive vector with tag ",
936  tag,
937  " in system '",
938  name(),
939  "'\nbecause a vector has not been associated with that tag.");
940  }
941 
942  return *_tagged_vectors[tag];
943 }
944 
945 const NumericVector<Number> &
947 {
948  if (!hasVector(tag))
949  {
950  if (!_subproblem.vectorTagExists(tag))
951  mooseError("Cannot retreive vector with tag ", tag, " because that tag does not exist");
952  else
953  mooseError("Cannot retreive 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 void
965 {
966  if (!_subproblem.vectorTagExists(tag))
967  mooseError("Cannot associate vector to tag ", tag, " because that tag does not exist");
968 
969  if (_tagged_vectors.size() < tag + 1)
970  _tagged_vectors.resize(tag + 1);
971 
972  _tagged_vectors[tag] = &vec;
973 }
974 
975 void
977 {
978  if (!_subproblem.vectorTagExists(tag))
979  mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
980  if (hasVector(tag) && &getVector(tag) != &vec)
981  mooseError("You can not disassociate a vector from a tag which it was not associated to");
982 
984 }
985 
986 void
988 {
989  if (!_subproblem.vectorTagExists(tag))
990  mooseError("Cannot disassociate vector from tag ", tag, " because that tag does not exist");
991 
992  if (_tagged_vectors.size() < tag + 1)
993  _tagged_vectors.resize(tag + 1);
994  _tagged_vectors[tag] = nullptr;
995 }
996 
997 void
999 {
1000  const auto tags = defaultVectorTags();
1001  for (const auto tag : tags)
1002  if (_subproblem.vectorTagExists(tag))
1004 }
1005 
1008 {
1009  if (!hasMatrix(tag))
1010  {
1011  if (!_subproblem.matrixTagExists(tag))
1012  mooseError("Cannot retreive matrix with tag ", tag, " because that tag does not exist");
1013  else
1014  mooseError("Cannot retreive matrix with tag ",
1015  tag,
1016  " in system '",
1017  name(),
1018  "'\nbecause a matrix has not been associated with that tag.");
1019  }
1020 
1021  return *_tagged_matrices[tag];
1022 }
1023 
1024 const SparseMatrix<Number> &
1026 {
1027  if (!hasMatrix(tag))
1028  {
1029  if (!_subproblem.matrixTagExists(tag))
1030  mooseError("Cannot retreive matrix with tag ", tag, " because that tag does not exist");
1031  else
1032  mooseError("Cannot retreive 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 void
1043 SystemBase::closeTaggedMatrices(const std::set<TagID> & tags)
1044 {
1045  for (auto tag : tags)
1046  if (hasMatrix(tag))
1047  getMatrix(tag).close();
1048 }
1049 
1050 void
1051 SystemBase::flushTaggedMatrices(const std::set<TagID> & tags)
1052 {
1053  for (auto tag : tags)
1054  if (hasMatrix(tag))
1055  getMatrix(tag).flush();
1056 }
1057 
1058 void
1060 {
1061  if (!_subproblem.matrixTagExists(tag))
1062  mooseError("Cannot associate matrix to tag ", tag, " because that tag does not exist");
1063 
1064  if (_tagged_matrices.size() < tag + 1)
1065  _tagged_matrices.resize(tag + 1);
1066 
1067  _tagged_matrices[tag] = &matrix;
1068 }
1069 
1070 void
1072 {
1073  if (!_subproblem.matrixTagExists(tag))
1074  mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1075  if (hasMatrix(tag) && &getMatrix(tag) != &matrix)
1076  mooseError("You can not disassociate a matrix from a tag which it was not associated to");
1077 
1079 }
1080 
1081 void
1083 {
1084  if (!_subproblem.matrixTagExists(tag))
1085  mooseError("Cannot disassociate matrix from tag ", tag, " because that tag does not exist");
1086 
1087  if (_tagged_matrices.size() < tag + 1)
1088  _tagged_matrices.resize(tag + 1);
1089  _tagged_matrices[tag] = nullptr;
1090 }
1091 
1092 void
1094 {
1095  const auto tags = defaultMatrixTags();
1096  for (const auto tag : tags)
1097  if (_subproblem.matrixTagExists(tag))
1099 }
1100 
1101 void
1103 {
1104  mooseAssert(_subproblem.matrixTagExists(tag),
1105  "Cannot active Matrix with matrix_tag : " << tag << "that does not exist");
1106 
1107  if (_matrix_tag_active_flags.size() < tag + 1)
1108  _matrix_tag_active_flags.resize(tag + 1);
1109 
1110  _matrix_tag_active_flags[tag] = true;
1111 }
1112 
1113 void
1115 {
1116  mooseAssert(_subproblem.matrixTagExists(tag),
1117  "Cannot deactivate Matrix with matrix_tag : " << tag << "that does not exist");
1118 
1119  if (_matrix_tag_active_flags.size() < tag + 1)
1120  _matrix_tag_active_flags.resize(tag + 1);
1121 
1122  _matrix_tag_active_flags[tag] = false;
1123 }
1124 
1125 void
1127 {
1128  auto num_matrix_tags = _subproblem.numMatrixTags();
1129 
1130  _matrix_tag_active_flags.resize(num_matrix_tags);
1131 
1132  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1133  _matrix_tag_active_flags[tag] = false;
1134 }
1135 
1136 void
1138 {
1139  auto num_matrix_tags = _subproblem.numMatrixTags();
1140 
1141  _matrix_tag_active_flags.resize(num_matrix_tags);
1142 
1143  for (decltype(num_matrix_tags) tag = 0; tag < num_matrix_tags; tag++)
1144  if (hasMatrix(tag))
1145  _matrix_tag_active_flags[tag] = true;
1146  else
1147  _matrix_tag_active_flags[tag] = false;
1148 }
1149 
1150 bool
1152 {
1153  mooseAssert(_subproblem.matrixTagExists(tag), "Matrix tag " << tag << " does not exist");
1154 
1155  return tag < _matrix_tag_active_flags.size() && _matrix_tag_active_flags[tag];
1156 }
1157 
1158 unsigned int
1160 {
1161  return system().number();
1162 }
1163 
1164 DofMap &
1166 {
1167  return system().get_dof_map();
1168 }
1169 
1170 const DofMap &
1172 {
1173  return system().get_dof_map();
1174 }
1175 
1176 void
1177 SystemBase::addVariableToCopy(const std::string & dest_name,
1178  const std::string & source_name,
1179  const std::string & timestep)
1180 {
1181  _var_to_copy.push_back(VarCopyInfo(dest_name, source_name, timestep));
1182 }
1183 
1184 void
1186 {
1187  int n_steps = io.get_num_time_steps();
1188 
1189  bool did_copy = false;
1190  for (const auto & vci : _var_to_copy)
1191  {
1192  int timestep = -1;
1193 
1194  if (vci._timestep == "LATEST")
1195  // Use the last time step in the file from which to retrieve the solution
1196  timestep = n_steps;
1197  else
1198  {
1199  timestep = MooseUtils::convert<int>(vci._timestep);
1200  if (timestep > n_steps)
1201  mooseError("Invalid value passed as \"initial_from_file_timestep\". Expected \"LATEST\" or "
1202  "a valid integer between 1 and ",
1203  n_steps,
1204  " inclusive, received ",
1205  vci._timestep);
1206  }
1207 
1208  did_copy = true;
1209 
1210  if (hasVariable(vci._dest_name))
1211  {
1212  const auto & var = getVariable(0, vci._dest_name);
1213  if (var.isArray())
1214  {
1215  const auto & array_var = getFieldVariable<RealEigenVector>(0, vci._dest_name);
1216  for (MooseIndex(var.count()) i = 0; i < var.count(); ++i)
1217  {
1218  const auto & exodus_var = var.arrayVariableComponent(i);
1219  const auto & system_var = array_var.componentName(i);
1220  if (var.isNodal())
1221  io.copy_nodal_solution(system(), exodus_var, system_var, timestep);
1222  else
1223  io.copy_elemental_solution(system(), exodus_var, system_var, timestep);
1224  }
1225  }
1226  else
1227  {
1228  if (var.isNodal())
1229  io.copy_nodal_solution(system(), vci._dest_name, vci._source_name, timestep);
1230  else
1231  io.copy_elemental_solution(system(), vci._dest_name, vci._source_name, timestep);
1232  }
1233  }
1234  else if (hasScalarVariable(vci._dest_name))
1235  io.copy_scalar_solution(system(), {vci._dest_name}, {vci._source_name}, timestep);
1236  else
1237  mooseError("Unrecognized variable ", vci._dest_name, " in variables to copy.");
1238  }
1239 
1240  if (did_copy)
1241  solution().close();
1242 }
1243 
1244 void
1246 {
1247  system().update();
1248 }
1249 
1250 void
1252 {
1253  system().solve();
1254 }
1255 
1259 void
1261 {
1262  system().update();
1263  copyOldSolutions();
1265 }
1266 
1270 void
1272 {
1273  // 1 is for nonlinear, 0 is for time, we do this for nonlinear only here
1274  const auto states = _solution_states[1].size();
1275  if (states > 1)
1276  for (unsigned int i = states - 1; i > 0; --i)
1279 
1280  if (solutionPreviousNewton())
1282 }
1283 
1287 void
1289 {
1290  // Copying the solutions backward so the current solution will become the old, and the old will
1291  // become older. 0 index is for time, 1 would be nonlinear iteration.
1292  const auto states = _solution_states[0].size();
1293  if (states > 1)
1294  for (unsigned int i = states - 1; i > 0; --i)
1295  solutionState(i) = solutionState(i - 1);
1296 
1297  if (solutionUDotOld())
1298  *solutionUDotOld() = *solutionUDot();
1299  if (solutionUDotDotOld())
1301 }
1302 
1306 void
1308 {
1309  if (!hasSolutionState(1))
1310  mooseError("Cannot restore solutions without old solution");
1311 
1312  *(const_cast<NumericVector<Number> *&>(currentSolution())) = solutionOld();
1313  solution() = solutionOld();
1314  if (solutionUDotOld())
1315  *solutionUDot() = *solutionUDotOld();
1316  if (solutionUDotDotOld())
1318  if (solutionPreviousNewton())
1320  system().update();
1321 }
1322 
1323 void
1324 SystemBase::removeVector(const std::string & name)
1325 {
1327 }
1328 
1329 const std::string &
1331 {
1332  return system().name();
1333 }
1334 
1337 {
1340  else
1341  return nullptr;
1342 }
1343 
1344 const NumericVector<Number> *
1346 {
1349  else
1350  return nullptr;
1351 }
1352 
1353 void
1355 {
1356  // Default is the current solution
1357  unsigned int state = 0;
1358 
1359  // Add additional states as required by the variable states requested
1360  for (const auto & var : getVariables(/* tid = */ 0))
1361  state = std::max(state, var->oldestSolutionStateRequested());
1362  for (const auto & var : getScalarVariables(/* tid = */ 0))
1363  state = std::max(state, var->oldestSolutionStateRequested());
1364 
1366 
1368 }
1369 
1370 TagName
1372  const Moose::SolutionIterationType iteration_type) const
1373 {
1374  mooseAssert(state != 0, "Not an old state");
1375 
1376  if (iteration_type == Moose::SolutionIterationType::Time)
1377  {
1378  if (state == 1)
1379  return Moose::OLD_SOLUTION_TAG;
1380  else if (state == 2)
1382  }
1383  else if (iteration_type == Moose::SolutionIterationType::Nonlinear && state == 1)
1385 
1386  return "solution_state_" + std::to_string(state) + "_" + Moose::stringify(iteration_type);
1387 }
1388 
1389 const NumericVector<Number> &
1390 SystemBase::solutionState(const unsigned int state,
1391  const Moose::SolutionIterationType iteration_type) const
1392 {
1393  if (!hasSolutionState(state, iteration_type))
1394  mooseError("For iteration type '",
1395  Moose::stringify(iteration_type),
1396  "': solution state ",
1397  state,
1398  " was requested in ",
1399  name(),
1400  " but only up to state ",
1401  (_solution_states[static_cast<unsigned short>(iteration_type)].size() == 0)
1402  ? 0
1403  : _solution_states[static_cast<unsigned short>(iteration_type)].size() - 1,
1404  " is available.");
1405 
1406  const auto & solution_states = _solution_states[static_cast<unsigned short>(iteration_type)];
1407 
1408  if (state == 0)
1409  mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1410  else
1411  mooseAssert(solution_states[state] ==
1412  &getVector(oldSolutionStateVectorName(state, iteration_type)),
1413  "Inconsistent solution state");
1414 
1415  return *solution_states[state];
1416 }
1417 
1419 SystemBase::solutionState(const unsigned int state,
1420  const Moose::SolutionIterationType iteration_type)
1421 {
1422  if (!hasSolutionState(state, iteration_type))
1423  needSolutionState(state, iteration_type);
1424  return *_solution_states[static_cast<unsigned short>(iteration_type)][state];
1425 }
1426 
1427 void
1428 SystemBase::needSolutionState(const unsigned int state,
1429  const Moose::SolutionIterationType iteration_type)
1430 {
1431  libmesh_parallel_only(this->comm());
1432  mooseAssert(!Threads::in_threads,
1433  "This routine is not thread-safe. Request the solution state before using it in "
1434  "a threaded region.");
1435 
1436  if (hasSolutionState(state, iteration_type))
1437  return;
1438 
1439  auto & solution_states = _solution_states[static_cast<unsigned short>(iteration_type)];
1440  solution_states.resize(state + 1);
1441 
1442  // The 0-th (current) solution state is owned by libMesh
1443  if (!solution_states[0])
1444  solution_states[0] = &solutionInternal();
1445  else
1446  mooseAssert(solution_states[0] == &solutionInternal(), "Inconsistent current solution");
1447 
1448  // We will manually add all states past current
1449  for (unsigned int i = 1; i <= state; ++i)
1450  if (!solution_states[i])
1451  {
1452  auto tag = _subproblem.addVectorTag(oldSolutionStateVectorName(i, iteration_type),
1454  solution_states[i] = &addVector(tag, true, GHOSTED);
1455  }
1456  else
1457  mooseAssert(solution_states[i] == &getVector(oldSolutionStateVectorName(i, iteration_type)),
1458  "Inconsistent solution state");
1459 }
1460 
1461 void
1462 SystemBase::applyScalingFactors(const std::vector<Real> & inverse_scaling_factors)
1463 {
1464  for (MooseIndex(_vars) thread = 0; thread < _vars.size(); ++thread)
1465  {
1466  auto & field_variables = _vars[thread].fieldVariables();
1467  for (MooseIndex(field_variables) i = 0, p = 0; i < field_variables.size(); ++i)
1468  {
1469  auto factors = field_variables[i]->arrayScalingFactor();
1470  for (unsigned int j = 0; j < field_variables[i]->count(); ++j, ++p)
1471  factors[j] /= inverse_scaling_factors[p];
1472 
1473  field_variables[i]->scalingFactor(factors);
1474  }
1475 
1476  auto offset = field_variables.size();
1477 
1478  auto & scalar_variables = _vars[thread].scalars();
1479  for (MooseIndex(scalar_variables) i = 0; i < scalar_variables.size(); ++i)
1480  scalar_variables[i]->scalingFactor(
1481  {1. / inverse_scaling_factors[offset + i] * scalar_variables[i]->scalingFactor()});
1482 
1483  if (thread == 0 && _verbose)
1484  {
1485  _console << "Automatic scaling factors:\n";
1486  auto original_flags = _console.flags();
1487  auto original_precision = _console.precision();
1488  _console.unsetf(std::ios_base::floatfield);
1489  _console.precision(6);
1490 
1491  for (const auto & field_variable : field_variables)
1492  {
1493  const auto & factors = field_variable->arrayScalingFactor();
1494  _console << " " << field_variable->name() << ":";
1495  for (const auto i : make_range(field_variable->count()))
1496  _console << " " << factors[i];
1497  _console << "\n";
1498  }
1499  for (const auto & scalar_variable : scalar_variables)
1500  _console << " " << scalar_variable->name() << ": " << scalar_variable->scalingFactor()
1501  << "\n";
1502  _console << "\n" << std::endl;
1503 
1504  // restore state
1505  _console.flags(original_flags);
1506  _console.precision(original_precision);
1507  }
1508  }
1509 }
1510 
1511 void
1513 {
1514  addVector("scaling_factors", /*project=*/false, libMesh::ParallelType::GHOSTED);
1516 }
1517 
1518 bool
1520 {
1522 }
1523 
1524 void
1526 {
1527  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1528  _vars[tid].initialSetup();
1529 
1530  // If we need raw gradients, we initialize them here.
1531  bool gradient_storage_initialized = false;
1532  for (const auto & field_var : _vars[0].fieldVariables())
1533  if (!gradient_storage_initialized && field_var->needsGradientVectorStorage())
1534  {
1535  _raw_grad_container.clear();
1536  for (const auto i : make_range(this->_mesh.dimension()))
1537  {
1538  libmesh_ignore(i);
1539  _raw_grad_container.push_back(currentSolution()->zero_clone());
1540  }
1541  }
1542 }
1543 
1544 void
1546 {
1547  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1548  _vars[tid].timestepSetup();
1549 }
1550 
1551 void
1553 {
1554  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1555  _vars[tid].customSetup(exec_type);
1556 }
1557 
1558 void
1560 {
1561  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1562  _vars[tid].subdomainSetup();
1563 }
1564 
1565 void
1567 {
1568  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1569  _vars[tid].residualSetup();
1570 }
1571 
1572 void
1574 {
1575  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); tid++)
1576  _vars[tid].jacobianSetup();
1577 }
1578 
1579 void
1581 {
1582  for (auto & var_warehouse : _vars)
1583  var_warehouse.clearAllDofIndices();
1584 }
1585 
1586 void
1588 {
1589  _vars[tid].setActiveVariableCoupleableVectorTags(vtags);
1590 }
1591 
1592 void
1594  THREAD_ID tid)
1595 {
1596  _vars[tid].setActiveScalarVariableCoupleableVectorTags(vtags);
1597 }
1598 
1599 void
1601 {
1602  if (_fe_problem.uDotRequested())
1603  _u_dot = &addVector("u_dot", true, GHOSTED);
1605  _u_dot_old = &addVector("u_dot_old", true, GHOSTED);
1607  _u_dotdot = &addVector("u_dotdot", true, GHOSTED);
1609  _u_dotdot_old = &addVector("u_dotdot_old", true, GHOSTED);
1610 }
1611 
1614 {
1615  if (!_serialized_solution.get())
1616  {
1618  _serialized_solution->init(system().n_dofs(), false, SERIAL);
1619  }
1620 
1621  return *_serialized_solution;
1622 }
1623 
1624 void
1625 SystemBase::addTimeIntegrator(const std::string & type,
1626  const std::string & name,
1627  InputParameters & parameters)
1628 {
1629  parameters.set<SystemBase *>("_sys") = this;
1630  _time_integrators.push_back(_factory.create<TimeIntegrator>(type, name, parameters));
1631 }
1632 
1633 void
1635 {
1637 }
1638 
1639 const TimeIntegrator *
1640 SystemBase::queryTimeIntegrator(const unsigned int var_num) const
1641 {
1642  for (auto & ti : _time_integrators)
1643  if (ti->integratesVar(var_num))
1644  return ti.get();
1645 
1646  return nullptr;
1647 }
1648 
1649 const TimeIntegrator &
1650 SystemBase::getTimeIntegrator(const unsigned int var_num) const
1651 {
1652  const auto * const ti = queryTimeIntegrator(var_num);
1653 
1654  if (ti)
1655  return *ti;
1656  else
1657  mooseError("No time integrator found that integrates variable number ",
1658  std::to_string(var_num));
1659 }
1660 
1661 const std::vector<std::shared_ptr<TimeIntegrator>> &
1663 {
1664  return _time_integrators;
1665 }
1666 
1667 const Number &
1668 SystemBase::duDotDu(const unsigned int var_num) const
1669 {
1670  return _du_dot_du[var_num];
1671 }
1672 
1673 const std::set<SubdomainID> &
1674 SystemBase::getSubdomainsForVar(const std::string & var_name) const
1675 {
1676  return getSubdomainsForVar(getVariable(0, var_name).number());
1677 }
1678 
1679 std::string
1681 {
1682  return "-" + (system().prefix_with_name() ? system().prefix() : "");
1683 }
1684 
1685 template MooseVariableFE<Real> & SystemBase::getFieldVariable<Real>(THREAD_ID tid,
1686  const std::string & var_name);
1687 
1689 SystemBase::getFieldVariable<RealVectorValue>(THREAD_ID tid, const std::string & var_name);
1690 
1692 SystemBase::getFieldVariable<RealEigenVector>(THREAD_ID tid, const std::string & var_name);
1693 
1694 template MooseVariableFE<Real> & SystemBase::getFieldVariable<Real>(THREAD_ID tid,
1695  unsigned int var_number);
1696 
1698 SystemBase::getFieldVariable<RealVectorValue>(THREAD_ID tid, unsigned int var_number);
1699 
1701 SystemBase::getFieldVariable<RealEigenVector>(THREAD_ID tid, unsigned int var_number);
1702 
1703 template MooseVariableField<Real> &
1704 SystemBase::getActualFieldVariable<Real>(THREAD_ID tid, const std::string & var_name);
1705 
1707 SystemBase::getActualFieldVariable<RealVectorValue>(THREAD_ID tid, const std::string & var_name);
1708 
1710 SystemBase::getActualFieldVariable<RealEigenVector>(THREAD_ID tid, const std::string & var_name);
1711 
1712 template MooseVariableField<Real> &
1713 SystemBase::getActualFieldVariable<Real>(THREAD_ID tid, unsigned int var_number);
1714 
1716 SystemBase::getActualFieldVariable<RealVectorValue>(THREAD_ID tid, unsigned int var_number);
1717 
1719 SystemBase::getActualFieldVariable<RealEigenVector>(THREAD_ID tid, unsigned int var_number);
1720 
1721 template MooseVariableFV<Real> & SystemBase::getFVVariable<Real>(THREAD_ID tid,
1722  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:666
std::vector< std::shared_ptr< TimeIntegrator > > _time_integrators
Time integrator.
Definition: SystemBase.h:1041
unsigned int add_variables(const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
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 void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Registers that the solution state state is needed.
Definition: SystemBase.C:1428
virtual void reinitNode(const Node *node, THREAD_ID tid)
Reinit nodal assembly info.
Definition: SystemBase.C:390
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:641
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:1044
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:1235
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
Order
std::vector< dof_id_type > _var_all_dof_indices
Container for the dof indices of a given variable.
Definition: SystemBase.h:1056
std::vector< Real > _du_dot_du
Derivative of time derivative of u with respect to uj.
Definition: SystemBase.h:1011
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:1017
const std::vector< MooseVariableScalar * > & getScalarVariables(THREAD_ID tid)
Definition: SystemBase.h:757
void zeroTaggedVectors(const std::set< TagID > &tags)
Zero all vectors for given tags.
Definition: SystemBase.C:685
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:907
void applyScalingFactors(const std::vector< Real > &inverse_scaling_factors)
Applies scaling factors to the system&#39;s variables.
Definition: SystemBase.C:1462
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:1288
bool _solution_states_initialized
Whether or not the solution states have been initialized.
Definition: SystemBase.h:1053
SCALAR
unsigned int TagID
Definition: MooseTypes.h:210
virtual bool checkNonlocalCouplingRequirement() const =0
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:3108
NumericVector< Number > & solution()
Definition: SystemBase.h:195
virtual void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &parameters)
Canonical method for adding a variable.
Definition: SystemBase.C:710
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:302
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:996
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:1005
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:1354
virtual void disassociateDefaultVectorTags()
Disassociate the vectors associated with the default vector tags of this system.
Definition: SystemBase.C:998
virtual void reinitElem(const Elem *elem, THREAD_ID tid)
Reinit an element assembly info.
Definition: SystemBase.C:339
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
Definition: SystemBase.C:382
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:92
const TimeIntegrator & getTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable&#39;s equation.
Definition: SystemBase.C:1650
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:454
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:964
virtual libMesh::Order getMinQuadratureOrder()
Get minimal quadrature order needed for integrating variables in this system.
Definition: SystemBase.C:240
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:1375
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:1419
MeshBase & mesh
Factory & _factory
Definition: SystemBase.h:983
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:155
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:1519
NumericVector< Number > * _u_dotdot
solution vector for u^dotdot
Definition: SystemBase.h:1002
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:1177
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:351
virtual NumericVector< Number > * solutionUDotDotOld()
Definition: SystemBase.h:255
void removeMatrix(TagID tag)
Removes a matrix with a given tag.
Definition: SystemBase.C:582
virtual void associateMatrixToTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Associate a matrix to a tag.
Definition: SystemBase.C:1059
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:278
void addScalingVector()
Add the scaling factor vector to the system.
Definition: SystemBase.C:1512
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:1625
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
Definition: SystemBase.C:1587
Base class for a system (of equations)
Definition: SystemBase.h:84
std::vector< std::unique_ptr< NumericVector< Number > > > _raw_grad_container
A cache for storing gradients at dof locations.
Definition: SystemBase.h:1065
virtual void copyPreviousNonlinearSolutions()
Shifts the solutions backwards in nonlinear iteration history.
Definition: SystemBase.C:1271
virtual bool isArrayVariable(const std::string &var_name) const
If a variable is an array variable.
Definition: SystemBase.C:847
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of nodes.
Definition: SystemBase.C:414
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:1060
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, THREAD_ID tid)
Reinit variables at a set of neighbor nodes.
Definition: SystemBase.C:425
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:124
virtual void disassociateMatrixFromTag(libMesh::SparseMatrix< Number > &matrix, TagID tag)
Disassociate a matrix from a tag.
Definition: SystemBase.C:1071
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:1245
virtual unsigned int nVariables() const
Get the number of variables in this system.
Definition: SystemBase.C:874
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
Definition: SystemBase.C:1593
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:1330
virtual void jacobianSetup()
Definition: SystemBase.C:1573
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:1043
virtual void deactiveAllMatrixTags()
Make matrices inactive.
Definition: SystemBase.C:1126
std::vector< VarCopyInfo > _var_to_copy
Definition: SystemBase.h:1032
virtual void flush()
virtual libMesh::DofMap & dofMap()
Gets writeable reference to the dof map.
Definition: SystemBase.C:1165
void libmesh_ignore(const Args &...)
void copyTimeIntegrators(const SystemBase &other_sys)
Copy time integrators from another system.
Definition: SystemBase.C:1634
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:1613
void remove_vector(std::string_view vec_name)
virtual std::unique_ptr< Base > create()=0
void copyVars(libMesh::ExodusII_IO &io)
Definition: SystemBase.C:1185
int convert< int >(const std::string &str, bool throw_on_failure)
Definition: MooseUtils.C:1009
virtual const Number & duDotDu(unsigned int var_num=0) const
Definition: SystemBase.C:1668
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:228
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
Definition: MooseMesh.C:2923
std::string prefix() const
std::vector< bool > _matrix_tag_active_flags
Active flags for tagged matrices.
Definition: SystemBase.h:1019
GHOSTED
std::vector< std::string > _vars_to_be_zeroed_on_jacobian
Definition: SystemBase.h:997
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:66
virtual NumericVector< Number > * solutionUDot()
Definition: SystemBase.h:252
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:1170
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:714
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition: SystemBase.C:323
An inteface for the _console for outputting to the Console object.
virtual NumericVector< Number > * solutionUDotOld()
Definition: SystemBase.h:254
virtual void reinitScalars(THREAD_ID tid, bool reinit_for_derivative_reordering=false)
Reinit scalar varaibles.
Definition: SystemBase.C:436
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:977
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:1151
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
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:366
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:562
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:1600
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:1026
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:1081
virtual void activeAllMatrixTags()
Make all exsiting matrices ative.
Definition: SystemBase.C:1137
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1159
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:659
virtual void reinitNeighbor(const Elem *elem, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition: SystemBase.C:374
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
Free function used for a libMesh callback.
Definition: SystemBase.C:39
const std::vector< std::shared_ptr< TimeIntegrator > > & getTimeIntegrators()
Definition: SystemBase.C:1662
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:834
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:992
virtual void copySolutionsBackwards()
Copy current solution into old and older.
Definition: SystemBase.C:1260
virtual std::set< TagID > defaultMatrixTags() const
Get the default matrix tags associted with this system.
Definition: SystemBase.h:310
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:1251
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:980
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 void activeMatrixTag(TagID tag)
Active a matrix for tag.
Definition: SystemBase.C:1102
ParallelType type() const
virtual void saveOldSolutions()
Save the old and older solutions.
Definition: SystemBase.C:502
std::vector< VariableWarehouse > _vars
Variable warehouses (one for each thread)
Definition: SystemBase.h:990
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:1559
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
bool _verbose
True if printing out additional information.
Definition: SystemBase.h:1050
void removeVector(const std::string &name)
Remove a vector from the system with the given name.
Definition: SystemBase.C:1324
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:893
MooseMesh & _mesh
Definition: SystemBase.h:985
NumericVector< Number > * _u_dot
solution vector for u^dot
Definition: SystemBase.h:1000
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
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
const Node * node_ptr(const unsigned int i) const
void prepareVariableNonlocal(MooseVariableFieldBase *var)
Definition: Assembly.C:2777
virtual libMesh::SparseMatrix< Number > & getMatrix(TagID tag)
Get a raw SparseMatrix.
Definition: SystemBase.C:1007
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, THREAD_ID tid)
Reinit nodal assembly info on a face.
Definition: SystemBase.C:402
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 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:303
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:1371
std::array< std::vector< NumericVector< Number > * >, 2 > _solution_states
The solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1075
Class for scalar variables (they are different).
IntRange< T > make_range(T beg, T end)
std::string prefix() const
Definition: SystemBase.C:1680
NumericVector< Real > * _saved_dotdot_old
Definition: SystemBase.h:1027
const std::vector< VariableName > & getVariableNames() const
Definition: SystemBase.h:861
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition: SystemBase.C:255
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
virtual const NumericVector< Number > * solutionPreviousNewton() const
Definition: SystemBase.C:1345
virtual void customSetup(const ExecFlagType &exec_type)
Definition: SystemBase.C:1552
const TimeIntegrator * queryTimeIntegrator(const unsigned int var_num) const
Retrieve the time integrator that integrates the given variable&#39;s equation.
Definition: SystemBase.C:1640
const std::set< SubdomainID > & getSubdomainsForVar(unsigned int var_number) const
Definition: SystemBase.h:762
void prepareVariable(MooseVariableFieldBase *var)
Used for preparing the dense residual and jacobian blocks for one particular variable.
Definition: Assembly.C:2749
virtual bool isScalarVariable(unsigned int var_name) const
Definition: SystemBase.C:868
unsigned int nFieldVariables() const
Get the number of field variables in this system.
Definition: SystemBase.C:883
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:358
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:221
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:460
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Definition: SystemBase.C:331
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
const std::string & name() const
dof_id_type first_dof(const processor_id_type proc) const
unsigned int number() const
virtual void deactiveMatrixTag(TagID tag)
deactive a matrix for tag
Definition: SystemBase.C:1114
Real Number
virtual NumericVector< Number > * solutionUDotDot()
Definition: SystemBase.h:253
unsigned int n_vars() const
void setVariableGlobalDoFs(const std::string &var_name)
set all the global dof indices for a variable
Definition: SystemBase.C:185
std::vector< NumericVector< Number > * > _tagged_vectors
Tagged vectors (pointer)
Definition: SystemBase.h:1015
void prefix_with_name(bool value)
NumericVector< Number > & solutionOld()
Definition: SystemBase.h:196
SystemBase(SubProblem &subproblem, FEProblemBase &fe_problem, const std::string &name, Moose::VarKindType var_kind)
Definition: SystemBase.C:56
virtual bool hasScalarVariable(const std::string &var_name) const
Definition: SystemBase.C:859
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:444
virtual void initialSetup()
Setup Functions.
Definition: SystemBase.C:1525
TYPE_VECTOR
bool active() const
virtual void restoreSolutions()
Restore current solutions (call after your solve failed)
Definition: SystemBase.C:1307
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:916
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:47
const DofMap & get_dof_map() const
virtual void residualSetup()
Definition: SystemBase.C:1566
std::vector< NumericVector< Number > * > _saved_solution_states
The saved solution states (0 = current, 1 = old, 2 = older, etc)
Definition: SystemBase.h:1077
virtual void disassociateDefaultMatrixTags()
Disassociate the matrices associated with the default matrix tags of this system. ...
Definition: SystemBase.C:1093
void clearAllDofIndices()
Clear all dof indices from moose variables.
Definition: SystemBase.C:1580
unsigned int _max_var_number
Maximum variable number.
Definition: SystemBase.h:994
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
virtual void restoreOldSolutions()
Restore the old and older solutions when the saved solutions present.
Definition: SystemBase.C:534
void flushTaggedMatrices(const std::set< TagID > &tags)
flushes all matrices associated to tags.
Definition: SystemBase.C:1051
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:328
SolutionIterationType
Definition: MooseTypes.h:241
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:1007
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:357
unsigned int THREAD_ID
Definition: MooseTypes.h:209
SubdomainID getSubdomainID(const SubdomainName &subdomain_name) const
Get the associated subdomain ID for the subdomain name.
Definition: MooseMesh.C:1728
ParallelType
virtual void timestepSetup()
Definition: SystemBase.C:1545
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 isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.