bool BlockRestrictable::hasBlockMaterialPropertyHelper(const std::string & prop_name) { // Reference to MaterialWarehouse for testing and retrieving block ids const MaterialWarehouse & warehouse = _blk_feproblem->getMaterialWarehouse(); // Complete set of ids that this object is active const std::set<SubdomainID> & ids = hasBlocks(Moose::ANY_BLOCK_ID) ? meshBlockIDs() : blockIDs(); // Loop over each id for this object for (const auto & id : ids) { // Storage of material properties that have been DECLARED on this id std::set<std::string> declared_props; // If block materials exist, populated the set of properties that were declared if (warehouse.hasActiveBlockObjects(id)) { const std::vector<MooseSharedPointer<Material> > & mats = warehouse.getActiveBlockObjects(id); for (const auto & mat : mats) { const std::set<std::string> & mat_props = mat->getSuppliedItems(); declared_props.insert(mat_props.begin(), mat_props.end()); } } // If the supplied property is not in the list of properties on the current id, return false if (declared_props.find(prop_name) == declared_props.end()) return false; } // If you get here the supplied property is defined on all blocks return true; }
bool BlockRestrictable::hasBlockMaterialPropertyHelper(const std::string & prop_name) { // Reference to MaterialWarehouse for testing and retrieving block ids MaterialWarehouse & material_warehouse = _blk_feproblem->getMaterialWarehouse(_blk_tid); // Complete set of ids that this object is active const std::set<SubdomainID> & ids = hasBlocks(Moose::ANY_BLOCK_ID) ? meshBlockIDs() : blockIDs(); // Loop over each id for this object for (std::set<SubdomainID>::const_iterator id_it = ids.begin(); id_it != ids.end(); ++id_it) { // Storage of material properties that have been DECLARED on this id std::set<std::string> declared_props; // If block materials exist, populated the set of properties that were declared if (material_warehouse.hasMaterials(*id_it)) { std::vector<Material *> mats = material_warehouse.getMaterials(*id_it); for (std::vector<Material *>::iterator mat_it = mats.begin(); mat_it != mats.end(); ++mat_it) { const std::set<std::string> & mat_props = (*mat_it)->getSuppliedItems(); declared_props.insert(mat_props.begin(), mat_props.end()); } } // If the supplied property is not in the list of properties on the current id, return false if (declared_props.find(prop_name) == declared_props.end()) return false; } // If you get here the supplied property is defined on all blocks return true; }
bool Material::hasBlockMaterialPropertyHelper(const std::string & name) { // Reference to MaterialWarehouse for testing and retrieving block ids MaterialWarehouse & material_warehouse = _fe_problem.getMaterialWarehouse(_tid); // Complete set of ids that this object is active const std::set<SubdomainID> & ids = hasBlocks(Moose::ANY_BLOCK_ID) ? meshBlockIDs() : blockIDs(); // Flags for the various material types bool neighbor = getParam<bool>("_neighbor"); bool bnd = getParam<bool>("_bnd"); // Define function pointers to the correct has/get methods for the type of material bool(MaterialWarehouse::*has_func)(SubdomainID) const; std::vector<Material *> & (MaterialWarehouse::*get_func)(SubdomainID); if (bnd && neighbor) { has_func = &MaterialWarehouse::hasNeighborMaterials; get_func = &MaterialWarehouse::getNeighborMaterials; } else if (bnd && !neighbor) { has_func = &MaterialWarehouse::hasFaceMaterials; get_func = &MaterialWarehouse::getFaceMaterials; } else { has_func = &MaterialWarehouse::hasMaterials; get_func = &MaterialWarehouse::getMaterials; } // Loop over each id for this object for (std::set<SubdomainID>::const_iterator id_it = ids.begin(); id_it != ids.end(); ++id_it) { // Storage of material properties that have been DECLARED on this id std::set<std::string> declared_props; // If block materials exist, populated the set of properties that were declared if ((material_warehouse.*has_func)(*id_it)) { std::vector<Material *> mats = (material_warehouse.*get_func)(*id_it); for (std::vector<Material *>::iterator mat_it = mats.begin(); mat_it != mats.end(); ++mat_it) { const std::set<std::string> & mat_props = (*mat_it)->getSuppliedItems(); declared_props.insert(mat_props.begin(), mat_props.end()); } } // If the supplied property is not in the list of properties on the current id, return false if (declared_props.find(name) == declared_props.end()) return false; } // If you get here the supplied property is defined on all blocks return true; }
Moose::CoordinateSystemType BlockRestrictable::getBlockCoordSystem() { if (!_blk_mesh) mooseError("No mesh available in BlockRestrictable::checkCoordSystem()"); if (!_blk_feproblem) mooseError("No problem available in BlockRestrictable::checkCoordSystem()"); const auto & subdomains = blockRestricted() ? blockIDs() : meshBlockIDs(); if (subdomains.empty()) mooseError("No subdomains found in the problem."); // make sure all subdomains are using the same coordinate system auto coord_system = _blk_feproblem->getCoordSystem(*subdomains.begin()); for (auto subdomain : subdomains) if (_blk_feproblem->getCoordSystem(subdomain) != coord_system) mooseError("This object requires all subdomains to have the same coordinate system."); return coord_system; }