51 const std::vector<Epetra_Vector*> initGuessVec_,
55 underlyingME(underlyingME_),
56 globalComm(globalComm_),
59 timeStepsOnTimeDomain(globalComm_->NumTimeStepsOnDomain()),
60 numTimeDomains(globalComm_->NumSubDomains()),
61 timeDomain(globalComm_->SubDomainRank()),
62 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
65 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
68 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
71 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
74 matching_vec(matching_vec_)
78 std::cout <<
"----------MultiPoint Partition Info------------"
80 <<
"\n\tSpatial Decomposition = " <<
globalComm->SubDomainComm().NumProc()
83 <<
"\n\tTotal Number of Steps = " <<
globalComm->NumTimeSteps();
84 std::cout <<
"\n-----------------------------------------------" << std::endl;
92 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
98 (*rowStencil_int)[i].push_back(0);
99 (*rowIndex_int).push_back(i +
globalComm->FirstTimeStepOnDomain());
106 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
112 (*rowStencil_LL)[i].push_back(0);
113 (*rowIndex_LL).push_back(i +
globalComm->FirstTimeStepOnDomain());
120 throw "EpetraExt::MultiPointModelEvaluator::MultiPointModelEvaluator: Global indices unknown";
186 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
192 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
215 if (underlyingNg)
delete block_DgDx;
216 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
217 delete rowStencil_int;
220 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
221 delete rowStencil_LL;
237 return Teuchos::rcp(&(block_W->OperatorDomainMap()),
false);
247 return underlyingME->get_p_map(l);
252 return underlyingME->get_g_map(j);
257 return solution_init;
262 return underlyingME->get_p_init(l);
290 DERIV_LINEARITY_NONCONST
295 outArgs.
setSupports(OUT_ARG_DfDp,0,DERIV_MV_BY_COL);
298 DERIV_LINEARITY_CONST
299 ,DERIV_RANK_DEFICIENT
305 outArgs.
setSupports(OUT_ARG_DgDx,0,DERIV_TRANS_MV_BY_ROW);
308 DERIV_LINEARITY_NONCONST
309 ,DERIV_RANK_DEFICIENT
313 outArgs.
setSupports(OUT_ARG_DgDp,0,0, orientation_DgDp);
316 DERIV_LINEARITY_NONCONST
317 ,DERIV_RANK_DEFICIENT
340 if (p_in.
get()) underlyingInArgs.
set_p(0, p_in);
343 block_x->Epetra_Vector::operator=(*x_in);
353 if (underlyingNg) g_out = outArgs.
get_g(0);
354 if (g_out.get()) g_out->PutScalar(0.0);
369 bool need_g = g_out.get();
375 for (
int i=0; i < timeStepsOnTimeDomain; i++) {
378 underlyingInArgs.
set_p(1, (*q_vec)[i]);
382 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
383 block_x->ExtractBlockValues(*split_x, (*rowIndex_LL)[i]);
387 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
388 block_x->ExtractBlockValues(*split_x, (*rowIndex_int)[i]);
391 underlyingInArgs.
set_x(split_x);
394 if (f_out.
get()) underlyingOutArgs.
set_f(split_f);
396 if (need_g) underlyingOutArgs.
set_g(0, split_g);
398 if (W_out.
get()) underlyingOutArgs.
set_W(split_W);
404 if (!DgDp_out.
isEmpty()) underlyingOutArgs.
set_DgDp(0, 0, *deriv_DgDp);
407 underlyingME->evalModel(underlyingInArgs, underlyingOutArgs);
411 if (matchingProblem) {
413 double diff = (*split_g)[0] - (*(*matching_vec)[i])[0];
414 double nrmlz = fabs((*(*matching_vec)[i])[0]) + 1.0e-6;
415 (*split_g)[0] = 0.5 * diff * diff/(nrmlz*nrmlz);
416 if (!DgDx_out.
isEmpty()) split_DgDx->Scale(diff/(nrmlz*nrmlz));
417 if (!DgDp_out.
isEmpty()) split_DgDp->Scale(diff/(nrmlz*nrmlz));
423 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
424 if (f_out.
get()) block_f->LoadBlockValues(*split_f, (*rowIndex_LL)[i]);
427 if (!DfDp_out.
isEmpty()) block_DfDp->LoadBlockValues(*split_DfDp, (*rowIndex_LL)[i]);
428 if (!DgDx_out.
isEmpty()) block_DgDx->LoadBlockValues(*split_DgDx, (*rowIndex_LL)[i]);
432 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
433 if (f_out.
get()) block_f->LoadBlockValues(*split_f, (*rowIndex_int)[i]);
436 if (!DfDp_out.
isEmpty()) block_DfDp->LoadBlockValues(*split_DfDp, (*rowIndex_int)[i]);
437 if (!DgDx_out.
isEmpty()) block_DgDx->LoadBlockValues(*split_DgDx, (*rowIndex_int)[i]);
442 if (g_out.get()) g_out->Update(1.0, *split_g, 1.0);
450 if (f_out.
get()) f_out->operator=(*block_f);
457 if (numTimeDomains > 1) {
458 double factorToZeroOutCopies = 0.0;
459 if (globalComm->SubDomainComm().MyPID()==0) factorToZeroOutCopies = 1.0;
461 (*g_out).Scale(factorToZeroOutCopies);
462 double* vPtr = &((*g_out)[0]);
464 globalComm->SumAll( &(tmp[0]), vPtr, num_g0);
470 globalComm->SumAll(tmp[0], mvPtr, num_dg0dp0);
bool supports(EOutArgsMembers arg) const
Teuchos::RCP< const Epetra_Vector > get_x_init() const
Teuchos::RCP< Epetra_MultiVector > split_DgDp
Teuchos::RCP< Epetra_MultiVector > split_DgDx
Split sensitivity vector – local storage.
EpetraExt::ModelEvaluator::DerivativeMultiVector * derivMV_DgDp
void LoadBlock(const Epetra_RowMatrix &BaseMatrix, const int Row, const int Col)
Routine for loading a base matrices values into the large Block Matrix The Row and Col arguments are ...
virtual Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
.
void set_W_properties(const DerivativeProperties &properties)
Evaluation< Epetra_Vector > get_g(int j) const
Get g(j) where 0 <= j && j < this->Ng().
Teuchos::RCP< Epetra_Operator > create_W() const
void set_DgDx(int j, const Derivative &DgDx_j)
Teuchos::RCP< const Epetra_Vector > get_p_init(int l) const
Derivative get_DfDp(int l) const
void setSupports(EOutArgsMembers arg, bool supports=true)
virtual const Epetra_Map & RowMatrixRowMap() const =0
std::vector< std::vector< long long > > * rowStencil_LL
std::vector< int > * rowIndex_int
Set of indices into global XYZT Jacobian matrix.
~MultiPointModelEvaluator()
void set_x(const Teuchos::RCP< const Epetra_Vector > &x)
bool is_null(const std::shared_ptr< T > &p)
Teuchos::RCP< Epetra_Operator > get_W() const
EpetraExt::BlockVector * block_x
Pointer to global multipoint solution vector – local storage.
void set_DfDp(int l, const Derivative &DfDp_l)
void evalModel(const InArgs &inArgs, const OutArgs &outArgs) const
Teuchos::RCP< Epetra_Vector > split_g
Split vector of response functions – local storage.
int numTimeDomains
Total number of time step domains.
void set_f(const Evaluation< Epetra_Vector > &f)
void setSupports(EInArgsMembers arg, bool supports=true)
Teuchos::RCP< Epetra_Vector > split_f
Split (spatial) residual vector – local storage.
Teuchos::RCP< const Epetra_Vector > get_p(int l) const
bool GlobalIndicesInt() const
Simple aggregate class that stores a derivative object as a general linear operator or as a multi-vec...
Teuchos::RCP< EpetraExt::BlockCrsMatrix > block_W
Pointer to global XYZT Jacobian matrix.
Derivative get_DgDx(int j) const
int underlyingNg
Number of g vectors supported by underlyingME, often used as a bool.
Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
.
EpetraExt::ModelEvaluator::Derivative * deriv_DgDp
Simple aggregate class for a derivative object represented as a column-wise multi-vector or its trans...
int timeStepsOnTimeDomain
Number of time steps computed on each time domain.
EpetraExt::ModelEvaluator::Derivative * deriv_DfDp
void set_DgDp_properties(int j, int l, const DerivativeProperties &properties)
Teuchos::RCP< Epetra_MultiVector > getMultiVector() const
int NumMyElements() const
Teuchos::RCP< Epetra_RowMatrix > split_W
Pointer to split (spatial) Jacobian matrix.
void set_DfDp_properties(int l, const DerivativeProperties &properties)
Teuchos::RCP< Epetra_Vector > split_x
Split (spatial) input vector – local storage.
OutArgs createOutArgs() const
void setModelEvalDescription(const std::string &modelEvalDescription)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
EpetraExt::ModelEvaluator::DerivativeMultiVector * derivMV_DgDx
std::vector< long long > * rowIndex_LL
void set_p(int l, const Teuchos::RCP< const Epetra_Vector > &p_l)
Derivative get_DgDp(int j, int l) const
Teuchos::RCP< Epetra_MultiVector > split_DfDp
Split sensitivity vector – local storage.
MultiPointModelEvaluator(Teuchos::RCP< EpetraExt::ModelEvaluator > underlyingME_, const Teuchos::RCP< EpetraExt::MultiComm > &globalComm_, const std::vector< Epetra_Vector * > initGuessVec, Teuchos::RCP< std::vector< Teuchos::RCP< Epetra_Vector > > > qvec, Teuchos::RCP< std::vector< Teuchos::RCP< Epetra_Vector > > > matching_vec=Teuchos::null)
Teuchos::RCP< EpetraExt::MultiComm > globalComm
Pointer to the global (full XYZT) communicator.
void set_W(const Teuchos::RCP< Epetra_Operator > &W)
virtual Teuchos::RCP< const Epetra_Map > get_p_map(int l) const
.
Teuchos::RCP< std::vector< Teuchos::RCP< Epetra_Vector > > > matching_vec
Array of vectors that have data for g-matching optimization problem.
Teuchos::RCP< const Epetra_Map > get_g_map(int j) const
.
void setModelEvalDescription(const std::string &modelEvalDescription)
EpetraExt::BlockVector * block_f
Pointer to global multipoint residual vector – local storage.
EpetraExt::BlockMultiVector * block_DfDp
Pointer to global multipoint DfDp multi vector – local storage.
void set_DgDp(int j, int l, const Derivative &DgDp_j_l)
TypeTo as(const TypeFrom &t)
EpetraExt::ModelEvaluator::DerivativeMultiVector * derivMV_DfDp
Teuchos::RCP< EpetraExt::ModelEvaluator > underlyingME
std::vector< std::vector< int > > * rowStencil_int
Stencil for each row of global XYZT Jacobian matrix.
void set_DgDx_properties(int j, const DerivativeProperties &properties)
InArgs createInArgs() const
Evaluation< Epetra_Vector > get_f() const
Teuchos::RCP< const Epetra_Vector > get_x() const
Set solution vector Taylor polynomial.
EpetraExt::BlockMultiVector * block_DgDx
Pointer to global multipoint DfDp multi vector – local storage.
void set_Np_Ng(int Np, int Ng)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Teuchos::RCP< const Epetra_Map > get_f_map() const
Teuchos::RCP< const Epetra_Map > get_x_map() const
Teuchos::RCP< EpetraExt::BlockVector > solution_init
Pointer to initial multipoint solution vector.
EpetraExt::ModelEvaluator::Derivative * deriv_DgDx
void set_g(int j, const Evaluation< Epetra_Vector > &g_j)
Set g(j) where 0 <= j && j < this->Ng().
EDerivativeMultiVectorOrientation orientation_DgDp
Some local data.