www.mooseframework.org
SubProblem.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "SubProblem.h"
11 #include "Factory.h"
12 #include "MooseMesh.h"
13 #include "Conversion.h"
14 #include "Function.h"
15 #include "MooseApp.h"
16 #include "MooseVariableFE.h"
17 #include "MooseArray.h"
18 #include "Assembly.h"
19 #include "MooseObjectName.h"
20 #include "RelationshipManager.h"
21 #include "MooseUtils.h"
22 #include "DisplacedSystem.h"
23 #include "NonlinearSystemBase.h"
24 #include "LinearSystem.h"
25 
26 #include "libmesh/equation_systems.h"
27 #include "libmesh/system.h"
28 #include "libmesh/dof_map.h"
29 #include "libmesh/string_to_enum.h"
30 
31 #include <regex>
32 
35 {
37 
38  params.addParam<bool>(
39  "default_ghosting",
40  false,
41  "Whether or not to use libMesh's default amount of algebraic and geometric ghosting");
42 
43  params.addParamNamesToGroup("default_ghosting", "Advanced");
44 
45  return params;
46 }
47 
48 // SubProblem /////
50  : Problem(parameters),
51  _factory(_app.getFactory()),
52  _requires_nonlocal_coupling(false),
53  _default_ghosting(getParam<bool>("default_ghosting")),
54  _currently_computing_jacobian(false),
55  _currently_computing_residual_and_jacobian(false),
56  _computing_nonlinear_residual(false),
57  _currently_computing_residual(false),
58  _safe_access_tagged_matrices(false),
59  _safe_access_tagged_vectors(false),
60  _have_ad_objects(false),
61  _output_functors(false),
62  _typed_vector_tags(2),
63  _have_p_refinement(false)
64 {
65  unsigned int n_threads = libMesh::n_threads();
68 
73 
74  _functors.resize(n_threads);
75  _pbblf_functors.resize(n_threads);
77 }
78 
80 
81 TagID
82 SubProblem::addVectorTag(const TagName & tag_name,
83  const Moose::VectorTagType type /* = Moose::VECTOR_TAG_RESIDUAL */)
84 {
86  mooseError("Vector tag type cannot be VECTOR_TAG_ANY");
87 
88  const auto tag_name_upper = MooseUtils::toUpper(tag_name);
89 
90  // First, see if the tag exists already
91  for (const auto & vector_tag : _vector_tags)
92  {
93  mooseAssert(_vector_tags[vector_tag._id] == vector_tag, "Vector tags index mismatch");
94  if (vector_tag._name == tag_name_upper)
95  {
96  if (vector_tag._type != type)
97  mooseError("While attempting to add vector tag with name '",
98  tag_name_upper,
99  "' and type ",
100  type,
101  ",\na tag with the same name but type ",
102  vector_tag._type,
103  " was found.\n\nA tag can only exist with one type.");
104 
105  return vector_tag._id;
106  }
107  }
108 
109  // Doesn't exist - create it
110  const TagID new_tag_id = _vector_tags.size();
111  const TagTypeID new_tag_type_id = _typed_vector_tags[type].size();
112  // Primary storage for all tags where the index in the vector == the tag ID
113  _vector_tags.emplace_back(new_tag_id, new_tag_type_id, tag_name_upper, type);
114  // Secondary storage for each type so that we can have quick access to all tags of a type
115  _typed_vector_tags[type].emplace_back(new_tag_id, new_tag_type_id, tag_name_upper, type);
116  // Name map storage for quick name access
117  _vector_tags_name_map.emplace(tag_name_upper, new_tag_id);
118 
119  // Make sure that _vector_tags, _typed_vector_tags, and _vector_tags_name_map are sane
121 
122  return new_tag_id;
123 }
124 
125 bool
126 SubProblem::vectorTagExists(const TagName & tag_name) const
127 {
128  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
129 
130  const auto tag_name_upper = MooseUtils::toUpper(tag_name);
131  for (const auto & vector_tag : _vector_tags)
132  if (vector_tag._name == tag_name_upper)
133  return true;
134 
135  return false;
136 }
137 
138 const VectorTag &
139 SubProblem::getVectorTag(const TagID tag_id) const
140 {
141  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
142 
143  if (!vectorTagExists(tag_id))
144  mooseError("Vector tag with ID ", tag_id, " does not exist");
145 
146  return _vector_tags[tag_id];
147 }
148 
149 std::vector<VectorTag>
150 SubProblem::getVectorTags(const std::set<TagID> & tag_ids) const
151 {
152  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
153 
154  std::vector<VectorTag> tags;
155  tags.reserve(tag_ids.size());
156  for (const auto & tag_id : tag_ids)
157  tags.push_back(getVectorTag(tag_id));
158  return tags;
159 }
160 
161 const std::vector<VectorTag> &
162 SubProblem::getVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
163 {
164  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
165 
167  return _vector_tags;
168  else
169  return _typed_vector_tags[type];
170 }
171 
172 unsigned int
173 SubProblem::numVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
174 {
175  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
176 
177  return getVectorTags(type).size();
178 }
179 
180 TagID
181 SubProblem::getVectorTagID(const TagName & tag_name) const
182 {
183  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
184 
185  const auto tag_name_upper = MooseUtils::toUpper(tag_name);
186  const auto search = _vector_tags_name_map.find(tag_name_upper);
187  if (search != _vector_tags_name_map.end())
188  return search->second;
189 
190  std::string message =
191  tag_name_upper == "TIME"
192  ? ".\n\nThis may occur if "
193  "you have a TimeKernel in your problem but did not specify a transient executioner."
194  : "";
195  mooseError("Vector tag '", tag_name_upper, "' does not exist", message);
196 }
197 
198 TagName
199 SubProblem::vectorTagName(const TagID tag_id) const
200 {
201  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
202  if (!vectorTagExists(tag_id))
203  mooseError("Vector tag with ID ", tag_id, " does not exist");
204 
205  return _vector_tags[tag_id]._name;
206 }
207 
209 SubProblem::vectorTagType(const TagID tag_id) const
210 {
211  mooseAssert(verifyVectorTags(), "Vector tag storage invalid");
212  if (!vectorTagExists(tag_id))
213  mooseError("Vector tag with ID ", tag_id, " does not exist");
214 
215  return _vector_tags[tag_id]._type;
216 }
217 
218 bool
220 {
221  for (TagID tag_id = 0; tag_id < _vector_tags.size(); ++tag_id)
222  {
223  const auto & vector_tag = _vector_tags[tag_id];
224 
225  if (vector_tag._id != tag_id)
226  mooseError("Vector tag ", vector_tag._id, " id mismatch in _vector_tags");
227  if (vector_tag._type == Moose::VECTOR_TAG_ANY)
228  mooseError("Vector tag '", vector_tag._name, "' has type VECTOR_TAG_ANY");
229 
230  const auto search = _vector_tags_name_map.find(vector_tag._name);
231  if (search == _vector_tags_name_map.end())
232  mooseError("Vector tag ", vector_tag._id, " is not in _vector_tags_name_map");
233  else if (search->second != tag_id)
234  mooseError("Vector tag ", vector_tag._id, " has incorrect id in _vector_tags_name_map");
235 
236  unsigned int found_in_type = 0;
237  for (TagTypeID tag_type_id = 0; tag_type_id < _typed_vector_tags[vector_tag._type].size();
238  ++tag_type_id)
239  {
240  const auto & vector_tag_type = _typed_vector_tags[vector_tag._type][tag_type_id];
241  if (vector_tag_type == vector_tag)
242  {
243  ++found_in_type;
244  if (vector_tag_type._type_id != tag_type_id)
245  mooseError("Type ID for Vector tag ", tag_id, " is incorrect");
246  }
247  }
248 
249  if (found_in_type == 0)
250  mooseError("Vector tag ", tag_id, " not found in _typed_vector_tags");
251  if (found_in_type > 1)
252  mooseError("Vector tag ", tag_id, " found multiple times in _typed_vector_tags");
253  }
254 
255  unsigned int num_typed_vector_tags = 0;
256  for (const auto & typed_vector_tags : _typed_vector_tags)
257  num_typed_vector_tags += typed_vector_tags.size();
258  if (num_typed_vector_tags != _vector_tags.size())
259  mooseError("Size mismatch between _vector_tags and _typed_vector_tags");
260  if (_vector_tags_name_map.size() != _vector_tags.size())
261  mooseError("Size mismatch between _vector_tags and _vector_tags_name_map");
262 
263  return true;
264 }
265 
266 void
268  const std::vector<VectorTag> & input_vector_tags,
269  std::set<TagID> & selected_tags)
270 {
271  selected_tags.clear();
272  for (const auto & vector_tag : input_vector_tags)
273  if (system.hasVector(vector_tag._id))
274  selected_tags.insert(vector_tag._id);
275 }
276 
277 void
279  const std::map<TagName, TagID> & input_matrix_tags,
280  std::set<TagID> & selected_tags)
281 {
282  selected_tags.clear();
283  for (const auto & matrix_tag_pair : input_matrix_tags)
284  if (system.hasMatrix(matrix_tag_pair.second))
285  selected_tags.insert(matrix_tag_pair.second);
286 }
287 
288 TagID
289 SubProblem::addMatrixTag(TagName tag_name)
290 {
291  auto tag_name_upper = MooseUtils::toUpper(tag_name);
292  auto existing_tag = _matrix_tag_name_to_tag_id.find(tag_name_upper);
293  if (existing_tag == _matrix_tag_name_to_tag_id.end())
294  {
295  auto tag_id = _matrix_tag_name_to_tag_id.size();
296 
297  _matrix_tag_name_to_tag_id[tag_name_upper] = tag_id;
298 
299  _matrix_tag_id_to_tag_name[tag_id] = tag_name_upper;
300  }
301 
302  return _matrix_tag_name_to_tag_id.at(tag_name_upper);
303 }
304 
305 bool
306 SubProblem::matrixTagExists(const TagName & tag_name) const
307 {
308  auto tag_name_upper = MooseUtils::toUpper(tag_name);
309 
310  return _matrix_tag_name_to_tag_id.find(tag_name_upper) != _matrix_tag_name_to_tag_id.end();
311 }
312 
313 bool
315 {
316  return _matrix_tag_id_to_tag_name.find(tag_id) != _matrix_tag_id_to_tag_name.end();
317 }
318 
319 TagID
320 SubProblem::getMatrixTagID(const TagName & tag_name) const
321 {
322  auto tag_name_upper = MooseUtils::toUpper(tag_name);
323 
324  if (!matrixTagExists(tag_name))
325  mooseError("Matrix tag: ",
326  tag_name,
327  " does not exist. ",
328  "If this is a TimeKernel then this may have happened because you didn't "
329  "specify a Transient Executioner.");
330 
331  return _matrix_tag_name_to_tag_id.at(tag_name_upper);
332 }
333 
334 TagName
336 {
337  return _matrix_tag_id_to_tag_name[tag];
338 }
339 
340 void
342 {
344 }
345 
346 void
348 {
350  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
353 }
354 
355 void
357 {
359 }
360 
361 void
363 {
365 }
366 
367 const std::set<TagID> &
369 {
371 }
372 
373 const std::set<TagID> &
375 {
377 }
378 
379 void
381  const THREAD_ID tid)
382 {
384 }
385 
386 void
388  const THREAD_ID tid)
389 {
391  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
394 }
395 
396 void
398 {
400 }
401 
402 void
404 {
406 }
407 
408 const std::set<TagID> &
410 {
412 }
413 
414 const std::set<TagID> &
416 {
418 }
419 
420 void
421 SubProblem::setActiveElementalMooseVariables(const std::set<MooseVariableFEBase *> & moose_vars,
422  const THREAD_ID tid)
423 {
424  if (!moose_vars.empty())
425  {
427  _active_elemental_moose_variables[tid] = moose_vars;
428  }
429 }
430 
431 const std::set<MooseVariableFEBase *> &
433 {
435 }
436 
437 bool
439 {
441 }
442 
443 void
445 {
448 }
449 
450 std::set<SubdomainID>
451 SubProblem::getMaterialPropertyBlocks(const std::string & prop_name)
452 {
453  std::set<SubdomainID> blocks;
454 
455  for (const auto & it : _map_block_material_props)
456  {
457  const std::set<std::string> & prop_names = it.second;
458  std::set<std::string>::iterator name_it = prop_names.find(prop_name);
459  if (name_it != prop_names.end())
460  blocks.insert(it.first);
461  }
462 
463  return blocks;
464 }
465 
466 std::vector<SubdomainName>
467 SubProblem::getMaterialPropertyBlockNames(const std::string & prop_name)
468 {
469  std::set<SubdomainID> blocks = getMaterialPropertyBlocks(prop_name);
470  std::vector<SubdomainName> block_names;
471  block_names.reserve(blocks.size());
472  for (const auto & block_id : blocks)
473  {
474  SubdomainName name;
475  name = mesh().getMesh().subdomain_name(block_id);
476  if (name.empty())
477  {
478  std::ostringstream oss;
479  oss << block_id;
480  name = oss.str();
481  }
482  block_names.push_back(name);
483  }
484 
485  return block_names;
486 }
487 
488 bool
489 SubProblem::hasBlockMaterialProperty(SubdomainID bid, const std::string & prop_name)
490 {
491  auto it = _map_block_material_props.find(bid);
492  if (it == _map_block_material_props.end())
493  return false;
494 
495  if (it->second.count(prop_name) > 0)
496  return true;
497  else
498  return false;
499 }
500 
501 // TODO: remove code duplication by templating
502 std::set<BoundaryID>
503 SubProblem::getMaterialPropertyBoundaryIDs(const std::string & prop_name)
504 {
505  std::set<BoundaryID> boundaries;
506 
507  for (const auto & it : _map_boundary_material_props)
508  {
509  const std::set<std::string> & prop_names = it.second;
510  std::set<std::string>::iterator name_it = prop_names.find(prop_name);
511  if (name_it != prop_names.end())
512  boundaries.insert(it.first);
513  }
514 
515  return boundaries;
516 }
517 
518 std::vector<BoundaryName>
519 SubProblem::getMaterialPropertyBoundaryNames(const std::string & prop_name)
520 {
521  std::set<BoundaryID> boundaries = getMaterialPropertyBoundaryIDs(prop_name);
522  std::vector<BoundaryName> boundary_names;
523  boundary_names.reserve(boundaries.size());
524  const BoundaryInfo & boundary_info = mesh().getMesh().get_boundary_info();
525 
526  for (const auto & bnd_id : boundaries)
527  {
528  BoundaryName name;
529  if (bnd_id == Moose::ANY_BOUNDARY_ID)
530  name = "ANY_BOUNDARY_ID";
531  else
532  {
533  name = boundary_info.get_sideset_name(bnd_id);
534  if (name.empty())
535  {
536  std::ostringstream oss;
537  oss << bnd_id;
538  name = oss.str();
539  }
540  }
541  boundary_names.push_back(name);
542  }
543 
544  return boundary_names;
545 }
546 
547 bool
548 SubProblem::hasBoundaryMaterialProperty(BoundaryID bid, const std::string & prop_name)
549 {
550  auto it = _map_boundary_material_props.find(bid);
551  if (it == _map_boundary_material_props.end())
552  return false;
553 
554  if (it->second.count(prop_name) > 0)
555  return true;
556  else
557  return false;
558 }
559 
560 void
561 SubProblem::storeSubdomainMatPropName(SubdomainID block_id, const std::string & name)
562 {
563  _map_block_material_props[block_id].insert(name);
564 }
565 
566 void
567 SubProblem::storeBoundaryMatPropName(BoundaryID boundary_id, const std::string & name)
568 {
569  _map_boundary_material_props[boundary_id].insert(name);
570 }
571 
572 void
573 SubProblem::storeSubdomainZeroMatProp(SubdomainID block_id, const MaterialPropertyName & name)
574 {
575  _zero_block_material_props[block_id].insert(name);
576 }
577 
578 void
579 SubProblem::storeBoundaryZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName & name)
580 {
581  _zero_boundary_material_props[boundary_id].insert(name);
582 }
583 
584 void
585 SubProblem::storeSubdomainDelayedCheckMatProp(const std::string & requestor,
586  SubdomainID block_id,
587  const std::string & name)
588 {
589  _map_block_material_props_check[block_id].insert(std::make_pair(requestor, name));
590 }
591 
592 void
593 SubProblem::storeBoundaryDelayedCheckMatProp(const std::string & requestor,
594  BoundaryID boundary_id,
595  const std::string & name)
596 {
597  _map_boundary_material_props_check[boundary_id].insert(std::make_pair(requestor, name));
598 }
599 
600 void
602 {
603  // Variable for storing all available blocks/boundaries from the mesh
604  std::set<SubdomainID> all_ids(mesh().meshSubdomains());
605 
606  std::stringstream errors;
607 
608  // Loop through the properties to check
609  for (const auto & check_it : _map_block_material_props_check)
610  {
611  // The current id for the property being checked (BoundaryID || BlockID)
612  SubdomainID check_id = check_it.first;
613 
614  std::set<SubdomainID> check_ids = {check_id};
615 
616  // Loop through all the block/boundary ids
617  for (const auto & id : check_ids)
618  {
619  // Loop through all the stored properties
620  for (const auto & prop_it : check_it.second)
621  {
622  // Produce an error if the material property is not defined on the current block/boundary
623  // and any block/boundary
624  // and not is not a zero material property.
625  if (_map_block_material_props[id].count(prop_it.second) == 0 &&
626  _zero_block_material_props[id].count(prop_it.second) == 0)
627  {
628  std::string check_name = restrictionSubdomainCheckName(id);
629  if (check_name.empty())
630  check_name = std::to_string(id);
631  errors << "Material property '" << prop_it.second << "', requested by '" << prop_it.first
632  << "' is not defined on block " << check_name << "\n";
633  }
634  }
635  }
636  }
637 
638  if (!errors.str().empty())
639  mooseError(errors.str());
640 }
641 
642 void
644 {
645  // Variable for storing the value for ANY_BOUNDARY_ID
647 
648  // Variable for storing all available blocks/boundaries from the mesh
649  std::set<BoundaryID> all_ids(mesh().getBoundaryIDs());
650 
651  std::stringstream errors;
652 
653  // Loop through the properties to check
654  for (const auto & check_it : _map_boundary_material_props_check)
655  {
656  // The current id for the property being checked (BoundaryID || BlockID)
657  BoundaryID check_id = check_it.first;
658 
659  // In the case when the material being checked has an ID is set to ANY, then loop through all
660  // the possible ids and verify that the material property is defined.
661  std::set<BoundaryID> check_ids{check_id};
662  if (check_id == any_id)
663  check_ids = all_ids;
664 
665  // Loop through all the block/boundary ids
666  for (const auto & id : check_ids)
667  {
668  // Loop through all the stored properties
669  for (const auto & prop_it : check_it.second)
670  {
671  // Produce an error if the material property is not defined on the current block/boundary
672  // and any block/boundary
673  // and not is not a zero material property.
674  if (_map_boundary_material_props[id].count(prop_it.second) == 0 &&
675  _map_boundary_material_props[any_id].count(prop_it.second) == 0 &&
676  _zero_boundary_material_props[id].count(prop_it.second) == 0 &&
677  _zero_boundary_material_props[any_id].count(prop_it.second) == 0)
678  {
679  std::string check_name = restrictionBoundaryCheckName(id);
680  if (check_name.empty())
681  check_name = std::to_string(id);
682  errors << "Material property '" << prop_it.second << "', requested by '" << prop_it.first
683  << "' is not defined on boundary " << check_name << "\n";
684  }
685  }
686  }
687  }
688 
689  if (!errors.str().empty())
690  mooseError(errors.str());
691 }
692 
693 void
694 SubProblem::markMatPropRequested(const std::string & prop_name)
695 {
696  _material_property_requested.insert(prop_name);
697 }
698 
699 bool
700 SubProblem::isMatPropRequested(const std::string & prop_name) const
701 {
702  return _material_property_requested.find(prop_name) != _material_property_requested.end();
703 }
704 
705 void
706 SubProblem::addConsumedPropertyName(const MooseObjectName & obj_name, const std::string & prop_name)
707 {
708  _consumed_material_properties[obj_name].insert(prop_name);
709 }
710 
711 const std::map<MooseObjectName, std::set<std::string>> &
713 {
715 }
716 
719 {
720  return _dirac_kernel_info;
721 }
722 
723 Real
725 {
726  return 0;
727 }
728 
729 unsigned int
731 {
732  return 0;
733 }
734 
735 unsigned int
736 SubProblem::nLinearIterations(unsigned int) const
737 {
738  return 0;
739 }
740 
741 void
743 {
744  mooseError("This system does not support changing the mesh");
745 }
746 
747 std::string
749 {
750  // TODO: Put a better a interface in MOOSE
751  std::map<subdomain_id_type, std::string> & name_map = mesh().getMesh().set_subdomain_name_map();
752  std::map<subdomain_id_type, std::string>::const_iterator pos = name_map.find(check_id);
753  if (pos != name_map.end())
754  return pos->second;
755  return "";
756 }
757 
758 std::string
760 {
761  return mesh().getMesh().get_boundary_info().sideset_name(check_id);
762 }
763 
764 void
766 {
767  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
768  assembly(tid, nl_sys_num).setCurrentBoundaryID(bid);
769 }
770 
771 unsigned int
773 {
774  return mesh().getAxisymmetricRadialCoord();
775 }
776 
777 template <typename T>
780  const std::string & var_name,
781  Moose::VarKindType expected_var_type,
782  Moose::VarFieldType expected_var_field_type,
783  const std::vector<T> & systems,
784  const SystemBase & aux) const
785 {
786  // Eventual return value
787  MooseVariableFEBase * var = nullptr;
788 
789  const auto [var_in_sys, sys_num] = determineSolverSystem(var_name);
790 
791  // First check that the variable is found on the expected system.
792  if (expected_var_type == Moose::VarKindType::VAR_ANY)
793  {
794  if (var_in_sys)
795  var = &(systems[sys_num]->getVariable(tid, var_name));
796  else if (aux.hasVariable(var_name))
797  var = &(aux.getVariable(tid, var_name));
798  else
799  mooseError("Unknown variable " + var_name);
800  }
801  else if (expected_var_type == Moose::VarKindType::VAR_SOLVER && var_in_sys &&
802  systems[sys_num]->hasVariable(var_name))
803  var = &(systems[sys_num]->getVariable(tid, var_name));
804  else if (expected_var_type == Moose::VarKindType::VAR_AUXILIARY && aux.hasVariable(var_name))
805  var = &(aux.getVariable(tid, var_name));
806  else
807  {
808  std::string expected_var_type_string =
809  (expected_var_type == Moose::VarKindType::VAR_SOLVER ? "nonlinear" : "auxiliary");
810  mooseError("No ",
811  expected_var_type_string,
812  " variable named ",
813  var_name,
814  " found. "
815  "Did you specify an auxiliary variable when you meant to specify a nonlinear "
816  "variable (or vice-versa)?");
817  }
818 
819  // Now make sure the var found has the expected field type.
820  if ((expected_var_field_type == Moose::VarFieldType::VAR_FIELD_ANY) ||
821  (expected_var_field_type == var->fieldType()))
822  return *var;
823  else
824  {
825  std::string expected_var_field_type_string =
826  MooseUtils::toLower(Moose::stringify(expected_var_field_type));
827  std::string var_field_type_string = MooseUtils::toLower(Moose::stringify(var->fieldType()));
828 
829  mooseError("No ",
830  expected_var_field_type_string,
831  " variable named ",
832  var_name,
833  " found. "
834  "Did you specify a ",
835  var_field_type_string,
836  " variable when you meant to specify a ",
837  expected_var_field_type_string,
838  " variable?");
839  }
840 }
841 
842 void
844  unsigned int side,
845  BoundaryID bnd_id,
846  Real tolerance,
847  const std::vector<Point> * const pts,
848  const std::vector<Real> * const weights,
849  const THREAD_ID tid)
850 {
851  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
852  {
853  // - Set our _current_elem for proper dof index getting in the moose variables
854  // - Reinitialize all of our FE objects so we have current phi, dphi, etc. data
855  // Note that our number of shape functions will reflect the number of shapes associated with the
856  // interior element while the number of quadrature points will be determined by the passed pts
857  // parameter (which presumably will have a number of pts reflective of a facial quadrature rule)
858  assembly(tid, nl_sys_num).reinitElemFaceRef(elem, side, tolerance, pts, weights);
859 
860  auto & nl = systemBaseNonlinear(nl_sys_num);
861 
862  // Actually get the dof indices in the moose variables
863  nl.prepare(tid);
864 
865  // Let's finally compute our variable values!
866  nl.reinitElemFace(elem, side, bnd_id, tid);
867  }
868 
869  // do same for aux as for nl
871  systemBaseAuxiliary().reinitElemFace(elem, side, bnd_id, tid);
872 
873  // With the dof indices set in the moose variables, now let's properly size
874  // our local residuals/Jacobians
875  auto & current_assembly = assembly(tid, currentNlSysNum());
877  current_assembly.prepareJacobianBlock();
879  current_assembly.prepareResidual();
880 }
881 
882 void
883 SubProblem::reinitNeighborFaceRef(const Elem * neighbor_elem,
884  unsigned int neighbor_side,
885  BoundaryID bnd_id,
886  Real tolerance,
887  const std::vector<Point> * const pts,
888  const std::vector<Real> * const weights,
889  const THREAD_ID tid)
890 {
891  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
892  {
893  // - Set our _current_neighbor_elem for proper dof index getting in the moose variables
894  // - Reinitialize all of our FE objects so we have current phi, dphi, etc. data
895  // Note that our number of shape functions will reflect the number of shapes associated with the
896  // interior element while the number of quadrature points will be determined by the passed pts
897  // parameter (which presumably will have a number of pts reflective of a facial quadrature rule)
898  assembly(tid, nl_sys_num)
899  .reinitNeighborFaceRef(neighbor_elem, neighbor_side, tolerance, pts, weights);
900 
901  auto & nl = systemBaseNonlinear(nl_sys_num);
902 
903  // Actually get the dof indices in the moose variables
904  nl.prepareNeighbor(tid);
905 
906  // Let's finally compute our variable values!
907  nl.reinitNeighborFace(neighbor_elem, neighbor_side, bnd_id, tid);
908  }
909 
910  // do same for aux as for nl
912  systemBaseAuxiliary().reinitNeighborFace(neighbor_elem, neighbor_side, bnd_id, tid);
913 
914  // With the dof indices set in the moose variables, now let's properly size
915  // our local residuals/Jacobians
917 }
918 
919 void
921  const THREAD_ID tid,
922  const std::vector<Point> * const pts,
923  const std::vector<Real> * const weights)
924 {
925  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
926  {
927  // - Set our _current_lower_d_elem for proper dof index getting in the moose variables
928  // - Reinitialize all of our lower-d FE objects so we have current phi, dphi, etc. data
929  assembly(tid, nl_sys_num).reinitLowerDElem(elem, pts, weights);
930 
931  auto & nl = systemBaseNonlinear(nl_sys_num);
932 
933  // Actually get the dof indices in the moose variables
934  nl.prepareLowerD(tid);
935 
936  // With the dof indices set in the moose variables, now let's properly size
937  // our local residuals/Jacobians
938  assembly(tid, nl_sys_num).prepareLowerD();
939 
940  // Let's finally compute our variable values!
941  nl.reinitLowerD(tid);
942  }
943 
944  // do same for aux as for nl
947 }
948 
949 void
950 SubProblem::reinitNeighborLowerDElem(const Elem * elem, const THREAD_ID tid)
951 {
952  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
953  assembly(tid, nl_sys_num).reinitNeighborLowerDElem(elem);
954 }
955 
956 void
957 SubProblem::reinitMortarElem(const Elem * elem, const THREAD_ID tid)
958 {
959  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
960  assembly(tid, nl_sys_num).reinitMortarElem(elem);
961 }
962 
963 void
964 SubProblem::cloneAlgebraicGhostingFunctor(GhostingFunctor & algebraic_gf, bool to_mesh)
965 {
966  EquationSystems & eq = es();
967  const auto n_sys = eq.n_systems();
968 
969  auto pr = _root_alg_gf_to_sys_clones.emplace(
970  &algebraic_gf, std::vector<std::shared_ptr<GhostingFunctor>>(n_sys - 1));
971  mooseAssert(pr.second, "We are adding a duplicate algebraic ghosting functor");
972  auto & clones_vec = pr.first->second;
973 
974  for (MooseIndex(n_sys) i = 1; i < n_sys; ++i)
975  {
976  DofMap & dof_map = eq.get_system(i).get_dof_map();
977  std::shared_ptr<GhostingFunctor> clone_alg_gf = algebraic_gf.clone();
979  ->init(mesh(), *algebraic_gf.get_mesh(), &dof_map);
980  dof_map.add_algebraic_ghosting_functor(clone_alg_gf, to_mesh);
981  clones_vec[i - 1] = clone_alg_gf;
982  }
983 }
984 
985 void
986 SubProblem::addAlgebraicGhostingFunctor(GhostingFunctor & algebraic_gf, bool to_mesh)
987 {
988  EquationSystems & eq = es();
989  const auto n_sys = eq.n_systems();
990  if (!n_sys)
991  return;
992 
993  eq.get_system(0).get_dof_map().add_algebraic_ghosting_functor(algebraic_gf, to_mesh);
994  cloneAlgebraicGhostingFunctor(algebraic_gf, to_mesh);
995 }
996 
997 void
998 SubProblem::cloneCouplingGhostingFunctor(GhostingFunctor & coupling_gf, bool to_mesh)
999 {
1000  const std::size_t num_nl_sys = numNonlinearSystems();
1001 
1002  auto pr = _root_coupling_gf_to_sys_clones.emplace(
1003  &coupling_gf, std::vector<std::shared_ptr<GhostingFunctor>>(num_nl_sys - 1));
1004  mooseAssert(pr.second, "We are adding a duplicate coupling functor");
1005  auto & clones_vec = pr.first->second;
1006 
1007  for (const auto i : make_range(std::size_t(1), num_nl_sys))
1008  {
1009  DofMap & dof_map = systemBaseNonlinear(i).system().get_dof_map();
1010  std::shared_ptr<GhostingFunctor> clone_coupling_gf = coupling_gf.clone();
1012  ->init(mesh(), *coupling_gf.get_mesh(), &dof_map);
1013  dof_map.add_coupling_functor(clone_coupling_gf, to_mesh);
1014  clones_vec[i - 1] = clone_coupling_gf;
1015  }
1016 }
1017 
1018 void
1019 SubProblem::addCouplingGhostingFunctor(GhostingFunctor & coupling_gf, bool to_mesh)
1020 {
1021  const auto num_nl_sys = numNonlinearSystems();
1022  if (!num_nl_sys)
1023  return;
1024 
1025  systemBaseNonlinear(0).system().get_dof_map().add_coupling_functor(coupling_gf, to_mesh);
1026  cloneCouplingGhostingFunctor(coupling_gf, to_mesh);
1027 }
1028 
1029 void
1030 SubProblem::removeAlgebraicGhostingFunctor(GhostingFunctor & algebraic_gf)
1031 {
1032  EquationSystems & eq = es();
1033  const auto n_sys = eq.n_systems();
1034 
1035 #ifndef NDEBUG
1036  const DofMap & nl_dof_map = eq.get_system(0).get_dof_map();
1037  const bool found_in_root_sys =
1038  std::find(nl_dof_map.algebraic_ghosting_functors_begin(),
1039  nl_dof_map.algebraic_ghosting_functors_end(),
1040  &algebraic_gf) != nl_dof_map.algebraic_ghosting_functors_end();
1041  const bool found_in_our_map =
1042  _root_alg_gf_to_sys_clones.find(&algebraic_gf) != _root_alg_gf_to_sys_clones.end();
1043  mooseAssert(found_in_root_sys == found_in_our_map,
1044  "If the ghosting functor exists in the root DofMap, then we need to have a key for "
1045  "it in our gf to clones map");
1046 #endif
1047 
1048  eq.get_system(0).get_dof_map().remove_algebraic_ghosting_functor(algebraic_gf);
1049 
1050  auto it = _root_alg_gf_to_sys_clones.find(&algebraic_gf);
1051  if (it == _root_alg_gf_to_sys_clones.end())
1052  return;
1053 
1054  auto & clones_vec = it->second;
1055  mooseAssert((n_sys - 1) == clones_vec.size(),
1056  "The size of the gf clones vector doesn't match the number of systems minus one");
1057  if (clones_vec.empty())
1058  {
1059  mooseAssert(n_sys == 1, "The clones vector should only be empty if there is only one system");
1060  return;
1061  }
1062 
1063  for (const auto i : make_range(n_sys))
1064  eq.get_system(i + 1).get_dof_map().remove_algebraic_ghosting_functor(*clones_vec[i]);
1065 
1066  _root_alg_gf_to_sys_clones.erase(it->first);
1067 }
1068 
1069 void
1070 SubProblem::removeCouplingGhostingFunctor(GhostingFunctor & coupling_gf)
1071 {
1072  EquationSystems & eq = es();
1073  const auto num_nl_sys = numNonlinearSystems();
1074  if (!num_nl_sys)
1075  return;
1076 
1077 #ifndef NDEBUG
1078  const DofMap & nl_dof_map = eq.get_system(0).get_dof_map();
1079  const bool found_in_root_sys = std::find(nl_dof_map.coupling_functors_begin(),
1080  nl_dof_map.coupling_functors_end(),
1081  &coupling_gf) != nl_dof_map.coupling_functors_end();
1082  const bool found_in_our_map =
1084  mooseAssert(found_in_root_sys == found_in_our_map,
1085  "If the ghosting functor exists in the root DofMap, then we need to have a key for "
1086  "it in our gf to clones map");
1087 #endif
1088 
1089  eq.get_system(0).get_dof_map().remove_coupling_functor(coupling_gf);
1090 
1091  auto it = _root_coupling_gf_to_sys_clones.find(&coupling_gf);
1092  if (it == _root_coupling_gf_to_sys_clones.end())
1093  return;
1094 
1095  auto & clones_vec = it->second;
1096  mooseAssert((num_nl_sys - 1) == clones_vec.size(),
1097  "The size of the gf clones vector doesn't match the number of systems minus one");
1098  if (clones_vec.empty())
1099  {
1100  mooseAssert(num_nl_sys == 1,
1101  "The clones vector should only be empty if there is only one nonlinear system");
1102  return;
1103  }
1104 
1105  for (const auto i : make_range(num_nl_sys))
1106  eq.get_system(i + 1).get_dof_map().remove_coupling_functor(*clones_vec[i]);
1107 
1108  _root_coupling_gf_to_sys_clones.erase(it->first);
1109 }
1110 
1111 void
1112 SubProblem::automaticScaling(bool automatic_scaling)
1113 {
1114  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1115  systemBaseNonlinear(nl_sys_num).automaticScaling(automatic_scaling);
1116 }
1117 
1118 bool
1120 {
1121  // Currently going to assume that we are applying or not applying automatic scaling consistently
1122  // across nonlinear systems
1124 }
1125 
1126 void
1127 SubProblem::hasScalingVector(const unsigned int nl_sys_num)
1128 {
1129  for (const THREAD_ID tid : make_range(libMesh::n_threads()))
1130  assembly(tid, nl_sys_num).hasScalingVector();
1131 }
1132 
1133 void
1135 {
1136  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1139 }
1140 
1141 void
1143 {
1144  for (auto & map : _pbblf_functors)
1145  for (auto & pr : map)
1146  pr.second->timestepSetup();
1147 }
1148 
1149 void
1151 {
1152  for (auto & map : _pbblf_functors)
1153  for (auto & pr : map)
1154  pr.second->customSetup(exec_type);
1155 }
1156 
1157 void
1159 {
1160  for (auto & map : _pbblf_functors)
1161  for (auto & pr : map)
1162  pr.second->residualSetup();
1163 }
1164 
1165 void
1167 {
1168  for (auto & map : _pbblf_functors)
1169  for (auto & pr : map)
1170  pr.second->jacobianSetup();
1171 }
1172 
1173 void
1175 {
1176  if (_output_functors)
1177  {
1178  showFunctors();
1180  }
1181 
1182  for (const auto & functors : _functors)
1183  for (const auto & [functor_wrapper_name, functor_wrapper] : functors)
1184  {
1185  const auto & [true_functor_type, non_ad_functor, ad_functor] = functor_wrapper;
1186  mooseAssert(non_ad_functor->wrapsNull() == ad_functor->wrapsNull(), "These must agree");
1187  const auto functor_name = removeSubstring(functor_wrapper_name, "wraps_");
1188  if (non_ad_functor->wrapsNull())
1189  mooseError(
1190  "No functor ever provided with name '",
1191  functor_name,
1192  "', which was requested by '",
1193  MooseUtils::join(libmesh_map_find(_functor_to_requestors, functor_wrapper_name), ","),
1194  "'.");
1195  if (true_functor_type == TrueFunctorIs::NONAD ? non_ad_functor->ownsWrappedFunctor()
1196  : ad_functor->ownsWrappedFunctor())
1197  mooseError("Functor envelopes should not own the functors they wrap, but '",
1198  functor_name,
1199  "' is owned by the wrapper. Please open a MOOSE issue for help resolving this.");
1200  }
1201 }
1202 
1203 void
1205 {
1206  _console << "[DBG] Wrapped functors found in Subproblem" << std::endl;
1207  std::string functor_names = "[DBG] ";
1208  for (const auto & functor_pair : _functors[0])
1209  functor_names += std::regex_replace(functor_pair.first, std::regex("wraps_"), "") + " ";
1210  if (functor_names.size())
1211  functor_names.pop_back();
1212  _console << functor_names << std::endl;
1213 }
1214 
1215 void
1217 {
1218  for (const auto & [functor, requestors] : _functor_to_requestors)
1219  {
1220  _console << "[DBG] Requestors for wrapped functor "
1221  << std::regex_replace(functor, std::regex("wraps_"), "") << std::endl;
1222  _console << "[DBG] " << MooseUtils::join(requestors, " ") << std::endl;
1223  }
1224 }
1225 
1226 bool
1227 SubProblem::hasFunctor(const std::string & name, const THREAD_ID tid) const
1228 {
1229  mooseAssert(tid < _functors.size(), "Too large a thread ID");
1230  auto & functors = _functors[tid];
1231  return (functors.find("wraps_" + name) != functors.end());
1232 }
1233 
1236 {
1237  return mesh().getCoordSystem(sid);
1238 }
1239 
1240 void
1242 {
1243  for (const auto nl : make_range(numNonlinearSystems()))
1244  assembly(tid, nl).reinitFVFace(fi);
1245 }
1246 
1247 void
1249 {
1250  assembly(tid, currentNlSysNum())
1252 }
1253 
1254 void
1256 {
1257  assembly(tid, currentNlSysNum())
1259 }
1260 
1261 void
1263 {
1264  assembly(tid, currentNlSysNum())
1266 }
1267 
1268 void
1270 {
1272  if (hasNonlocalCoupling())
1274 }
1275 
1276 void
1278 {
1280 }
1281 
1282 void
1284 {
1286 }
1287 
1288 void
1289 SubProblem::doingPRefinement(const bool doing_p_refinement,
1290  const MultiMooseEnum & disable_p_refinement_for_families_enum)
1291 {
1292  mesh().doingPRefinement(doing_p_refinement);
1293 
1294  if (doing_p_refinement)
1295  {
1296  std::vector<FEFamily> disable_families(disable_p_refinement_for_families_enum.size());
1297  for (const auto i : index_range(disable_families))
1298  disable_families[i] =
1299  Utility::string_to_enum<FEFamily>(disable_p_refinement_for_families_enum[i]);
1300 
1301  for (const auto tid : make_range(libMesh::n_threads()))
1302  for (const auto s : make_range(numNonlinearSystems()))
1303  assembly(tid, s).havePRefinement(disable_families);
1304 
1305  auto & eq = es();
1306  for (const auto family : disable_families)
1307  for (const auto i : make_range(eq.n_systems()))
1308  {
1309  auto & system = eq.get_system(i);
1310  auto & dof_map = system.get_dof_map();
1311  for (const auto vg : make_range(system.n_variable_groups()))
1312  {
1313  const auto & var_group = system.variable_group(vg);
1314  if (var_group.type().family == family)
1315  dof_map.should_p_refine(vg, false);
1316  }
1317  }
1318 
1319  _have_p_refinement = true;
1320  }
1321 }
1322 
1323 bool
1325 {
1326  return mesh().doingPRefinement();
1327 }
1328 
1329 void
1330 SubProblem::setCurrentLowerDElem(const Elem * const lower_d_elem, const THREAD_ID tid)
1331 {
1332  for (const auto nl_sys_num : make_range(numNonlinearSystems()))
1333  assembly(tid, nl_sys_num).setCurrentLowerDElem(lower_d_elem);
1334 }
1335 
1336 template MooseVariableFEBase &
1338  const std::string & var_name,
1339  Moose::VarKindType expected_var_type,
1340  Moose::VarFieldType expected_var_field_type,
1341  const std::vector<std::shared_ptr<SolverSystem>> & nls,
1342  const SystemBase & aux) const;
1343 template MooseVariableFEBase &
1345  const std::string & var_name,
1346  Moose::VarKindType expected_var_type,
1347  Moose::VarFieldType expected_var_field_type,
1348  const std::vector<std::unique_ptr<DisplacedSystem>> & nls,
1349  const SystemBase & aux) const;
virtual MooseMesh & mesh()=0
virtual void init()=0
virtual void addCachedResidual(const THREAD_ID tid)
Definition: SubProblem.C:1262
VarFieldType
Definition: MooseTypes.h:634
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition: SubProblem.C:772
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:181
void reinitNeighborLowerDElem(const Elem *elem, const THREAD_ID tid=0)
reinitialize a neighboring lower dimensional element
Definition: SubProblem.C:950
void cacheResidualNeighbor(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Rn of all field variables and appends them to the cached ...
Definition: Assembly.C:3451
std::map< TagName, TagID > _matrix_tag_name_to_tag_id
The currently declared tags.
Definition: SubProblem.h:1006
virtual void clearActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition: SubProblem.C:362
unsigned int TagTypeID
Definition: MooseTypes.h:200
virtual unsigned int nNonlinearIterations(const unsigned int nl_sys_num) const
Definition: SubProblem.C:730
virtual void clearActiveFEVariableCoupleableVectorTags(const THREAD_ID tid)
Definition: SubProblem.C:356
virtual bool hasBoundaryMaterialProperty(BoundaryID boundary_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition: SubProblem.C:548
virtual void setActiveScalarVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition: SubProblem.C:380
MooseVariableFieldBase & getVariableHelper(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type, Moose::VarFieldType expected_var_field_type, const std::vector< T > &nls, const SystemBase &aux) const
Helper function called by getVariable that handles the logic for checking whether Variables of the re...
std::map< BoundaryID, std::multimap< std::string, std::string > > _map_boundary_material_props_check
Definition: SubProblem.h:1038
The DiracKernelInfo object is a place where all the Dirac points added by different DiracKernels are ...
const std::set< TagID > & getActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition: SubProblem.C:415
std::string toLower(const std::string &name)
Convert supplied string to lower case.
Definition: MooseUtils.C:1048
virtual void reinitNeighborFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
Compute the values of the variables at all the current points.
Definition: SystemBase.C:367
virtual std::set< BoundaryID > getMaterialPropertyBoundaryIDs(const std::string &prop_name)
Get a vector containing the block ids the material property is defined on.
Definition: SubProblem.C:503
unsigned int n_threads()
void setCurrentBoundaryID(BoundaryID i)
set the current boundary ID
Definition: Assembly.h:387
virtual void reinitLowerDElem(const Elem *lower_d_elem, const THREAD_ID tid, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Definition: SubProblem.C:920
bool hasVector(const std::string &tag_name) const
Check if the named vector exists in the system.
Definition: SystemBase.C:880
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
unsigned int TagID
Definition: MooseTypes.h:199
virtual void storeSubdomainZeroMatProp(SubdomainID block_id, const MaterialPropertyName &name)
Adds to a map based on block ids of material properties for which a zero value can be returned...
Definition: SubProblem.C:573
virtual const std::vector< VectorTag > & currentResidualVectorTags() const =0
Return the residual vector tags we are currently computing.
virtual bool hasBlockMaterialProperty(SubdomainID block_id, const std::string &prop_name)
Check if a material property is defined on a block.
Definition: SubProblem.C:489
const std::set< TagID > & getActiveFEVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition: SubProblem.C:368
std::string restrictionBoundaryCheckName(BoundaryID check_id)
Definition: SubProblem.C:759
void reinitNeighborLowerDElem(const Elem *elem)
reinitialize a neighboring lower dimensional element
Definition: Assembly.C:2375
void setCurrentLowerDElem(const Elem *const lower_d_elem)
Set the current lower dimensional element.
Definition: Assembly.h:3176
static InputParameters validParams()
Definition: Problem.C:15
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, THREAD_ID tid)
Reinit assembly info for a side of an element.
Definition: SystemBase.C:356
virtual const SystemBase & systemBaseNonlinear(const unsigned int sys_num) const =0
Return the nonlinear system object as a base class reference given the system number.
const std::set< TagID > & getActiveFEVariableCoupleableVectorTags(const THREAD_ID tid) const
Definition: SubProblem.C:374
virtual unsigned int currentNlSysNum() const =0
void addConsumedPropertyName(const MooseObjectName &obj_name, const std::string &prop_name)
Helper for tracking the object that is consuming a property for MaterialPropertyDebugOutput.
Definition: SubProblem.C:706
std::map< std::string, std::set< std::string > > _functor_to_requestors
The requestors of functors where the key is the prop name and the value is a set of names of requesto...
Definition: SubProblem.h:1124
virtual void setActiveElementalMooseVariables(const std::set< MooseVariableFieldBase *> &moose_vars, const THREAD_ID tid)
Set the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:421
virtual void setCurrentBoundaryID(BoundaryID bid, const THREAD_ID tid)
sets the current boundary ID in assembly
Definition: SubProblem.C:765
virtual void storeSubdomainDelayedCheckMatProp(const std::string &requestor, SubdomainID block_id, const std::string &name)
Adds to a map based on block ids of material properties to validate.
Definition: SubProblem.C:585
virtual void setCurrentLowerDElem(const Elem *const lower_d_elem, const THREAD_ID tid)
Set the current lower dimensional element.
Definition: SubProblem.C:1330
virtual void reinitLowerD(THREAD_ID tid)
Compute the values of the variables on the lower dimensional element.
Definition: SystemBase.C:386
virtual ~SubProblem()
Definition: SubProblem.C:79
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:82
virtual const std::set< MooseVariableFieldBase * > & getActiveElementalMooseVariables(const THREAD_ID tid) const
Get the MOOSE variables to be reinited on each element.
Definition: SubProblem.C:432
virtual void addCachedJacobian(const THREAD_ID tid)
Definition: SubProblem.C:1283
virtual void residualSetup()
Definition: SubProblem.C:1158
virtual void storeBoundaryZeroMatProp(BoundaryID boundary_id, const MaterialPropertyName &name)
Adds to a map based on boundary ids of material properties for which a zero value can be returned...
Definition: SubProblem.C:579
Class that hold the whole problem being solved.
Definition: Problem.h:19
std::unordered_map< GhostingFunctor *, std::vector< std::shared_ptr< GhostingFunctor > > > _root_alg_gf_to_sys_clones
A map from a root algebraic ghosting functor, e.g.
Definition: SubProblem.h:1158
unsigned int size() const
Return the number of active items in the MultiMooseEnum.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void storeBoundaryDelayedCheckMatProp(const std::string &requestor, BoundaryID boundary_id, const std::string &name)
Adds to a map based on boundary ids of material properties to validate.
Definition: SubProblem.C:593
void prepareNeighbor()
Definition: Assembly.C:2795
virtual bool hasMatrix(TagID tag) const
Check if the tagged matrix exists in the system.
Definition: SystemBase.h:338
void reinitFVFace(const THREAD_ID tid, const FaceInfo &fi)
reinitialize the finite volume assembly data for the provided face and thread
Definition: SubProblem.C:1241
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
static void selectVectorTagsFromSystem(const SystemBase &system, const std::vector< VectorTag > &input_vector_tags, std::set< TagID > &selected_tags)
Select the vector tags which belong to a specific system.
Definition: SubProblem.C:267
bool _output_functors
Whether to output a list of the functors used and requested (currently only at initialSetup) ...
Definition: SubProblem.h:1131
void addAlgebraicGhostingFunctor(GhostingFunctor &algebraic_gf, bool to_mesh=true)
Add an algebraic ghosting functor to this problem&#39;s DofMaps.
Definition: SubProblem.C:986
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual void jacobianSetup()
Definition: SubProblem.C:1166
void setActiveVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the variables.
Definition: SystemBase.C:1545
void showFunctors() const
Lists all functors in the problem.
Definition: SubProblem.C:1204
Base class for a system (of equations)
Definition: SystemBase.h:85
const bool & currentlyComputingResidualAndJacobian() const
Returns true if the problem is in the process of computing the residual and the Jacobian.
Definition: SubProblem.h:1431
std::vector< VectorTag > _vector_tags
The declared vector tags.
Definition: SubProblem.h:1134
virtual void clearActiveElementalMooseVariables(const THREAD_ID tid)
Clear the active elemental MooseVariableFieldBase.
Definition: SubProblem.C:444
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
virtual void markMatPropRequested(const std::string &)
Helper method for adding a material property name to the _material_property_requested set...
Definition: SubProblem.C:694
void clearAllDofIndices()
Clear dof indices from variables in nl and aux systems.
Definition: SubProblem.C:1134
std::vector< std::set< TagID > > _active_sc_var_coupleable_vector_tags
Definition: SubProblem.h:1054
std::map< BoundaryID, std::set< MaterialPropertyName > > _zero_boundary_material_props
Definition: SubProblem.h:1026
void cacheJacobian(GlobalDataKey)
Takes the values that are currently in _sub_Kee and appends them to the cached values.
Definition: Assembly.C:4054
virtual EquationSystems & es()=0
bool verifyVectorTags() const
Verify the integrity of _vector_tags and _typed_vector_tags.
Definition: SubProblem.C:219
void addCachedResiduals(GlobalDataKey, const std::vector< VectorTag > &tags)
Pushes all cached residuals to the global residual vectors associated with each tag.
Definition: Assembly.C:3481
const std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid) const
Definition: SubProblem.C:409
std::map< BoundaryID, std::set< std::string > > _map_boundary_material_props
Map for boundary material properties (boundary_id -> list of properties)
Definition: SubProblem.h:1022
virtual Real finalNonlinearResidual(const unsigned int nl_sys_num) const
Definition: SubProblem.C:724
void setActiveScalarVariableCoupleableVectorTags(const std::set< TagID > &vtags, THREAD_ID tid)
Set the active vector tags for the scalar variables.
Definition: SystemBase.C:1551
virtual void customSetup(const ExecFlagType &exec_type)
Definition: SubProblem.C:1150
virtual void checkBoundaryMatProps()
Checks boundary material properties integrity.
Definition: SubProblem.C:643
virtual void setActiveScalarVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition: SubProblem.C:387
void prepareLowerD()
Prepare the Jacobians and residuals for a lower dimensional element.
Definition: Assembly.C:2834
bool automaticScaling() const
Automatic scaling getter.
Definition: SubProblem.C:1119
void reinitLowerDElem(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for a lower dimenesional element with a given set of reference points...
Definition: Assembly.C:2282
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:35
virtual void reinitNeighborFaceRef(const Elem *neighbor_elem, unsigned int neighbor_side, BoundaryID bnd_id, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0)
reinitialize FE objects on a given neighbor element on a given side at a given set of reference point...
Definition: SubProblem.C:883
void removeCouplingGhostingFunctor(GhostingFunctor &coupling_gf)
Remove a coupling ghosting functor from this problem&#39;s DofMaps.
Definition: SubProblem.C:1070
virtual bool isMatPropRequested(const std::string &prop_name) const
Find out if a material property has been requested by any object.
Definition: SubProblem.C:700
std::map< MooseObjectName, std::set< std::string > > _consumed_material_properties
Definition: SubProblem.h:1152
void removeAlgebraicGhostingFunctor(GhostingFunctor &algebraic_gf)
Remove an algebraic ghosting functor from this problem&#39;s DofMaps.
Definition: SubProblem.C:1030
bool automaticScaling() const
Getter for whether we are performing automatic scaling.
Definition: SystemBase.h:123
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3199
std::map< TagID, TagName > _matrix_tag_id_to_tag_name
Reverse map.
Definition: SubProblem.h:1009
virtual bool hasNonlocalCoupling() const =0
Whether the simulation has nonlocal coupling which should be accounted for in the Jacobian...
virtual DiracKernelInfo & diracKernelInfo()
Definition: SubProblem.C:718
virtual void setActiveFEVariableCoupleableVectorTags(std::set< TagID > &vtags, const THREAD_ID tid)
Definition: SubProblem.C:347
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:320
virtual const SystemBase & systemBaseAuxiliary() const =0
Return the auxiliary system object as a base class reference.
virtual void clearActiveScalarVariableCoupleableVectorTags(const THREAD_ID tid)
Definition: SubProblem.C:397
void cacheJacobianNeighbor(GlobalDataKey)
Takes the values that are currently in the neighbor Dense Matrices and appends them to the cached val...
Definition: Assembly.C:4106
unsigned int getAxisymmetricRadialCoord() const
Returns the desired radial direction for RZ coordinate transformation.
Definition: MooseMesh.C:4038
std::vector< std::multimap< std::string, std::pair< bool, bool > > > _functor_to_request_info
A multimap (for each thread) from unfilled functor requests to whether the requests were for AD funct...
Definition: SubProblem.h:1128
boundary_id_type BoundaryID
virtual unsigned int nLinearIterations(const unsigned int nl_sys_num) const
Definition: SubProblem.C:736
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:1127
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:627
virtual void storeBoundaryMatPropName(BoundaryID boundary_id, const std::string &name)
Adds the given material property to a storage map based on boundary ids.
Definition: SubProblem.C:567
SubProblem(const InputParameters &parameters)
Definition: SubProblem.C:49
virtual void prepareNeighbor(THREAD_ID tid)
Prepare the system for use.
Definition: SystemBase.C:320
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
Definition: SubProblem.C:289
std::string restrictionSubdomainCheckName(SubdomainID check_id)
Helper functions for checking MaterialProperties.
Definition: SubProblem.C:748
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const
Definition: SubProblem.C:209
void cacheResidual(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Re of all field variables and appends them to the cached ...
Definition: Assembly.C:3400
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
virtual void checkBlockMatProps()
Checks block material properties integrity.
Definition: SubProblem.C:601
void havePRefinement(const std::vector< FEFamily > &disable_p_refinement_for_families)
Indicate that we have p-refinement.
Definition: Assembly.C:4834
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition: SubProblem.C:150
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
Gets the boundary IDs with their names.
virtual void reinitElemFaceRef(const Elem *elem, unsigned int side, BoundaryID bnd_id, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0)
reinitialize FE objects on a given element on a given side at a given set of reference points and the...
Definition: SubProblem.C:843
virtual std::vector< SubdomainName > getMaterialPropertyBlockNames(const std::string &prop_name)
Get a vector of block id equivalences that the material property is defined on.
Definition: SubProblem.C:467
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:173
virtual System & system()=0
Get the reference to the libMesh system.
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:62
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Get the coordinate system type, e.g.
Definition: MooseMesh.C:3919
void cloneCouplingGhostingFunctor(GhostingFunctor &coupling_gf, bool to_mesh=true)
Creates (n_sys - 1) clones of the provided coupling ghosting functor (corresponding to the nonlinear ...
Definition: SubProblem.C:998
virtual bool hasVariable(const std::string &var_name) const =0
Whether or not this problem has the variable.
virtual void clearActiveScalarVariableCoupleableMatrixTags(const THREAD_ID tid)
Definition: SubProblem.C:403
void showFunctorRequestors() const
Lists all functors and all the objects that requested them.
Definition: SubProblem.C:1216
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
Definition: SystemBase.C:807
bool doingPRefinement() const
Definition: SubProblem.C:1324
void reinitMortarElem(const Elem *elem)
reinitialize a mortar segment mesh element in order to get a proper JxW
Definition: Assembly.C:2396
VectorTagType
Definition: MooseTypes.h:891
virtual void cacheJacobianNeighbor(const THREAD_ID tid)
Definition: SubProblem.C:1277
void cloneAlgebraicGhostingFunctor(GhostingFunctor &algebraic_gf, bool to_mesh=true)
Creates (n_sys - 1) clones of the provided algebraic ghosting functor (corresponding to the nonlinear...
Definition: SubProblem.C:964
std::vector< std::map< std::string, std::unique_ptr< Moose::FunctorAbstract > > > _pbblf_functors
Container to hold PiecewiseByBlockLambdaFunctors.
Definition: SubProblem.h:1114
std::vector< std::set< TagID > > _active_fe_var_coupleable_vector_tags
Definition: SubProblem.h:1050
void reinitFVFace(const FaceInfo &fi)
Definition: Assembly.C:1850
virtual void cacheResidual(const THREAD_ID tid)
Definition: SubProblem.C:1248
virtual void timestepSetup()
Definition: SubProblem.C:1142
std::unordered_map< GhostingFunctor *, std::vector< std::shared_ptr< GhostingFunctor > > > _root_coupling_gf_to_sys_clones
A map from a root coupling ghosting functor, e.g.
Definition: SubProblem.h:1164
void removeSubstring(std::string &main, const std::string &sub)
find, erase, length algorithm for removing a substring from a string
Definition: MooseUtils.C:1256
std::vector< std::set< MooseVariableFieldBase * > > _active_elemental_moose_variables
This is the set of MooseVariableFieldBase that will actually get reinited by a call to reinit(elem) ...
Definition: SubProblem.h:1042
virtual std::set< SubdomainID > getMaterialPropertyBlocks(const std::string &prop_name)
Get a vector containing the block ids the material property is defined on.
Definition: SubProblem.C:451
virtual void initialSetup()
Definition: SubProblem.C:1174
bool _have_p_refinement
Whether p-refinement has been requested at any point during the simulation.
Definition: SubProblem.h:1167
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
RelationshipManagers are used for describing what kinds of non-local resources are needed for an obje...
void hasScalingVector()
signals this object that a vector containing variable scaling factors should be used when doing resid...
Definition: Assembly.C:4568
std::map< SubdomainID, std::set< MaterialPropertyName > > _zero_block_material_props
Set of properties returned as zero properties.
Definition: SubProblem.h:1025
CoordinateSystemType
Definition: MooseTypes.h:722
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
virtual std::vector< BoundaryName > getMaterialPropertyBoundaryNames(const std::string &prop_name)
Get a vector of block id equivalences that the material property is defined on.
Definition: SubProblem.C:519
void reinitNeighborFaceRef(const Elem *neighbor_elem, unsigned int neighbor_side, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for the given neighbor_element on the given side with a given set of reference p...
Definition: Assembly.C:2186
std::map< TagName, TagID > _vector_tags_name_map
Map of vector tag TagName to TagID.
Definition: SubProblem.h:1144
std::vector< unsigned int > _has_active_elemental_moose_variables
Whether or not there is currently a list of active elemental moose variables.
Definition: SubProblem.h:1046
std::vector< std::vector< VectorTag > > _typed_vector_tags
The vector tags associated with each VectorTagType This is kept separate from _vector_tags for quick ...
Definition: SubProblem.h:1141
virtual Assembly & assembly(const THREAD_ID tid, const unsigned int sys_num)=0
void addCouplingGhostingFunctor(GhostingFunctor &coupling_gf, bool to_mesh=true)
Add a coupling functor to this problem&#39;s DofMaps.
Definition: SubProblem.C:1019
static void selectMatrixTagsFromSystem(const SystemBase &system, const std::map< TagName, TagID > &input_matrix_tags, std::set< TagID > &selected_tags)
Select the matrix tags which belong to a specific system.
Definition: SubProblem.C:278
virtual std::pair< bool, unsigned int > determineSolverSystem(const std::string &var_name, bool error_if_not_found=false) const =0
void cacheJacobianNonlocal(GlobalDataKey)
Takes the values that are currently in _sub_Keg and appends them to the cached values.
Definition: Assembly.C:4084
IntRange< T > make_range(T beg, T end)
std::set< std::string > _material_property_requested
set containing all material property names that have been requested by getMaterialProperty* ...
Definition: SubProblem.h:1029
virtual Moose::VarFieldType fieldType() const =0
Filed type of this variable.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
The total number of tags, which can be limited to the tag type.
Definition: SubProblem.C:173
virtual void prepare(THREAD_ID tid)
Prepare the system for use.
Definition: SystemBase.C:252
virtual void setActiveFEVariableCoupleableMatrixTags(std::set< TagID > &mtags, const THREAD_ID tid)
Definition: SubProblem.C:341
void reinitElemFaceRef(const Elem *elem, unsigned int elem_side, Real tolerance, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Reinitialize FE data for the given element on the given side, optionally with a given set of referenc...
Definition: Assembly.C:2015
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
std::vector< std::multimap< std::string, std::tuple< TrueFunctorIs, std::unique_ptr< Moose::FunctorEnvelopeBase >, std::unique_ptr< Moose::FunctorEnvelopeBase > > > > _functors
A container holding pointers to all the functors in our problem.
Definition: SubProblem.h:1111
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Definition: SubProblem.C:1235
virtual void cacheResidualNeighbor(const THREAD_ID tid)
Definition: SubProblem.C:1255
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:199
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:438
virtual void prepareLowerD(THREAD_ID tid)
Prepare the system for use for lower dimensional elements.
Definition: SystemBase.C:328
static InputParameters validParams()
Definition: SubProblem.C:34
std::map< SubdomainID, std::multimap< std::string, std::string > > _map_block_material_props_check
Data structures of the requested material properties.
Definition: SubProblem.h:1037
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
Definition: SystemBase.C:86
void doingPRefinement(bool doing_p_refinement)
Indicate whether the kind of adaptivity we&#39;re doing is p-refinement.
Definition: MooseMesh.h:1325
const bool & currentlyComputingJacobian() const
Returns true if the problem is in the process of computing the Jacobian.
Definition: SubProblem.h:654
virtual std::size_t numNonlinearSystems() const =0
bool hasFunctor(const std::string &name, const THREAD_ID tid) const
checks whether we have a functor corresponding to name on the thread id tid
Definition: SubProblem.C:1227
const std::map< MooseObjectName, std::set< std::string > > & getConsumedPropertyMap() const
Return the map that tracks the object with consumed material properties.
Definition: SubProblem.C:712
Storage for all of the information pretaining to a vector tag.
Definition: VectorTag.h:15
DiracKernelInfo _dirac_kernel_info
nonlocal coupling matrix;
Definition: SubProblem.h:1016
std::map< SubdomainID, std::set< std::string > > _map_block_material_props
Map of material properties (block_id -> list of properties)
Definition: SubProblem.h:1019
A class for storing the names of MooseObject by tag and object name.
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition: Assembly.C:3811
std::vector< std::set< TagID > > _active_fe_var_coupleable_matrix_tags
Definition: SubProblem.h:1048
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
Definition: SubProblem.C:139
std::vector< std::set< TagID > > _active_sc_var_coupleable_matrix_tags
Definition: SubProblem.h:1052
void clearAllDofIndices()
Clear all dof indices from moose variables.
Definition: SystemBase.C:1538
auto index_range(const T &sizable)
virtual void storeSubdomainMatPropName(SubdomainID block_id, const std::string &name)
Adds the given material property to a storage map based on block ids.
Definition: SubProblem.C:561
std::string join(const T &strings, const std::string &delimiter)
Python like join function for strings.
Definition: MooseUtils.h:130
virtual void cacheJacobian(const THREAD_ID tid)
Definition: SubProblem.C:1269
virtual void meshChanged()
Definition: SubProblem.C:742
void reinitMortarElem(const Elem *elem, const THREAD_ID tid=0)
Reinit a mortar element to obtain a valid JxW.
Definition: SubProblem.C:957
virtual bool matrixTagExists(const TagName &tag_name) const
Check to see if a particular Tag exists.
Definition: SubProblem.C:306
virtual TagName matrixTagName(TagID tag)
Retrieve the name associated with a TagID.
Definition: SubProblem.C:335
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:23
unsigned int THREAD_ID
Definition: MooseTypes.h:198
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...
Key structure for APIs manipulating global vectors/matrices.
Definition: Assembly.h:794