void PointVec::correctNameIDMapping() { // create mapping id -> name using the std::vector id_names std::vector<std::string> id_names(_pnt_id_map.size(), std::string("")); for (auto it = _name_id_map->begin(); it != _name_id_map->end(); it++) { id_names[it->second] = it->first; } for (auto it = _name_id_map->begin(); it != _name_id_map->end(); ) { // extract the id associated with the name const std::size_t id(it->second); if (_pnt_id_map[id] == id) { it++; continue; } if (_pnt_id_map[_pnt_id_map[id]] == _pnt_id_map[id]) { if (id_names[_pnt_id_map[id]].length() != 0) { // point has already a name, erase the second occurrence it = _name_id_map->erase(it); } else { // until now the point has not a name // assign the second occurrence the correct id it->second = _pnt_id_map[id]; it++; } } else { it->second = _pnt_id_map[id]; // update id associated to the name it++; } } }
BlkResTestDiffusion::BlkResTestDiffusion(const InputParameters & parameters) : Kernel(modifyParams(parameters)) { // Get an test enum from the kernel parameters MooseEnum test = parameters.get<MooseEnum>("test"); // test that hasBlocks is working if (test == "hasBlocks") { // Define a SubdomainName vector for testing against std::vector<SubdomainName> id_names(2); id_names[0] = "1"; id_names[1] = "2"; // Define a SubdomainID vector for testing against std::vector<SubdomainID> ids(2); ids[0] = 1; ids[1] = 2; // Define a SubdomainID set for testing against std::set<SubdomainID> id_set(ids.begin(), ids.end()); // Test true single SudomainName input if (!hasBlocks("1")) mooseError("Test 1: hasBlocks(SubdomainName) = true failed"); // Test false of single Subdomain input if (hasBlocks("3")) mooseError("Test 2: hasBlocks(SubdomainName) = false failed"); // Test true vector SubdomainName input if (!hasBlocks(id_names)) mooseError("Test 3: hasBlocks(std::vector<SubdomainName>) = true failed"); // Test false vector SudomainName input id_names.push_back("3"); if (hasBlocks(id_names)) mooseError("Test 4: hasBlocks(std::vector<SubdomainName>) = false failed"); // Test true single SubdomainID input if (!hasBlocks(1)) mooseError("Test 5: hasBlocks(SubdomainID) = true failed"); // Test false single SubdomainID input if (hasBlocks(5)) mooseError("Test 6: hasBlocks(SubdomainID) = false failed"); // Test true for std::vector<SubdomainID> if (!hasBlocks(ids)) mooseError("Test 7: hasBlocks(std::vector<SubdomainID>) = true failed"); // Test false for std::vector<SubdomainID> ids.push_back(4); if (hasBlocks(ids)) mooseError("Test 8: hasBlocks(std::vector<SubdomainID>) = false failed"); // Test true for std::set<SubdomainID> if (!hasBlocks(id_set)) mooseError("Test 9: hasBlocks(std::set<SubdomainID) = true failed"); // Test false for std::set<SubdomainID> id_set.insert(12); if (hasBlocks(id_set)) mooseError("Test 10: hasBlocks(std::set<SubdomainID>) = false failed"); // This is the expected error, all the above tests passed mooseError("hasBlocks testing passed"); } // Test of stored ANY_BLOCK_ID on object else if (test == "hasBlocks_ANY_BLOCK_ID") { // Test that ANY_BLOCK_ID is working if (hasBlocks(1)) mooseError("hasBlocks_ANY_BLOCK_ID test passed"); else mooseError("hasBlocks_ANY_BLOCK_ID test failed"); } // Test that the blocks() method is working else if (test == "blocks") { const std::vector<SubdomainName> & blks = blocks(); if (blks[0] == "1" && blks[1] == "2" && blks.size() == 2) mooseError("Blocks testing passed"); // expected error else mooseError("Blocks testing failed"); } // Test that the getSubdomains() is working else if (test == "blockIDs") { const std::set<SubdomainID> & ids = blockIDs(); if (ids.count(1) == 1 && ids.count(2) == 1) mooseError("blockIDs testing passed"); // expected error else mooseError("blockIDs testing failed"); } // Test that the isSubset() is working else if (test == "isBlockSubset") { std::set<SubdomainID> sub_id; sub_id.insert(10); sub_id.insert(1); sub_id.insert(4); sub_id.insert(2); if (isBlockSubset(sub_id)) mooseError("isBlockSubset testing passed"); // expected error else mooseError("isBlockSubset testing failed"); } // Test that hasMaterialPropertyBlock is working properly else if (test == "hasBlockMaterialProperty_true") { if (hasBlockMaterialProperty<Real>("a")) mooseError("hasBlockMaterialProperty is true, test passed"); // expected error else mooseError("hasBlockMaterialProperty is false, test failed"); } else if (test == "hasBlockMaterialProperty_false") { if (hasBlockMaterialProperty<Real>("b")) mooseError("hasBlockMaterialProperty is true, test failed"); else mooseError("hasBlockMaterialProperty is false, test passed"); // expected error } }
BndTestDirichletBC::BndTestDirichletBC(const InputParameters & parameters) : NodalBC(parameters), _value(getParam<Real>("value")) { // Get an test enum from the kernel parameters MooseEnum test = parameters.get<MooseEnum>("test"); // test that hasBlocks is working if (test == "hasBoundary") { // Define a SubdomainName vector for testing against std::vector<BoundaryName> id_names(1); id_names[0] = "1"; // Define a SubdomainID vector for testing against std::vector<BoundaryID> ids(1); ids[0] = 1; // Define a SubdomainID set for testing against std::set<BoundaryID> id_set(ids.begin(), ids.end()); // Test true single SudomainName input if (!hasBoundary("1")) mooseError("Test 1: hasBoundary(SubdomainName) = true failed"); // Test false of single Subdomain input if (hasBoundary("3")) mooseError("Test 2: hasBoundary(BoundaryName) = false failed"); // Test true vector BoundaryName input if (!hasBoundary(id_names)) mooseError("Test 3: hasBoundary(std::vector<BoundaryName>) = true failed"); // Test false vector SudomainName input id_names.push_back("3"); if (hasBoundary(id_names)) mooseError("Test 4: hasBoundary(std::vector<BoundaryName>) = false failed"); // Test true single BoundaryID input if (!hasBoundary(1)) mooseError("Test 5: hasBoundary(BoundaryID) = true failed"); // Test false single BoundaryID input if (hasBoundary(5)) mooseError("Test 6: hasBoundary(BoundaryID) = false failed"); // Test true for std::vector<BoundaryID> if (!hasBoundary(ids)) mooseError("Test 7: hasBoundary(std::vector<BoundaryID>) = true failed"); // Test false for std::vector<BoundaryID> ids.push_back(4); if (hasBoundary(ids)) mooseError("Test 8: hasBoundary(std::vector<BoundaryID>) = false failed"); // Test true for std::set<BoundaryID> if (!hasBoundary(id_set)) mooseError("Test 9: hasBoundary(std::set<BoundaryID) = true failed"); // Test false for std::set<BoundaryID> id_set.insert(12); if (hasBoundary(id_set)) mooseError("Test 10: hasBoundary(std::set<BoundaryID>) = false failed"); // This is the expected error, all the above tests passed mooseError("hasBoundary testing passed"); } // Test that the boundarhNames() method is working else if (test == "boundaryNames") { const std::vector<BoundaryName> & bnds = boundaryNames(); if (bnds.size() == 1 && bnds[0] == "1") mooseError("boundaryNames test passed"); // expected error else mooseError("boundaryNames test failed"); } // Test that the boundaryIDS() is working else if (test == "boundaryIDs") { const std::set<BoundaryID> & ids = boundaryIDs(); if (ids.count(1) == 1) mooseError("boundaryIDs test passed"); // expected error else mooseError("boundaryIDs test faild"); } // Test that the isBoundarySubset() is working else if (test == "isBoundarySubset") { std::set<BoundaryID> sub_id; sub_id.insert(10); sub_id.insert(1); sub_id.insert(4); sub_id.insert(2); if (isBoundarySubset(sub_id)) mooseError("isBoundarySubset test passed"); // expetect error else mooseError("isBoundarySubset test failed"); } // Test that hasMaterialPropertyBoundary is working properly else if (test == "hasBoundaryMaterialProperty_true") { if (hasBoundaryMaterialProperty<Real>("a")) mooseError("hasBoundaryMaterialProperty is true, test passed"); // expected error else mooseError("hasBoundaryMaterialProperty is false, test failed"); } else if (test == "hasBoundaryMaterialProperty_false") { if (hasBoundaryMaterialProperty<Real>("b")) mooseError("hasBoundaryMaterialProperty is true, test failed"); else mooseError("hasBoundaryMaterialProperty is false, test passed"); // expected error } }