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