コード例 #1
0
ファイル: pzadaptmesh.cpp プロジェクト: labmec/neopz
void TPZAdaptMesh::RemoveCloneBC(TPZCompMesh *mesh)
{
    int nelem = mesh->NElements();
    int iel;
    for(iel=0; iel<nelem; iel++) {
        TPZCompEl *cel = mesh->ElementVec()[iel];
        if(!cel) continue;
        int matid = cel->Material()->Id();
        if(matid == -1000) delete cel;
    }
}
コード例 #2
0
ファイル: pzanalysiserror.cpp プロジェクト: JoaoFelipe/oceano
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);
}
コード例 #3
0
ファイル: pzanalysiserror.cpp プロジェクト: labmec/neopz
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);
}
コード例 #4
0
ファイル: pzanalysis.cpp プロジェクト: JoaoFelipe/oceano
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;
}
コード例 #5
0
ファイル: PZ_Process.cpp プロジェクト: labmec/neopz
// Output as Mathematica format
void OutputMathematica(std::ofstream &outMath,int var,int pointsByElement,TPZCompMesh *cmesh) {
	int i, j, k, nnodes;
	int nelem = cmesh->ElementVec().NElements();
	int dim = cmesh->Dimension();   // Dimension of the model
	REAL w;
	if(var-1 < 0) var = 1;
	// Map to store the points and values 
	map<REAL,TPZVec<REAL> > Graph;
	TPZVec<REAL> tograph(4,0.);
	map<TPZVec<REAL>,REAL> Graphics;
	
	for(i=0;i<nelem;i++) {
		TPZCompEl *cel = cmesh->ElementVec()[i];
		TPZGeoEl *gel = cel->Reference();
		TPZInterpolationSpace * sp = dynamic_cast <TPZInterpolationSpace*>(cel);
		int nstates = cel->Material()->NStateVariables();
		// If var is higher than nstates of the element, go to next element
		if(var > nstates)
			continue;
		TPZVec<REAL> qsi(3,0.), sol(nstates,0.), outfem(3,0.);
		nnodes = gel->NNodes();
		if(pointsByElement < nnodes) pointsByElement = nnodes;
		for(j=0;j<gel->NNodes();j++) {
			// Get corners points to compute solution on
			gel->CenterPoint(j,qsi);
			sp->Solution(qsi,0,sol);
			cel->Reference()->X(qsi,outfem);
			// Jointed point coordinates and solution value on			
			for(k=0;k<3;k++) tograph[k] = outfem[k];
			tograph[k] = sol[var-1];
			Graph.insert(pair<REAL,TPZVec<REAL> >(outfem[0],tograph));
			Graphics.insert(pair<TPZVec<REAL>,REAL>(outfem,sol[var-1]));
			// If cel is point gets one point value
			if(cel->Type() == EPoint) {
				break;
			}
		}
		// If cel is point gets one point value
		if(cel->Type() == EPoint) continue;
		// Print another points using integration points
		TPZIntPoints *rule = NULL;
		int order = 1, npoints = 0;
		while(pointsByElement-(npoints+nnodes) > 0) {
			if(rule) delete rule;   // Cleaning unnecessary allocation
			int nsides = gel->NSides();
			// Get the integration rule to compute internal points to print, not to print
			rule = gel->CreateSideIntegrationRule(nsides-1,order);
			if(!rule) break;
			npoints = rule->NPoints();
			order += 2;
		}
		for(j=0;j<npoints;j++) {
			// Get integration points to get internal points
			rule->Point(j,qsi,w);
			sp->Solution(qsi,0,sol);
			cel->Reference()->X(qsi,outfem);
			// Jointed point coordinates and solution value on
			for(k=0;k<3;k++) tograph[k] = outfem[k];
			tograph[k] = sol[var-1];
			Graph.insert(pair<REAL,TPZVec<REAL> >(outfem[0],tograph));
			Graphics.insert(pair<TPZVec<REAL>,REAL>(outfem,sol[var-1]));
		}
	}
	
	// Printing the points and values into the Mathematica file
	outMath << "Saida = { ";
	// Formatting output
	outMath << fixed << setprecision(10);
	if(dim<2) {
		map<REAL,TPZVec<REAL> >::iterator it;
		for(it=Graph.begin();it!=Graph.end();it++) {
			if(it!=Graph.begin()) outMath << ",";
			outMath << "{";
			for(j=0;j<dim;j++)
				outMath << (*it).second[j] << ",";
			outMath << (*it).second[3] << "}";
		}
		outMath << "};" << std::endl;
		// Choose Mathematica command depending on model dimension
		outMath << "ListPlot[Saida,Joined->True]"<< endl;
	}
	else {
		map<TPZVec<REAL>,REAL>::iterator it;
		for(it=Graphics.begin();it!=Graphics.end();it++) {
			if(it!=Graphics.begin()) outMath << ",";
			outMath << "{";
			for(j=0;j<dim;j++)
				outMath << (*it).first[j] << ",";
			outMath << (*it).second << "}";
		}
		outMath << "};" << std::endl;
		outMath << "ListPlot3D[Saida]"<< endl;
	}
}