Example #1
0
bool
BoundaryRestrictable::hasBoundaryMaterialPropertyHelper(const std::string & prop_name) const
{
  // Reference to MaterialWarehouse for testing and retrieving boundary ids
  const MaterialWarehouse & warehouse = _bnd_feproblem->getMaterialWarehouse();

  // Complete set of BoundaryIDs that this object is defined
  const std::set<BoundaryID> & ids = hasBoundary(Moose::ANY_BOUNDARY_ID) ? meshBoundaryIDs() : boundaryIDs();

  // Loop over each BoundaryID for this object
  for (const auto & id : ids)
  {
    // Storage of material properties that have been DECLARED on this BoundaryID
    std::set<std::string> declared_props;

    // If boundary materials exist, populated the set of properties that were declared
    if (warehouse.hasActiveBoundaryObjects(id))
    {
      const std::vector<MooseSharedPointer<Material> > & mats = warehouse.getActiveBoundaryObjects(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 boundaries
  return true;
}
Example #2
0
bool
BoundaryRestrictable::hasBoundary(BoundaryName name) const
{
  // Create a vector and utilize the getBoundaryIDs function, which
  // handles the ANY_BOUNDARY_ID (getBoundaryID does not)
  return hasBoundary(_bnd_mesh->getBoundaryIDs({name}));
}
Example #3
0
bool
BoundaryRestrictable::hasBoundary(std::set<BoundaryID> ids, TEST_TYPE type) const
{
  // An empty input is assumed to be ANY_BOUNDARY_ID
  if (ids.empty() || ids.find(Moose::ANY_BOUNDARY_ID) != ids.end())
    return true;

  // All supplied IDs must match those of the object
  else if (type == ALL)
  {
    if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
      return true;
    else
      return std::includes(_bnd_ids.begin(), _bnd_ids.end(), ids.begin(), ids.end());
  }
  // Any of the supplied IDs must match those of the object
  else
  {
    // Loop through the supplied ids
    for (const auto & id : ids)
    {
      // Test the current supplied id
      bool test = hasBoundary(id);

      // If the id exists in the stored ids, then return true, otherwise
      if (test)
        return true;
    }
    return false;
  }
}
Example #4
0
bool
BoundaryRestrictable::hasBoundaryMaterialPropertyHelper(const std::string & prop_name) const
{
  // Reference to MaterialWarehouse for testing and retrieving boundary ids
  MaterialWarehouse & material_warehouse = _bnd_feproblem->getMaterialWarehouse(_bnd_tid);

  // Complete set of BoundaryIDs that this object is defined
  const std::set<BoundaryID> & ids = hasBoundary(Moose::ANY_BOUNDARY_ID) ? meshBoundaryIDs() : boundaryIDs();

  // Loop over each BoundaryID for this object
  for (std::set<BoundaryID>::const_iterator id_it = ids.begin(); id_it != ids.end(); ++id_it)
  {
    // Storage of material properties that have been DECLARED on this BoundaryID
    std::set<std::string> declared_props;

    // If boundary materials exist, populated the set of properties that were declared
    if (material_warehouse.hasBoundaryMaterials(*id_it))
    {
      std::vector<Material *> mats = material_warehouse.getBoundaryMaterials(*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 boundaries
  return true;
}
Example #5
0
bool
BoundaryRestrictable::hasBoundary(std::set<BoundaryID> ids, TEST_TYPE type) const
{
  // An empty input is assumed to be ANY_BOUNDARY_ID
  if (ids.empty() || ids.count(Moose::ANY_BOUNDARY_ID) > 0)
    return true;

  // All supplied IDs must match those of the object
  else if (type == ALL)
    return std::includes(_bnd_ids.begin(), _bnd_ids.end(), ids.begin(), ids.end());

  // Any of the supplid IDs must match those of the object
  else
  {
    // Loop through the supplied ids
    for (std::set<BoundaryID>::const_iterator it = ids.begin(); it != ids.end(); ++it)
    {
      // Test the current supplied id
      bool test = hasBoundary(*it);

      // If the id exists in the stored ids, then return true, otherwise
      if (test)
        return true;
    }
    return false;
  }
}
Example #6
0
bool
BoundaryRestrictable::hasBoundary(BoundaryName name) const
{
  // Create a vector and utilize the getBoundaryIDs function, which
  // handles the ANY_BOUNDARY_ID (getBoundaryID does not)
  std::vector<BoundaryName> names(1);
  names[0] = name;
  return hasBoundary(_bnd_mesh->getBoundaryIDs(names));
}
void
NodalNormalsPreprocessor::execute()
{
  NumericVector<Number> & sln = _aux.solution();

  // Get a reference to our BoundaryInfo object for later use...
  BoundaryInfo & boundary_info = _mesh.getMesh().get_boundary_info();

  // Container to catch IDs handed back by BoundaryInfo.
  std::vector<BoundaryID> node_boundary_ids;

  // Loop through each node on the current element
  for (unsigned int i = 0; i < _current_elem->n_nodes(); i++)
  {
    // Extract a pointer to a node
    const Node * node = _current_elem->node_ptr(i);

    // Only continue if the node is on a boundary
    if (_mesh.isBoundaryNode(node->id()))
    {
      // List of IDs for the boundary
      boundary_info.boundary_ids(node, node_boundary_ids);

      // Perform the calculation, the node must be:
      //    (1) On a boundary to which the object is restricted
      //    (2) Not on a corner of the boundary
      if (hasBoundary(node_boundary_ids, _boundaries) &&
          (!_has_corners || !boundary_info.has_boundary_id(node, _corner_boundary_id)))
      {
        // Perform the caluation of the normal
        if (node->n_dofs(_aux.number(), _fe_problem.getVariable(_tid, "nodal_normal_x").number()) >
            0)
        {
          // but it is not a corner node, they will be treated differently later on
          dof_id_type dof_x = node->dof_number(
              _aux.number(), _fe_problem.getVariable(_tid, "nodal_normal_x").number(), 0);
          dof_id_type dof_y = node->dof_number(
              _aux.number(), _fe_problem.getVariable(_tid, "nodal_normal_y").number(), 0);
          dof_id_type dof_z = node->dof_number(
              _aux.number(), _fe_problem.getVariable(_tid, "nodal_normal_z").number(), 0);

          for (unsigned int qp = 0; qp < _qrule->n_points(); qp++)
          {
            Threads::spin_mutex::scoped_lock lock(nodal_normals_preprocessor_mutex);

            sln.add(dof_x, _JxW[qp] * _grad_phi[i][qp](0));
            sln.add(dof_y, _JxW[qp] * _grad_phi[i][qp](1));
            sln.add(dof_z, _JxW[qp] * _grad_phi[i][qp](2));
          }
        }
      }
    }
  }
}
Example #8
0
void
CrackFrontDefinition::getCrackFrontNodes(std::set<unsigned int>& nodes)
{
  ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange();
  for (ConstBndNodeRange::const_iterator nd = bnd_nodes.begin() ; nd != bnd_nodes.end(); ++nd)
  {
    const BndNode * bnode = *nd;
    BoundaryID boundary_id = bnode->_bnd_id;

    if (hasBoundary(boundary_id))
    {
      nodes.insert(bnode->_node->id());
    }
  }
  if (_treat_as_2d)
  {
    if (nodes.size() > 1)
    {
      //Delete all but one node if they are collinear in the axis normal to the 2d plane
      unsigned int axis0;
      unsigned int axis1;

      switch (_axis_2d)
      {
        case 0:
          axis0 = 1;
          axis1 = 2;
          break;
        case 1:
          axis0 = 0;
          axis1 = 2;
          break;
        case 2:
          axis0 = 0;
          axis1 = 1;
          break;
      }

      Real node0coor0;
      Real node0coor1;

      for (std::set<unsigned int>::iterator sit=nodes.begin(); sit != nodes.end(); ++sit)
      {
        Node & curr_node = _mesh.node(*sit);
        if (sit == nodes.begin())
        {
          node0coor0 = curr_node(axis0);
          node0coor1 = curr_node(axis1);
        }
        else
        {
          if ((std::abs(curr_node(axis0) - node0coor0) > _tol) ||
              (std::abs(curr_node(axis1) - node0coor1) > _tol))
          {
            mooseError("Boundary provided in CrackFrontDefinition contains "<<nodes.size()<<" nodes, which are not collinear in the "<<_axis_2d<<" axis.  Must contain either 1 node or collinear nodes to treat as 2D.");
          }
        }
      }

      std::set<unsigned int>::iterator second_node = nodes.begin();
      ++second_node;
      nodes.erase(second_node,nodes.end());
    }
  }
}
Example #9
0
bool
BoundaryRestrictable::hasBoundary(std::vector<BoundaryID> ids, TEST_TYPE type) const
{
  std::set<BoundaryID> ids_set(ids.begin(), ids.end());
  return hasBoundary(ids_set, type);
}
Example #10
0
bool
BoundaryRestrictable::hasBoundary(std::vector<BoundaryName> names) const
{
  return hasBoundary(_bnd_mesh->getBoundaryIDs(names));
}
Example #11
0
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
  }
}