Esempio n. 1
0
void EpetraLinearOp::describe(
  FancyOStream &out,
  const Teuchos::EVerbosityLevel verbLevel
  ) const
{
  using Teuchos::includesVerbLevel;
  using Teuchos::as;
  using Teuchos::rcp_dynamic_cast;
  using Teuchos::OSTab;
  using Teuchos::describe;
  OSTab tab(out);
  if ( as<int>(verbLevel) == as<int>(Teuchos::VERB_LOW) || is_null(op_)) {
    out << this->description() << std::endl;
  }
  else if (includesVerbLevel(verbLevel,Teuchos::VERB_MEDIUM)) {
    out
      << Teuchos::Describable::description()
      << "{"
      << "rangeDim=" << this->range()->dim()
      << ",domainDim=" << this->domain()->dim()
      << "}\n";
    OSTab tab2(out);
    if (op_.get()) {
      if ( as<int>(verbLevel) >= as<int>(Teuchos::VERB_HIGH) ) {
        out << "opTrans="<<toString(opTrans_)<<"\n";
        out << "applyAs="<<toString(applyAs_)<<"\n";
        out << "adjointSupport="<<toString(adjointSupport_)<<"\n";
        out << "op="<<typeName(*op_)<<"\n";
      }
      if ( as<int>(verbLevel) >= as<int>(Teuchos::VERB_EXTREME) ) {
        OSTab tab3(out);
        RCP<const Epetra_CrsMatrix>
          csr_op = rcp_dynamic_cast<const Epetra_CrsMatrix>(op_);
        if (!is_null(csr_op)) {
          csr_op->Print(out);
        }
      }
    }
    else {
      out << "op=NULL"<<"\n";
    }
  }
}
void EpetraExt::unscaleModelVars(
  const ModelEvaluator::InArgs &scaledVars,
  const ModelEvaluator::InArgs &varScalings,
  ModelEvaluator::InArgs *origVars,
  Teuchos::FancyOStream *out,
  Teuchos::EVerbosityLevel verbLevel
  )
{

  using Teuchos::RCP;
  using Teuchos::includesVerbLevel;
  typedef ModelEvaluator EME;

#ifdef TEUCHOS_DEBUG
  TEUCHOS_TEST_FOR_EXCEPT(!origVars);
  assertModelVarScalings(varScalings);
#endif

  // Print scaling vectors

  if (out && includesVerbLevel(verbLevel,Teuchos::VERB_HIGH)) {
    RCP<const Epetra_Vector> inv_s_x;
    if ( scaledVars.supports(EME::IN_ARG_x) &&
      !is_null(inv_s_x=varScalings.get_x()) )
    {
      *out << "\nState inverse scaling vector inv_s_x:\n";
      Teuchos::OSTab tab(*out);
      inv_s_x->Print(*out);
    }
  }

  // Scal the input varaibles

  if (scaledVars.supports(EME::IN_ARG_x_dot)) {
    unscaleModelVar( InArgsGetterSetter_x_dot(), scaledVars, varScalings, origVars,
      out, verbLevel );
  }

  if (scaledVars.supports(EME::IN_ARG_x_dotdot)) {
    unscaleModelVar( InArgsGetterSetter_x_dotdot(), scaledVars, varScalings, origVars,
      out, verbLevel );
  }

  if (scaledVars.supports(EME::IN_ARG_x)) {
    unscaleModelVar( InArgsGetterSetter_x(), scaledVars, varScalings, origVars,
      out, verbLevel );
  }

  const int Np = scaledVars.Np();
  for ( int l = 0; l < Np; ++l ) {
    unscaleModelVar( InArgsGetterSetter_p(l), scaledVars, varScalings, origVars,
      out, verbLevel );
  }

  if (scaledVars.supports(EME::IN_ARG_x_dot_poly)) {
    TEUCHOS_TEST_FOR_EXCEPTION(
      !is_null(varScalings.get_x()), std::logic_error,
      "Error, can't hanlde unscaling of x_dot_poly yet!"
      );
    origVars->set_x_dot_poly(scaledVars.get_x_dot_poly());
  }

  if (scaledVars.supports(EME::IN_ARG_x_dotdot_poly)) {
    TEUCHOS_TEST_FOR_EXCEPTION(
      !is_null(varScalings.get_x()), std::logic_error,
      "Error, can't hanlde unscaling of x_dotdot_poly yet!"
      );
    origVars->set_x_dotdot_poly(scaledVars.get_x_dotdot_poly());
  }

  if (scaledVars.supports(EME::IN_ARG_x_poly)) {
    TEUCHOS_TEST_FOR_EXCEPTION(
      !is_null(varScalings.get_x()), std::logic_error,
      "Error, can't hanlde unscaling of x_poly yet!"
      );
    origVars->set_x_poly(scaledVars.get_x_poly());
  }

  if (scaledVars.supports(EME::IN_ARG_t)) {
    TEUCHOS_TEST_FOR_EXCEPTION(
      varScalings.get_t() > 0.0, std::logic_error,
      "Error, can't hanlde unscaling of t yet!"
      );
    origVars->set_t(scaledVars.get_t());
  }

  if (scaledVars.supports(EME::IN_ARG_alpha)) {
    TEUCHOS_TEST_FOR_EXCEPTION(
      varScalings.get_alpha() > 0.0, std::logic_error,
      "Error, can't hanlde unscaling of alpha yet!"
      );
    origVars->set_alpha(scaledVars.get_alpha());
  }

  if (scaledVars.supports(EME::IN_ARG_beta)) {
    TEUCHOS_TEST_FOR_EXCEPTION(
      varScalings.get_beta() > 0.0, std::logic_error,
      "Error, can't hanlde unscaling of beta yet!"
      );
    origVars->set_beta(scaledVars.get_beta());
  }

}