本文整理汇总了C++中Tpetra_Vector::getMap方法的典型用法代码示例。如果您正苦于以下问题:C++ Tpetra_Vector::getMap方法的具体用法?C++ Tpetra_Vector::getMap怎么用?C++ Tpetra_Vector::getMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tpetra_Vector
的用法示例。
在下文中一共展示了Tpetra_Vector::getMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Albany::SolutionMaxValueResponseFunction::
computeMaxValueT(const Tpetra_Vector& xT, double& global_max, int& global_index)
{
//The following is needed b/c Epetra_MaxDouble comes from Trilinos Epetra package.
double Tpetra_MaxDouble = 1.0E+100;
double my_max = -Tpetra_MaxDouble;
int my_index = -1, index;
Teuchos::ArrayRCP<const ST> xT_constView = xT.get1dView();
// Loop over nodes to find max value for equation eq
int num_my_nodes = xT.getLocalLength() / neq;
for (int node=0; node<num_my_nodes; node++) {
if (interleavedOrdering) index = node*neq+eq;
else index = node + eq*num_my_nodes;
if (xT_constView[index] > my_max) {
my_max = xT_constView[index];
my_index = index;
}
}
// Check remainder (AGS: NOT SURE HOW THIS CODE GETS CALLED?)
if (num_my_nodes*neq+eq < xT.getLocalLength()) {
if (interleavedOrdering) index = num_my_nodes*neq+eq;
else index = num_my_nodes + eq*num_my_nodes;
if (xT_constView[index] > my_max) {
my_max = xT_constView[index];
my_index = index;
}
}
Teuchos::RCP<const Teuchos::Comm<int> > commT = xT.getMap()->getComm();
// Get max value across all proc's
Teuchos::reduceAll(*commT, Teuchos::REDUCE_MAX, my_max, Teuchos::ptr(&global_max));
// Compute min of all global indices equal to max value
if (my_max == global_max)
my_index = xT.getMap()->getGlobalElement(my_index);
else
my_index = xT.getGlobalLength();
Teuchos::reduceAll(*commT, Teuchos::REDUCE_MIN, my_index, Teuchos::ptr(&global_index));
}
示例2: computeMaxValueT
void
Albany::SolutionMaxValueResponseFunction::
evaluateGradientT(const double current_time,
const Tpetra_Vector* xdotT,
const Tpetra_Vector* xdotdotT,
const Tpetra_Vector& xT,
const Teuchos::Array<ParamVec>& p,
ParamVec* deriv_p,
Tpetra_Vector* gT,
Tpetra_MultiVector* dg_dxT,
Tpetra_MultiVector* dg_dxdotT,
Tpetra_MultiVector* dg_dxdotdotT,
Tpetra_MultiVector* dg_dpT)
{
int global_index;
double mxv;
computeMaxValueT(xT, mxv, global_index);
// Evaluate response g
if (gT != NULL) {
Teuchos::ArrayRCP<ST> gT_nonconstView = gT->get1dViewNonConst();
gT_nonconstView[0] = mxv;
}
Teuchos::ArrayRCP<const ST> xT_constView = xT.get1dView();
// Evaluate dg/dx
if (dg_dxT != NULL) {
Teuchos::ArrayRCP<ST> dg_dxT_nonconstView;
int im = -1;
for (int i=0; i<xT.getMap()->getNodeNumElements(); i++) {
dg_dxT_nonconstView = dg_dxT->getDataNonConst(0);
if (xT_constView[i] == mxv) { dg_dxT_nonconstView[i] = 1.0; im = i; }
else dg_dxT_nonconstView[i] = 0.0;
}
}
// Evaluate dg/dxdot
if (dg_dxdotT != NULL)
dg_dxdotT->putScalar(0.0);
if (dg_dxdotdotT != NULL)
dg_dxdotdotT->putScalar(0.0);
// Evaluate dg/dp
if (dg_dpT != NULL)
dg_dpT->putScalar(0.0);
}