www.mooseframework.org
MooseObjectWarehouseBase.h
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 #pragma once
11 
12 // MOOSE includes
14 #include "BoundaryRestrictable.h"
15 #include "BlockRestrictable.h"
16 #include "TransientInterface.h"
17 #include "Coupleable.h"
20 #include "SubProblem.h"
21 
22 // Forward declarations
24 
28 template <typename T>
30 {
31 public:
36  MooseObjectWarehouseBase(bool threaded = true);
37 
41  virtual ~MooseObjectWarehouseBase();
42 
48  virtual void addObject(std::shared_ptr<T> object, THREAD_ID tid = 0, bool recurse = true);
49 
53  unsigned int size(THREAD_ID tid = 0) const;
54 
56 
60  const std::vector<std::shared_ptr<T>> & getObjects(THREAD_ID tid = 0) const;
61  const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
62  getBlockObjects(THREAD_ID tid = 0) const;
63  const std::vector<std::shared_ptr<T>> & getBlockObjects(SubdomainID id, THREAD_ID tid = 0) const;
64  const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
65  getBoundaryObjects(THREAD_ID tid = 0) const;
66  const std::vector<std::shared_ptr<T>> & getBoundaryObjects(BoundaryID id,
67  THREAD_ID tid = 0) const;
69 
71 
76  const std::vector<std::shared_ptr<T>> & getActiveObjects(THREAD_ID tid = 0) const;
77  const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
78  getActiveBlockObjects(THREAD_ID tid = 0) const;
79  const std::vector<std::shared_ptr<T>> & getActiveBlockObjects(SubdomainID id,
80  THREAD_ID tid = 0) const;
81  const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
82  getActiveBoundaryObjects(THREAD_ID tid = 0) const;
83  const std::vector<std::shared_ptr<T>> & getActiveBoundaryObjects(BoundaryID id,
84  THREAD_ID tid = 0) const;
86 
88 
91  bool hasObjects(THREAD_ID tid = 0) const;
92  bool hasActiveObjects(THREAD_ID tid = 0) const;
93  bool hasActiveBlockObjects(THREAD_ID tid = 0) const;
94  bool hasActiveBlockObjects(SubdomainID id, THREAD_ID tid = 0) const;
95  bool hasActiveBoundaryObjects(THREAD_ID tid = 0) const;
96  bool hasActiveBoundaryObjects(BoundaryID id, THREAD_ID tid = 0) const;
97  bool hasBoundaryObjects(BoundaryID id, THREAD_ID tid = 0) const;
99 
103  std::set<SubdomainID> getActiveBlocks(THREAD_ID tid = 0) const;
104 
106 
109  bool hasActiveObject(const std::string & name, THREAD_ID tid = 0) const;
110  std::shared_ptr<T> getObject(const std::string & name, THREAD_ID tid = 0) const;
111  std::shared_ptr<T> getActiveObject(const std::string & name, THREAD_ID tid = 0) const;
113 
117  virtual void updateActive(THREAD_ID tid = 0);
118 
122  void sort(THREAD_ID tid = 0);
123 
125 
128  void updateVariableDependency(std::set<MooseVariableFieldBase *> & needed_moose_vars,
129  THREAD_ID tid = 0) const;
131  std::set<MooseVariableFieldBase *> & needed_moose_vars,
132  THREAD_ID tid = 0) const;
133  void updateBoundaryVariableDependency(std::set<MooseVariableFieldBase *> & needed_moose_vars,
134  THREAD_ID tid = 0) const;
136  std::set<MooseVariableFieldBase *> & needed_moose_vars,
137  THREAD_ID tid = 0) const;
139 
141 
145  std::set<TagID> & needed_fe_var_vector_tags,
146  THREAD_ID tid = 0) const;
148  BoundaryID id, std::set<TagID> & needed_fe_var_vector_tags, THREAD_ID tid = 0) const;
150 
152 
155  void updateMatPropDependency(std::unordered_set<unsigned int> & needed_mat_props,
156  THREAD_ID tid = 0) const;
158  std::unordered_set<unsigned int> & needed_mat_props,
159  THREAD_ID tid = 0) const;
160  void updateBoundaryMatPropDependency(std::unordered_set<unsigned int> & needed_mat_props,
161  THREAD_ID tid = 0) const;
163  std::unordered_set<unsigned int> & needed_mat_props,
164  THREAD_ID tid = 0) const;
166 
170  void subdomainsCovered(std::set<SubdomainID> & subdomains_covered,
171  std::set<std::string> & unique_variables,
172  THREAD_ID tid = 0) const;
173 
177  THREAD_ID numThreads() const { return _num_threads; }
178 
184  std::string activeObjectsToFormattedString(THREAD_ID tid = 0,
185  const std::string & prefix = "[DBG]") const;
186 
187 protected:
190 
192  std::vector<std::vector<std::shared_ptr<T>>> _all_objects;
193 
195  std::vector<std::vector<std::shared_ptr<T>>> _active_objects;
196 
197  // All block restricted objects (THREAD_ID on outer vector)
198  std::vector<std::map<SubdomainID, std::vector<std::shared_ptr<T>>>> _all_block_objects;
199 
201  std::vector<std::map<SubdomainID, std::vector<std::shared_ptr<T>>>> _active_block_objects;
202 
203  // All boundary restricted objects (THREAD_ID on outer vector)
204  std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<T>>>> _all_boundary_objects;
205 
207  std::vector<std::map<BoundaryID, std::vector<std::shared_ptr<T>>>> _active_boundary_objects;
208 
212  static void updateActiveHelper(std::vector<std::shared_ptr<T>> & active,
213  const std::vector<std::shared_ptr<T>> & all);
214 
218  static void sortHelper(std::vector<std::shared_ptr<T>> & objects);
219 
223  static void updateVariableDependencyHelper(std::set<MooseVariableFieldBase *> & needed_moose_vars,
224  const std::vector<std::shared_ptr<T>> & objects);
225 
229  static void
230  updateFEVariableCoupledVectorTagDependencyHelper(std::set<TagID> & needed_fe_var_vector_tags,
231  const std::vector<std::shared_ptr<T>> & objects);
232 
236  static void updateMatPropDependencyHelper(std::unordered_set<unsigned int> & needed_mat_props,
237  const std::vector<std::shared_ptr<T>> & objects);
238 
242  void checkThreadID(THREAD_ID tid) const;
243 
244  friend class MaterialWarehouse;
245 };
246 
247 template <typename T>
249  : _num_threads(threaded ? libMesh::n_threads() : 1),
256 {
257 }
258 
259 template <typename T>
261 {
262 }
263 
264 template <typename T>
265 unsigned int
267 {
268  checkThreadID(tid);
269  return _all_objects[tid].size();
270 }
271 
272 template <typename T>
273 void
274 MooseObjectWarehouseBase<T>::addObject(std::shared_ptr<T> object,
275  THREAD_ID tid /*= 0*/,
276  bool /* recurse = true */)
277 {
278  checkThreadID(tid);
279 
280  // Stores object in list of all objects
281  _all_objects[tid].push_back(object);
282 
283  // If enabled, store object in a list of all active
284  bool enabled = object->enabled();
285  if (enabled)
286  _active_objects[tid].push_back(object);
287 
288  // Perform casts to the Block/BoundaryRestrictable
289  std::shared_ptr<BoundaryRestrictable> bnd =
291  std::shared_ptr<BlockRestrictable> blk = std::dynamic_pointer_cast<BlockRestrictable>(object);
292 
293  // Boundary Restricted
294  if (bnd && bnd->boundaryRestricted())
295  {
296  const std::set<BoundaryID> & ids = bnd->boundaryIDs();
297  for (std::set<BoundaryID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
298  {
299  _all_boundary_objects[tid][*it].push_back(object);
300  if (enabled)
301  _active_boundary_objects[tid][*it].push_back(object);
302  }
303  }
304 
305  // Block Restricted
306  else if (blk)
307  {
308  const std::set<SubdomainID> & ids =
309  blk->blockRestricted() ? blk->blockIDs() : blk->meshBlockIDs();
310  for (std::set<SubdomainID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
311  {
312  _all_block_objects[tid][*it].push_back(object);
313  if (enabled)
314  _active_block_objects[tid][*it].push_back(object);
315  }
316 
317  // Check variables
318  std::shared_ptr<Coupleable> c_ptr = std::dynamic_pointer_cast<Coupleable>(object);
319  if (c_ptr)
320  for (MooseVariableFieldBase * var : c_ptr->getCoupledMooseVars())
321  blk->checkVariable(*var);
322 
323  const InputParameters & parameters = object->parameters();
324 
325  SubProblem & problem = *parameters.get<SubProblem *>("_subproblem");
326 
327  THREAD_ID tid = parameters.get<THREAD_ID>("_tid");
328 
329  if (parameters.isParamValid("variable"))
330  {
331  // Try the scalar version first
332  std::string variable_name = parameters.getMooseType("variable");
333  if (variable_name == "")
334  // When using vector variables, we are only going to use the first one in the list at the
335  // interface level...
336  variable_name = parameters.getVecMooseType("variable")[0];
337 
338  blk->checkVariable(problem.getVariable(
340  }
341  }
342 }
343 
344 template <typename T>
345 inline const std::vector<std::shared_ptr<T>> &
347 {
348  checkThreadID(tid);
349  return _all_objects[tid];
350 }
351 
352 template <typename T>
353 inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
355 {
356  checkThreadID(tid);
357  return _all_boundary_objects[tid];
358 }
359 
360 template <typename T>
361 bool
363 {
364  checkThreadID(tid);
365  return _all_boundary_objects[tid].find(id) != _all_boundary_objects[tid].end();
366 }
367 
368 template <typename T>
369 const std::vector<std::shared_ptr<T>> &
371 {
372  checkThreadID(tid);
373  const auto iter = _all_boundary_objects[tid].find(id);
374  mooseAssert(iter != _all_boundary_objects[tid].end(),
375  "Unable to located active boundary objects for the given id: " << id << ".");
376  return iter->second;
377 }
378 
379 template <typename T>
380 inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
382 {
383  checkThreadID(tid);
384  return _all_block_objects[tid];
385 }
386 
387 template <typename T>
388 const std::vector<std::shared_ptr<T>> &
390 {
391  checkThreadID(tid);
392  const auto iter = _all_block_objects[tid].find(id);
393  mooseAssert(iter != _all_block_objects[tid].end(),
394  "Unable to located active block objects for the given id: " << id << ".");
395  return iter->second;
396 }
397 
398 template <typename T>
399 inline const std::vector<std::shared_ptr<T>> &
401 {
402  checkThreadID(tid);
403  return _active_objects[tid];
404 }
405 
406 template <typename T>
407 inline const std::map<BoundaryID, std::vector<std::shared_ptr<T>>> &
409 {
410  checkThreadID(tid);
411  return _active_boundary_objects[tid];
412 }
413 
414 template <typename T>
415 const std::vector<std::shared_ptr<T>> &
417 {
418  checkThreadID(tid);
419  const auto iter = _active_boundary_objects[tid].find(id);
420  mooseAssert(iter != _active_boundary_objects[tid].end(),
421  "Unable to located active boundary objects for the given id: " << id << ".");
422  return iter->second;
423 }
424 
425 template <typename T>
426 inline const std::map<SubdomainID, std::vector<std::shared_ptr<T>>> &
428 {
429  checkThreadID(tid);
430  return _active_block_objects[tid];
431 }
432 
433 template <typename T>
434 const std::vector<std::shared_ptr<T>> &
436 {
437  checkThreadID(tid);
438  const auto iter = _active_block_objects[tid].find(id);
439  mooseAssert(iter != _active_block_objects[tid].end(),
440  "Unable to located active block objects for the given id: " << id << ".");
441  return iter->second;
442 }
443 
444 template <typename T>
445 bool
447 {
448  checkThreadID(tid);
449  return !_all_objects[tid].empty();
450 }
451 
452 template <typename T>
453 bool
455 {
456  checkThreadID(tid);
457  return !_active_objects[tid].empty();
458 }
459 
460 template <typename T>
461 bool
463 {
464  checkThreadID(tid);
465  bool has_active_block_objects = false;
466  for (const auto & object_pair : _active_block_objects[tid])
467  has_active_block_objects |= !(object_pair.second.empty());
468  return has_active_block_objects;
469 }
470 
471 template <typename T>
472 bool
474 {
475  checkThreadID(tid);
476  const auto iter = _active_block_objects[tid].find(id);
477  return iter != _active_block_objects[tid].end();
478 }
479 
480 template <typename T>
481 bool
483 {
484  checkThreadID(tid);
485  bool has_active_boundary_objects = false;
486  for (const auto & object_pair : _active_boundary_objects[tid])
487  has_active_boundary_objects |= !(object_pair.second.empty());
488  return has_active_boundary_objects;
489 }
490 
491 template <typename T>
492 bool
494 {
495  checkThreadID(tid);
496  const auto iter = _active_boundary_objects[tid].find(id);
497  return iter != _active_boundary_objects[tid].end();
498 }
499 
500 template <typename T>
501 bool
502 MooseObjectWarehouseBase<T>::hasActiveObject(const std::string & name, THREAD_ID tid /* = 0*/) const
503 {
504  checkThreadID(tid);
505  for (const auto & object : _active_objects[tid])
506  if (object->name() == name)
507  return true;
508  return false;
509 }
510 
511 template <typename T>
512 std::shared_ptr<T>
513 MooseObjectWarehouseBase<T>::getObject(const std::string & name, THREAD_ID tid /* = 0*/) const
514 {
515  checkThreadID(tid);
516  for (const auto & object : _all_objects[tid])
517  if (object->name() == name)
518  return object;
519  mooseError("Unable to locate object: ", name, ".");
520 }
521 
522 template <typename T>
523 std::shared_ptr<T>
524 MooseObjectWarehouseBase<T>::getActiveObject(const std::string & name, THREAD_ID tid /* = 0*/) const
525 {
526  checkThreadID(tid);
527  for (const auto & object : _active_objects[tid])
528  if (object->name() == name)
529  return object;
530  mooseError("Unable to locate active object: ", name, ".");
531 }
532 
533 template <typename T>
534 std::set<SubdomainID>
536 {
537  checkThreadID(tid);
538  std::set<SubdomainID> ids;
539  for (const auto & object_pair : _active_block_objects[tid])
540  ids.insert(object_pair.first);
541  return ids;
542 }
543 
544 template <typename T>
545 void
547 {
548  checkThreadID(tid);
549 
551 
552  for (const auto & object_pair : _all_block_objects[tid])
553  updateActiveHelper(_active_block_objects[tid][object_pair.first], object_pair.second);
554 
555  for (const auto & object_pair : _all_boundary_objects[tid])
556  updateActiveHelper(_active_boundary_objects[tid][object_pair.first], object_pair.second);
557 }
558 
559 template <typename T>
560 void
561 MooseObjectWarehouseBase<T>::updateActiveHelper(std::vector<std::shared_ptr<T>> & active,
562  const std::vector<std::shared_ptr<T>> & all)
563 {
564  // Clear the active list
565  active.clear();
566 
567  std::copy_if(all.begin(),
568  all.end(),
569  std::back_inserter(active),
570  [](const std::shared_ptr<T> & object) { return object->enabled(); });
571 }
572 
573 template <typename T>
574 void
576 {
577  checkThreadID(tid);
578 
579  for (auto & object_pair : _all_block_objects[tid])
580  sortHelper(object_pair.second);
581 
582  for (auto & object_pair : _all_boundary_objects[tid])
583  sortHelper(object_pair.second);
584 
585  sortHelper(_all_objects[tid]);
586 
587  // The active lists now must be update to reflect the order changes
588  updateActive(tid);
589 }
590 
591 template <typename T>
592 void
594  std::set<MooseVariableFieldBase *> & needed_moose_vars, THREAD_ID tid /* = 0*/) const
595 {
596  if (hasActiveObjects(tid))
597  updateVariableDependencyHelper(needed_moose_vars, _all_objects[tid]);
598 }
599 
600 template <typename T>
601 void
603  SubdomainID id,
604  std::set<MooseVariableFieldBase *> & needed_moose_vars,
605  THREAD_ID tid /* = 0*/) const
606 {
607  if (hasActiveBlockObjects(id, tid))
608  updateVariableDependencyHelper(needed_moose_vars, getActiveBlockObjects(id, tid));
609 }
610 
611 template <typename T>
612 void
614  std::set<MooseVariableFieldBase *> & needed_moose_vars, THREAD_ID tid /* = 0*/) const
615 {
616  if (hasActiveBoundaryObjects(tid))
617  {
618  typename std::map<BoundaryID, std::vector<std::shared_ptr<T>>>::const_iterator it;
619  for (const auto & object_pair : _active_boundary_objects[tid])
620  updateVariableDependencyHelper(needed_moose_vars, object_pair.second);
621  }
622 }
623 
624 template <typename T>
625 void
627  BoundaryID id,
628  std::set<MooseVariableFieldBase *> & needed_moose_vars,
629  THREAD_ID tid /* = 0*/) const
630 {
631  if (hasActiveBoundaryObjects(id, tid))
632  updateVariableDependencyHelper(needed_moose_vars, getActiveBoundaryObjects(id, tid));
633 }
634 
635 template <typename T>
636 void
638  std::set<MooseVariableFieldBase *> & needed_moose_vars,
639  const std::vector<std::shared_ptr<T>> & objects)
640 {
641  for (const auto & object : objects)
642  {
643  auto c = dynamic_cast<const MooseVariableDependencyInterface *>(object.get());
644  if (c)
645  {
646  const auto & mv_deps = c->getMooseVariableDependencies();
647  needed_moose_vars.insert(mv_deps.begin(), mv_deps.end());
648  }
649  }
650 }
651 
652 template <typename T>
653 void
655  SubdomainID id, std::set<TagID> & needed_fe_var_vector_tags, THREAD_ID tid /* = 0*/) const
656 {
657  if (hasActiveBlockObjects(id, tid))
658  updateFEVariableCoupledVectorTagDependencyHelper(needed_fe_var_vector_tags,
659  getActiveBlockObjects(id, tid));
660 }
661 
662 template <typename T>
663 void
665  BoundaryID id, std::set<TagID> & needed_fe_var_vector_tags, THREAD_ID tid /* = 0*/) const
666 {
667  if (hasActiveBoundaryObjects(id, tid))
668  updateFEVariableCoupledVectorTagDependencyHelper(needed_fe_var_vector_tags,
669  getActiveBoundaryObjects(id, tid));
670 }
671 
672 template <typename T>
673 void
675  std::set<TagID> & needed_fe_var_vector_tags, const std::vector<std::shared_ptr<T>> & objects)
676 {
677  for (const auto & object : objects)
678  {
679  auto c = dynamic_cast<const Coupleable *>(object.get());
680  if (c)
681  {
682  const auto & tag_deps = c->getFEVariableCoupleableVectorTags();
683  needed_fe_var_vector_tags.insert(tag_deps.begin(), tag_deps.end());
684  }
685  }
686 }
687 
688 template <typename T>
689 void
691  std::unordered_set<unsigned int> & needed_mat_props, THREAD_ID tid /* = 0*/) const
692 {
693  if (hasActiveObjects(tid))
694  updateMatPropDependencyHelper(needed_mat_props, _all_objects[tid]);
695 }
696 
697 template <typename T>
698 void
700  SubdomainID id,
701  std::unordered_set<unsigned int> & needed_mat_props,
702  THREAD_ID tid /* = 0*/) const
703 {
704  if (hasActiveBlockObjects(id, tid))
705  updateMatPropDependencyHelper(needed_mat_props, getActiveBlockObjects(id, tid));
706 }
707 
708 template <typename T>
709 void
711  std::unordered_set<unsigned int> & needed_mat_props, THREAD_ID tid /* = 0*/) const
712 {
713  if (hasActiveBoundaryObjects(tid))
714  for (auto & active_bnd_object : _active_boundary_objects[tid])
715  updateMatPropDependencyHelper(needed_mat_props, active_bnd_object.second);
716 }
717 
718 template <typename T>
719 void
721  BoundaryID id,
722  std::unordered_set<unsigned int> & needed_mat_props,
723  THREAD_ID tid /* = 0*/) const
724 {
725  if (hasActiveBoundaryObjects(id, tid))
726  updateMatPropDependencyHelper(needed_mat_props, getActiveBoundaryObjects(id, tid));
727 }
728 
729 template <typename T>
730 void
732  std::unordered_set<unsigned int> & needed_mat_props,
733  const std::vector<std::shared_ptr<T>> & objects)
734 {
735  for (auto & object : objects)
736  {
737  auto c = dynamic_cast<const MaterialPropertyInterface *>(object.get());
738  if (c)
739  {
740  auto & mp_deps = c->getMatPropDependencies();
741  needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
742  }
743  }
744 }
745 
746 template <typename T>
747 void
748 MooseObjectWarehouseBase<T>::subdomainsCovered(std::set<SubdomainID> & subdomains_covered,
749  std::set<std::string> & unique_variables,
750  THREAD_ID tid /*=0*/) const
751 {
752  for (const auto & object : _active_objects[tid])
753  unique_variables.insert(object->variable().name());
754 
755  for (const auto & object_pair : _active_block_objects[tid])
756  subdomains_covered.insert(object_pair.first);
757 }
758 
759 template <typename T>
760 std::string
762  const THREAD_ID tid /*=0*/, const std::string & prefix /*="[DBG]"*/) const
763 {
764  std::vector<std::string> output;
765  for (const auto & object : _active_objects[tid])
766  output.push_back(object->name());
767  return ConsoleUtils::formatString(MooseUtils::join(output, " "), prefix);
768 }
769 
770 template <typename T>
771 void
772 MooseObjectWarehouseBase<T>::sortHelper(std::vector<std::shared_ptr<T>> & objects)
773 {
774  // Do nothing if the vector is empty
775  if (objects.empty())
776  return;
777 
778  try
779  {
780  // Sort based on dependencies
781  DependencyResolverInterface::sort<std::shared_ptr<T>>(objects);
782  }
783  catch (CyclicDependencyException<std::shared_ptr<T>> & e)
784  {
785  DependencyResolverInterface::cyclicDependencyError<std::shared_ptr<T>>(
786  e, "Cyclic dependency detected in object ordering");
787  }
788 }
789 
790 template <typename T>
791 inline void
793 {
794  mooseAssert(tid < _num_threads,
795  "Attempting to access a thread id ("
796  << tid << ") greater than the number allowed by the storage item ("
797  << _num_threads << ")");
798 }
std::string name(const ElemQuality q)
void updateVariableDependency(std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
Update variable dependency vector.
std::string activeObjectsToFormattedString(THREAD_ID tid=0, const std::string &prefix="[DBG]") const
Output the active content of the warehouse to a string, meant to be output to the console...
void sort(THREAD_ID tid=0)
Sort the objects using the DependencyResolver.
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class...
const std::set< MooseVariableFieldBase * > & getMooseVariableDependencies() const
Retrieve the set of MooseVariableFieldBase that this object depends on.
unsigned int size(THREAD_ID tid=0) const
Return how many kernels we store in the current warehouse.
unsigned int n_threads()
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
bool hasObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< T > > > > _all_block_objects
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
std::vector< std::vector< std::shared_ptr< T > > > _all_objects
Storage container for the ALL pointers (THREAD_ID on outer vector)
std::vector< std::map< SubdomainID, std::vector< std::shared_ptr< T > > > > _active_block_objects
Active block restricted objects (THREAD_ID on outer vector)
void checkThreadID(THREAD_ID tid) const
Calls assert on thread id.
virtual ~MooseObjectWarehouseBase()
Destructor.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary...
MooseObjectWarehouseBase(bool threaded=true)
Constructor.
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.
This class provides an interface for common operations on field variables of both FE and FV types wit...
MaterialBase objects are special in that they have additional objects created automatically (see FEPr...
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
void updateBlockVariableDependency(SubdomainID id, std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
void updateBoundaryFEVariableCoupledVectorTagDependency(BoundaryID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
static void updateFEVariableCoupledVectorTagDependencyHelper(std::set< TagID > &needed_fe_var_vector_tags, const std::vector< std::shared_ptr< T >> &objects)
Helper method for updating FE variable coupleable vector tag vector.
bool hasBoundaryObjects(BoundaryID id, THREAD_ID tid=0) const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > _active_boundary_objects
Active boundary restricted objects (THREAD_ID on outer vector)
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
std::set< SubdomainID > getActiveBlocks(THREAD_ID tid=0) const
Return a set of active SubdomainsIDs.
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
const std::vector< std::shared_ptr< T > > & getObjects(THREAD_ID tid=0) const
Retrieve complete vector to the all/block/boundary restricted objects for a given thread...
std::shared_ptr< T > getObject(const std::string &name, THREAD_ID tid=0) const
static void updateMatPropDependencyHelper(std::unordered_set< unsigned int > &needed_mat_props, const std::vector< std::shared_ptr< T >> &objects)
Helper method for updating material property dependency vector.
static void sortHelper(std::vector< std::shared_ptr< T >> &objects)
Helper method for sorting vectors of objects.
std::string formatString(std::string message, const std::string &prefix)
Add new lines and prefixes to a string for pretty display in output NOTE: This makes a copy of the st...
Definition: ConsoleUtils.C:436
boundary_id_type BoundaryID
static void updateVariableDependencyHelper(std::set< MooseVariableFieldBase *> &needed_moose_vars, const std::vector< std::shared_ptr< T >> &objects)
Helper method for updating variable dependency vector.
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Populates a set of covered subdomains and the associated variable names.
virtual void updateActive(THREAD_ID tid=0)
Update the active status of Kernels.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getBlockObjects(THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getBoundaryObjects(THREAD_ID tid=0) const
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 =0
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
std::vector< std::map< BoundaryID, std::vector< std::shared_ptr< T > > > > _all_boundary_objects
void updateBoundaryMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
void updateMatPropDependency(std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
Update material property dependency vector.
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
const THREAD_ID _num_threads
Convenience member storing the number of threads used for storage (1 or libMesh::n_threads) ...
Interface for objects that needs coupling capabilities.
Definition: Coupleable.h:45
void updateBlockMatPropDependency(SubdomainID id, std::unordered_set< unsigned int > &needed_mat_props, THREAD_ID tid=0) const
void updateBlockFEVariableCoupledVectorTagDependency(SubdomainID id, std::set< TagID > &needed_fe_var_vector_tags, THREAD_ID tid=0) const
Update FE variable coupleable vector tag vector.
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:75
bool hasActiveObject(const std::string &name, THREAD_ID tid=0) const
Convenience functions for checking/getting specific objects.
bool hasActiveObjects(THREAD_ID tid=0) const
An interface for accessing Materials.
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0, bool recurse=true)
Adds an object to the storage structure.
std::vector< std::vector< std::shared_ptr< T > > > _active_objects
All active objects (THREAD_ID on outer vector)
const std::unordered_set< unsigned int > & getMatPropDependencies() const
Retrieve the set of material properties that this object depends on.
void updateBoundaryVariableDependency(std::set< MooseVariableFieldBase *> &needed_moose_vars, THREAD_ID tid=0) const
std::vector< std::string > getVecMooseType(const std::string &name) const
THREAD_ID numThreads() const
Return the number of threads.
A base storage container for MooseObjects.
std::set< TagID > & getFEVariableCoupleableVectorTags()
Definition: Coupleable.h:106
static void updateActiveHelper(std::vector< std::shared_ptr< T >> &active, const std::vector< std::shared_ptr< T >> &all)
Helper method for updating active vectors.
std::string join(const T &strings, const std::string &delimiter)
Python like join function for strings.
Definition: MooseUtils.h:130
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.
unsigned int THREAD_ID
Definition: MooseTypes.h:198
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.