本文整理汇总了C++中TPZFMatrix::Zero方法的典型用法代码示例。如果您正苦于以下问题:C++ TPZFMatrix::Zero方法的具体用法?C++ TPZFMatrix::Zero怎么用?C++ TPZFMatrix::Zero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPZFMatrix
的用法示例。
在下文中一共展示了TPZFMatrix::Zero方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GradX
inline void TPZQuadraticQuad::GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx){
gradx.Resize(3,2);
gradx.Zero();
int nrow = nodes.Rows();
int ncol = nodes.Cols();
#ifdef PZDEBUG
if(nrow != 3 || ncol != 8){
std::cout << "Objects of incompatible lengths, gradient cannot be computed." << std::endl;
std::cout << "nodes matrix must be 3x8." << std::endl;
DebugStop();
}
#endif
TPZFNMatrix<3,T> phi(NNodes,1);
TPZFNMatrix<6,T> dphi(2,NNodes);
TShape(loc,phi,dphi);
for(int i = 0; i < NNodes; i++)
{
for(int j = 0; j < 3; j++)
{
gradx(j,0) += nodes.GetVal(j,i)*dphi(0,i);
gradx(j,1) += nodes.GetVal(j,i)*dphi(1,i);
}
}
}
示例2: Jacobian
void TPZGeoTriangle::Jacobian(TPZFMatrix<REAL> & coord, TPZVec<REAL> ¶m,TPZFMatrix<REAL> &jacobian,TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv) {
int spacedim = coord.Rows();
jacobian.Resize(2,2);
axes.Resize(2,3);
jacinv.Resize(2,2);
TPZFNMatrix<3> phi(3,1);
TPZFNMatrix<6> dphi(2,3),axest(3,2);
jacobian.Zero();
Shape(param,phi,dphi);
TPZFNMatrix<6> VecMatrix(3,2,0.);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < spacedim; j++) {
VecMatrix(j,0) += coord(j,i)*dphi(0,i);
VecMatrix(j,1) += coord(j,i)*dphi(1,i);
}
}
VecMatrix.GramSchmidt(axest,jacobian);
axest.Transpose(&axes);
detjac = jacobian(0,0)*jacobian(1,1)-jacobian(1,0)*jacobian(0,1);
if(IsZero(detjac))
{
std::stringstream sout;
sout << "Singular Jacobian " << detjac;
LOGPZ_ERROR(logger, sout.str())
detjac = ZeroTolerance();
}
if(detjac)
{
jacinv(0,0) = jacobian(1,1)/detjac;
jacinv(1,1) = jacobian(0,0)/detjac;
jacinv(0,1) = -jacobian(0,1)/detjac;
jacinv(1,0) = -jacobian(1,0)/detjac;
}
else
{
jacinv.Zero();
}
}
示例3: TransformGradient
void TPZCartsys::TransformGradient(TPZVec<REAL> &X, TPZFMatrix &GradX, TPZVec<REAL> &x, TPZFMatrix &Gradx, TPZCosys *dest) {
int i,j;
Gradx.Zero();
for (i=0;i<3;i++){
x=X;
for (j=0;j<3;j++)
Gradx(i,i)+=fTr(i,j)*GradX(j,j);
}
if (dest != fReference) {
TPZFMatrix gradin(GradX);
FromReference(x);
TransformGradient(x,gradin,x,Gradx,dest);
}
}
示例4: Size
void TPZSkylMatrix<TVar>::SolveSOR(int & numiterations,const TPZFMatrix<TVar> &F,
TPZFMatrix<TVar> &result, TPZFMatrix<TVar> *residual, TPZFMatrix<TVar> &scratch,const TVar overrelax,
TVar &tol,const int FromCurrent,const int direction) {
if(residual == &F) {
cout << "TPZMatrix::SolveSOR called with residual and F equal, no solution\n";
return;
}
TVar res = 2*tol+1.;;
if(residual) res = Norm(*residual);
if(!FromCurrent) {
result.Zero();
}
int r = this->Dim();
int c = F.Cols();
int i,ifirst = 0, ilast = r, iinc = 1;
if(direction == -1) {
ifirst = r-1;
ilast = 0;
iinc = -1;
}
int it;
for(it=0; it<numiterations && res > tol; it++) {
res = 0.;
scratch = F;
for(int ic=0; ic<c; ic++) {
if(direction == 1) {
//
// compute the upper triangular part first and put into the scractch vector
//
for(i=ifirst; i!=ilast; i+= iinc) {
//TPZColuna *mydiag = &fDiag[i];
int offset = Size(i);
TVar val;
TVar *diag;
TVar *diaglast = fElem[i];
TVar *scratchp = &scratch(i-offset+1,ic);
val = result(i,ic);
diag = fElem[i] + offset-1;
int lastid = diag-diaglast;
int id;
for(id=0; id<=lastid; id++) *(scratchp+id) -= *(diag-id) * val;
/* codeguard fix
while( diag >= diaglast ) *scratchp++ -= *diag-- * val;
*/
}
//
// perform the SOR operation
//
for(i=ifirst; i!=ilast; i+= iinc) {
//TPZColuna *mydiag = &fDiag[i];
int offset = Size(i);
TVar val = scratch(i,ic);
TVar *p = &result(i-offset+1,ic);
TVar *diag = fElem[i] + offset-1;
TVar *diaglast = fElem[i];
while( diag > diaglast ) val -= *diag-- * *p++;
res += val*val;
result(i,ic) += val*overrelax/ *diag;
}
} else {
//
// the direction is upward
//
// put the lower triangular part of the multiplication into the scratch vector
//
for(i=ifirst; i!=ilast; i+= iinc) {
//TPZColuna *mydiag = &fDiag[i];
int offset = Size(i);
TVar val = scratch(i,ic);
TVar *p = &result(i-offset+1,ic);
TVar *diag = fElem[i] + offset-1;
TVar *diaglast = fElem[i];
while( diag > diaglast ) val -= *diag-- * *p++;
// res += val*val;
scratch(i,ic) = val;
}
//
// perform the SOR operation
//
for(i=ifirst; i!=ilast; i+= iinc) {
//TPZColuna *mydiag = &fDiag[i];
int offset = Size(i);
// REAL val = scratch(i,ic);
TVar *diag;
TVar *diaglast = fElem[i];
TVar *scratchp = &scratch(i-offset+1,ic);
//val= result(i,ic);
TVar val = scratch(i,ic);
val -= *diaglast * result(i,ic);
res += val*val;
val = overrelax * val / *diaglast;
result(i,ic) += val;
val = result(i,ic);
diag = fElem[i] + offset-1;
while( diag > diaglast ) *scratchp++ -= *diag-- * val;
}
}
}
res = sqrt(res);
//.........这里部分代码省略.........