NOX::Abstract::Group::ReturnType
LOCA::EigenvalueSort::LargestRealInverseCayley::sort(
                            int n, double* r_evals,
                        double* i_evals,
                        std::vector<int>* perm) const
{
  int i, j;
  int tempord = 0;
  double temp, tempr, tempi;
  Teuchos::LAPACK<int,double> lapack;

  TEUCHOS_TEST_FOR_EXCEPT(perm == NULL);

  // Reset the index
  for (i=0; i < n; i++)
    (*perm)[i] = i;

  //---------------------------------------------------------------
  // Sort eigenvalues according to the real part of the inverse-Cayley
  // transformation
  //---------------------------------------------------------------
  for (j=1; j < n; ++j) {
    tempr = r_evals[j]; tempi = i_evals[j];
    tempord = (*perm)[j];
    temp=realLambda(r_evals[j],i_evals[j]);
    for (i=j-1; i>=0 && realLambda(r_evals[i],i_evals[i])<temp; --i) {
      r_evals[i+1]=r_evals[i]; i_evals[i+1]=i_evals[i];
      (*perm)[i+1]=(*perm)[i];
    }
    r_evals[i+1] = tempr; i_evals[i+1] = tempi; (*perm)[i+1] = tempord;
  }
  return NOX::Abstract::Group::Ok;
}
int GModel_ThyraModelEvaluator::calcDerivs(double *yin, double *yout, double t) {
  TEUCHOS_TEST_FOR_EXCEPT(is_null(thyraModel_));
  // Set up const view of yin as Thyra::VectorBase<double>

  // Convert double * to const Thyra::VectorBase view
  Teuchos::RCP<const Thyra::VectorBase<double> > thyra_yin = 
    constThyraVectorBaseDouble(thyraModel_->get_x_space(), yin, dim_);
  
  // Set x on the inArgs.
  inArgs_.set_x(thyra_yin);
  
  // Set t on the inArgs.
  inArgs_.set_t(t);
  
  // Set up non const view of yout as Thyra::VectorBase<double>

  // Convert double * to nonconst Thyra::VectorBase view
  Teuchos::RCP<Thyra::VectorBase<double> > thyra_yout = 
    thyraVectorBaseDouble( thyraModel_->get_f_space(), yout, dim_ );

  // Set f on the outArgs.
  outArgs_.set_f(thyra_yout);

  // Evaluate model
  thyraModel_->evalModel(inArgs_,outArgs_);
  
  // All the magic happens when we go out of scope and the views are deleted.
  return(0);
}
void Albany::MultiSTKFieldContainer<Interleaved>::transferSolutionToCoords() {

  const bool MultiSTKFieldContainer_transferSolutionToCoords_not_implemented = true;
  TEUCHOS_TEST_FOR_EXCEPT(MultiSTKFieldContainer_transferSolutionToCoords_not_implemented);
  //     this->copySTKField(solution_field, this->coordinates_field);

}
Ejemplo n.º 4
0
int RCPNodeTracer::numActiveRCPNodes()
{
  // This list always exists, no matter debug or not so just access it.
  TEUCHOS_TEST_FOR_EXCEPT(0==rcp_node_list());
  return rcp_node_list()->size();
  return 0;
}
Ejemplo n.º 5
0
bool Tpetra::Utils::parseRfmt(Teuchos::ArrayRCP<char> fmt, int &perline, int &width, int &prec, char &valformat) {
  TEUCHOS_TEST_FOR_EXCEPT(fmt.size() != 0 && fmt[fmt.size()-1] != '\0');
  std::transform(fmt.begin(), fmt.end(), fmt, static_cast < int(*)(int) > (std::toupper));
  // find the first left paren '(' and the last right paren ')'
  Teuchos::ArrayRCP<char>::iterator firstLeftParen = std::find( fmt.begin(),  fmt.end(), '(');
  Teuchos::ArrayRCP<char>::iterator lastRightParen = std::find(std::reverse_iterator<Teuchos::ArrayRCP<char>::iterator>(fmt.end()), 
                                                               std::reverse_iterator<Teuchos::ArrayRCP<char>::iterator>(fmt.begin()), 
                                                               ')').base()-1;
  // select the substring between the parens, including them
  // if neither was found, set the string to empty
  if (firstLeftParen == fmt.end() || lastRightParen == fmt.begin()) {
    fmt.resize(0 + 1);
    fmt[0] = '\0';
  }
  else {
    fmt += (firstLeftParen - fmt.begin());
    size_t newLen = lastRightParen - firstLeftParen + 1;
    fmt.resize(newLen + 1);
    fmt[newLen] = '\0';
  }
  if (std::find(fmt.begin(),fmt.end(),'P') != fmt.end()) {
    // not supported
    return true;
  }
  bool error = true;
  if (std::sscanf(fmt.getRawPtr(),"(%d%c%d.%d)",&perline,&valformat,&width,&prec) == 4) {
    if (valformat == 'E' || valformat == 'D' || valformat == 'F') {
      error = false;
    }
  } 
  return error;
}
void Ifpack2PreconditionerFactory<MatrixType>::uninitializePrec(
  PreconditionerBase<scalar_type> *prec,
  Teuchos::RCP<const LinearOpSourceBase<scalar_type> > *fwdOp,
  ESupportSolveUse *supportSolveUse
  ) const
{
  // Check precondition

  TEUCHOS_ASSERT(prec);

  // Retrieve concrete preconditioner object

  const Teuchos::Ptr<DefaultPreconditioner<scalar_type> > defaultPrec =
    Teuchos::ptr(dynamic_cast<DefaultPreconditioner<scalar_type> *>(prec));
  TEUCHOS_TEST_FOR_EXCEPT(Teuchos::is_null(defaultPrec));

  if (fwdOp) {
    // TODO: Implement properly instead of returning default value
    *fwdOp = Teuchos::null;
  }

  if (supportSolveUse) {
    // TODO: Implement properly instead of returning default value
    *supportSolveUse = Thyra::SUPPORT_SOLVE_UNSPECIFIED;
  }

  defaultPrec->uninitialize();
}
void QPSolverRelaxedTesterSetOptions::setOption(
  int option_num, const std::string& option_value )
{
  typedef QPSolverRelaxedTester target_t;
  switch( (local_EOptions)option_num ) {
      case OPT_WARNING_TOL:
      target().opt_warning_tol(std::fabs(std::atof(option_value.c_str())));
      break;
      case OPT_ERROR_TOL:
      target().opt_error_tol(std::fabs(std::atof(option_value.c_str())));
      break;
      case FEAS_WARNING_TOL:
      target().feas_warning_tol(std::fabs(std::atof(option_value.c_str())));
      break;
      case FEAS_ERROR_TOL:
      target().feas_error_tol(std::fabs(std::atof(option_value.c_str())));
      break;
      case COMP_WARNING_TOL:
      target().comp_warning_tol(std::fabs(std::atof(option_value.c_str())));
      break;
      case COMP_ERROR_TOL:
      target().comp_error_tol(std::fabs(std::atof(option_value.c_str())));
      break;
    default:
      TEUCHOS_TEST_FOR_EXCEPT(true);	// Local error only?
  }
}
Ejemplo n.º 8
0
Teuchos::Array<bool> createResponseTable(
    int count,
    const std::string selectionType,
    int index,
    const Teuchos::ArrayView<const int> &list)
{
  Teuchos::Array<bool> result;

  if (count > 0) {
    if (selectionType == "All") {
      result.resize(count, true);
    } else if (selectionType == "Last") {
      result = createResponseTableFromIndex(count - 1, count);
    } else if (selectionType == "AllButLast") {
      result.reserve(count);
      result.resize(count - 1, true);
      result.push_back(false);
    } else if (selectionType == "Index") {
      result = createResponseTableFromIndex(index, count);
    } else if (selectionType == "List") {
      result.resize(count, false);
      for (Teuchos::ArrayView<const int>::const_iterator it = list.begin(), it_end = list.end(); it != it_end; ++it) {
        result.at(*it) = true;
      }
    } else {
      TEUCHOS_TEST_FOR_EXCEPT(false);
    }
  }

  return result;
}
void MeritFunc_ModifiedL1LargerSteps_AddedStepSetOptions::setOption(
  int option_num, const std::string& option_value )
{
  switch( (local_EOptions)option_num ) {
    case AFTER_K_ITER: {
      target().after_k_iter( ::atoi( option_value.c_str() ) );
      break;
    }
    case OBJ_INCREASE_THRESHOLD: {
      target().obj_increase_threshold( ::atof( option_value.c_str() ) );
      break;
    }
    case MAX_POS_PENALTY_INCREASE: {
      target().max_pos_penalty_increase( ::fabs( ::atof( option_value.c_str() ) ) );
      break;
    }
    case POS_TO_NEG_PENALTY_INCREASE: {
      target().pos_to_neg_penalty_increase( ::fabs( ::atof( option_value.c_str() ) ) );
      break;
    }
    case INCR_MULT_FACTOR: {
      target().incr_mult_factor( ::fabs( ::atof( option_value.c_str() ) ) );
      break;
    }
    default:
      TEUCHOS_TEST_FOR_EXCEPT(true);	// Local error only?
  }
}
 /** \brief Virtual implementation of <tt>solveSupports()</tt>. */
 virtual bool solveSupportsNewImpl(EOpTransp transp,
   const Ptr<const SolveCriteria<Scalar> > solveCriteria
   ) const
   {
     TEUCHOS_TEST_FOR_EXCEPT(true);
     return(false);
   }
void InitFinDiffReducedHessian_StepSetOptions::setOption(
  int option_num, const std::string& option_value )
{
  typedef InitFinDiffReducedHessian_Step target_t;
  switch( (local_EOptions)option_num ) {
      case INITIALIZATION_METHOD:
    {
      const std::string &option = option_value.c_str();
      if( option == "SCALE_IDENTITY" )
        target().initialization_method( target_t::SCALE_IDENTITY );
      else if( option == "SCALE_DIAGONAL" )
        target().initialization_method( target_t::SCALE_DIAGONAL );
      else if( option == "SCALE_DIAGONAL_ABS" )
        target().initialization_method( target_t::SCALE_DIAGONAL_ABS );
      else
        throw std::invalid_argument( "Error, incorrect value for "
          "\"initialization_method\"." );
      break;
    }
      case MAX_COND:
      target().max_cond(std::fabs(std::atof(option_value.c_str())));
      break;
    case MIN_DIAG:
      target().min_diag(std::abs(std::atoi(option_value.c_str())));
      break;
    case STEP_SCALE:
      target().step_scale(std::fabs(std::atof(option_value.c_str())));
      break;
    default:
      TEUCHOS_TEST_FOR_EXCEPT(true);	// Local error only?
  }
}
void HermiteInterpolator<Scalar>::setParameterList(RCP<ParameterList> const& paramList)
{
  TEUCHOS_TEST_FOR_EXCEPT(is_null(paramList));
  paramList->validateParametersAndSetDefaults(*this->getValidParameters());
  parameterList_ = paramList;
  Teuchos::readVerboseObjectSublist(&*parameterList_,this);
}
void GModel_ThyraModelEvaluator::setThyraModel(Teuchos::RCP<Thyra::ModelEvaluator<double> > model) {
  TEUCHOS_TEST_FOR_EXCEPT(is_null(model));
  thyraModel_ = model;
  dim_ = thyraModel_->get_x_space()->dim();
  inArgs_ = thyraModel_->createInArgs();
  outArgs_ = thyraModel_->createOutArgs();
}
Ejemplo n.º 14
0
//----------------------------------------------------------------------------
//
// Transfer solution between meshes.
//
void
AAdapt::CopyRemesh::
solutionTransfer(const Epetra_Vector& oldSolution,
                 Epetra_Vector& newSolution) {

  TEUCHOS_TEST_FOR_EXCEPT(oldSolution.MyLength() != newSolution.MyLength());
  newSolution = oldSolution;
}
Ejemplo n.º 15
0
RCP<CommRequest> SerialComm<Ordinal>::ireceive(
  const ArrayView<char> &/*Buffer*/,
  const int /*sourceRank*/
  ) const
{
  TEUCHOS_TEST_FOR_EXCEPT(true);
  return null;
}
void
dft_HardSphereA22_Tpetra_Operator<Scalar,MatrixType>::
applyInverse
(const MV& X, MV& Y) const
{
    // Our algorithm is:
    // Y = D \ X

    TEUCHOS_TEST_FOR_EXCEPT(Y.getNumVectors()!=X.getNumVectors());
#ifdef KDEBUG
    TEUCHOS_TEST_FOR_EXCEPT(!X.getMap()->isSameAs(*getDomainMap()));
    TEUCHOS_TEST_FOR_EXCEPT(!Y.getMap()->isSameAs(*getRangeMap()));
#endif

    Y.elementWiseMultiply(STS::one(), *densityOnDensityInverse_, X, STS::zero());

}
Ejemplo n.º 17
0
RCP<CommRequest> SerialComm<Ordinal>::isend(
  const ArrayView<const char> &/*sendBuffer*/,
  const int /*destRank*/
  ) const
{
  TEUCHOS_TEST_FOR_EXCEPT(true);
  return null;
}
Ejemplo n.º 18
0
Teuchos::RCP<Thyra::PreconditionerBase<ST> >
Albany::ModelEvaluatorT::create_W_prec() const
{
  // TODO: Analog of EpetraExt::ModelEvaluator::Preconditioner does not exist in Thyra yet!
  const bool W_prec_not_supported = true;
  TEUCHOS_TEST_FOR_EXCEPT(W_prec_not_supported);
  return Teuchos::null;
}
void GAASPErrorEstimator::setParameterList(
  Teuchos::RCP<Teuchos::ParameterList> const& paramList)
{
  TEUCHOS_TEST_FOR_EXCEPT(is_null(paramList));
  paramList->validateParametersAndSetDefaults(*this->getValidParameters(),0);
  paramList_ = paramList;
  Teuchos::readVerboseObjectSublist(&*paramList_,this);
}
Ejemplo n.º 20
0
void
Albany::StateManager::registerStateVariable(const std::string &stateName, 
					    const Teuchos::RCP<PHX::DataLayout> &dl,
                                            const std::string& ebName,
                                            const std::string &init_type,                                            
                                            const double init_val,
                                            const bool registerOldState,
					    const bool outputToExodus,
					    const std::string &responseIDtoRequire)

{
  TEUCHOS_TEST_FOR_EXCEPT(stateVarsAreAllocated);

  if( statesToStore[ebName].find(stateName) != statesToStore[ebName].end() ) {
    //Duplicate registration.  This will occur when a problem's 
    // constructEvaluators function (templated) registers state variables.

    //Perform a check here that dl and statesToStore[stateName] are the same:
    //TEUCHOS_TEST_FOR_EXCEPT(dl != statesToStore[stateName]);  //I don't know how to do this correctly (erik)
    return;  // Don't re-register the same state name
  }

  statesToStore[ebName][stateName] = dl;

  // Load into StateInfo
  (*stateInfo).push_back(Teuchos::rcp(new Albany::StateStruct(stateName)));
  Albany::StateStruct& stateRef = *stateInfo->back();
  stateRef.initType  = init_type; 
  stateRef.initValue = init_val; 
  if ( dl->rank() > 1 )
    stateRef.entity = dl->name(1); //Tag, should be Node or QuadPoint
  else if ( dl->rank() == 1 )
    stateRef.entity = "ScalarValue";
  stateRef.output = outputToExodus;
  stateRef.responseIDtoRequire = responseIDtoRequire;
  dl->dimensions(stateRef.dim); 

  // If space is needed for old state
  if (registerOldState) {
    stateRef.saveOldState = true; 

    std::string stateName_old = stateName + "_old";
    (*stateInfo).push_back(Teuchos::rcp(new Albany::StateStruct(stateName_old)));
    Albany::StateStruct& pstateRef = *stateInfo->back();
    pstateRef.initType  = init_type; 
    pstateRef.initValue = init_val; 
    pstateRef.pParentStateStruct = &stateRef;
    if ( dl->rank() > 1 )
      pstateRef.entity = dl->name(1); //Tag, should be Node or QuadPoint
    else if ( dl->rank() == 1 )
      pstateRef.entity = "ScalarValue";
    pstateRef.output = false; 
    dl->dimensions(pstateRef.dim); 
  }

  // insert
  stateRef.nameMap[stateName] = ebName;
}
Ejemplo n.º 21
0
//==============================================================================
int Komplex_LinearProblem::GetRow(int Row, const Epetra_RowMatrix & A0, const Epetra_RowMatrix & A1,
				  int & NumIndices0, double * & Values0, int * & Indices0,
				  int & NumIndices1, double * & Values1, int * & Indices1) {

  if (A0A1AreCrs_) { // View of current row
    TEUCHOS_TEST_FOR_EXCEPT(CrsA0_->ExtractMyRowView(Row, NumIndices0, Values0, Indices0)<0); 
    TEUCHOS_TEST_FOR_EXCEPT(CrsA1_->ExtractMyRowView(Row, NumIndices1, Values1, Indices1)<0); 
  }
  else { // Copy of current row
    TEUCHOS_TEST_FOR_EXCEPT(A0.ExtractMyRowCopy(Row, MaxNumMyEntries0_, NumIndices0, &Values0_[0], &Indices0_[0])<0); 
    TEUCHOS_TEST_FOR_EXCEPT(A1.ExtractMyRowCopy(Row, MaxNumMyEntries1_, NumIndices1, &Values1_[0], &Indices1_[0])<0); 
    Values0 = &Values0_[0];
    Indices0 = &Indices0_[0];
    Values1 = &Values1_[0];
    Indices1 = &Indices1_[0];
  } 
  return(0);
}
void DefaultDiagonalLinearOp<Scalar>::initialize(
  const RCP<const VectorSpaceBase<Scalar> > &space
  )
{
#ifdef TEUCHOS_DEBUG
  TEUCHOS_TEST_FOR_EXCEPT(space.get()==NULL);
#endif
  initialize(createMember(space)); // Note that the space is guaranteed to be remembered here!
}
void MultiVectorMutableDense::commit_gms_view(DMatrixSlice* gms_view)
{
  if(gms_trans_ == BLAS_Cpp::trans) {
    TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: We need to free the copy that we created in get_gms_view()
  }
  else {
    // Nothing to free!
  }
}
void LineSearch2ndOrderCorrect_StepSetOptions::setOption(
  int option_num, const std::string& option_value )
{
  typedef LineSearch2ndOrderCorrect_Step target_t;
  switch( (local_EOptions)option_num ) {
      case NEWTON_OLEVEL:
    {
      const std::string &option = option_value.c_str();
      if( option == "PRINT_USE_DEFAULT" )
        target().newton_olevel( target_t::PRINT_USE_DEFAULT );
      else if( option == "PRINT_NOTHING" )
        target().newton_olevel( target_t::PRINT_NEWTON_NOTHING );
      else if( option == "PRINT_SUMMARY_INFO" )
        target().newton_olevel( target_t::PRINT_NEWTON_SUMMARY_INFO );
      else if( option == "PRINT_STEPS" )
        target().newton_olevel( target_t::PRINT_NEWTON_STEPS );
      else if( option == "PRINT_VECTORS" )
        target().newton_olevel( target_t::PRINT_NEWTON_VECTORS );
      else
        throw std::invalid_argument( "Error, incorrect value for "
          "\"newton_olevel\"." );
      break;
    }
      case CONSTR_NORM_THRESHOLD:
      target().constr_norm_threshold(::fabs(::atof(option_value.c_str())));
      break;
      case CONSTR_INCR_RATIO:
      target().constr_incr_ratio(::fabs(::atof(option_value.c_str())));
      break;
    case AFTER_K_ITER:
      target().after_k_iter(::abs(::atoi(option_value.c_str())));
      break;
    case FORCED_CONSTR_REDUCTION:
    {
      const std::string &option = option_value.c_str();
      if( option == "LESS_X_D" )
        target().forced_constr_reduction(target_t::CONSTR_LESS_X_D );
      else if( option == "LESS_X" )
        target().forced_constr_reduction( target_t::CONSTR_LESS_X );
      else
        throw std::invalid_argument( "Error, incorrect value for "
          "\"forced_constr_reduction\"." );
      break;
    }
      case FORCED_REDUCT_RATIO:
      target().forced_reduct_ratio(::fabs(::atof(option_value.c_str())));
      break;
    case MAX_STEP_RATIO:
      target().max_step_ratio(::fabs(::atof(option_value.c_str())));
      break;
    case MAX_NEWTON_ITER:
      target().max_newton_iter(::abs(::atoi(option_value.c_str())));
      break;
    default:
      TEUCHOS_TEST_FOR_EXCEPT(true);	// Local error only?
  }
}
Ejemplo n.º 25
0
//==============================================================================
int Komplex_LinearProblem::UpdateValues(double c0r, double c0i, const Epetra_RowMatrix & A0,
					     double c1r, double c1i, const Epetra_RowMatrix & A1,
					     const Epetra_MultiVector & Xr, const Epetra_MultiVector & Xi,
					     const Epetra_MultiVector & Br, const Epetra_MultiVector & Bi) {
  bool firstTime = false;
  KomplexMatrix_->PutScalar(0.0);
  TEUCHOS_TEST_FOR_EXCEPT(ProcessValues(c0r, c0i, A0, c1r, c1i, A1, Xr, Xi, Br, Bi, firstTime)!=0);

}
MpiReductionOpSetter::MpiReductionOpSetter(
  const Teuchos::RCP<const MpiReductionOpBase>& reduct_op
  )
{
#ifdef TEUCHOS_DEBUG
  TEUCHOS_TEST_FOR_EXCEPT(!reduct_op.get())
#endif
  set_reduct_op(reduct_op);
}
Ejemplo n.º 27
0
  static void deserialize(
    const Ordinal bytes, const char charBuffer[], const Ordinal count, T buffer[]
    )
    {
#ifdef TEUCHOS_DEBUG
      TEUCHOS_TEST_FOR_EXCEPT(count!=fromDirectBytesToCount(bytes));
#endif
      char *_buffer = convertToCharPtr(buffer);
      std::copy(charBuffer,charBuffer+bytes,_buffer);
    }
Ejemplo n.º 28
0
  static void serialize(
    const Ordinal count, const T buffer[], const Ordinal bytes, char charBuffer[]
    )
    {
#ifdef TEUCHOS_DEBUG
      TEUCHOS_TEST_FOR_EXCEPT(bytes!=fromCountToDirectBytes(count));
#endif
      const char *_buffer = convertToCharPtr(buffer);
      std::copy(_buffer,_buffer+bytes,charBuffer);
    }
void assembleERKSolution(
  const Teuchos::SerialDenseVector<int,Scalar> &b_in,
  const Scalar dt,
  const Thyra::VectorBase<Scalar> &x_base,
  const Thyra::VectorBase<Scalar> &x_stage_bar,
  Teuchos::Ptr<Thyra::VectorBase<Scalar> > x_out_ptr
  )
{
  TEUCHOS_TEST_FOR_EXCEPT(true);
}
Ejemplo n.º 30
0
bool Tpetra::Utils::parseIfmt(Teuchos::ArrayRCP<char> fmt, int &perline, int &width) {
  TEUCHOS_TEST_FOR_EXCEPT(fmt.size() != 0 && fmt[fmt.size()-1] != '\0');
  // parses integers n and d out of (nId)
  bool error = true;
  std::transform(fmt.begin(), fmt.end(), fmt, static_cast < int(*)(int) > (std::toupper));
  if (std::sscanf(fmt.getRawPtr(),"(%dI%d)",&perline,&width) == 2) {
    error = false;
  }
  return error;
}