www.mooseframework.org
DisplacedProblem.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 // MOOSE includes
11 
12 #include "AuxiliarySystem.h"
13 #include "FEProblem.h"
14 #include "MooseApp.h"
15 #include "MooseMesh.h"
16 #include "NonlinearSystem.h"
17 #include "Problem.h"
19 #include "SubProblem.h"
21 #include "Assembly.h"
22 #include "DisplacedProblem.h"
23 #include "libmesh/numeric_vector.h"
24 #include "libmesh/fe_interface.h"
25 #include "libmesh/mesh_base.h"
26 
28 
31 {
33  params.addClassDescription(
34  "A Problem object for providing access to the displaced finite element "
35  "mesh and associated variables.");
36  params.addPrivateParam<MooseMesh *>("mesh");
37  params.addPrivateParam<std::vector<std::string>>("displacements", {});
38  return params;
39 }
40 
42  : SubProblem(parameters),
43  _mproblem(parameters.have_parameter<FEProblemBase *>("_fe_problem_base")
44  ? *getParam<FEProblemBase *>("_fe_problem_base")
45  : *getParam<FEProblem *>("_fe_problem")),
46  _mesh(*getParam<MooseMesh *>("mesh")),
47  _eq(_mesh),
48  _ref_mesh(_mproblem.mesh()),
49  _displacements(getParam<std::vector<std::string>>("displacements")),
50  _geometric_search_data(*this, _mesh)
51 
52 {
53  // TODO: Move newAssemblyArray further up to SubProblem so that we can use it here
54  unsigned int n_threads = libMesh::n_threads();
55 
56  _assembly.resize(n_threads);
57  for (const auto nl_sys_num : make_range(_mproblem.numNonlinearSystems()))
58  {
59  _displaced_nl.emplace_back(std::make_unique<DisplacedSystem>(
60  *this,
62  "displaced_" + _mproblem.getNonlinearSystemBase(nl_sys_num).name() + "_" +
63  std::to_string(nl_sys_num),
65  auto & displaced_nl = _displaced_nl.back();
66 
67  for (unsigned int i = 0; i < n_threads; ++i)
68  _assembly[i].emplace_back(std::make_unique<Assembly>(*displaced_nl, i));
69 
70  displaced_nl->addTimeIntegrator(
72  }
73  _nl_solution.resize(_displaced_nl.size(), nullptr);
74 
76  std::make_unique<DisplacedSystem>(*this,
78  "displaced_" + _mproblem.getAuxiliarySystem().name(),
81 
82  // // Generally speaking, the mesh is prepared for use, and consequently remote elements are deleted
83  // // well before our Problem(s) are constructed. Historically, in MooseMesh we have a bunch of
84  // // needs_prepare type flags that make it so we never call prepare_for_use (and consequently
85  // // delete_remote_elements) again. So the below line, historically, has had no impact. HOWEVER:
86  // // I've added some code in SetupMeshCompleteAction for deleting remote elements post
87  // // EquationSystems::init. If I execute that code without default ghosting, then I get > 40 MOOSE
88  // // test failures, so we clearly have some simulations that are not yet covered properly by
89  // // relationship managers. Until that is resolved, I am going to retain default geometric ghosting
90  // if (!_default_ghosting)
91  // _mesh.getMesh().remove_ghosting_functor(_mesh.getMesh().default_ghosting());
92 
94 
96 }
97 
99 
100 bool
102 {
103  return _mproblem.isTransient();
104 }
105 
106 std::set<dof_id_type> &
108 {
109  return _mproblem.ghostedElems();
110 }
111 
112 void
114  Order order,
115  Order volume_order,
116  Order face_order,
117  SubdomainID block,
118  const bool allow_negative_qweights)
119 {
120  for (unsigned int tid = 0; tid < libMesh::n_threads(); ++tid)
121  for (const auto nl_sys_num : index_range(_assembly[tid]))
122  _assembly[tid][nl_sys_num]->createQRules(
123  type, order, volume_order, face_order, block, allow_negative_qweights);
124 }
125 
126 void
128 {
129  for (unsigned int tid = 0; tid < libMesh::n_threads(); ++tid)
130  for (const auto nl_sys_num : index_range(_assembly[tid]))
131  _assembly[tid][nl_sys_num]->bumpVolumeQRuleOrder(order, block);
132 }
133 
134 void
136 {
137  for (unsigned int tid = 0; tid < libMesh::n_threads(); ++tid)
138  for (const auto nl_sys_num : index_range(_assembly[tid]))
139  _assembly[tid][nl_sys_num]->bumpAllQRuleOrder(order, block);
140 }
141 
142 void
144 {
145  for (THREAD_ID tid = 0; tid < libMesh::n_threads(); ++tid)
146  {
147  for (const auto nl_sys_num : index_range(_displaced_nl))
148  _assembly[tid][nl_sys_num]->init(_mproblem.couplingMatrix(nl_sys_num));
149 
150  for (const auto nl_sys_num : index_range(_displaced_nl))
151  {
152  std::vector<std::pair<unsigned int, unsigned short>> disp_numbers_and_directions;
153  for (const auto direction : index_range(_displacements))
154  {
155  const auto & disp_string = _displacements[direction];
156  const auto & disp_variable = getVariable(tid, disp_string);
157  if (disp_variable.sys().number() == nl_sys_num)
158  disp_numbers_and_directions.push_back(
159  std::make_pair(disp_variable.number(), cast_int<unsigned short>(direction)));
160  }
161  _assembly[tid][nl_sys_num]->assignDisplacements(std::move(disp_numbers_and_directions));
162  }
163  }
164 
165  for (auto & nl : _displaced_nl)
166  {
167  nl->dofMap().attach_extra_send_list_function(&extraSendList, nl.get());
168  nl->init();
169  }
170 
171  _displaced_aux->dofMap().attach_extra_send_list_function(&extraSendList, _displaced_aux.get());
172  _displaced_aux->init();
173 
174  {
175  TIME_SECTION("eq::init", 2, "Initializing Displaced Equation System");
176  _eq.init();
177  }
178 
180  for (auto & nl : _displaced_nl)
181  nl->update(/*update_libmesh_system=*/false);
182  _displaced_aux->update(/*update_libmesh_system=*/false);
183 
184  _mesh.meshChanged();
185 
186  if (haveFV())
188 }
189 
190 void
192 {
193 }
194 
195 void
197 {
198  for (auto & displaced_nl : _displaced_nl)
199  displaced_nl->saveOldSolutions();
200  _displaced_aux->saveOldSolutions();
201 }
202 
203 void
205 {
206  for (auto & displaced_nl : _displaced_nl)
207  displaced_nl->restoreOldSolutions();
208  _displaced_aux->restoreOldSolutions();
209 }
210 
211 void
213 {
214  TIME_SECTION("syncSolutions", 5, "Syncing Displaced Solutions");
215 
216  for (const auto nl_sys_num : index_range(_displaced_nl))
217  {
218  auto & displaced_nl = _displaced_nl[nl_sys_num];
219  mooseAssert(nl_sys_num == displaced_nl->number(),
220  "We should have designed things such that the nl system numbers make their system "
221  "numbering in the EquationSystems object");
222  (*displaced_nl->sys().solution) =
223  *_mproblem.getNonlinearSystemBase(displaced_nl->number()).currentSolution();
224  displaced_nl->update();
225  }
227 }
228 
229 void
231  const std::map<unsigned int, const NumericVector<Number> *> & nl_solns,
232  const NumericVector<Number> & aux_soln)
233 {
234  TIME_SECTION("syncSolutions", 5, "Syncing Displaced Solutions");
235 
236  for (const auto [nl_sys_num, nl_soln] : nl_solns)
237  {
238  (*_displaced_nl[nl_sys_num]->sys().solution) = *nl_soln;
239  _displaced_nl[nl_sys_num]->update();
240  }
241  (*_displaced_aux->sys().solution) = aux_soln;
242 }
243 
244 void
245 DisplacedProblem::updateMesh(bool mesh_changing)
246 {
247  TIME_SECTION("updateMesh", 3, "Updating Displaced Mesh");
248 
249  // If the mesh is changing, we are probably performing adaptivity. In that case, we do *not* want
250  // to use the undisplaced mesh solution because it may be out-of-sync, whereas our displaced mesh
251  // solution should be in the correct state after getting restricted/prolonged in
252  // EquationSystems::reinit (must have been called before this method)
253  if (!mesh_changing)
254  syncSolutions();
255 
256  for (const auto nl_sys_num : index_range(_displaced_nl))
257  _nl_solution[nl_sys_num] = _displaced_nl[nl_sys_num]->sys().solution.get();
258  _aux_solution = _displaced_aux->sys().solution.get();
259 
260  // If the displaced mesh has been serialized to one processor (as
261  // may have occurred if it was used for Exodus output), then we need
262  // the reference mesh to be also. For that matter, did anyone
263  // somehow serialize the whole mesh? Hopefully not but let's avoid
264  // causing errors if so.
265  if (_mesh.getMesh().is_serial() && !this->refMesh().getMesh().is_serial())
266  this->refMesh().getMesh().allgather();
267 
268  if (_mesh.getMesh().is_serial_on_zero() && !this->refMesh().getMesh().is_serial_on_zero())
269  this->refMesh().getMesh().gather_to_zero();
270 
272 
273  // We displace all nodes, not just semilocal nodes, because
274  // parallel-inconsistent mesh geometry makes libMesh cry.
275  NodeRange node_range(_mesh.getMesh().nodes_begin(),
276  _mesh.getMesh().nodes_end(),
277  /*grainsize=*/1);
278 
279  Threads::parallel_reduce(node_range, udmt);
280  // Displacement of the mesh has invalidated the point locator data (e.g. bounding boxes)
281  _mesh.getMesh().clear_point_locator();
282 
283  // The mesh has changed. Face information normals, areas, etc. must be re-calculated
284  if (haveFV())
286 
287  for (auto & disp_nl : _displaced_nl)
288  disp_nl->update(false);
289  _displaced_aux->update(false);
290 
291  // Update the geometric searches that depend on the displaced mesh. This call can end up running
292  // NearestNodeThread::operator() which has a throw inside of it. We need to catch it and make sure
293  // it's propagated to all processes before updating the point locator because the latter requires
294  // communication
295  try
296  {
297  // We may need to re-run geometric operations like SecondaryNeighborhoodTread if, for instance,
298  // we have performed mesh adaptivity
299  if (mesh_changing)
301  else
303  }
304  catch (MooseException & e)
305  {
307  }
308 
309  // The below call will throw an exception on all processes if any of our processes had an
310  // exception above. This exception will be caught higher up the call stack and the error message
311  // will be printed there
312  _mproblem.checkExceptionAndStopSolve(/*print_message=*/false);
313 
314  // Since the Mesh changed, update the PointLocator object used by DiracKernels.
316 }
317 
318 void
319 DisplacedProblem::updateMesh(const std::map<unsigned int, const NumericVector<Number> *> & nl_solns,
320  const NumericVector<Number> & aux_soln)
321 {
322  TIME_SECTION("updateMesh", 3, "Updating Displaced Mesh");
323 
324  syncSolutions(nl_solns, aux_soln);
325 
326  for (const auto nl_sys_num : index_range(_displaced_nl))
327  _nl_solution[nl_sys_num] = _displaced_nl[nl_sys_num]->sys().solution.get();
328  _aux_solution = _displaced_aux->sys().solution.get();
329 
331 
332  // We displace all nodes, not just semilocal nodes, because
333  // parallel-inconsistent mesh geometry makes libMesh cry.
334  NodeRange node_range(_mesh.getMesh().nodes_begin(),
335  _mesh.getMesh().nodes_end(),
336  /*grainsize=*/1);
337 
338  Threads::parallel_reduce(node_range, udmt);
339 
340  // Update the geometric searches that depend on the displaced mesh. This call can end up running
341  // NearestNodeThread::operator() which has a throw inside of it. We need to catch it and make sure
342  // it's propagated to all processes before updating the point locator because the latter requires
343  // communication
344  try
345  {
347  }
348  catch (MooseException & e)
349  {
351  }
352 
353  // The below call will throw an exception on all processes if any of our processes had an
354  // exception above. This exception will be caught higher up the call stack and the error message
355  // will be printed there
356  _mproblem.checkExceptionAndStopSolve(/*print_message=*/false);
357 
358  // Since the Mesh changed, update the PointLocator object used by DiracKernels.
360 }
361 
362 TagID
363 DisplacedProblem::addVectorTag(const TagName & tag_name,
364  const Moose::VectorTagType type /* = Moose::VECTOR_TAG_RESIDUAL */)
365 {
366  return _mproblem.addVectorTag(tag_name, type);
367 }
368 
369 const VectorTag &
371 {
372  return _mproblem.getVectorTag(tag_id);
373 }
374 
375 TagID
376 DisplacedProblem::getVectorTagID(const TagName & tag_name) const
377 {
378  return _mproblem.getVectorTagID(tag_name);
379 }
380 
381 TagName
383 {
384  return _mproblem.vectorTagName(tag_id);
385 }
386 
387 bool
389 {
390  return _mproblem.vectorTagExists(tag_id);
391 }
392 
393 bool
394 DisplacedProblem::vectorTagExists(const TagName & tag_name) const
395 {
396  return _mproblem.vectorTagExists(tag_name);
397 }
398 
399 unsigned int
400 DisplacedProblem::numVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
401 {
402  return _mproblem.numVectorTags(type);
403 }
404 
405 const std::vector<VectorTag> &
406 DisplacedProblem::getVectorTags(const Moose::VectorTagType type /* = Moose::VECTOR_TAG_ANY */) const
407 {
408  return _mproblem.getVectorTags(type);
409 }
410 
413 {
414  return _mproblem.vectorTagType(tag_id);
415 }
416 
417 TagID
419 {
420  return _mproblem.addMatrixTag(tag_name);
421 }
422 
423 TagID
424 DisplacedProblem::getMatrixTagID(const TagName & tag_name) const
425 {
426  return _mproblem.getMatrixTagID(tag_name);
427 }
428 
429 TagName
431 {
432  return _mproblem.matrixTagName(tag);
433 }
434 
435 bool
436 DisplacedProblem::matrixTagExists(const TagName & tag_name) const
437 {
438  return _mproblem.matrixTagExists(tag_name);
439 }
440 
441 bool
443 {
444  return _mproblem.matrixTagExists(tag_id);
445 }
446 
447 unsigned int
449 {
450  return _mproblem.numMatrixTags();
451 }
452 
453 bool
454 DisplacedProblem::hasVariable(const std::string & var_name) const
455 {
456  for (auto & nl : _displaced_nl)
457  if (nl->hasVariable(var_name))
458  return true;
459  if (_displaced_aux->hasVariable(var_name))
460  return true;
461 
462  return false;
463 }
464 
467  const std::string & var_name,
468  Moose::VarKindType expected_var_type,
469  Moose::VarFieldType expected_var_field_type) const
470 {
471  return getVariableHelper(
472  tid, var_name, expected_var_type, expected_var_field_type, _displaced_nl, *_displaced_aux);
473 }
474 
476 DisplacedProblem::getStandardVariable(const THREAD_ID tid, const std::string & var_name)
477 {
478  for (auto & nl : _displaced_nl)
479  if (nl->hasVariable(var_name))
480  return nl->getFieldVariable<Real>(tid, var_name);
481  if (_displaced_aux->hasVariable(var_name))
482  return _displaced_aux->getFieldVariable<Real>(tid, var_name);
483 
484  mooseError("No variable with name '" + var_name + "'");
485 }
486 
488 DisplacedProblem::getActualFieldVariable(const THREAD_ID tid, const std::string & var_name)
489 {
490  for (auto & nl : _displaced_nl)
491  if (nl->hasVariable(var_name))
492  return nl->getActualFieldVariable<Real>(tid, var_name);
493  if (_displaced_aux->hasVariable(var_name))
494  return _displaced_aux->getActualFieldVariable<Real>(tid, var_name);
495 
496  mooseError("No variable with name '" + var_name + "'");
497 }
498 
500 DisplacedProblem::getVectorVariable(const THREAD_ID tid, const std::string & var_name)
501 {
502  for (auto & nl : _displaced_nl)
503  if (nl->hasVariable(var_name))
504  return nl->getFieldVariable<RealVectorValue>(tid, var_name);
505  if (_displaced_aux->hasVariable(var_name))
506  return _displaced_aux->getFieldVariable<RealVectorValue>(tid, var_name);
507 
508  mooseError("No variable with name '" + var_name + "'");
509 }
510 
512 DisplacedProblem::getArrayVariable(const THREAD_ID tid, const std::string & var_name)
513 {
514  for (auto & nl : _displaced_nl)
515  if (nl->hasVariable(var_name))
516  return nl->getFieldVariable<RealEigenVector>(tid, var_name);
517  if (_displaced_aux->hasVariable(var_name))
518  return _displaced_aux->getFieldVariable<RealEigenVector>(tid, var_name);
519 
520  mooseError("No variable with name '" + var_name + "'");
521 }
522 
523 bool
524 DisplacedProblem::hasScalarVariable(const std::string & var_name) const
525 {
526  for (auto & nl : _displaced_nl)
527  if (nl->hasScalarVariable(var_name))
528  return true;
529  if (_displaced_aux->hasScalarVariable(var_name))
530  return true;
531 
532  return false;
533 }
534 
536 DisplacedProblem::getScalarVariable(const THREAD_ID tid, const std::string & var_name)
537 {
538  for (auto & nl : _displaced_nl)
539  if (nl->hasScalarVariable(var_name))
540  return nl->getScalarVariable(tid, var_name);
541  if (_displaced_aux->hasScalarVariable(var_name))
542  return _displaced_aux->getScalarVariable(tid, var_name);
543 
544  mooseError("No variable with name '" + var_name + "'");
545 }
546 
547 System &
548 DisplacedProblem::getSystem(const std::string & var_name)
549 {
550  for (const auto sys_num : make_range(_eq.n_systems()))
551  {
552  auto & sys = _eq.get_system(sys_num);
553  if (sys.has_variable(var_name))
554  return sys;
555  }
556 
557  mooseError("Unable to find a system containing the variable " + var_name);
558 }
559 
560 void
561 DisplacedProblem::addVariable(const std::string & var_type,
562  const std::string & name,
563  InputParameters & parameters,
564  const unsigned int nl_system_number)
565 {
566  _displaced_nl[nl_system_number]->addVariable(var_type, name, parameters);
567 }
568 
569 void
570 DisplacedProblem::addAuxVariable(const std::string & var_type,
571  const std::string & name,
572  InputParameters & parameters)
573 {
574  _displaced_aux->addVariable(var_type, name, parameters);
575 }
576 
577 unsigned int
579 {
580  return _mproblem.currentNlSysNum();
581 }
582 
583 void
584 DisplacedProblem::prepare(const Elem * elem, const THREAD_ID tid)
585 {
586  for (const auto nl_sys_num : index_range(_displaced_nl))
587  {
588  _assembly[tid][nl_sys_num]->reinit(elem);
589  _displaced_nl[nl_sys_num]->prepare(tid);
590  // This method is called outside of residual/Jacobian callbacks during initial condition
591  // evaluation
593  _assembly[tid][nl_sys_num]->prepareJacobianBlock();
594  _assembly[tid][nl_sys_num]->prepareResidual();
595  }
596 
597  _displaced_aux->prepare(tid);
598 }
599 
600 void
602 {
603  _assembly[tid][currentNlSysNum()]->prepareNonlocal();
604 }
605 
606 void
607 DisplacedProblem::prepareFace(const Elem * /*elem*/, const THREAD_ID tid)
608 {
609  for (auto & nl : _displaced_nl)
610  nl->prepareFace(tid, true);
611  _displaced_aux->prepareFace(tid, false);
612 }
613 
614 void
615 DisplacedProblem::prepare(const Elem * elem,
616  unsigned int ivar,
617  unsigned int jvar,
618  const std::vector<dof_id_type> & dof_indices,
619  const THREAD_ID tid)
620 {
621  for (const auto nl_sys_num : index_range(_displaced_nl))
622  {
623  _assembly[tid][nl_sys_num]->reinit(elem);
624  _displaced_nl[nl_sys_num]->prepare(tid);
625  }
626  _displaced_aux->prepare(tid);
627  _assembly[tid][currentNlSysNum()]->prepareBlock(ivar, jvar, dof_indices);
628 }
629 
630 void
632 {
633  SubdomainID did = elem->subdomain_id();
634  for (auto & assembly : _assembly[tid])
636 }
637 
638 void
639 DisplacedProblem::setNeighborSubdomainID(const Elem * elem, unsigned int side, const THREAD_ID tid)
640 {
641  SubdomainID did = elem->neighbor_ptr(side)->subdomain_id();
642  for (auto & assembly : _assembly[tid])
644 }
645 
646 void
648  unsigned int jvar,
649  const std::vector<dof_id_type> & idof_indices,
650  const std::vector<dof_id_type> & jdof_indices,
651  const THREAD_ID tid)
652 {
653  _assembly[tid][currentNlSysNum()]->prepareBlockNonlocal(ivar, jvar, idof_indices, jdof_indices);
654 }
655 
656 void
658 {
659  _assembly[tid][currentNlSysNum()]->prepare();
660 }
661 
662 void
664 {
665  _assembly[tid][currentNlSysNum()]->prepareNeighbor();
666 }
667 
668 bool
669 DisplacedProblem::reinitDirac(const Elem * elem, const THREAD_ID tid)
670 {
671  std::vector<Point> & points = _dirac_kernel_info.getPoints()[elem].first;
672 
673  unsigned int n_points = points.size();
674 
675  if (n_points)
676  {
677  for (const auto nl_sys_num : index_range(_displaced_nl))
678  {
679  _assembly[tid][nl_sys_num]->reinitAtPhysical(elem, points);
680  _displaced_nl[nl_sys_num]->prepare(tid);
681  }
682  _displaced_aux->prepare(tid);
683 
684  reinitElem(elem, tid);
685  }
686 
687  _assembly[tid][currentNlSysNum()]->prepare();
688 
689  return n_points > 0;
690 }
691 
692 void
693 DisplacedProblem::reinitElem(const Elem * elem, const THREAD_ID tid)
694 {
695  for (auto & nl : _displaced_nl)
696  nl->reinitElem(elem, tid);
697  _displaced_aux->reinitElem(elem, tid);
698 }
699 
700 void
702  const std::vector<Point> & phys_points_in_elem,
703  const THREAD_ID tid)
704 {
705  mooseAssert(_mesh.queryElemPtr(elem->id()) == elem,
706  "Are you calling this method with a undisplaced mesh element?");
707 
708  for (const auto nl_sys_num : index_range(_displaced_nl))
709  {
710  _assembly[tid][nl_sys_num]->reinitAtPhysical(elem, phys_points_in_elem);
711  _displaced_nl[nl_sys_num]->prepare(tid);
712  _assembly[tid][nl_sys_num]->prepare();
713  }
714  _displaced_aux->prepare(tid);
715 
716  reinitElem(elem, tid);
717 }
718 
719 void
721  unsigned int side,
722  BoundaryID bnd_id,
723  const THREAD_ID tid)
724 {
725  for (const auto nl_sys_num : index_range(_displaced_nl))
726  {
727  _assembly[tid][nl_sys_num]->reinit(elem, side);
728  _displaced_nl[nl_sys_num]->reinitElemFace(elem, side, bnd_id, tid);
729  }
730  _displaced_aux->reinitElemFace(elem, side, bnd_id, tid);
731 }
732 
733 void
734 DisplacedProblem::reinitNode(const Node * node, const THREAD_ID tid)
735 {
736  for (const auto nl_sys_num : index_range(_displaced_nl))
737  {
738  _assembly[tid][nl_sys_num]->reinit(node);
739  _displaced_nl[nl_sys_num]->reinitNode(node, tid);
740  }
741  _displaced_aux->reinitNode(node, tid);
742 }
743 
744 void
745 DisplacedProblem::reinitNodeFace(const Node * node, BoundaryID bnd_id, const THREAD_ID tid)
746 {
747  for (const auto nl_sys_num : index_range(_displaced_nl))
748  {
749  _assembly[tid][nl_sys_num]->reinit(node);
750  _displaced_nl[nl_sys_num]->reinitNodeFace(node, bnd_id, tid);
751  }
752  _displaced_aux->reinitNodeFace(node, bnd_id, tid);
753 }
754 
755 void
756 DisplacedProblem::reinitNodes(const std::vector<dof_id_type> & nodes, const THREAD_ID tid)
757 {
758  for (auto & nl : _displaced_nl)
759  nl->reinitNodes(nodes, tid);
760  _displaced_aux->reinitNodes(nodes, tid);
761 }
762 
763 void
764 DisplacedProblem::reinitNodesNeighbor(const std::vector<dof_id_type> & nodes, const THREAD_ID tid)
765 {
766  for (auto & nl : _displaced_nl)
767  nl->reinitNodesNeighbor(nodes, tid);
768  _displaced_aux->reinitNodesNeighbor(nodes, tid);
769 }
770 
771 void
772 DisplacedProblem::reinitNeighbor(const Elem * elem, unsigned int side, const THREAD_ID tid)
773 {
774  reinitNeighbor(elem, side, tid, nullptr);
775 }
776 
777 void
779  unsigned int side,
780  const THREAD_ID tid,
781  const std::vector<Point> * neighbor_reference_points)
782 {
783  setNeighborSubdomainID(elem, side, tid);
784 
785  const Elem * neighbor = elem->neighbor_ptr(side);
786  unsigned int neighbor_side = neighbor->which_neighbor_am_i(elem);
787 
788  for (const auto nl_sys_num : index_range(_displaced_nl))
789  {
790  _assembly[tid][nl_sys_num]->reinitElemAndNeighbor(
791  elem, side, neighbor, neighbor_side, neighbor_reference_points);
792  _displaced_nl[nl_sys_num]->prepareNeighbor(tid);
793  // Called during stateful material property evaluation outside of solve
794  _assembly[tid][nl_sys_num]->prepareNeighbor();
795  }
796  _displaced_aux->prepareNeighbor(tid);
797 
798  BoundaryID bnd_id = 0; // some dummy number (it is not really used for anything, right now)
799  for (auto & nl : _displaced_nl)
800  {
801  nl->reinitElemFace(elem, side, bnd_id, tid);
802  nl->reinitNeighborFace(neighbor, neighbor_side, bnd_id, tid);
803  }
804  _displaced_aux->reinitElemFace(elem, side, bnd_id, tid);
805  _displaced_aux->reinitNeighborFace(neighbor, neighbor_side, bnd_id, tid);
806 }
807 
808 void
810  unsigned int neighbor_side,
811  const std::vector<Point> & physical_points,
812  const THREAD_ID tid)
813 {
814  mooseAssert(_mesh.queryElemPtr(neighbor->id()) == neighbor,
815  "Are you calling this method with a undisplaced mesh element?");
816 
817  for (const auto nl_sys_num : index_range(_displaced_nl))
818  {
819  // Reinit shape functions
820  _assembly[tid][nl_sys_num]->reinitNeighborAtPhysical(neighbor, neighbor_side, physical_points);
821 
822  // Set the neighbor dof indices
823  _displaced_nl[nl_sys_num]->prepareNeighbor(tid);
824  }
825  _displaced_aux->prepareNeighbor(tid);
826 
828 
829  // Compute values at the points
830  for (auto & nl : _displaced_nl)
831  nl->reinitNeighborFace(neighbor, neighbor_side, 0, tid);
832  _displaced_aux->reinitNeighborFace(neighbor, neighbor_side, 0, tid);
833 }
834 
835 void
837  const std::vector<Point> & physical_points,
838  const THREAD_ID tid)
839 {
840  mooseAssert(_mesh.queryElemPtr(neighbor->id()) == neighbor,
841  "Are you calling this method with a undisplaced mesh element?");
842 
843  for (const auto nl_sys_num : index_range(_displaced_nl))
844  {
845  // Reinit shape functions
846  _assembly[tid][nl_sys_num]->reinitNeighborAtPhysical(neighbor, physical_points);
847 
848  // Set the neighbor dof indices
849  _displaced_nl[nl_sys_num]->prepareNeighbor(tid);
850  }
851  _displaced_aux->prepareNeighbor(tid);
852 
854 
855  // Compute values at the points
856  for (auto & nl : _displaced_nl)
857  nl->reinitNeighbor(neighbor, tid);
858  _displaced_aux->reinitNeighbor(neighbor, tid);
859 }
860 
861 void
863  unsigned int side,
864  const THREAD_ID tid)
865 {
866  reinitNeighbor(elem, side, tid);
867 
868  const Elem * lower_d_elem = _mesh.getLowerDElem(elem, side);
869  if (lower_d_elem && lower_d_elem->subdomain_id() == Moose::INTERNAL_SIDE_LOWERD_ID)
870  reinitLowerDElem(lower_d_elem, tid);
871  else
872  {
873  // with mesh refinement, lower-dimensional element might be defined on neighbor side
874  auto & neighbor = _assembly[tid][currentNlSysNum()]->neighbor();
875  auto & neighbor_side = _assembly[tid][currentNlSysNum()]->neighborSide();
876  const Elem * lower_d_elem_neighbor = _mesh.getLowerDElem(neighbor, neighbor_side);
877  if (lower_d_elem_neighbor &&
878  lower_d_elem_neighbor->subdomain_id() == Moose::INTERNAL_SIDE_LOWERD_ID)
879  {
880  auto qps = _assembly[tid][currentNlSysNum()]->qPointsFaceNeighbor().stdVector();
881  std::vector<Point> reference_points;
882  FEInterface::inverse_map(
883  lower_d_elem_neighbor->dim(), FEType(), lower_d_elem_neighbor, qps, reference_points);
884  reinitLowerDElem(lower_d_elem_neighbor, tid, &qps);
885  }
886  }
887 }
888 
889 void
891  bool reinit_for_derivative_reordering /*=false*/)
892 {
893  for (auto & nl : _displaced_nl)
894  nl->reinitScalars(tid, reinit_for_derivative_reordering);
895  _displaced_aux->reinitScalars(tid, reinit_for_derivative_reordering);
896 }
897 
898 void
900 {
901  _assembly[tid][currentNlSysNum()]->prepareOffDiagScalar();
902 }
903 
904 void
905 DisplacedProblem::getDiracElements(std::set<const Elem *> & elems)
906 {
908 }
909 
910 void
912 {
914 }
915 
916 void
918 {
919  _assembly[tid][currentNlSysNum()]->addResidual(Assembly::GlobalDataKey{},
921 }
922 
923 void
925 {
926  _assembly[tid][currentNlSysNum()]->addResidualNeighbor(Assembly::GlobalDataKey{},
928 }
929 
930 void
932 {
933  _assembly[tid][currentNlSysNum()]->addResidualLower(Assembly::GlobalDataKey{},
935 }
936 
937 void
939 {
940  if (_displaced_nl[currentNlSysNum()]->hasVector(
941  _displaced_nl[currentNlSysNum()]->timeVectorTag()))
942  _assembly[tid][currentNlSysNum()]->addCachedResidualDirectly(
943  residual,
945  getVectorTag(_displaced_nl[currentNlSysNum()]->timeVectorTag()));
946 
947  if (_displaced_nl[currentNlSysNum()]->hasVector(
948  _displaced_nl[currentNlSysNum()]->nonTimeVectorTag()))
949  _assembly[tid][currentNlSysNum()]->addCachedResidualDirectly(
950  residual,
952  getVectorTag(_displaced_nl[currentNlSysNum()]->nonTimeVectorTag()));
953 
954  // We do this because by adding the cached residual directly, we cannot ensure that all of the
955  // cached residuals are emptied after only the two add calls above
956  _assembly[tid][currentNlSysNum()]->clearCachedResiduals(Assembly::GlobalDataKey{});
957 }
958 
959 void
961 {
962  _assembly[tid][currentNlSysNum()]->setResidual(
963  residual,
965  getVectorTag(_displaced_nl[currentNlSysNum()]->residualVectorTag()));
966 }
967 
968 void
970 {
971  _assembly[tid][currentNlSysNum()]->setResidualNeighbor(
972  residual,
974  getVectorTag(_displaced_nl[currentNlSysNum()]->residualVectorTag()));
975 }
976 
977 void
979 {
980  _assembly[tid][currentNlSysNum()]->addJacobian(Assembly::GlobalDataKey{});
981 }
982 
983 void
985 {
986  _assembly[tid][currentNlSysNum()]->addJacobianNonlocal(Assembly::GlobalDataKey{});
987 }
988 
989 void
991 {
992  _assembly[tid][currentNlSysNum()]->addJacobianNeighbor(Assembly::GlobalDataKey{});
993 }
994 
995 void
997 {
998  _assembly[tid][currentNlSysNum()]->addJacobianNeighborLowerD(Assembly::GlobalDataKey{});
999 }
1000 
1001 void
1003 {
1004  _assembly[tid][currentNlSysNum()]->addJacobianLowerD(Assembly::GlobalDataKey{});
1005 }
1006 
1007 void
1009 {
1010  _assembly[tid][currentNlSysNum()]->cacheJacobianNonlocal(Assembly::GlobalDataKey{});
1011 }
1012 
1013 void
1015  unsigned int ivar,
1016  unsigned int jvar,
1017  const DofMap & dof_map,
1018  std::vector<dof_id_type> & dof_indices,
1019  const std::set<TagID> & tags,
1020  const THREAD_ID tid)
1021 {
1022  _assembly[tid][currentNlSysNum()]->addJacobianBlockTags(
1023  jacobian, ivar, jvar, dof_map, dof_indices, Assembly::GlobalDataKey{}, tags);
1024 }
1025 
1026 void
1028  unsigned int ivar,
1029  unsigned int jvar,
1030  const DofMap & dof_map,
1031  const std::vector<dof_id_type> & idof_indices,
1032  const std::vector<dof_id_type> & jdof_indices,
1033  const std::set<TagID> & tags,
1034  const THREAD_ID tid)
1035 {
1036  _assembly[tid][currentNlSysNum()]->addJacobianBlockNonlocalTags(
1037  jacobian, ivar, jvar, dof_map, idof_indices, jdof_indices, Assembly::GlobalDataKey{}, tags);
1038 }
1039 
1040 void
1042  unsigned int ivar,
1043  unsigned int jvar,
1044  const DofMap & dof_map,
1045  std::vector<dof_id_type> & dof_indices,
1046  std::vector<dof_id_type> & neighbor_dof_indices,
1047  const std::set<TagID> & tags,
1048  const THREAD_ID tid)
1049 {
1050  _assembly[tid][currentNlSysNum()]->addJacobianNeighborTags(jacobian,
1051  ivar,
1052  jvar,
1053  dof_map,
1054  dof_indices,
1055  neighbor_dof_indices,
1057  tags);
1058 }
1059 
1060 void
1061 DisplacedProblem::prepareShapes(unsigned int var, const THREAD_ID tid)
1062 {
1063  _assembly[tid][currentNlSysNum()]->copyShapes(var);
1064 }
1065 
1066 void
1068 {
1069  _assembly[tid][currentNlSysNum()]->copyFaceShapes(var);
1070 }
1071 
1072 void
1074 {
1075  _assembly[tid][currentNlSysNum()]->copyNeighborShapes(var);
1076 }
1077 
1078 void
1080 {
1081  TIME_SECTION("updateGeometricSearch", 3, "Updating Displaced GeometricSearch");
1082 
1084 }
1085 
1086 void
1088 {
1089  // The mesh changed. The displaced equations system object only holds ExplicitSystems, so calling
1090  // EquationSystems::reinit only prolongs/restricts the solution vectors, which is something that
1091  // needs to happen for every step of mesh adaptivity.
1092  _eq.reinit();
1093 
1094  // We've performed some mesh adaptivity. We need to
1095  // clear any quadrature nodes such that when we build the boundary node lists in
1096  // MooseMesh::meshChanged we don't have any extraneous extra boundary nodes lying around
1098 
1099  _mesh.meshChanged();
1100 
1101  // Before performing mesh adaptivity we un-displaced the mesh. We need to re-displace the mesh and
1102  // then reinitialize GeometricSearchData such that we have all the correct geometric information
1103  // for the changed mesh
1104  updateMesh(/*mesh_changing=*/true);
1105 
1106  // Since the mesh has changed, we need to make sure that we update any of our
1107  // MOOSE-system specific data. libmesh system data has already been updated
1108  for (auto & nl : _displaced_nl)
1109  nl->update(/*update_libmesh_system=*/false);
1110  _displaced_aux->update(/*update_libmesh_system=*/false);
1111 }
1112 
1113 void
1115 {
1116  _mproblem.addGhostedElem(elem_id);
1117 }
1118 
1119 void
1121 {
1122  _mproblem.addGhostedBoundary(boundary_id);
1123 }
1124 
1125 void
1127 {
1129 }
1130 
1131 MooseMesh &
1133 {
1134  return _ref_mesh;
1135 }
1136 
1137 bool
1138 DisplacedProblem::nlConverged(const unsigned int nl_sys_num)
1139 {
1140  return _mproblem.converged(nl_sys_num);
1141 }
1142 
1143 bool
1144 DisplacedProblem::computingInitialResidual(const unsigned int nl_sys_num) const
1145 {
1146  return _mproblem.computingInitialResidual(nl_sys_num);
1147 }
1148 
1149 void
1151 {
1152 }
1153 
1154 void
1156 {
1157 }
1158 
1159 void
1161 {
1162  // If undisplaceMesh() is called during initial adaptivity, it is
1163  // not valid to call _mesh.getActiveSemiLocalNodeRange() since it is
1164  // not set up yet. So we are creating the Range by hand.
1165  //
1166  // We must undisplace *all* our nodes to the _ref_mesh
1167  // configuration, not just the local ones, since the partitioners
1168  // require this. We are using the GRAIN_SIZE=1 from MooseMesh.C,
1169  // not sure how this value was decided upon.
1170  //
1171  // (DRG: The grainsize parameter is ultimately passed to TBB to help
1172  // it choose how to split up the range. A grainsize of 1 says "split
1173  // it as much as you want". Years ago I experimentally found that it
1174  // didn't matter much and that using 1 was fine.)
1175  //
1176  // Note: we don't have to invalidate/update as much stuff as
1177  // DisplacedProblem::updateMesh() does, since this will be handled
1178  // by a later call to updateMesh().
1179  NodeRange node_range(_mesh.getMesh().nodes_begin(),
1180  _mesh.getMesh().nodes_end(),
1181  /*grainsize=*/1);
1182 
1183  ResetDisplacedMeshThread rdmt(_mproblem, *this);
1184 
1185  // Undisplace the mesh using threads.
1186  Threads::parallel_reduce(node_range, rdmt);
1187 }
1188 
1189 LineSearch *
1191 {
1192  return _mproblem.getLineSearch();
1193 }
1194 
1195 const CouplingMatrix *
1196 DisplacedProblem::couplingMatrix(const unsigned int nl_sys_num) const
1197 {
1198  return _mproblem.couplingMatrix(nl_sys_num);
1199 }
1200 
1201 bool
1203 {
1205 }
1206 
1207 bool
1209 {
1211 }
1212 
1213 void
1215 {
1217 
1218  for (auto & nl : _displaced_nl)
1219  nl->initialSetup();
1220  _displaced_aux->initialSetup();
1221 }
1222 
1223 void
1225 {
1227 
1228  for (auto & nl : _displaced_nl)
1229  nl->timestepSetup();
1230  _displaced_aux->timestepSetup();
1231 }
1232 
1233 void
1235 {
1236  SubProblem::customSetup(exec_type);
1237 
1238  for (auto & nl : _displaced_nl)
1239  nl->customSetup(exec_type);
1240  _displaced_aux->customSetup(exec_type);
1241 }
1242 
1243 void
1245 {
1247 
1248  for (auto & nl : _displaced_nl)
1249  nl->residualSetup();
1250  _displaced_aux->residualSetup();
1251 }
1252 
1253 void
1255 {
1257 
1258  for (auto & nl : _displaced_nl)
1259  nl->jacobianSetup();
1260  _displaced_aux->jacobianSetup();
1261 }
1262 
1263 void
1264 DisplacedProblem::haveADObjects(const bool have_ad_objects)
1265 {
1266  _have_ad_objects = have_ad_objects;
1267  _mproblem.SubProblem::haveADObjects(have_ad_objects);
1268 }
1269 
1270 std::pair<bool, unsigned int>
1271 DisplacedProblem::determineNonlinearSystem(const std::string & var_name,
1272  const bool error_if_not_found) const
1273 {
1274  return _mproblem.determineNonlinearSystem(var_name, error_if_not_found);
1275 }
1276 
1277 Assembly &
1278 DisplacedProblem::assembly(const THREAD_ID tid, const unsigned int nl_sys_num)
1279 {
1280  mooseAssert(tid < _assembly.size(), "Assembly objects not initialized");
1281  mooseAssert(nl_sys_num < _assembly[tid].size(),
1282  "Nonlinear system number larger than the assembly container size");
1283  return *_assembly[tid][nl_sys_num];
1284 }
1285 
1286 const Assembly &
1287 DisplacedProblem::assembly(const THREAD_ID tid, const unsigned int nl_sys_num) const
1288 {
1289  mooseAssert(tid < _assembly.size(), "Assembly objects not initialized");
1290  mooseAssert(nl_sys_num < _assembly[tid].size(),
1291  "Nonlinear system number larger than the assembly container size");
1292  return *_assembly[tid][nl_sys_num];
1293 }
1294 
1295 std::size_t
1297 {
1298  return _mproblem.numNonlinearSystems();
1299 }
1300 
1301 const std::vector<VectorTag> &
1303 {
1305 }
1306 
1307 bool
1309 {
1311 }
1312 
1313 bool
1315 {
1317 }
1318 
1319 void
1321 {
1322  _mproblem.needFV();
1323 }
1324 
1325 bool
1327 {
1328  return _mproblem.haveFV();
1329 }
1330 
1331 bool
1333 {
1334  return _mproblem.hasNonlocalCoupling();
1335 }
1336 
1337 unsigned int
1338 DisplacedProblem::nlSysNum(const NonlinearSystemName & nl_sys_name) const
1339 {
1340  return _mproblem.nlSysNum(nl_sys_name);
1341 }
LineSearch * getLineSearch() override
virtual void update(bool update_libmesh_system=true)
Update the system (doing libMesh magic)
Definition: SystemBase.C:1211
VarFieldType
Definition: MooseTypes.h:634
GeometricSearchData _geometric_search_data
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:180
virtual void reinitNodesNeighbor(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
virtual void addGhostedElem(dof_id_type elem_id) override
Will make sure that all dofs connected to elem_id are ghosted to this processor.
bool _have_ad_objects
AD flag indicating whether any AD objects have been added.
Definition: SubProblem.h:1044
virtual System & getSystem(const std::string &var_name) override
Returns the equation system containing the variable provided.
virtual void reinitNode(const Node *node, const THREAD_ID tid) override
Order
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...
virtual void addGhostedElem(dof_id_type elem_id) override
Will make sure that all dofs connected to elem_id are ghosted to this processor.
virtual void saveOldSolutions()
Allocate vectors and save old solutions into them.
virtual const char * what() const
Get out the error message.
unsigned int n_threads()
void undisplaceMesh()
Resets the displaced mesh to the reference mesh.
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
virtual bool hasNonlocalCoupling() const override
Whether the simulation has nonlocal coupling which should be accounted for in the Jacobian...
virtual void checkExceptionAndStopSolve(bool print_message=true)
Check to see if an exception has occurred on any processor and, if possible, force the solve to fail...
virtual bool converged(const unsigned int nl_sys_num)
Eventually we want to convert this virtual over to taking a nonlinear system number argument...
Definition: SubProblem.h:101
Keeps track of stuff related to assembling.
Definition: Assembly.h:93
Class for stuff related to variables.
Definition: Adaptivity.h:31
void setCoordData(const MooseMesh &other_mesh)
Set the coordinate system data to that of other_mesh.
Definition: MooseMesh.C:4038
virtual void addAuxVariable(const std::string &var_type, const std::string &name, InputParameters &parameters)
unsigned int TagID
Definition: MooseTypes.h:199
virtual std::size_t numNonlinearSystems() const override
virtual MooseVariableFieldBase & getActualFieldVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested MooseVariableField which may be in any system...
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
void addJacobianBlockNonlocal(SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const DofMap &dof_map, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, const std::set< TagID > &tags, const THREAD_ID tid)
void residualSetup() override
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: FEProblem.h:20
virtual void initAdaptivity()
void bumpAllQRuleOrder(Order order, SubdomainID block)
virtual bool safeAccessTaggedVectors() const
Is it safe to access the tagged vectors.
Definition: SubProblem.h:689
void initialSetup() override
virtual void addJacobianNeighborLowerD(const THREAD_ID tid) override
virtual void needFV() override
marks this problem as including/needing finite volume functionality.
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL) override
Create a Tag.
const Elem * getLowerDElem(const Elem *, unsigned short int) const
Returns a const pointer to a lower dimensional element that corresponds to a side of a higher dimensi...
Definition: MooseMesh.C:1483
virtual void prepareShapes(unsigned int var, const THREAD_ID tid) override
FEProblemBase & _mproblem
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
Definition: SubProblem.C:81
virtual void prepareNeighborShapes(unsigned int var, const THREAD_ID tid) override
virtual void createQRules(QuadratureType type, Order order, Order volume_order, Order face_order, SubdomainID block, bool allow_negative_qweights=true)
virtual void reinitNodes(const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
virtual void residualSetup()
Definition: SubProblem.C:1146
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
virtual bool haveFV() const override
returns true if this problem includes/needs finite volume functionality.
virtual bool safeAccessTaggedMatrices() const override
Is it safe to access the tagged matrices.
virtual bool hasScalarVariable(const std::string &var_name) const override
Returns a Boolean indicating whether any system contains a variable with the name provided...
MeshBase & mesh
const NumericVector< Number > *const & currentSolution() const override
The solution vector that is currently being operated on.
virtual void prepareAssemblyNeighbor(const THREAD_ID tid)
virtual void addGhostedBoundary(BoundaryID boundary_id) override
Will make sure that all necessary elements from boundary_id are ghosted to this processor.
virtual const std::vector< VectorTag > & currentResidualVectorTags() const override
Return the residual vector tags we are currently computing.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
QuadratureType
virtual TagName vectorTagName(const TagID tag_id) const override
Retrieve the name associated with a TagID.
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual void addJacobianLowerD(const THREAD_ID tid) override
virtual TagID getMatrixTagID(const TagName &tag_name) const override
Get a TagID from a TagName.
virtual void jacobianSetup()
Definition: SubProblem.C:1154
void timestepSetup() override
void computingScalingJacobian(bool computing_scaling_jacobian)
Setter for whether we&#39;re computing the scaling jacobian.
virtual unsigned int numVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const override
The total number of tags, which can be limited to the tag type.
virtual unsigned int nlSysNum(const NonlinearSystemName &nl_sys_name) const override
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
registerMooseObject("MooseApp", DisplacedProblem)
virtual void onTimestepBegin() override
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:56
virtual void syncSolutions()
Copy the solutions on the undisplaced systems to the displaced systems.
virtual void prepareBlockNonlocal(unsigned int ivar, unsigned int jvar, const std::vector< dof_id_type > &idof_indices, const std::vector< dof_id_type > &jdof_indices, const THREAD_ID tid)
virtual Elem * queryElemPtr(const dof_id_type i)
Definition: MooseMesh.C:2875
virtual std::set< dof_id_type > & ghostedElems() override
Return the list of elements that should have their DoFs ghosted to this processor.
virtual void reinitElemPhys(const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid) override
virtual void meshChanged() override
virtual MooseVariable & getStandardVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested MooseVariable which may be in any system.
virtual MooseVariableScalar & getScalarVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the scalar variable reference from whichever system contains it.
std::vector< std::vector< std::unique_ptr< Assembly > > > _assembly
DisplacedProblem(DisplacedProblem &&)=delete
virtual const std::string & name() const
Definition: SystemBase.C:1297
virtual void customSetup(const ExecFlagType &exec_type)
Definition: SubProblem.C:1138
bool automaticScaling() const
Automatic scaling getter.
Definition: SubProblem.C:1107
bool hasJacobian() const
Returns _has_jacobian.
EquationSystems _eq
unsigned int currentNlSysNum() const override
MultiPointMap & getPoints()
Returns a writeable reference to the _points container.
void clearQuadratureNodes()
Clear out any existing quadrature nodes.
Definition: MooseMesh.C:1462
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3198
std::vector< const NumericVector< Number > * > _nl_solution
The nonlinear system solutions.
MooseMesh & _ref_mesh
reference mesh
bool computingScalingResidual() const override final
Getter for whether we&#39;re computing the scaling residual.
virtual TagID getMatrixTagID(const TagName &tag_name) const
Get a TagID from a TagName.
Definition: SubProblem.C:308
void extraSendList(std::vector< dof_id_type > &send_list, void *context)
///< Type of coordinate system
Definition: SystemBase.C:34
std::unique_ptr< DisplacedSystem > _displaced_aux
virtual void addJacobian(const THREAD_ID tid) override
virtual void setResidual(NumericVector< Number > &residual, const THREAD_ID tid) override
boundary_id_type BoundaryID
virtual void clearDiracInfo() override
Gets called before Dirac Kernels are asked to add the points they are supposed to be evaluated in...
bool constJacobian() const
Returns _const_jacobian (whether a MOOSE object has specified that the Jacobian is the same as the pr...
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:627
virtual void reinitNeighbor(const Elem *elem, unsigned int side, const THREAD_ID tid) override
void computingScalingResidual(bool computing_scaling_residual)
Setter for whether we&#39;re computing the scaling residual.
virtual void restoreOldSolutions()
Restore old solutions from the backup vectors and deallocate them.
virtual const std::vector< VectorTag > & getVectorTags(const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const override
Return all vector tags, where a tag is represented by a map from name to ID.
virtual TagID addMatrixTag(TagName tag_name)
Create a Tag.
Definition: SubProblem.C:277
virtual void setResidualNeighbor(NumericVector< Number > &residual, const THREAD_ID tid) override
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const
Definition: SubProblem.C:208
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
virtual unsigned int currentNlSysNum() const override
Assembly & assembly(const THREAD_ID tid, const unsigned int nl_sys_num) override
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:50
virtual bool hasVariable(const std::string &var_name) const override
Whether or not this problem has the variable.
void reinit()
Completely redo all geometric search objects.
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition: SubProblem.C:149
virtual void addVariable(const std::string &var_type, const std::string &name, InputParameters &parameters, unsigned int nl_system_number)
virtual Moose::VectorTagType vectorTagType(const TagID tag_id) const override
virtual void reinitOffDiagScalars(const THREAD_ID tid) override
LineSearch * getLineSearch() override
getter for the MOOSE line search
virtual std::set< dof_id_type > & ghostedElems()
Return the list of elements that should have their DoFs ghosted to this processor.
Definition: SubProblem.h:627
std::vector< std::string > _displacements
std::pair< bool, unsigned int > determineNonlinearSystem(const std::string &var_name, bool error_if_not_found=false) const override
virtual bool vectorTagExists(const TagID tag_id) const
Check to see if a particular Tag exists.
Definition: SubProblem.h:163
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
virtual const VectorTag & getVectorTag(const TagID tag_id) const override
Get a VectorTag from a TagID.
void clearPoints()
Remove all of the current points and elements.
virtual void addJacobianBlockTags(SparseMatrix< Number > &jacobian, unsigned int ivar, unsigned int jvar, const DofMap &dof_map, std::vector< dof_id_type > &dof_indices, const std::set< TagID > &tags, const THREAD_ID tid)
const NumericVector< Number > * _aux_solution
The auxiliary system solution.
virtual void addResidualLower(const THREAD_ID tid) override
AuxiliarySystem & getAuxiliarySystem()
bool haveADObjects() const
Method for reading wehther we have any ad objects.
Definition: SubProblem.h:726
virtual bool isTransient() const override
GeometricSearchType
Used to select groups of geometric search objects to update.
VectorTagType
Definition: MooseTypes.h:891
virtual void onTimestepEnd() override
std::vector< std::unique_ptr< DisplacedSystem > > _displaced_nl
std::size_t numNonlinearSystems() const override
virtual void reinitElem(const Elem *elem, const THREAD_ID tid) override
virtual void addCachedResidualDirectly(NumericVector< Number > &residual, const THREAD_ID tid)
virtual void reinitElemFace(const Elem *elem, unsigned int side, BoundaryID bnd_id, const THREAD_ID tid) override
virtual void timestepSetup()
Definition: SubProblem.C:1130
virtual unsigned int numMatrixTags() const
The total number of tags.
Definition: SubProblem.h:210
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
void customSetup(const ExecFlagType &exec_type) override
virtual TagName matrixTagName(TagID tag) override
Retrieve the name associated with a TagID.
virtual void reinitNodeFace(const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
Provides a way for users to bail out of the current solve.
void setCurrentSubdomainID(SubdomainID i)
set the current subdomain ID
Definition: Assembly.h:377
virtual void initialSetup()
Definition: SubProblem.C:1162
virtual void prepareAssembly(const THREAD_ID tid) override
std::shared_ptr< TimeIntegrator > getSharedTimeIntegrator()
Definition: SystemBase.h:872
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
virtual void reinitNeighborPhys(const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid) override
virtual VectorMooseVariable & getVectorVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested VectorMooseVariable which may be in any system...
virtual bool computingInitialResidual(const unsigned int nl_sys_num) const override
Returns true if the problem is in the process of computing it&#39;s initial residual. ...
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
const CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const override
The coupling matrix defining what blocks exist in the preconditioning matrix.
virtual bool matrixTagExists(const TagName &tag_name) const override
Check to see if a particular Tag exists.
bool computingScalingJacobian() const override final
Getter for whether we&#39;re computing the scaling jacobian.
virtual TagID addMatrixTag(TagName tag_name) override
Create a Tag.
const SubdomainID INTERNAL_SIDE_LOWERD_ID
Definition: MooseTypes.C:20
virtual void addResidualNeighbor(const THREAD_ID tid) override
std::pair< bool, unsigned int > determineNonlinearSystem(const std::string &var_name, bool error_if_not_found=false) const override
Determine what nonlinear system the provided variable name lies in.
virtual void addResidual(const THREAD_ID tid) override
virtual const std::vector< VectorTag > & currentResidualVectorTags() const override
Return the residual vector tags we are currently computing.
virtual void cacheJacobianNonlocal(const THREAD_ID tid)
void update(GeometricSearchType type=ALL)
Update all of the search objects.
Class for scalar variables (they are different).
IntRange< T > make_range(T beg, T end)
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 setCurrentSubdomainID(const Elem *elem, const THREAD_ID tid) override
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
const InputParameters & parameters() const
Get the parameters of the object.
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid) override
virtual bool computingInitialResidual(const unsigned int nl_sys_num) const override
Returns true if the problem is in the process of computing it&#39;s initial residual. ...
virtual unsigned int numMatrixTags() const override
The total number of tags.
virtual void updateGeomSearch(GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
virtual void reinitElemNeighborAndLowerD(const Elem *elem, unsigned int side, const THREAD_ID tid) override
Eigen::Matrix< Real, Eigen::Dynamic, 1 > RealEigenVector
Definition: MooseTypes.h:138
std::set< const Elem * > & getElements()
Returns a writeable reference to the _elements container.
MooseMesh & refMesh()
virtual bool reinitDirac(const Elem *elem, const THREAD_ID tid) override
Returns true if the Problem has Dirac kernels it needs to compute on elem.
virtual TagName vectorTagName(const TagID tag) const
Retrieve the name associated with a TagID.
Definition: SubProblem.C:198
virtual void setNeighborSubdomainID(const Elem *elem, unsigned int side, const THREAD_ID tid) override
static InputParameters validParams()
Definition: SubProblem.C:33
void automaticScaling(bool automatic_scaling) override
Automatic scaling setter.
virtual ArrayMooseVariable & getArrayVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested ArrayMooseVariable which may be in any system...
virtual void addJacobianNonlocal(const THREAD_ID tid)
virtual bool isTransient() const override
virtual void reinitScalars(const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
fills the VariableValue arrays for scalar variables from the solution vector
virtual bool safeAccessTaggedMatrices() const
Is it safe to access the tagged matrices.
Definition: SubProblem.h:686
virtual void updateMesh(bool mesh_changing=false)
Copy the solutions on the undisplaced systems to the displaced systems and reinitialize the geometry ...
virtual bool safeAccessTaggedVectors() const override
Is it safe to access the tagged vectors.
virtual void getDiracElements(std::set< const Elem *> &elems) override
Fills "elems" with the elements that should be looped over for Dirac Kernels.
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
void jacobianSetup() override
StoredRange< MeshBase::node_iterator, Node *> NodeRange
void setCurrentNeighborSubdomainID(SubdomainID i)
set the current subdomain ID
Definition: Assembly.h:455
virtual void addGhostedBoundary(BoundaryID boundary_id) override
Will make sure that all necessary elements from boundary_id are ghosted to this processor.
virtual void prepareNonlocal(const THREAD_ID tid)
virtual void needFV() override
marks this problem as including/needing finite volume functionality.
virtual void prepareFace(const Elem *elem, const THREAD_ID tid) override
virtual void prepare(const Elem *elem, const THREAD_ID tid) override
virtual TagID getVectorTagID(const TagName &tag_name) const override
Get a TagID from a TagName.
virtual const VectorTag & getVectorTag(const TagID tag_id) const
Get a VectorTag from a TagID.
Definition: SubProblem.C:138
void updatePointLocator(const MooseMesh &mesh)
Called during FEProblemBase::meshChanged() to update the PointLocator object used by the DiracKernels...
auto index_range(const T &sizable)
virtual bool hasNonlocalCoupling() const override
Whether the simulation has nonlocal coupling which should be accounted for in the Jacobian...
const CouplingMatrix * couplingMatrix(const unsigned int nl_sys_num) const override
The coupling matrix defining what blocks exist in the preconditioning matrix.
virtual bool vectorTagExists(const TagID tag_id) const override
Check to see if a particular Tag exists.
virtual unsigned int nlSysNum(const NonlinearSystemName &nl_sys_name) const override
virtual bool nlConverged(const unsigned int nl_sys_num) override
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
void meshChanged()
Declares that the MooseMesh has changed, invalidates cached data and rebuilds caches.
Definition: MooseMesh.C:684
static InputParameters validParams()
unsigned int THREAD_ID
Definition: MooseTypes.h:198
virtual void ghostGhostedBoundaries() override
Causes the boundaries added using addGhostedBoundary to actually be ghosted.
uint8_t dof_id_type
void bumpVolumeQRuleOrder(Order order, SubdomainID block)
virtual void init() override
virtual void addJacobianNeighbor(const THREAD_ID tid) override
virtual void ghostGhostedBoundaries() override
Causes the boundaries added using addGhostedBoundary to actually be ghosted.
void setupFiniteVolumeMeshData() const
Sets up the additional data needed for finite volume computations.
Definition: MooseMesh.C:3814
Key structure for APIs manipulating global vectors/matrices.
Definition: Assembly.h:794