Exemple #1
0
void
EBSDMeshErrorTest::fileDoesNotExist()
{
  // generate input parameter set
  InputParameters params = _factory->getValidParams("EBSDMesh");
  params.addPrivateParam("_moose_app", _app);
  params.set<std::string>("name", "EBSD");

  // set filename
  params.set<FileName>("filename") = "FILEDOESNOTEXIST";

  // construct mesh object
  EBSDMesh * mesh = new EBSDMesh("unit_test_mesh", params);

  try
  {
    // trigger mesh building with invalid EBSD filename
    mesh->buildMesh();
  }
  catch(const std::exception & e)
  {
    std::string msg(e.what());
    CPPUNIT_ASSERT( msg.find("Can't open EBSD file: FILEDOESNOTEXIST") != std::string::npos );
  }

  // delete mesh object
  delete mesh;
}
Exemple #2
0
void
EBSDMeshErrorTest::headerErrorHelper(const char * filename, const char * error)
{
  // generate input parameter set
  InputParameters params = _factory->getValidParams("EBSDMesh");
  params.addPrivateParam("_moose_app", _app);
  params.set<std::string>("name", "EBSD");

  // set filename
  params.set<FileName>("filename") = filename;
  params.set<unsigned int>("uniform_refine") = 2;

  // construct mesh object
  EBSDMesh * mesh = new EBSDMesh("unit_test_mesh", params);

  try
  {
    // trigger mesh building with invalid EBSD filename
    mesh->buildMesh();
  }
  catch(const std::exception & e)
  {
    std::string msg(e.what());
    CPPUNIT_ASSERT_MESSAGE( filename, msg.find(error) != std::string::npos );
  }

  // delete mesh object
  delete mesh;
}
Exemple #3
0
void
EBSDMeshErrorTest::testParam(unsigned int nparam, const char ** param_list)
{
  for (unsigned int i = 0; i < nparam; ++i)
  {
    // generate input parameter set
    InputParameters params = _factory->getValidParams("EBSDMesh");
    params.addPrivateParam("_moose_app", _app);
    params.set<std::string>("name", "EBSD");

    // set a single parameter
    params.set<T>(param_list[i]) = T(1.0);

    // set filename (is a required param but not used in these tests)
    params.set<FileName>("filename") = "DUMMY";

    try
    {
      // construct mesh object
      EBSDMesh * mesh = new EBSDMesh("unit_test_mesh", params);
      delete mesh;
    }
    catch(const std::exception & e)
    {
      std::string msg(e.what());
      CPPUNIT_ASSERT( msg.find("Do not specify mesh geometry information, it is read from the EBSD file.") != std::string::npos );
    }
  }
}
Exemple #4
0
CoupledExecutioner::CoupledExecutioner(const std::string & name, InputParameters parameters) :
    Executioner(name, parameters)
{
  InputParameters params = emptyInputParameters();
  params.addPrivateParam("_moose_app", &_app);
  _problem = MooseSharedNamespace::static_pointer_cast<CoupledProblem>(_app.getFactory().create("CoupledProblem", "master_problem", params));
}
Exemple #5
0
MooseSharedPointer<Action>
ActionFactory::create(const std::string & action, const std::string & action_name, InputParameters parameters)
{
  parameters.addPrivateParam("_moose_app", &_app);
  parameters.addPrivateParam("action_type", action);
  std::pair<ActionFactory::iterator, ActionFactory::iterator> iters;
  BuildInfo *build_info = NULL;

  // Check to make sure that all required parameters are supplied
  parameters.checkParams(action_name);

  iters = _name_to_build_info.equal_range(action);

  // Find the Action that matches the one we have registered based on unique_id
  unsigned short count = 0;
  for (ActionFactory::iterator it = iters.first; it != iters.second; ++it)
  {
    ++count;
    if (parameters.have_parameter<unsigned int>("unique_id") && it->second._unique_id == parameters.get<unsigned int>("unique_id"))
    {
      build_info = &(it->second);
      break;
    }
  }
  // For backwards compatibility - If there is only one Action registered but it doesn't contain a unique_id that
  // matches, then surely it must still be the correct one
  if (count == 1 && !build_info)
    build_info = &(iters.first->second);

  if (!build_info)
    mooseError(std::string("Unable to find buildable Action from supplied InputParameters Object for ") + action_name);

  // Add the name to the parameters and create the object
  parameters.set<std::string>("_action_name") = action_name;
  MooseSharedPointer<Action> action_obj = (*build_info->_build_pointer)(parameters);

  if (parameters.get<std::string>("task") == "")
    action_obj->appendTask(build_info->_task);

  return action_obj;
}
Exemple #6
0
InputParameters
Factory::getValidParams(const std::string & obj_name)
{
  std::map<std::string, paramsPtr>::iterator it = _name_to_params_pointer.find(obj_name);

  // Check if the object is registered
  if (it == _name_to_params_pointer.end())
    reportUnregisteredError(obj_name);

  // Print out deprecated message, if it exists
  deprecatedMessage(obj_name);

  // Return the parameters
  paramsPtr & func = it->second;
  InputParameters params = (*func)();
  params.addPrivateParam("_moose_app", &_app);

  return params;
}
Exemple #7
0
InputParameters
ActionFactory::getValidParams(const std::string & name)
{
  /**
   * If an Action is registered more than once, it'll appear in the _name_to_build_info data
   * structure multiple times.  The actual parameters function remains the same however
   * so we can safely use the first instance
   */
  ActionFactory::iterator iter = _name_to_build_info.find(name);

  if (iter == _name_to_build_info.end())
    mooseError(std::string("A '") + name + "' is not a registered Action\n\n");

  InputParameters params = (iter->second._params_pointer)();
  params.addPrivateParam<unsigned int>("unique_id", iter->second._unique_id);
  params.addPrivateParam("_moose_app", &_app);

  return params;
}
Exemple #8
0
InputParameters
AdvancedOutput<T>::enableOutputTypes(const std::string & names)
{
  // The parameters object that will be returned
  InputParameters params = emptyInputParameters();

  // Set private parameter indicating that this method was called
  params.addPrivateParam("_output_valid_params_was_called", true);

  // Get the MultiEnum of output types
  MultiMooseEnum output_types = AdvancedOutput<T>::getOutputTypes();

  // Update the enum of output types to append
  if (names.empty())
    output_types = output_types.getRawNames();
  else
    output_types = names;

  // Add the parameters and return them
  AdvancedOutput::addValidParams(params, output_types);
  return params;
}
Exemple #9
0
void
CoupledExecutioner::addVariableAction(const std::string & task, ActionWarehouse & src, const std::string & src_var_name, ActionWarehouse & dest, const std::string & dest_var_name)
{
  // first, try to find if the destination warehouse already has the variable we are going to add
  bool dest_var_exists = false;
  for (ActionIterator ai = dest.actionBlocksWithActionBegin(task); ai != dest.actionBlocksWithActionEnd(task); ai++)
  {
    Action * action = *ai;
    if (action->getShortName() == dest_var_name)
    {
      dest_var_exists = true;
      break;
    }
  }

  if (!dest_var_exists)
  {
    for (ActionIterator ai = src.actionBlocksWithActionBegin(task); ai != src.actionBlocksWithActionEnd(task); ai++)
    {
      Action * action = *ai;
      if (action->getShortName() == src_var_name)
      {
        // take the action params and change them to create an aux variable
        InputParameters src_params = action->parameters();
        InputParameters params = _app.getActionFactory().getValidParams("AddAuxVariableAction");
        params.addPrivateParam("_moose_app", &_app);
        std::string dest_name("AuxVariables/" + dest_var_name);
        params.set<Parser *>("parser") = NULL;                    // set parser to NULL, since this action was not create by a parser
        params.set<ActionWarehouse *>("awh") = &dest;             // move the action into destination action warehouse
        params.set<MooseEnum>("family") = src_params.get<MooseEnum>("family");
        params.set<MooseEnum>("order") = src_params.get<MooseEnum>("order");

        MooseSharedPointer<Action> dest_action = _app.getActionFactory().create("AddAuxVariableAction", dest_name, params);
        mooseAssert (dest_action.get(), std::string("Action AddAuxVariableAction not created"));
        dest.addActionBlock(dest_action);
      }
    }
  }
}