Beispiel #1
0
void
MooseApp::executeMeshModifiers()
{
  DependencyResolver<MooseSharedPointer<MeshModifier> > resolver;

  // Add all of the dependencies into the resolver and sort them
  for (std::map<std::string, MooseSharedPointer<MeshModifier> >::const_iterator it = _mesh_modifiers.begin(); it != _mesh_modifiers.end(); ++it)
  {
    // Make sure an item with no dependencies comes out too!
    resolver.addItem(it->second);

    std::vector<std::string> & modifiers = it->second->getDependencies();
    for (std::vector<std::string>::const_iterator depend_name_it = modifiers.begin(); depend_name_it != modifiers.end(); ++depend_name_it)
    {
      std::map<std::string, MooseSharedPointer<MeshModifier> >::const_iterator depend_it = _mesh_modifiers.find(*depend_name_it);

      if (depend_it == _mesh_modifiers.end())
        mooseError("The MeshModifier \"" << *depend_name_it << "\" was not created, did you make a spelling mistake or forget to include it in your input file?");

      resolver.insertDependency(it->second, depend_it->second);
    }
  }

  const std::vector<MooseSharedPointer<MeshModifier> > & ordered_modifiers = resolver.getSortedValues();

  if (ordered_modifiers.size())
  {
    MooseMesh * mesh = _action_warehouse.mesh().get();
    MooseMesh * displaced_mesh = _action_warehouse.displacedMesh().get();

    // Run the MeshModifiers in the proper order
    for (std::vector<MooseSharedPointer<MeshModifier> >::const_iterator it = ordered_modifiers.begin(); it != ordered_modifiers.end(); ++it)
    {
      MeshModifier * modifier_ptr = it->get();

      modifier_ptr->setMeshPointer(mesh);
      modifier_ptr->modify();

      if (displaced_mesh)
      {
        modifier_ptr->setMeshPointer(displaced_mesh);
        modifier_ptr->modify();
      }
    }

    mesh->prepared(false);
    if (displaced_mesh)
      displaced_mesh->prepared(false);
  }

  // Clear the modifiers, they are not used again during the simulation
  _mesh_modifiers.clear();
}
Beispiel #2
0
void
MooseApp::executeMeshModifiers()
{
  DependencyResolver<std::shared_ptr<MeshModifier>> resolver;

  // Add all of the dependencies into the resolver and sort them
  for (const auto & it : _mesh_modifiers)
  {
    // Make sure an item with no dependencies comes out too!
    resolver.addItem(it.second);

    std::vector<std::string> & modifiers = it.second->getDependencies();
    for (const auto & depend_name : modifiers)
    {
      auto depend_it = _mesh_modifiers.find(depend_name);

      if (depend_it == _mesh_modifiers.end())
        mooseError("The MeshModifier \"",
                   depend_name,
                   "\" was not created, did you make a "
                   "spelling mistake or forget to include it "
                   "in your input file?");

      resolver.insertDependency(it.second, depend_it->second);
    }
  }

  const auto & ordered_modifiers = resolver.getSortedValues();

  if (ordered_modifiers.size())
  {
    MooseMesh * mesh = _action_warehouse.mesh().get();
    MooseMesh * displaced_mesh = _action_warehouse.displacedMesh().get();

    // Run the MeshModifiers in the proper order
    for (const auto & modifier : ordered_modifiers)
      modifier->modifyMesh(mesh, displaced_mesh);

    /**
     * Set preparation flag after modifers are run. The final preparation
     * will be handled by the SetupMeshComplete Action.
     */
    mesh->prepared(false);
    if (displaced_mesh)
      displaced_mesh->prepared(false);
  }
}