61 const std::string Implicit_name =
"Implicit";
62 const bool Implicit_default =
true;
64 const std::string Gamma_min_name =
"Gamma_min";
65 const double Gamma_min_default = -0.9;
67 const std::string Gamma_max_name =
"Gamma_max";
68 const double Gamma_max_default = -0.01;
70 const std::string Coeff_s_name =
"Coeff_s";
71 const std::string Coeff_s_default =
"{ 0.0 }";
73 const std::string Gamma_fit_name =
"Gamma_fit";
74 const std::string Gamma_fit_default =
"Linear";
76 const std::string NumElements_name =
"NumElements";
77 const int NumElements_default = 1;
79 const std::string x0_name =
"x0";
80 const double x0_default = 10.0;
82 const std::string ExactSolutionAsResponse_name =
"Exact Solution as Response";
83 const bool ExactSolutionAsResponse_default =
false;
87 double evalR(
const double& t,
const double& gamma,
const double& s )
89 return (exp(gamma*t)*sin(s*t));
94 double d_evalR_d_s(
const double& t,
const double& gamma,
const double& s )
96 return (exp(gamma*t)*cos(s*t)*t);
102 const double& x,
const double& t,
const double& gamma,
const double& s
105 return ( gamma*x + evalR(t,gamma,s) );
111 const double& x0,
const double& t,
const double& gamma,
const double& s
115 return ( x0 * exp(gamma*t) );
116 return ( exp(gamma*t) * (x0 + (1.0/s) * ( 1.0 - cos(s*t) ) ) );
126 const double& t,
const double& gamma,
const double& s
131 return ( -exp(gamma*t)/(s*s) * ( 1.0 - sin(s*t)*(s*t) - cos(s*t) ) );
135 class UnsetParameterVector {
137 ~UnsetParameterVector()
142 UnsetParameterVector(
143 const RCP<RCP<const Epetra_Vector> > &vec
148 void setVector(
const RCP<RCP<const Epetra_Vector> > &vec )
153 RCP<RCP<const Epetra_Vector> > vec_;
160 namespace EpetraExt {
169 : epetra_comm_(epetra_comm.assert_not_null()),
170 implicit_(Implicit_default),
171 numElements_(NumElements_default),
172 gamma_min_(Gamma_min_default),
173 gamma_max_(Gamma_max_default),
174 coeff_s_(Teuchos::fromStringToArray<double>(Coeff_s_default)),
175 gamma_fit_(GAMMA_FIT_LINEAR),
177 exactSolutionAsResponse_(ExactSolutionAsResponse_default),
202 int myN = x_star.MyLength();
203 for (
int i=0 ; i<myN ; ++i ) {
204 x_star[i] = x_exact(
x0_, t, gamma[i],
coeff_s(i) );
220 dxds_star.PutScalar(0.0);
222 int myN = dxds_star.MyLength();
223 for (
int i=0 ; i<myN ; ++i ) {
225 (*dxds_star(coeff_s_idx_i))[i] = dxds_exact( t, gamma[i],
coeff_s(i) );
230 return (dxds_star_ptr);
241 using Teuchos::get;
using Teuchos::getIntegralValue;
242 using Teuchos::getArrayFromStringParameter;
286 using Teuchos::tuple;
287 using Teuchos::setIntParameter;
using Teuchos::setDoubleParameter;
288 using Teuchos::setStringToIntegralParameter;
289 static RCP<const ParameterList> validPL;
291 RCP<ParameterList> pl = Teuchos::parameterList();
292 pl->set(Implicit_name,
true);
294 Gamma_min_name, Gamma_min_default,
"",
298 Gamma_max_name, Gamma_max_default,
"",
301 setStringToIntegralParameter<EGammaFit>(
302 Gamma_fit_name, Gamma_fit_default,
"",
303 tuple<std::string>(
"Linear",
"Random"),
308 NumElements_name, NumElements_default,
"",
312 x0_name, x0_default,
"",
315 pl->set( Coeff_s_name, Coeff_s_default );
316 pl->set( ExactSolutionAsResponse_name, ExactSolutionAsResponse_default );
468 const double t = inArgs.
get_t();
470 UnsetParameterVector unsetParameterVector(
rcp(&
coeff_s_p_,
false));
488 int localNumElements = x.MyLength();
496 for (
int i=0 ; i<localNumElements ; ++i )
497 f[i] = x_dot[i] - f_func(x[i],t,gamma[i],
coeff_s(i));
500 for (
int i=0 ; i<localNumElements ; ++i )
501 f[i] = - f_func(x[i],t,gamma[i],
coeff_s(i));
505 for (
int i=0 ; i<localNumElements ; ++i )
506 f[i] = f_func(x[i],t,gamma[i],
coeff_s(i));
513 const double beta = inArgs.
get_beta();
519 for(
int i = 0; i < localNumElements; ++i ) {
520 values[0] = alpha - beta*gamma[i];
521 indices[0] = i + offset;
535 for(
int i = 0; i < localNumElements; ++i ) {
537 = - d_evalR_d_s(t,gamma[i],
coeff_s(i));
541 for(
int i = 0; i < localNumElements; ++i ) {
543 = + d_evalR_d_s(t,gamma[i],
coeff_s(i));
588 const int N = gamma.GlobalLength();
590 const int MyLength = gamma.MyLength();
595 for (
int i=0 ; i<MyLength ; ++i )
597 gamma[i] = slope*(procRank*MyLength+i)+
gamma_min_;
610 int MyLength = gamma.MyLength();
611 for (
int i=0 ; i<MyLength ; ++i)
613 gamma[i] = slope*gamma[i] + tmp;
635 for (
int i = 0; i <
np_; ++i )
643 for (
int coeff_s_idx_i = 0; coeff_s_idx_i <
np_; ++coeff_s_idx_i ) {
644 const int num_func_per_coeff_s_idx_i
645 = num_func_per_coeff_s
646 + ( coeff_s_idx_i < num_func_per_coeff_s_rem ? 1 : 0 );
648 int coeff_s_idx_i_j = 0;
649 coeff_s_idx_i_j < num_func_per_coeff_s_idx_i;
693 indices[0] = i + offset;
773 EpetraExt::diagonalTransientModel(
781 diagonalTransientModel->setParameterList(paramList);
RCP_Eptra_Vector_Array_t p_init_
Teuchos::RCP< Epetra_CrsGraph > W_graph_
void set_W_properties(const DerivativeProperties &properties)
Teuchos::RCP< Epetra_Comm > epetra_comm_
OutArgs createOutArgs() const
Evaluation< Epetra_Vector > get_g(int j) const
Get g(j) where 0 <= j && j < this->Ng().
bool is_null(const boost::shared_ptr< T > &p)
void setSupports(EOutArgsMembers arg, bool supports=true)
Teuchos::RCP< const Epetra_Vector > getExactSolution(const double t, const Epetra_Vector *coeff_s_p=0) const
Return the exact solution as a function of time.
void unset_coeff_s_p() const
void set_x(const Teuchos::RCP< const Epetra_Vector > &x)
Teuchos::RCP< Epetra_MultiVector > get_DgDp_mv(const int j, const int l, const ModelEvaluator::OutArgs &outArgs, const ModelEvaluator::EDerivativeMultiVectorOrientation mvOrientation)
Teuchos::RCP< const Epetra_Vector > get_gamma() const
Return the model vector gamma,.
Teuchos::RCP< Epetra_Operator > get_W() const
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
.
void set_f(const Evaluation< Epetra_Vector > &f)
void setSupports(EInArgsMembers arg, bool supports=true)
Teuchos::RCP< const Epetra_Vector > get_p(int l) const
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
DiagonalTransientModel(Teuchos::RCP< Epetra_Comm > const &epetra_comm)
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Teuchos::RCP< Epetra_Vector > gamma_
int InsertGlobalIndices(int_type GlobalRow, int NumIndices, int_type *Indices)
virtual int MyPID() const =0
void set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
#define TEUCHOS_ASSERT_IN_RANGE_UPPER_EXCLUSIVE(index, lower_inclusive, upper_exclusive)
Teuchos::RCP< const Epetra_Map > get_f_map() const
Teuchos::RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
.
RCP_Eptra_Map_Array_t map_g_
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
void set_DfDp_properties(int l, const DerivativeProperties &properties)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Epetra_MultiVector > get_DfDp_mv(const int l, const ModelEvaluator::OutArgs &outArgs)
std::string toString(const HashSet< Key > &h)
T_To & dyn_cast(T_From &from)
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
Teuchos::RCP< const Epetra_Vector > get_x_dot() const
Teuchos::RCP< DiagonalTransientModel > diagonalTransientModel(Teuchos::RCP< Epetra_Comm > const &epetra_comm, Teuchos::RCP< Teuchos::ParameterList > const ¶mList=Teuchos::null)
Nonmember constructor.
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
bool exactSolutionAsResponse_
coeff_s_idx_t coeff_s_idx_
Teuchos::RCP< const Epetra_MultiVector > getExactSensSolution(const double t, const Epetra_Vector *coeff_s_p=0) const
Return the exact sensitivity of x as a function of time.
TypeTo as(const TypeFrom &t)
Teuchos::RCP< const Epetra_Vector > coeff_s_p_
Teuchos::RCP< const Epetra_Map > get_x_map() const
InArgs createInArgs() const
Teuchos::RCP< Epetra_Operator > create_W() const
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const ¶mList)
void push_back(const value_type &x)
virtual int NumProc() const =0
void set_coeff_s_p(const Teuchos::RCP< const Epetra_Vector > &coeff_s_p) const
Teuchos::RCP< const Epetra_Vector > get_x_dot_init() const
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
int coeff_s_idx(int i) const
RCP_Eptra_Map_Array_t map_p_
RCP_Array_String_Array_t names_p_
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< Teuchos::ParameterList > paramList_
Evaluation< Epetra_Vector > get_f() const
Teuchos::RCP< Epetra_Map > epetra_map_
Teuchos::RCP< const Epetra_Vector > get_x() const
Set solution vector Taylor polynomial.
virtual int ReplaceGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Teuchos::RCP< Epetra_Vector > x_init_
void set_Np_Ng(int Np, int Ng)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Teuchos::RCP< Epetra_Vector > x_dot_init_
double coeff_s(int i) const
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
.