Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "InitialConditionWarehouse.h" 11 : 12 : // MOOSE includes 13 : #include "InitialConditionBase.h" 14 : #include "MooseVariableFE.h" 15 : 16 57974 : InitialConditionWarehouse::InitialConditionWarehouse() 17 : : MooseObjectWarehouseBase<InitialConditionBase>(), 18 57974 : _boundary_ics(libMesh::n_threads()), 19 115948 : _block_ics(libMesh::n_threads()) 20 : { 21 57974 : } 22 : 23 : void 24 56835 : InitialConditionWarehouse::initialSetup(THREAD_ID tid) 25 : { 26 56835 : MooseObjectWarehouseBase<InitialConditionBase>::sort(tid); 27 82824 : for (const auto & ic : _active_objects[tid]) 28 25997 : ic->initialSetup(); 29 56827 : } 30 : 31 : void 32 29160 : InitialConditionWarehouse::addObject(std::shared_ptr<InitialConditionBase> object, 33 : THREAD_ID tid, 34 : bool recurse) 35 : { 36 : // Check that when object is boundary restricted that the variable is nodal 37 29160 : const MooseVariableFEBase & var = object->variable(); 38 29160 : const auto ic_key = std::tuple(var.name(), object->getState()); 39 : 40 : // Boundary Restricted 41 29160 : if (object->boundaryRestricted()) 42 : { 43 26 : if (!var.isNodal()) 44 4 : mooseError("You are trying to set a boundary restricted variable on non-nodal variable. That " 45 : "is not allowed."); 46 : 47 22 : const auto iter = _boundary_ics[tid].find(ic_key); 48 22 : if (iter != _boundary_ics[tid].end() && object->hasBoundary(iter->second)) 49 8 : mooseError("The initial condition '", 50 4 : object->name(), 51 : "' is being defined on a boundary that already has an initial condition defined " 52 : "with the same variable and state."); 53 : else 54 18 : _boundary_ics[tid][ic_key].insert(object->boundaryIDs().begin(), object->boundaryIDs().end()); 55 : } 56 : 57 : // Block Restricted 58 29134 : else if (object->blockRestricted()) 59 : { 60 2352 : auto iter = _block_ics[tid].find(ic_key); 61 2835 : if (iter != _block_ics[tid].end() && 62 962 : (object->hasBlocks(iter->second) || 63 2831 : (iter->second.find(Moose::ANY_BLOCK_ID) != iter->second.end()))) 64 8 : mooseError("The initial condition '", 65 4 : object->name(), 66 : "' is being defined on a block that already has an initial condition defined " 67 : "with the same variable and state."); 68 : else 69 2348 : _block_ics[tid][ic_key].insert(object->blockIDs().begin(), object->blockIDs().end()); 70 : } 71 : 72 : // Non-restricted 73 : else 74 : { 75 26782 : auto iter = _block_ics[tid].find(ic_key); 76 26782 : if (iter != _block_ics[tid].end()) 77 16 : mooseError("The initial condition '", 78 8 : object->name(), 79 : "' is being defined on a block that already has an initial condition defined " 80 : "with the same variable and state."); 81 : else 82 26774 : _block_ics[tid][ic_key].insert(Moose::ANY_BLOCK_ID); 83 : } 84 : 85 : // Add the IC to the storage 86 29140 : MooseObjectWarehouseBase<InitialConditionBase>::addObject(object, tid, recurse); 87 29140 : } 88 : 89 : std::set<std::string> 90 55380 : InitialConditionWarehouse::getDependObjects() const 91 : { 92 55380 : std::set<std::string> depend_objects; 93 : 94 55380 : const auto & ics = getActiveObjects(); 95 80831 : for (const auto & ic : ics) 96 : { 97 25451 : const auto & uo = ic->getDependObjects(); 98 25451 : depend_objects.insert(uo.begin(), uo.end()); 99 : } 100 : 101 55380 : return depend_objects; 102 0 : }