PenetrationAux::PenetrationAux(const InputParameters & parameters) : AuxKernel(parameters), // Here we cast the value of the MOOSE enum to an integer to the class-based enum. _quantity(getParam<MooseEnum>("quantity").getEnum<PenetrationAux::PA_ENUM>()), _penetration_locator( _nodal ? getPenetrationLocator( parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order"))) : getQuadraturePenetrationLocator( parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))) { if (parameters.isParamValid("tangential_tolerance")) _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance")); if (parameters.isParamValid("normal_smoothing_distance")) _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance")); if (parameters.isParamValid("normal_smoothing_method")) _penetration_locator.setNormalSmoothingMethod( parameters.get<std::string>("normal_smoothing_method")); }
NearestNodeValueAux::NearestNodeValueAux(const InputParameters & parameters) : AuxKernel(parameters), _nearest_node( getNearestNodeLocator(parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0])), _serialized_solution(_nl_sys.currentSolution()), _paired_variable(coupled("paired_variable")) { if (boundaryNames().size() > 1) mooseError("NearestNodeValueAux can only be used with one boundary at a time!"); }
GapValueAux::GapValueAux(const InputParameters & parameters) : AuxKernel(parameters), _penetration_locator( _nodal ? getPenetrationLocator( parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order"))) : getQuadraturePenetrationLocator( parameters.get<BoundaryName>("paired_boundary"), boundaryNames()[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))), _moose_var(_subproblem.getStandardVariable(_tid, getParam<VariableName>("paired_variable"))), _serialized_solution(_moose_var.sys().currentSolution()), _dof_map(_moose_var.dofMap()), _warnings(getParam<bool>("warnings")) { if (parameters.isParamValid("tangential_tolerance")) _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance")); if (parameters.isParamValid("normal_smoothing_distance")) _penetration_locator.setNormalSmoothingDistance(getParam<Real>("normal_smoothing_distance")); if (parameters.isParamValid("normal_smoothing_method")) _penetration_locator.setNormalSmoothingMethod( parameters.get<std::string>("normal_smoothing_method")); Order pairedVarOrder(_moose_var.order()); Order gvaOrder(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order"))); if (pairedVarOrder != gvaOrder && pairedVarOrder != CONSTANT) mooseError("ERROR: specified order for GapValueAux (", Utility::enum_to_string<Order>(gvaOrder), ") does not match order for paired_variable \"", _moose_var.name(), "\" (", Utility::enum_to_string<Order>(pairedVarOrder), ")"); }
void SideSetsBetweenSubdomains::modify() { MeshBase & mesh = _mesh_ptr->getMesh(); SubdomainID master_id = _mesh_ptr->getSubdomainID(getParam<SubdomainName>("master_block")); SubdomainID paired_id = _mesh_ptr->getSubdomainID(getParam<SubdomainName>("paired_block")); std::vector<BoundaryName> boundary_names = boundaryNames(); std::vector<BoundaryID> boundary_ids(boundaryIDs().begin(), boundaryIDs().end()); // Get a reference to our BoundaryInfo object for later use BoundaryInfo & boundary_info = mesh.get_boundary_info(); MeshBase::const_element_iterator el = mesh.active_elements_begin(); const MeshBase::const_element_iterator end_el = mesh.active_elements_end(); for (; el != end_el ; ++el) { const Elem* elem = *el; SubdomainID curr_subdomain = elem->subdomain_id(); // We only need to loop over elements in the master subdomain if (curr_subdomain != master_id) continue; for (unsigned int side=0; side<elem->n_sides(); side++) { const Elem * neighbor = elem->neighbor(side); if (neighbor != NULL && neighbor->subdomain_id() == paired_id) // is this side between the two blocks? // Add the boundaries for (unsigned int i=0; i<boundary_ids.size(); ++i) boundary_info.add_side(elem, side, boundary_ids[i]); } } for (unsigned int i=0; i<boundary_ids.size(); ++i) boundary_info.sideset_name(boundary_ids[i]) = boundary_names[i]; }
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 } }
void AddExtraNodeset::modify() { // make sure the input is not empty bool data_valid = false; if (_pars.isParamValid("nodes")) if (getParam<std::vector<unsigned int> >("nodes").size() != 0) data_valid = true; if (_pars.isParamValid("coord")) { unsigned int n_coord = getParam<std::vector<Real> >("coord").size(); if (n_coord % _mesh_ptr->dimension() != 0) mooseError("Size of node coordinates does not match the mesh dimension"); if (n_coord !=0) data_valid = true; } if (!data_valid) mooseError("Node set can not be empty!"); // Get the BoundaryIDs from the mesh std::vector<BoundaryName> boundary_names = boundaryNames(); std::vector<BoundaryID> boundary_ids(boundaryIDs().begin(), boundaryIDs().end()); // Get a reference to our BoundaryInfo object BoundaryInfo & boundary_info = _mesh_ptr->getMesh().get_boundary_info(); // add nodes with their ids const std::vector<unsigned int> & nodes = getParam<std::vector<unsigned int> >("nodes"); for (unsigned int i=0; i<nodes.size(); i++) for (unsigned int j=0; j<boundary_ids.size(); ++j) boundary_info.add_node(nodes[i], boundary_ids[j]); // add nodes with their coordinates const std::vector<Real> & coord = getParam<std::vector<Real> >("coord"); unsigned int dim = _mesh_ptr->dimension(); unsigned int n_nodes = coord.size() / dim; for (unsigned int i=0; i<n_nodes; i++) { Point p; for (unsigned int j=0; j<dim; j++) p(j) = coord[i*dim+j]; const Elem* elem = _mesh_ptr->getMesh().point_locator() (p); if (!elem) mooseError("Unable to locate the following point within the domain, please check its coordinates:\n" << p); bool on_node = false; for (unsigned int j=0; j<elem->n_nodes(); j++) { const Node* node = elem->get_node(j); Point q; for (unsigned int k=0; k<dim; k++) q(k) = (*node)(k); if (p.absolute_fuzzy_equals(q, getParam<Real>("tolerance"))) { for (unsigned int j=0; j<boundary_ids.size(); ++j) boundary_info.add_node(node, boundary_ids[j]); on_node = true; break; } } if (!on_node) mooseError("Point can not be located!"); } for (unsigned int i=0; i<boundary_ids.size(); ++i) boundary_info.sideset_name(boundary_ids[i]) = boundary_names[i]; }