void ErrorH1(TPZCompMesh *l2mesh, std::ostream &out) { int64_t nel = l2mesh->NElements(); int dim = l2mesh->Dimension(); TPZManVector<STATE,10> globerrors(10,0.); for (int64_t el=0; el<nel; el++) { TPZCompEl *cel = l2mesh->ElementVec()[el]; if (!cel) { continue; } TPZGeoEl *gel = cel->Reference(); if (!gel || gel->Dimension() != dim) { continue; } TPZManVector<STATE,10> elerror(10,0.); elerror.Fill(0.); cel->EvaluateError(SolSuave, elerror, NULL); int nerr = elerror.size(); //globerrors.resize(nerr); #ifdef LOG4CXX if (logger->isDebugEnabled()) { std::stringstream sout; sout << "L2 Error sq of element " << el << elerror[0]*elerror[0]; LOGPZ_DEBUG(logger, sout.str()) } #endif for (int i=0; i<nerr; i++) { globerrors[i] += elerror[i]*elerror[i]; } }
void TPZAnalysisError::EvaluateError(REAL CurrentEtaAdmissible, std::ostream &out) { //Code isn�t place to chat //#warning Philippe, tambem nao entendo aqui //<!> TPZManVector<REAL,3> elerror(3); elerror.Fill(0.); TPZManVector<REAL,3> errorSum(3); errorSum.Fill(0.0); TPZBlock<REAL> *flux = 0; int elcounter=0; int numel = Mesh()->ElementVec().NElements(); fElErrors.Resize(numel); fElIndexes.Resize(numel); Mesh()->ElementSolution().Redim(numel,1); //soma de erros sobre os elementos int el; for(el=0;el< numel;el++) { TPZCompEl *elptr = Mesh()->ElementVec()[el]; if(elptr && !(elptr->Material()->Id() < 0)) { elptr->EvaluateError(fExact,elerror, flux); int nerrors = elerror.NElements(); errorSum.Resize(nerrors, 0.); for(int ii = 0; ii < nerrors; ii++) errorSum[ii] += elerror[ii]*elerror[ii]; fElErrors[elcounter] = elerror[0]; (Mesh()->ElementSolution())(el,0) = elerror[0]; fElIndexes[elcounter++] = el; } else { (Mesh()->ElementSolution())(el,0) = 0.; } } fElErrors.Resize(elcounter); fElIndexes.Resize(elcounter); fTotalError = sqrt(errorSum[0]); Mesh()->EvaluateError(NullFunction,elerror); // fAdmissibleError = CurrentEtaAdmissible*sqrt(true_error*true_error + fTotalError*fTotalError) / sqrt(1.*elcounter); //<!>pra compilar //Code isn�t place to chat //#warning Phil, ver isso urgente. Tiago fAdmissibleError = CurrentEtaAdmissible*sqrt(elerror[0]*elerror[0] + fTotalError*fTotalError) / sqrt(1.*elcounter); }
void TPZAnalysisError::EvaluateError(REAL CurrentEtaAdmissible, bool store_error, std::ostream &out) { //Code isn�t place to chat //#warning Philippe, tambem nao entendo aqui //<!> TPZManVector<REAL,3> elerror(3); elerror.Fill(0.); TPZManVector<REAL,3> errorSum(3); errorSum.Fill(0.0); TPZBlock<REAL> *flux = 0; int64_t elcounter=0; int64_t numel = Mesh()->ElementVec().NElements(); fElErrors.Resize(numel); fElIndexes.Resize(numel); Mesh()->ElementSolution().Redim(numel,1); // Sum of the errors over all computational elements int64_t el; for(el=0;el< numel;el++) { TPZCompEl *elptr = Mesh()->ElementVec()[el]; if(elptr && !(elptr->Material()->Id() < 0)) { elptr->EvaluateError(fExact,elerror, flux); int nerrors = elerror.NElements(); errorSum.Resize(nerrors, 0.); for(int ii = 0; ii < nerrors; ii++) errorSum[ii] += elerror[ii]*elerror[ii]; fElErrors[elcounter] = elerror[0]; (Mesh()->ElementSolution())(el,0) = elerror[0]; fElIndexes[elcounter++] = el; } else { (Mesh()->ElementSolution())(el,0) = 0.; } } fElErrors.Resize(elcounter); fElIndexes.Resize(elcounter); fTotalError = sqrt(errorSum[0]); // void NullFunction(TPZVec<REAL> &point,TPZVec<STATE>&val,TPZFMatrix<STATE> &deriv); std::function<void(const TPZVec<REAL> &,TPZVec<STATE>&,TPZFMatrix<STATE> &)> func(NullFunction); Mesh()->EvaluateError(func,store_error, elerror); fAdmissibleError = CurrentEtaAdmissible*sqrt(elerror[0]*elerror[0] + fTotalError*fTotalError) / sqrt(1.*elcounter); }
void TPZAnalysis::PostProcess(TPZVec<REAL> &, std::ostream &out ){ int i, neq = fCompMesh->NEquations(); TPZVec<REAL> ux((int) neq); TPZVec<REAL> sigx((int) neq); TPZManVector<REAL,10> values(10,0.); TPZManVector<REAL,10> values2(10,0.); fCompMesh->LoadSolution(fSolution); // SetExact(&Exact); TPZAdmChunkVector<TPZCompEl *> elvec = fCompMesh->ElementVec(); TPZManVector<REAL,10> errors(10); errors.Fill(0.0); int nel = elvec.NElements(); int matId0; for(i=0;i<nel;i++) { matId0=elvec[i]->Material()->Id(); if(matId0 > 0) break; } bool lastEl=false; for(i=0;i<nel;i++) { TPZCompEl *el = (TPZCompEl *) elvec[i]; if(el) { errors.Fill(0.0); el->EvaluateError(fExact, errors, 0); if(matId0==el->Material()->Id()){ for(int ier = 0; ier < errors.NElements(); ier++) values[ier] += errors[ier] * errors[ier]; lastEl=false; } else{ for(int ier = 0; ier < errors.NElements(); ier++) values2[ier] += errors[ier] * errors[ier]; lastEl=true; } } } int nerrors = errors.NElements(); if (nerrors==4) { if(lastEl){ out << endl << "############" << endl; out << endl << "L2 Norm for pressure = " << sqrt(values2[0]) << endl; out << endl << "L2 Norm for flux = " << sqrt(values2[1]) << endl; out << endl << "L2 Norm for divergence = " << sqrt(values2[2]) <<endl; out << endl << "Hdiv Norm for flux = " << sqrt(values2[3]) <<endl; out << endl << "############" << endl; out << endl << "true_error (Norma H1) = " << sqrt(values[0]) << endl; out << endl << "L2_error (Norma L2) = " << sqrt(values[1]) << endl; out << endl << "estimate (Semi-norma H1) = " << sqrt(values[2]) <<endl; } else{ out << endl << "############" << endl; out << endl << "L2 Norm for pressure = " << sqrt(values[0]) << endl; out << endl << "L2 Norm for flux = " << sqrt(values[1]) << endl; out << endl << "L2 Norm for divergence = " << sqrt(values[2]) <<endl; out << endl << "Hdiv Norm for flux = " << sqrt(values[3]) <<endl; out << endl << "############" << endl; out << endl << "true_error (Norma H1) = " << sqrt(values2[0]) << endl; out << endl << "L2_error (Norma L2) = " << sqrt(values2[1]) << endl; out << endl << "estimate (Semi-norma H1) = " << sqrt(values2[2]) <<endl; } } else { if(lastEl){ out << endl << "############" << endl; out << endl << "L2 Norm for pressure = " << sqrt(values[0]) << endl; out << endl << "L2 Norm for flux = " << sqrt(values[1]) << endl; out << endl << "L2 Norm for divergence = " << sqrt(values[2]) <<endl; out << endl << "Hdiv Norm for flux = " << sqrt(values[3]) <<endl; out << endl << "############" << endl; out << endl << "true_error (Norma H1) = " << sqrt(values2[0]) << endl; out << endl << "L2_error (Norma L2) = " << sqrt(values2[1]) << endl; out << endl << "estimate (Semi-norma H1) = " << sqrt(values2[2]) <<endl; } else{ out << endl << "############" << endl; out << endl << "L2 Norm for pressure = " << sqrt(values2[0]) << endl; out << endl << "L2 Norm for flux = " << sqrt(values2[1]) << endl; out << endl << "L2 Norm for divergence = " << sqrt(values2[2]) <<endl; out << endl << "Hdiv Norm for flux = " << sqrt(values2[3]) <<endl; out << endl << "############" << endl; out << endl << "true_error (Norma H1) = " << sqrt(values[0]) << endl; out << endl << "L2_error (Norma L2) = " << sqrt(values[1]) << endl; out << endl << "estimate (Semi-norma H1) = " << sqrt(values[2]) <<endl; } } return; }