本文整理汇总了C++中Tpetra_Vector类的典型用法代码示例。如果您正苦于以下问题:C++ Tpetra_Vector类的具体用法?C++ Tpetra_Vector怎么用?C++ Tpetra_Vector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tpetra_Vector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeResponse
void
twoD_diffusion_problem<Scalar,MeshScalar,BasisScalar,LocalOrdinal,GlobalOrdinal,
Node>::
computeResponse(const Tpetra_Vector& x,
const Tpetra_Vector& p,
Tpetra_Vector& g)
{
// g = average of x
Teuchos::ArrayRCP<Scalar> g_view = g.get1dViewNonConst();
x.meanValue(g_view());
g_view[0] *= Scalar(x.getGlobalLength()) / Scalar(mesh.size());
}
示例2: evaluateResponseT
void
Albany::SolutionTwoNormResponseFunction::
evaluateResponseT(const double current_time,
const Tpetra_Vector* xdotT,
const Tpetra_Vector* xdotdotT,
const Tpetra_Vector& xT,
const Teuchos::Array<ParamVec>& p,
Tpetra_Vector& gT)
{
Teuchos::ScalarTraits<ST>::magnitudeType twonorm = xT.norm2();
Teuchos::ArrayRCP<ST> gT_nonconstView = gT.get1dViewNonConst();
gT_nonconstView[0] = twonorm;
}
示例3: evaluateResponseT
void
Albany::SolutionAverageResponseFunction::
evaluateResponseT(const double current_time,
const Tpetra_Vector* xdotT,
const Tpetra_Vector* xdotdotT,
const Tpetra_Vector& xT,
const Teuchos::Array<ParamVec>& p,
Tpetra_Vector& gT)
{
ST mean = xT.meanValue();
Teuchos::ArrayRCP<ST> gT_nonconstView = gT.get1dViewNonConst();
gT_nonconstView[0] = mean;
}
示例4: evaluateGradientT
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);
}
示例5: evaluateTangentT
void
Albany::SolutionAverageResponseFunction::
evaluateTangentT(const double alpha,
const double beta,
const double omega,
const double current_time,
bool sum_derivs,
const Tpetra_Vector* xdotT,
const Tpetra_Vector* xdotdotT,
const Tpetra_Vector& xT,
const Teuchos::Array<ParamVec>& p,
ParamVec* deriv_p,
const Tpetra_MultiVector* VxdotT,
const Tpetra_MultiVector* VxdotdotT,
const Tpetra_MultiVector* VxT,
const Tpetra_MultiVector* VpT,
Tpetra_Vector* gT,
Tpetra_MultiVector* gxT,
Tpetra_MultiVector* gpT)
{
// Evaluate response g
if (gT != NULL) {
ST mean = xT.meanValue();
Teuchos::ArrayRCP<ST> gT_nonconstView = gT->get1dViewNonConst();
gT_nonconstView[0] = mean;
}
// Evaluate tangent of g = dg/dx*Vx + dg/dxdot*Vxdot + dg/dp*Vp
// If Vx == NULL, Vx is the identity
if (gxT != NULL) {
Teuchos::ArrayRCP<ST> gxT_nonconstView;
if (VxT != NULL) {
Teuchos::Array<ST> means;
means.resize(VxT->getNumVectors());
VxT->meanValue(means());
for (int j=0; j<VxT->getNumVectors(); j++) {
gxT_nonconstView = gxT->getDataNonConst(j);
gxT_nonconstView[0] = means[j];
}
}
else {
gxT->putScalar(1.0/xT.getGlobalLength());
}
gxT->scale(alpha);
}
if (gpT != NULL)
gpT->putScalar(0.0);
}
示例6: return
//==============================================================================
int Ifpack2_LocalFilter::ExtractDiagonalCopy(Tpetra_Vector & Diagonal) const
{
if (!Diagonal.Map().SameAs(*Map_))
IFPACK2_CHK_ERR(-1);
Diagonal = *Diagonal_;
return(0);
}
示例7:
void Albany::GenericSTKFieldContainer<Interleaved>::fillVectorHelperT(Tpetra_Vector &solnT,
ScalarFieldType *solution_field,
const Teuchos::RCP<const Tpetra_Map>& node_mapT,
const stk::mesh::Bucket & bucket, int offset){
// Fill the result vector
// Create a multidimensional array view of the
// solution field data for this bucket of nodes.
// The array is two dimensional ( Cartesian X NumberNodes )
// and indexed by ( 0..2 , 0..NumberNodes-1 )
BucketArray<ScalarFieldType> solution_array(*solution_field, bucket);
const int num_nodes_in_bucket = solution_array.dimension(0);
stk::mesh::BulkData& mesh = solution_field->get_mesh();
for (std::size_t i=0; i < num_nodes_in_bucket; i++) {
const GO node_gid = mesh.identifier(bucket[i]) - 1;
int node_lid = node_mapT->getLocalElement(node_gid);
solnT.replaceLocalValue(getDOF(node_lid, offset), solution_array(i));
}
}
示例8: ExtractDiagonalCopy
//==============================================================================
int Ifpack2_ReorderFilter::
ExtractDiagonalCopy(Tpetra_Vector & Diagonal) const
{
Tpetra_Vector DiagonalTilde(Diagonal.Map());
IFPACK2_CHK_ERR(Matrix()->ExtractDiagonalCopy(DiagonalTilde));
IFPACK2_CHK_ERR((Reordering_->P(DiagonalTilde,Diagonal)));
return(0);
}
示例9: evaluateGradientT
void
Albany::SolutionTwoNormResponseFunction::
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)
{
Teuchos::ScalarTraits<ST>::magnitudeType nrm = xT.norm2();
// Evaluate response g
Teuchos::ArrayRCP<ST> gT_nonconstView;
if (gT != NULL) {
gT_nonconstView = gT->get1dViewNonConst();
gT_nonconstView[0] = nrm;
}
// Evaluate dg/dx
if (dg_dxT != NULL) {
//double nrm;
if (gT != NULL)
nrm = gT_nonconstView[0];
else
nrm = xT.norm2();
dg_dxT->scale(1.0/nrm,xT);
}
// 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);
}
示例10: evaluateResponseT
void Albany::AlbanyPeridigmOBCFunctional::
evaluateResponseT(const double current_time,
const Tpetra_Vector* xdotT,
const Tpetra_Vector* xdotdotT,
const Tpetra_Vector& xT,
const Teuchos::Array<ParamVec>& p,
Tpetra_Vector& gT)
{
LCM::PeridigmManager& peridigmManager = *LCM::PeridigmManager::self();
Teuchos::ArrayRCP<ST> gT_nonconstView = gT.get1dViewNonConst();
peridigmManager.obcOverlappingElementSearch();
gT_nonconstView[0] = peridigmManager.obcEvaluateFunctional();
}
示例11: evaluateResponseT
void
Albany::SolutionMaxValueResponseFunction::
evaluateResponseT(const double current_time,
const Tpetra_Vector* xdotT,
const Tpetra_Vector* xdotdotT,
const Tpetra_Vector& xT,
const Teuchos::Array<ParamVec>& p,
Tpetra_Vector& gT)
{
int index;
Teuchos::ArrayRCP<ST> gT_nonconstView = gT.get1dViewNonConst();
computeMaxValueT(xT, gT_nonconstView[0], index);
}
示例12: computeResidual
void
twoD_diffusion_problem<Scalar,MeshScalar,BasisScalar,LocalOrdinal,GlobalOrdinal,
Node>::
computeResidual(const Tpetra_Vector& x,
const Tpetra_Vector& p,
Tpetra_Vector& f)
{
// f = A*x - b
if (log_normal)
computeA(*lnFunc, p, *A);
else
computeA(*klFunc, p, *A);
A->apply(x,f);
f.update(-1.0, *b, 1.0);
}
示例13: evaluateGradientT
void
Albany::SolutionAverageResponseFunction::
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)
{
// Evaluate response g
if (gT != NULL) {
ST mean = xT.meanValue();
Teuchos::ArrayRCP<ST> gT_nonconstView = gT->get1dViewNonConst();
gT_nonconstView[0] = mean;
}
// Evaluate dg/dx
if (dg_dxT != NULL)
dg_dxT->putScalar(1.0 / xT.getGlobalLength());
// 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);
}
示例14: evaluateTangentT
void
Albany::SolutionTwoNormResponseFunction::
evaluateTangentT(const double alpha,
const double beta,
const double omega,
const double current_time,
bool sum_derivs,
const Tpetra_Vector* xdotT,
const Tpetra_Vector* xdotdotT,
const Tpetra_Vector& xT,
const Teuchos::Array<ParamVec>& p,
ParamVec* deriv_p,
const Tpetra_MultiVector* VxdotT,
const Tpetra_MultiVector* VxdotdotT,
const Tpetra_MultiVector* VxT,
const Tpetra_MultiVector* VpT,
Tpetra_Vector* gT,
Tpetra_MultiVector* gxT,
Tpetra_MultiVector* gpT)
{
Teuchos::ScalarTraits<ST>::magnitudeType nrm = xT.norm2();
// Evaluate response g
if (gT != NULL) {
Teuchos::ArrayRCP<ST> gT_nonconstView = gT->get1dViewNonConst();
gT_nonconstView[0] = nrm;
}
// Evaluate tangent of g = dg/dx*dx/dp + dg/dxdot*dxdot/dp + dg/dp
// dg/dx = 1/||x|| * x^T
Teuchos::ETransp T = Teuchos::TRANS;
Teuchos::ETransp N = Teuchos::NO_TRANS;
if (gxT != NULL) {
if (VxT != NULL)
gxT->multiply(T, N, alpha/nrm, xT, *VxT, 0.0);
else
gxT->update(alpha/nrm, xT, 0.0);
}
if (gpT != NULL)
gpT->putScalar(0.0);
}
示例15: computeMaxValueT
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));
}