예제 #1
0
파일: main.cpp 프로젝트: labmec/neopz
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
0
TPZCompEl *TPZGraphMesh::FindFirstInterpolatedElement(TPZCompMesh *mesh, int dim) {
	int64_t nel = mesh->NElements();
	TPZCompEl *cel;
	int64_t iel;
	for(iel=0; iel<nel; iel++) {
		cel = mesh->ElementVec()[iel];
		if(!cel) continue;
		int type = cel->Type();
		if(type == EAgglomerate){
#ifndef STATE_COMPLEX
			if(!cel->Reference()) continue;
			TPZAgglomerateElement *agg = dynamic_cast<TPZAgglomerateElement *>(cel);
			if(agg && agg->Dimension() == dim) return agg;
#else
			DebugStop();
#endif
		}
		if(type == EDiscontinuous){
			TPZCompElDisc *disc = dynamic_cast<TPZCompElDisc *>(cel);
			if(disc && disc->Reference()->Dimension() == dim) return disc;
		}
		TPZCompEl *intel = dynamic_cast<TPZInterpolatedElement *>(cel);
		if(intel && intel->Reference()->Dimension() == dim) return intel;
		TPZSubCompMesh *subcmesh = dynamic_cast<TPZSubCompMesh *> (cel);
		if(subcmesh) {
			intel = FindFirstInterpolatedElement(subcmesh,dim);
			if(intel) return intel;
		}
	}
	return 0;
}
예제 #3
0
파일: main.cpp 프로젝트: labmec/neopz
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];
        }
    }
예제 #4
0
TPZDXGraphMesh::TPZDXGraphMesh(TPZCompMesh *cmesh, int dimension, TPZAutoPointer<TPZMaterial> mat, const TPZVec<std::string> &scalarnames, const TPZVec<std::string> &vecnames) :
TPZGraphMesh(cmesh,dimension,mat) {
	SetNames(scalarnames,vecnames);
	fNextDataField = 1;
	fStyle = EDXStyle;
	//	int index = 0;
	TPZCompEl *ce = FindFirstInterpolatedElement(cmesh,dimension);
	fElementType = "noname";
	if(ce) {
		int type = ce->Type();
		if(type == EOned)               fElementType = "lines";
		if(type == ETriangle)           fElementType = "triangles";
		if(type == EQuadrilateral)      fElementType = "quads";
		if(type == ECube)               fElementType = "cubes";
		if(type == EPrisma)             fElementType = "cubes";
		TPZGeoEl *gel = ce->Reference();
		if( type == EDiscontinuous || (type == EAgglomerate && gel) ){
			int nnodes = gel->NNodes();
			if(nnodes==4 && dimension==2) fElementType = "quads";
			if(nnodes==3 && dimension==2) fElementType = "triangles";
			if(dimension==3)              fElementType = "cubes";
		}
	}
	fNumCases = 0;
	fNumConnectObjects[0] = 1;
	fNumConnectObjects[1] = 1;
	fNumConnectObjects[2] = 1;
	fNormalObject = 0;
	
	for(int i = 0; i < 8; i++) fElConnectivityObject[i] = -1;
	
}
예제 #5
0
void TPZDarcyAnalysis::CreateInterfaces()
{
    fgmesh->ResetReference();
    fcmeshdarcy->LoadReferences();
    
    // Creation of interface elements
    int nel = fcmeshdarcy->ElementVec().NElements();
    for(int el = 0; el < nel; el++)
    {
        TPZCompEl * compEl = fcmeshdarcy->ElementVec()[el];
        if(!compEl) continue;
        TPZGeoEl * gel = compEl->Reference();
        if(!gel) {continue;}
        if(gel->HasSubElement()) {continue;}
        int index = compEl ->Index();
        if(compEl->Dimension() == fcmeshdarcy->Dimension())
        {
            TPZMultiphysicsElement * InterpEl = dynamic_cast<TPZMultiphysicsElement *>(fcmeshdarcy->ElementVec()[index]);
            if(!InterpEl) continue;
            InterpEl->CreateInterfaces();
        }
    }
}
예제 #6
0
void InputDataStruct::UpdateLeakoff(TPZCompMesh * cmesh)
{
  
  
#ifdef PZDEBUG
  if(fLeakoffmap.size() == 0)
  {//Se a fratura nao alcancou ainda a regiao elastica 2, este mapa estah vazio!!!
   //DebugStop();
  }
#endif
  
  std::map<int,REAL>::iterator it;
  
  int outVlCount = 0;
  for(int i = 0;  i < cmesh->ElementVec().NElements(); i++)
  {
    ///////////////////////
    TPZCompEl * cel = cmesh->ElementVec()[i];
    
#ifdef PZDEBUG
    if(!cel)
    {
      DebugStop();
    }
#endif
    
    TPZGeoEl * gel = cel->Reference();
    
    if(gel->Dimension() != 1)
    {
      continue;
    }
    
    TPZInterpolatedElement * sp = dynamic_cast <TPZInterpolatedElement*> (cel);
    if(!sp)
    {
      continue;
    }
    
    it = globFractInputData.GetLeakoffmap().find(gel->Id());
    
    if(it == globFractInputData.GetLeakoffmap().end())
    {
      continue;
    }
    
    TPZVec<REAL> qsi(1,0.);
    cel->Reference()->CenterPoint(cel->Reference()->NSides()-1, qsi);
    TPZMaterialData data;
    sp->InitMaterialData(data);
    
    sp->ComputeShape(qsi, data);
    sp->ComputeSolution(qsi, data);
    
    REAL pfrac = data.sol[0][0];
    ///////////////////////
    
    REAL deltaT = globFractInputData.actDeltaT();
    
    REAL VlAcum = it->second;
    REAL tStar = FictitiousTime(VlAcum, pfrac);
    REAL Vlnext = VlFtau(pfrac, tStar + deltaT);
    
    if (fusingLeakOff) {
      it->second = Vlnext;
    }
    else{
      it->second = 0.;
    }

    outVlCount++;
  }
  
#ifdef PZDEBUG
  if(outVlCount < globFractInputData.GetLeakoffmap().size())
  {
    DebugStop();
  }
#endif
}
예제 #7
0
파일: substruct.cpp 프로젝트: labmec/neopz
int SubStructure(TPZAutoPointer<TPZCompMesh> cmesh, REAL height)
{
	int nelem = cmesh->NElements();
	TPZManVector<int> subindex(nelem,-1);
	int iel;
	int nsub = 0;
	for (iel=0; iel<nelem; iel++) 
	{
		TPZCompEl *cel = cmesh->ElementVec()[iel];
		if (!cel) {
			continue;
		}
		TPZGeoEl *gel = cel->Reference();
		if (!gel) {
			continue;
		}
		int nsides = gel->NSides();
		TPZManVector<REAL> center(gel->Dimension(),0.), xco(3,0.);
		gel->CenterPoint(nsides-1,center);
		gel->X(center,xco);
		REAL z = xco[2];
		int floor = (int) z/height;
		nsub = (floor+1) > nsub ? (floor+1) : nsub;
		subindex[iel] = floor;
	}
	
#ifdef DEBUG 
	{
		TPZGeoMesh *gmesh = cmesh->Reference();
		int nelgeo = gmesh->NElements();
		TPZVec<int> domaincolor(nelgeo,-999);
		int cel;
		int nel = cmesh->NElements();
		for (cel=0; cel<nel; cel++) {
			TPZCompEl *compel = cmesh->ElementVec()[cel];
			if(!compel) continue;
			TPZGeoEl *gel = compel->Reference();
			if (!gel) {
				continue;
			}
			domaincolor[gel->Index()] = subindex[cel];
		}
		ofstream vtkfile("partition.vtk");
		TPZVTKGeoMesh::PrintGMeshVTK(gmesh, vtkfile, domaincolor);
	}
#endif
	
	int isub;
	TPZManVector<TPZSubCompMesh *> submeshes(nsub,0);
	for (isub=0; isub<nsub; isub++) 
	{
		int index;
		std::cout << '^'; std::cout.flush();
		submeshes[isub] = new TPZSubCompMesh(cmesh,index);
		
		if (index < subindex.NElements()) 
		{
			subindex[index] = -1;
		}
	}
	for (iel=0; iel<nelem; iel++) 
	{
		int domindex = subindex[iel];
		if (domindex >= 0) 
		{
			TPZCompEl *cel = cmesh->ElementVec()[iel];
			if (!cel) 
			{
				continue;
			}
			submeshes[domindex]->TransferElement(cmesh.operator->(),iel);
		}
	}
	cmesh->ComputeNodElCon();
	for (isub=0; isub<nsub; isub++) 
	{
		submeshes[isub]->MakeAllInternal();
		std::cout << '*'; std::cout.flush();
	}
	
	cmesh->ComputeNodElCon();
	cmesh->CleanUpUnconnectedNodes();
	return nsub;
}
예제 #8
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;
	}
}