10#ifndef THYRA_PARAMETER_DRIVEN_MULTI_VECTOR_INPUT_HPP 
   11#define THYRA_PARAMETER_DRIVEN_MULTI_VECTOR_INPUT_HPP 
   13#include "Thyra_MultiVectorFileIOBase.hpp" 
   14#include "Thyra_DetachedVectorView.hpp" 
   15#include "Thyra_MultiVectorStdOps.hpp" 
   16#include "Teuchos_ParameterListAcceptor.hpp" 
   17#include "Teuchos_VerboseObject.hpp" 
   18#include "Teuchos_StandardCompositionMacros.hpp" 
   19#include "Teuchos_implicit_cast.hpp" 
  142    const std::string                 &mvName
 
  187    const std::string &vName
 
  210  std::string fileNameBase_;
 
  215  static const std::string FileNameBase_name_;
 
  216  static const std::string FileNameBase_default_;
 
  218  static const std::string ExplicitArray_name_;
 
  219  static const std::string ExplicitArray_default_;
 
  221  static const std::string ScaleBy_name_;
 
  222  static const double ScaleBy_default_;
 
  224  static const std::string AddScalar_name_;
 
  225  static const double AddScalar_default_;
 
 
  234template<
class Scalar>
 
  238  const std::string &vName,
 
  244  if (!is_null(vector))
 
  246  return defaultVector;
 
 
  253template<
class Scalar>
 
  258  return fileNameBase_;
 
 
  261template<
class Scalar>
 
  266  return explicitArray_;
 
 
  269template<
class Scalar>
 
  280namespace PDMVIUtilityPack {
 
  282template<
class Scalar>
 
  292  for( 
Ordinal i = 0; i < dVec.subDim(); ++i ) {
 
  301template<
class Scalar>
 
  303ParameterDrivenMultiVectorInput<Scalar>::FileNameBase_name_ = 
"File Name Base";
 
  304template<
class Scalar>
 
  306ParameterDrivenMultiVectorInput<Scalar>::FileNameBase_default_ = 
"";
 
  308template<
class Scalar>
 
  310ParameterDrivenMultiVectorInput<Scalar>::ExplicitArray_name_ = 
"Explicit Array";
 
  311template<
class Scalar>
 
  313ParameterDrivenMultiVectorInput<Scalar>::ExplicitArray_default_ = 
"{}";
 
  315template<
class Scalar>
 
  317ParameterDrivenMultiVectorInput<Scalar>::ScaleBy_name_ = 
"Scale By";
 
  318template<
class Scalar>
 
  320ParameterDrivenMultiVectorInput<Scalar>::ScaleBy_default_ = 1.0;
 
  322template<
class Scalar>
 
  324ParameterDrivenMultiVectorInput<Scalar>::AddScalar_name_ = 
"Add Scalar";
 
  325template<
class Scalar>
 
  327ParameterDrivenMultiVectorInput<Scalar>::AddScalar_default_ = 0.0;
 
  331template<
class Scalar>
 
  333  :fileNameBase_(FileNameBase_default_),
 
  334   scaleBy_(ScaleBy_default_),
 
  335   addScalar_(AddScalar_default_)
 
 
  340template<
class Scalar>
 
  346  paramList->validateParameters(*getValidParameters());
 
  347  paramList_ = paramList;
 
  348  fileNameBase_ = paramList_->
get(
 
  349    FileNameBase_name_,FileNameBase_default_ );
 
  351    *paramList_,ExplicitArray_name_
 
  355  scaleBy_ = paramList_->get(ScaleBy_name_,ScaleBy_default_);
 
  356  addScalar_ = paramList_->get(AddScalar_name_,AddScalar_default_);
 
  358  paramList_->validateParameters(*getValidParameters(),0);
 
 
  362template<
class Scalar>
 
  369template<
class Scalar>
 
  374    _paramList = paramList_;
 
 
  379template<
class Scalar>
 
  386template<
class Scalar>
 
  390  if(!validParamList_.get()) {
 
  394      FileNameBase_name_,FileNameBase_default_
 
  395      ,
"Base-name of file(s) that will be used to read in the vector.\n" 
  396      "If this parameter is empty \"\", no file(s) will be read.\n" 
  397      "Note that a MultiVectorFileIOBase object and a VectorSpaceBase object\n" 
  398      "must be set internally for this to work." 
  401      ExplicitArray_name_,ExplicitArray_default_
 
  402      ,
"The vector specified explicitly as a string interpreted as a Teuchos::Array\n" 
  403      "object.  If this array is set, it will override the vector specified\n" 
  404      "by the above \"" + FileNameBase_name_ + 
"\" parameter.\n" 
  405      "Note that a VectorSpaceBase object\n" 
  406      "must be set internally for this to work." 
  409      ScaleBy_name_,ScaleBy_default_,
 
  410      "A factor by which the read in vector will be scaled by." 
  413      AddScalar_name_, AddScalar_default_,
 
  414      "A scalar that will added to the read in vector after it\n" 
  417    validParamList_ = pl;
 
  419  return validParamList_;
 
 
  424template<
class Scalar>
 
  426  const std::string                 &mvName
 
  435    out = this->getOStream();
 
  438  bool vectorWasRead = 
false;
 
  439  if(fileNameBase_.length()) {
 
  440    if( out.
get() && trace )
 
  441      *out << 
"\nReading \"" << mvName << 
"\" from the file(s) with base name \"" 
  442           << fileNameBase_ << 
"\" ...\n";
 
  443    fileIO().readMultiVectorFromFile(fileNameBase_,mv);
 
  444    vectorWasRead = 
true;
 
  446  if(explicitArray_.size()) {
 
  447    if( implicit_cast<Ordinal>(explicitArray_.size()) != vecSpc().dim() ) {
 
  450        *paramList_,ExplicitArray_name_,vecSpc().dim(),
false);
 
  453    if( out.
get() && trace )
 
  454      *out << 
"\nSetting \"" << mvName << 
"\" directly from the parameter array " 
  455           << explicitArray_ << 
" ...\n";
 
  457      mv->
domain()->dim()!=implicit_cast<Ordinal>(1), std::logic_error
 
  458      ,
"Error! We can not handle reading in multi-vectors directly from" 
  459      " the parameter list yet!" 
  461    PDMVIUtilityPack::copy(explicitArray_,&*mv->
col(0));
 
  464    vectorWasRead = 
true;
 
  466  if( scaleBy_ != ST::one() && vectorWasRead ) {
 
  467    if( out.
get() && trace )
 
  468      *out << 
"\nScaling \"" << mvName << 
"\" by " << scaleBy_ << 
" ...\n";
 
  469    Vt_S(Teuchos::ptr(mv), scaleBy_);
 
  471  if( addScalar_ != ST::zero() && vectorWasRead ) {
 
  472    if( out.
get() && trace )
 
  473      *out << 
"\nAdding scalar " << addScalar_ << 
" to \"" << mvName << 
"\" ...\n";
 
  474    Vp_S(Teuchos::ptr(mv), addScalar_);
 
  476  return vectorWasRead;
 
 
  479template<
class Scalar>
 
  481  const std::string                                   &vName
 
  486  bool vectorWasRead = 
false;
 
  487  if( fileNameBase_.length() || explicitArray_.size() ) {
 
  489      (*v) = createMember(this->vecSpc());
 
  490    vectorWasRead = this->readMultiVector(vName, &*(*v));
 
  492  return vectorWasRead;
 
 
  495template<
class Scalar>
 
  498  const std::string &vName
 
  502  const bool vectorWasRead = readVector(vName,&v);
 
 
Create an explicit mutable (non-const) view of a VectorBase object.
 
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
 
Interface for a collection of column vectors called a multi-vector.
 
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
 
Abstract strategy interface for reading and writing (multi)vector objects to and from files.
 
Abstract interface for finite-dimensional dense vectors.
 
Abstract interface for objects that represent a space for vectors.
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
 
TypeTo implicit_cast(const TypeFrom &t)
 
T_To & dyn_cast(T_From &from)
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)