当前位置: 首页>>代码示例>>C++>>正文


C++ TPZFMatrix::Zero方法代码示例

本文整理汇总了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);
        }
    }
    
}
开发者ID:labmec,项目名称:neopz,代码行数:27,代码来源:tpzquadraticquad.cpp

示例2: Jacobian

void TPZGeoTriangle::Jacobian(TPZFMatrix<REAL> & coord, TPZVec<REAL> &param,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();
    }
}
开发者ID:JoaoFelipe,项目名称:oceano,代码行数:39,代码来源:pzgeotriangle.cpp

示例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);
	}
}
开发者ID:labmec,项目名称:neopz,代码行数:14,代码来源:pzcartsys.cpp

示例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);
//.........这里部分代码省略.........
开发者ID:JoaoFelipe,项目名称:oceano,代码行数:101,代码来源:pzskylmat.cpp


注:本文中的TPZFMatrix::Zero方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。