本文整理汇总了C++中TPZVec::Fill方法的典型用法代码示例。如果您正苦于以下问题:C++ TPZVec::Fill方法的具体用法?C++ TPZVec::Fill怎么用?C++ TPZVec::Fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPZVec
的用法示例。
在下文中一共展示了TPZVec::Fill方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadSolution
void ReadSolution(ifstream &arq, TPZVec<REAL> &sol, TPZCompMesh *cmesh, int &nstate, TPZVec<int> &dimstate){
int i,j,totaldim=0;
for(i=0;i<nstate;i++) totaldim += dimstate[i];
TPZVec<REAL> pt(3,0.);
TPZVec<REAL> coord(3,0.);
TPZVec<REAL> auxsol(totaldim,0.);
int iter = 0;
int nel = cmesh->NElements();
int solsize = totaldim * nel;
sol.Resize(solsize);
sol.Fill(0.);
for(i=0; i<nel; i++){
TPZCompEl *el = cmesh->ElementVec()[i];
if (!el) continue;
el->Reference()->CenterPoint(el->Reference()->NSides()-1,pt);
el->Reference()->X(pt,coord);
EvaluateSolution(coord,auxsol);
for (j=0;j<totaldim;j++){
sol[iter] = auxsol[j];
iter++;
}
}
}
示例2: MeshError
void TPZMGAnalysis::MeshError(TPZCompMesh *fine, TPZCompMesh *coarse, TPZVec<REAL> &ervec,
void (*f)(TPZVec<REAL> &loc, TPZVec<REAL> &val, TPZFMatrix<REAL> &deriv),TPZVec<REAL> &truervec){
coarse->Reference()->ResetReference();
coarse->LoadReferences();
int dim = fine->MaterialVec().begin()->second->Dimension();
ervec.Resize(coarse->NElements());
if(f) {
truervec.Resize(coarse->NElements());
truervec.Fill(0.,0);
}
ervec.Fill(0.,0);
TPZCompEl *cel;
TPZAdmChunkVector<TPZCompEl *> &elementvec = fine->ElementVec();
int numel = elementvec.NElements();
int el;
for(el=0; el<numel; el++) {
cel = elementvec[el];
if (!cel) continue;
TPZInterpolatedElement *cint = dynamic_cast<TPZInterpolatedElement *> (cel);
if(!cint) continue;
int ncon = cint->NConnects();
TPZGeoElSide gelside(cint->Reference(),ncon-1);
if(gelside.Dimension() != dim) continue;
TPZGeoElSide gellarge(gelside);
while(!gellarge.Reference().Exists() && gellarge.Father2().Exists()) gellarge = gellarge.Father2();
if(!gellarge.Reference().Exists()) {
cout << "TPZMGAnalsysis::BuildTransferMatrix element " << el << " found no corresponding element\n";
continue;
}
TPZCompElSide cellargeside = gellarge.Reference();
TPZCompEl *cellarge = cellargeside.Element();
TPZInterpolatedElement *cintlarge = (TPZInterpolatedElement *) cellarge;
TPZTransform transform(gelside.Dimension(),gellarge.Dimension());
gelside.SideTransform3(gellarge,transform);
int index = cellarge->Index();
REAL truerror = 0.;
ervec[index] += ElementError(cint,cintlarge,transform,f,truerror);
if(f) truervec[index] += truerror;
}
}
示例3: ODotOperator
void TPZArtDiff::ODotOperator(TPZVec<REAL> &dphi, TPZVec<TPZVec<T> > &TauDiv, TPZVec<T> &Result){
int dim = TauDiv.NElements();
int size = dphi.NElements();
int neq = TauDiv[0].NElements();
if(size<1 || size>3){
PZError << "TPZArtDiff::PointOperator: error data size";
}
Result.Resize(neq);
Result.Fill(REAL(0.));
int i, k;
for(k=0;k<dim;k++)
for(i=0;i<neq;i++)Result[i] += TauDiv[k][i] * dphi[k];
}
示例4: sol
void TPZMatPoissonD3::ErrorsHdiv(TPZMaterialData &data,TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &values){
values.Fill(0.0);
TPZVec<STATE> sol(1),dsol(3),div(1);
// if(data.numberdualfunctions) Solution(data,2,sol);//pressao
Solution(data,1,dsol);//fluxo
//Solution(data,14,div);//divergente
#ifdef LOG4CXX
// if(logger->isDebugEnabled()){
// std::stringstream sout;
// sout<< "\n";
// sout << " Pto " << data.x << std::endl;
// sout<< " pressao exata " <<u_exact <<std::endl;
// sout<< " pressao aprox " <<sol <<std::endl;
// sout<< " ---- "<<std::endl;
// sout<< " fluxo exato " <<du_exact(0,0)<<", " << du_exact(1,0)<<std::endl;
// sout<< " fluxo aprox " <<dsol<<std::endl;
// sout<< " ---- "<<std::endl;
// if(du_exact.Rows()>fDim) sout<< " div exato " <<du_exact(2,0)<<std::endl;
// sout<< " div aprox " <<div<<std::endl;
// LOGPZ_DEBUG(logger,sout.str())
// }
#endif
// //values[0] : pressure error using L2 norm
// if(data.numberdualfunctions){
// REAL diffP = abs(u_exact[0]-sol[0]);
// values[0] = diffP*diffP;
// }
//values[1] : flux error using L2 norm
for(int id=0; id<fDim; id++) {
REAL diffFlux = abs(dsol[id] - du_exact(id,0));
values[1] += diffFlux*diffFlux;
}
// if(du_exact.Rows()>3){
// //values[2] : divergence using L2 norm
// REAL diffDiv = abs(div[0] - du_exact(2,0));
// values[2]=diffDiv*diffDiv;
// //values[3] : Hdiv norm => values[1]+values[2];
// values[3]= values[1]+values[2];
// }
}
示例5: Divergent
void TPZArtDiff::Divergent(TPZFMatrix<STATE> &dsol,
TPZFMatrix<REAL> & dphi,
TPZVec<TPZDiffMatrix<STATE> > & Ai,
TPZVec<STATE> & Div,
TPZDiffMatrix<STATE> * dDiv)
{
int nstate = Ai[0].Cols();
int dim = nstate - 2;
int nshape = dphi.Cols();
Div.Resize(nstate);
Div.Fill(0.);
int i, j, k;
// computing the divergent:
// A.du/dx + B.du/dy + C.du/dz
for(k=0;k<dim;k++)
for(i=0;i<nstate; i++)
for(j=0;j<nstate;j++)
{
Div[i]+=Ai[k](i,j)*dsol(k,j);
}
if(!dDiv)return;
// computing an approximation to the divergent derivative:
// dDiv/dUj ~= A.d2U/dUidx + B.d2U/dUidy + C.d2U/dUidz
dDiv->Redim(nstate, nstate * nshape);
int l;
REAL buff;
for(l=0;l<nshape;l++)
for(j=0;j<nstate;j++)
for(i=0;i<nstate; i++)
{
buff =0.;
for(k=0;k<dim;k++)
{
buff+=Ai[k](i,j)*dphi(k,l);
}
dDiv->operator()(i,j+l*nstate)=buff;
}
}
示例6: Errors
void TPZPrimalPoisson::Errors(TPZVec<REAL> &x,TPZVec<STATE> &u,TPZFMatrix<STATE> &du, TPZFMatrix<REAL> &axes, TPZVec<STATE> &flux,TPZVec<STATE> &u_exact,TPZFMatrix<STATE> &du_exact,TPZVec<REAL> &error){
error.Fill(0.0);
// q = - grad (p)
du *= -1.0;
/** @brief error[0] : primal error using L2 norm */
STATE p_error = u[0] - u_exact[0];
error[0] = p_error*p_error;
/** @brief error[1] : dual error using L2 norm */
for(int i = 0; i < this->Dimension(); i++) {
STATE d_error = du(i,0) - du_exact(i,0);
error[1] += d_error*d_error;
}
/** @brief error[2] : H1 error norm */
error[2]= error[1];
}