Exemplo n.º 1
0
void
AdvancedOutput<T>::initialSetup()
{
  // Do not initialize more than once
  // This check is needed for YAK which calls Executioners from within Executioners
  if (T::_initialized)
    return;

  // Check that enable[disable]OutputTypes was called
  if (!T::isParamValid("_execute_valid_params_was_called"))
    mooseError("The static method AdvancedOutput<T>::enableOutputTypes must be called inside the validParams function for this object to properly define the input parameters for the output object named '" << T::name() << "'");

  // Initialize the available output
  initAvailableLists();

  // Separate the hide/show list into components
  initShowHideLists(T::template getParam<std::vector<VariableName> >("show"),
                    T::template getParam<std::vector<VariableName> >("hide"));

  // If 'elemental_as_nodal = true' the elemental variable names must be appended to the
  // nodal variable names. Thus, when libMesh::EquationSystem::build_solution_vector is called
  // it will create the correct nodal variable from the elemental
  if (T::isParamValid("elemental_as_nodal") && T::template getParam<bool>("elemental_as_nodal"))
  {
    OutputData & nodal = _execute_data["nodal"];
    OutputData & elemental = _execute_data["elemental"];
    nodal.show.insert(elemental.show.begin(), elemental.show.end());
    nodal.hide.insert(elemental.hide.begin(), elemental.hide.end());
    nodal.available.insert(elemental.available.begin(), elemental.available.end());
  }

  // Similarly as above, if 'scalar_as_nodal = true' append the elemental variable lists
  if (T::isParamValid("scalar_as_nodal") && T::template getParam<bool>("scalar_as_nodal"))
  {
    OutputData & nodal = _execute_data["nodal"];
    OutputData & scalar = _execute_data["scalars"];
    nodal.show.insert(scalar.show.begin(), scalar.show.end());
    nodal.hide.insert(scalar.hide.begin(), scalar.hide.end());
    nodal.available.insert(scalar.available.begin(), scalar.available.end());
  }

  // Initialize the show/hide/output lists for each of the types of output
  for (std::map<std::string, OutputData>::iterator it = _execute_data.begin(); it != _execute_data.end(); ++it)
    initOutputList(it->second);

  // Initialize the execution flags
  for (std::map<std::string, MultiMooseEnum>::iterator it = T::_advanced_execute_on.begin(); it != T::_advanced_execute_on.end(); ++it)
    initExecutionTypes(it->first, it->second);

  // Set the initialization flag
  T::_initialized = true;
}
Exemplo n.º 2
0
void
Output::init()
{
  // Do not initialize more than once
  /* This check is needed for YAK which calls Executioners from within Executioners */
  if (_initialized)
    return;

  // If recovering disable output of initial condition to avoid duplicate files
  if (_app.isRecovering())
    _output_initial = false;

  // Set the sequence flag to true if it has not been set and 'use_displaced = true'
  if (!isParamValid("sequence") && _use_displaced)
    sequence(true);

  // Initialize the available output
  initAvailableLists();

  // Separate the hide/show list into components
  initShowHideLists(getParam<std::vector<VariableName> >("show"), getParam<std::vector<VariableName> >("hide"));

  // If 'elemental_as_nodal = true' the elemental variable names must be appended to the
  // nodal variable names. Thus, when libMesh::EquationSystem::build_solution_vector is called
  // it will create the correct nodal variable from the elemental
  if (_elemental_as_nodal)
  {
    _nonlinear_nodal.show.insert(_nonlinear_nodal.show.end(), _nonlinear_elemental.show.begin(), _nonlinear_elemental.show.end());
    _nonlinear_nodal.hide.insert(_nonlinear_nodal.hide.end(), _nonlinear_elemental.hide.begin(), _nonlinear_elemental.hide.end());
    _nonlinear_nodal.available.insert(_nonlinear_nodal.available.end(), _nonlinear_elemental.available.begin(), _nonlinear_elemental.available.end());
  }

  // Similarly as above, if 'scalar_as_nodal = true' append the elemental variable lists
  if (_scalar_as_nodal)
  {
    _nonlinear_nodal.show.insert(_nonlinear_nodal.show.end(), _scalar.show.begin(), _scalar.show.end());
    _nonlinear_nodal.hide.insert(_nonlinear_nodal.hide.end(), _scalar.hide.begin(), _scalar.hide.end());
    _nonlinear_nodal.available.insert(_nonlinear_nodal.available.end(), _scalar.available.begin(), _scalar.available.end());
  }

  // Initialize the show/hide/output lists for each of the types of output
  initOutputList(_nonlinear_nodal);
  initOutputList(_nonlinear_elemental);
  initOutputList(_scalar);
  initOutputList(_postprocessor);
  initOutputList(_vector_postprocessor);

  // Disable output lists based on two items:
  //   (1) If the toggle parameter is invalid
  //   (2) If the toggle is set to false
  // This is done after initialization to allow for the appending of the elemental output to occur, because
  // it is possible to output a scalar variable as a nodal, then disable the output of scalars, resulting
  // in only the nodal version of the scalar variable to be in the output file (Exodus supports this). The
  // same is true for elemental variables.
  if (isParamValid("output_elemental_variables") ? !getParam<bool>("output_elemental_variables") : true)
    _nonlinear_elemental.output.clear();

  if (isParamValid("output_nodal_variables") ? !getParam<bool>("output_nodal_variables") : true)
    _nonlinear_nodal.output.clear();

  if (isParamValid("output_scalar_variables") ? !getParam<bool>("output_scalar_variables") : true)
    _scalar.output.clear();

  if (isParamValid("output_postprocessors") ? !getParam<bool>("output_postprocessors") : true)
    _postprocessor.output.clear();

  if (isParamValid("output_vector_postprocessors") ? !getParam<bool>("output_vector_postprocessors") : true)
    _vector_postprocessor.output.clear();

  // Set the _output_input bool, this is done here rather than the constructor so that CheckOutputAction can force in case --show-input is used
  _output_input = getParam<bool>("output_input");

  // Set the initialization flag
  _initialized = true;

  // Assume after init()
  /* Between init() and the first call of outputStep() all output is considered to be a part of initial output. This is
     mainly only import for calls to _console that occur during this time */
  _on_initial = true;
}
Exemplo n.º 3
0
OutputBase::OutputBase(const std::string & name, InputParameters & parameters) :
    MooseObject(name, parameters),
    Restartable(name, parameters, "OutputBase"),
    _problem_ptr(getParam<FEProblem *>("_fe_problem")),
    _transient(_problem_ptr->isTransient()),
    _use_displaced(getParam<bool>("use_displaced")),
    _es_ptr(_use_displaced ? &_problem_ptr->getDisplacedProblem()->es() : &_problem_ptr->es()),
    _time(_problem_ptr->time()),
    _time_old(_problem_ptr->timeOld()),
    _t_step(_problem_ptr->timeStep()),
    _dt(_problem_ptr->dt()),
    _dt_old(_problem_ptr->dtOld()),
    _output_initial(isParamValid("output_initial") ? getParam<bool>("output_initial") : false),
    _output_final(isParamValid("output_final") ? getParam<bool>("output_final") : false),
    _output_input(getParam<bool>("output_input")),
    _elemental_as_nodal(getParam<bool>("elemental_as_nodal")),
    _scalar_as_nodal(getParam<bool>("scalar_as_nodal")),
    _system_information(getParam<bool>("output_system_information")),
    _mesh_changed(declareRestartableData<bool>("mesh_changed", false)),
    _sequence(declareRestartableData<bool>("sequence", isParamValid("sequence") ? getParam<bool>("sequence") : false)),
    _num(declareRestartableData<unsigned int>("num", 0)),
    _interval(isParamValid("interval") ? getParam<unsigned int>("interval") : 1),
    _sync_times(isParamValid("sync_times") ?
                std::set<Real>(getParam<std::vector<Real> >("sync_times").begin(), getParam<std::vector<Real> >("sync_times").end()) :
                std::set<Real>()),
    _sync_only(getParam<bool>("sync_only")),
    _allow_output(true),
    _force_output(false),
    _output_failed(false),
    _output_setup_called(false)
{
  // If recovering disable output of initial condition to avoid duplicate files
  if (_app.isRecovering())
    _output_initial = false;

  // Set the sequence flag to true if it has not been set and 'use_displaced = true'
  if (!isParamValid("sequence") && _use_displaced)
    sequence(true);

  // Initialize the available output
  initAvailableLists();

  // Seperate the hide/show list into components
  initShowHideLists(getParam<std::vector<VariableName> >("show"), getParam<std::vector<VariableName> >("hide"));

  // Initialize the show/hide/output lists for each of the types of output
  initOutputList(_nonlinear_elemental);
  initOutputList(_nonlinear_nodal);
  initOutputList(_scalar);
  initOutputList(_postprocessor);

  // If 'elemental_as_nodal = true' the elemental variable names must be appended to the
  // nodal variable names. Thus, when libMesh::EquationSystem::build_solution_vector is called
  // it will create the correct nodal variable from the elemental
  if (_elemental_as_nodal)
      _nonlinear_nodal.output.insert(_nonlinear_nodal.output.end(),
                                     _nonlinear_elemental.output.begin(),
                                     _nonlinear_elemental.output.end());

  // Similarly as above, if 'scalar_as_nodal = true' append the elemental variable list
  if (_scalar_as_nodal)
      _nonlinear_nodal.output.insert(_nonlinear_nodal.output.end(),
                                     _scalar.output.begin(),
                                     _scalar.output.end());

  // Disable output lists based on two items:
  //   (1) If the toggle parameter is invalid
  //   (2) If the toggle is set to false
  // This is done after initialization to allow for the appending of the elemental output to occur, because
  // it is possible to output a scalar variable as a nodal, then disable the output of scalars, resulting
  // in only the nodal version of the scalar variable to be in the output file (Exodus supports this). The
  // same is true for elemental variables.
  if (isParamValid("output_elemental_variables") ? !getParam<bool>("output_elemental_variables") : true)
    _nonlinear_elemental.output.clear();

  if (isParamValid("output_nodal_variables") ? !getParam<bool>("output_nodal_variables") : true)
    _nonlinear_nodal.output.clear();

  if (isParamValid("output_scalar_variables") ? !getParam<bool>("output_scalar_variables") : true)
    _scalar.output.clear();

  if (isParamValid("output_postprocessors") ? !getParam<bool>("output_postprocessors") : true)
    _postprocessor.output.clear();
}